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

Rels should use common supertype in HAL responses [DATAREST-215]

Open
#600 7 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Aaron Loes opened DATAREST-215 and commented

See my spring.io forum post about this. Also pasted below:

When fetching the contents of a one-to-many relation, the content being returned is organized by type which i believe is unnecessary and problematic.

Example:

Given a request:

GET: http://localhost:8080/farms/132/animals

This is the response:

{
  "_links" : { },
  "_embedded" : {
    "horses" : [{
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/horses/5234"
        }
      },
      "name" : "Whinney",
      "age" : 7
    },{
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/horses/1234"
        }
      },
      "name" : "Wilbur",
      "age" : 16
    }],
    "cows" : {
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/cows/2351"
        }
      },
      "name" : "Bessy"
    }
  }
}

As someone processing this response how am i to determine the order of the relations? I expected Bessy to be between Whinney and Wilbur but that is not the case when the data is organized as such.

I believe the previous behavior was the proper behavior where the data was just listed in an array.

Thoughts?


Affects: 2.0 M1 (Codd)

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.