Skip to content

Hateoas: Links entity has wrong structure #1090

Closed
@mathias-ewald

Description

@mathias-ewald

Describe the bug
The _links property of HAL entities are generated as an array of Links. The real structure is an object with the link names as properties.

To Reproduce
Springboot: 2.4.1
Springdoc: 1.5.5

It happens for every entity exposed over Spring Data Rest. An example schema looks like this:

    EntityModelProduct:
      type: object
      properties:
        ...
        _links:
          type: array
          items:
            $ref: '#/components/schemas/Link'

Spring Data Rest does not produce an array:

{
  ...
  "_links" : {
    "self" : {
      "href" : "https://api.edit.local/catalog/products/05c519ab-1735-42c2-9b11-b99926ef9fa1"
    },
    "product" : {
      "href" : "https://api.edit.local/catalog/products/05c519ab-1735-42c2-9b11-b99926ef9fa1{?projection}",
      "templated" : true
    },
    "vendor" : {
      "href" : "https://api.edit.local/catalog/products/05c519ab-1735-42c2-9b11-b99926ef9fa1/vendor"
    }
  }
}

Expected behavior
There should probably be a Links schema for every model. In this case EntityModelProductLinks with self, product and all relations as properties.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions