HATEOAS part shows direct object instead of the thing we get
See original GitHub issueHi, currently I am using spring HATEOAS 1.0.1.RELEASE with spring-boot 2.2.1.RELEASE and springdoc-openapi-webmvc-core version 1.2.17. I saw that the project shows it support HATEOAS now but in swagger, I still see the example value show all the fields of EntityModel instead of the response we will get. Is there anything I need to config for that
Example value:
{
"id": "string",
"links": [
{
"rel": "string",
"href": "string",
"hreflang": "string",
"media": "string",
"title": "string",
"type": "string",
"deprecation": "string",
"profile": "string",
"name": "string"
}
]
}
Response thing:
{
"id": "test-id",
"_links": {
"self": {
"href": "http://localhost:8374/my-path"
}
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Spring HATEOAS - Reference Documentation
Spring HATEOAS lets you work with links through its immutable Link value type. Its constructor takes both a hypertext reference and a link ......
Read more >How to remove the "_embedded" property in Spring HATEOAS
I have a projection on an object, and am limiting it to only display the name. The problem is that there are over...
Read more >JSON:API for Spring HATEOAS - GitHub Pages
A complex Link object of Spring HATEOAS can have optional properties like name, type, hreflang, title and others. In previous versions of this ......
Read more >Applying HATEOAS to a REST API with Spring Boot
In this scenario it returns ResponseEntity<PersonResource> (HATEOAS) instead of ResponseEntity<Person> (REST). So what is this resource object I keep mentioning ...
Read more >Insecure Direct Object Reference: Is your ... - Lock Me Down
We're all familiar with the idea of showing products on our website, ... In this case, what we have is a direct object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
As @kingtran2112 is pointing out, there is a mismatch between the generated documentation (based on EntityModel) and the actual JSON representations. If you are relying on the OpenAPI specification for customers and you are using Spring HATEOAS, this is not desirable.
I would expect
links
andembedded
to follow the HAL specification draft (link), i.e._links
and_embedded
. Furthermore, I would expect the structure within these sections to reflect the actual response representations rather than being based on the EntityModel structure.Thanks. I fixed it by doing the following.
Declare a CaseHrefRepresentation class
In the method definition, use the class in the schema
I’m sure there’s a better more correct way to do this. But for now, it works for me.