Swagger documentation differing in structure from API response when using HAL
See original GitHub issueHi,
I am using Springfox 2.9.2.
I seem to still be experiencing a bug with HAL which is reported as fixed. The issue is described in #1980 and was reported fixed in #1927.
What I am seeing is that for a HAL enabled endpoint the swagger Documentation has a different structure to what is actually returned.
The swagger documentation describes this (I have simplified the model as we have a lot of fields):
{
"_embedded": [
{
"_links": [
{
"deprecation": "string",
"href": "string",
"hreflang": "string",
"media": "string",
"rel": "string",
"templated": true,
"title": "string",
"type": "string"
}
],
"name": "string",
"key": "string",
"referenceItemKey": "string"
}
],
"_links": [
{
"deprecation": "string",
"href": "string",
"hreflang": "string",
"media": "string",
"rel": "string",
"templated": true,
"title": "string",
"type": "string"
}
]
}
however the API returns this:
{
"_embedded" : {
"itemList" : [ {
"name" : "Test Item 1",
"key" : "ITEM_1",
"referenceItemKey" : "ITEM_2",
"_links" : {
"self" : {
"href" : "https://url.net/item-api/items/ITEM_1"
},
"referenceItem" : {
"href" : "https://url.net/item-api/items/ITEM_2"
}
}
}, {
"name" : "Test Item 2",
"key" : "ITEM_2",
"_links" : {
"self" : {
"href" : "https://url.net/item-api/items/ITEM_2"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "https://url.net/item-api/items"
}
}
}
The main issue I am having is that in the swagger-doc the _embedded
entry is an array, however in the return (and HAL specification) it is an object which contains a named object of type array.
Perhaps this is still a bug?
Further note is that my API is returning only content type application/hal+json;charset=UTF-8
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (1 by maintainers)
Top Results From Across the Web
Describing Responses - Swagger
A response is defined by its HTTP status code and the data returned in the response body and/or headers. Here is a minimal...
Read more >RESTful API Documentation Made Easy with Swagger and ...
Swagger is a set of open-source tools built around the OpenAPI Specification that can help us to design, build, document and consume REST...
Read more >Hypertext Application Language (HAL) - Apigility
HAL presents two hypermedia types, one for XML and one for JSON. Typically, the type is only relevant for resources returned by the...
Read more >Spring REST Docs vs OpenAPI - Baeldung
REST docs is a totally different take on API documentation. As described earlier, the process is test-driven, and the output is in the...
Read more >Python REST APIs With Flask, Connexion, and SQLAlchemy
You'll also test your API with Swagger UI API documentation. ... By now, your Flask project structure should look like this:.
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
Any news on this? @caiodorn @altrdev @davidepedone did any of you manage to solve this problem?
Same issue here. Still getting content instead of _embedded