spring-projects / spring-projects/spring-data-rest
Schema+Json looses array type when there's a reference involved [DATAREST-788]
Open
@odrotbohm is already working on this.
Since Dec 31, 2020.
in: content-negotiation
status: feedback-provided
type: bug
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Wallace Wadge opened DATAREST-788 and commented
Consider:
class Account{
@OneToMany
@ReadOnlyProperty @Reference
List<ApiAccountEntry> accountEntries = new LinkedList<>();
}
Asking for schema+json returns
"accountEntries": {
"title": "Account entries",
"readOnly": true,
"type": "string",
"format": "uri"
},
while if @Reference isn't defined in the model we get:
"accountEntries": {
"title": "Account entries",
"readOnly": true,
"type": "array",
"items": {
"$ref": "#/definitions/apiAccountEntry"
}
},
Note that we've lost the "array" bit.
Therefore if we have @Reference, we don't know from the returned type that we have a @OneToMany (as opposed to for eg @ManyToOne).
If you agree that this is a bug, I'll submit a PR to fix.
Affects: 2.5 RC1 (Hopper)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.