Closed
Description
Hi!
I'm trying to setup springdoc-openapi in my project and I'm facing an issue regarding the docs generated for HAL objects.
Used dependencies:
- springdoc-openapi-ui - 1.3.1
- springdoc-openapi-data-rest - 1.3.1
- spring boot - 2.2.5.RELEASE
I have defined a REST endpoint that will respond with the following data example:
{
"_embedded": {
"albums": [
{
"title": "album-title-1",
"description": "album-description-1",
"releaseDate": "album-release-date-1"
},
{
"title": "album-title-2",
"description": "album-description-2",
"releaseDate": "album-release-date-2"
}
]
},
"_links": {
"self": {
"href": "http://localhost:8080/api/albums"
}
},
"page": {
"size": 2,
"totalElements": 2,
"totalPages": 1,
"number": 0
}
}
However, the schema for the response looks differently:
{
"links": [
{
"rel": "string",
"href": "string",
"hreflang": "string",
"media": "string",
"title": "string",
"type": "string",
"deprecation": "string",
"profile": "string",
"name": "string"
}
],
"content": [
{
"title": "string",
"description": "string",
"releaseDate": "string",
"links": [
{
"rel": "string",
"href": "string",
"hreflang": "string",
"media": "string",
"title": "string",
"type": "string",
"deprecation": "string",
"profile": "string",
"name": "string"
}
]
}
],
"page": {
"size": 0,
"totalElements": 0,
"totalPages": 0,
"number": 0
}
}
This is how I implemented the endpoint:
@RestController
public class WebController {
@Autowired
private AlbumModelAssembler albumModelAssembler;
@Autowired
private PagedResourcesAssembler pagedResourcesAssembler;
@GetMapping("/api/albums")
public PagedModel<Album> getAllAlbums() {
Album album1 = new Album("album-title-1", "album-description-1", "album-release-date-1");
Album album2 = new Album("album-title-2", "album-description-2", "album-release-date-2");
Page<Album> albumPage = new PageImpl<>(Arrays.asList(album1, album2));
return pagedResourcesAssembler.toModel(albumPage, albumModelAssembler);
}
}
You can also find the full example here.
Has springdocs-openapi support for HAL objects? Is there any configuration that I'm missing? Thank you!