spring-projects / spring-projects/spring-data-rest

Collection attributes represented as string in schema [DATAREST-580]

Open
#954 2 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: content-negotiation type: enhancement
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Etki opened DATAREST-580 and commented

Hi.
First of all, i want to say that is highly possible that i misunderstood something. I'm new to Java and sometimes i get lost inside source code and specs.
I'm building new application using Spring REST data and @RestResource annotations, and i develop an automatic entity admin dashboard for that application. The point is, whenever i dump entity schema, both *-to-one and *-to-many relationship attribute appear the same - as "string" type of "uri" format. As far as i understand, *-to-many relationships should be represented as "array" type; i haven't fiddled a lot with curl, but it seems that SDR simply rejects passed entity if it contains string representation of link instead of array. As you can see in related URL, passed type doesn't have a chance to be specified as array, because if it receives "uri" format, it is represented as string only. So, to sum up, i believe that following attribute

@ManyToMany
List<X> exes;

Should be represented in schema as

"exes": {
    "type": "array",
    "format": "uri"
}

While it appears as

"exes": {
    "type": "string",
    "format": "uri"
}

Affects: 2.3 GA (Fowler)

Reference URL: https://github.com/spring-projects/spring-data-rest/blob/018fa22593989291d392115c43af5406145e979e/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/JsonSchema.java#L355-L358

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.