Description
Hi,
There is something wrong with the serialization (to openapi) of the org.springframework.data.domain.Sort
I've a method which returns a org.springframework.data.domain.Page from a method in a RestController class.
The implementation of org.springframework.data.domain.Page is org.springframework.data.domain.PageImpl
@RestController
public class MyRestController {
@PostMapping(path = "/", produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
@Operation(operationId="myOperation")
public org.springframework.data.domain.Page<MyDto> queryMyDto(@RequestBody MyDtoQuery query, @ParameterObject org.springframework.data.domain.Pageable pageable) {
// This return a PageImpl with the data, the method parameter 'query' is a pojo containg filter properties
return myService.getResult(query, pageable);
}
}
The openapi defintion generated is:
"PageMyDto": {
"type": "object",
"properties": {
"totalPages": {
"type": "integer",
"format": "int32"
},
"totalElements": {
"type": "integer",
"format": "int64"
},
"first": {
"type": "boolean"
},
"last": {
"type": "boolean"
},
"size": {
"type": "integer",
"format": "int32"
},
"content": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MyDto"
}
},
"number": {
"type": "integer",
"format": "int32"
},
"sort": {
"$ref": "#/components/schemas/SortObject"
},
"numberOfElements": {
"type": "integer",
"format": "int32"
},
"pageable": {
"$ref": "#/components/schemas/PageableObject"
},
"empty": {
"type": "boolean"
}
}
},
"SortObject": {
"type": "object",
"properties": {
"empty": {
"type": "boolean"
},
"sorted": {
"type": "boolean"
},
"unsorted": {
"type": "boolean"
}
}
}
When i call the method, the return object is (content is empty for this example):
{
"number": 0,
"numberOfElements": 0,
"totalElements": 0,
"totalPages": 0,
"size": 20,
"sort": [],
"content": []
}
As you can see, the "sort" property generated is not an array, and the SortObject does not contains the Sort properties like orders.
If i set the query parameter sort, the result is:
{
"number": 0,
"numberOfElements": 0,
"totalElements": 0,
"totalPages": 0,
"size": 20,
"sort": [
{
"property": "id",
"direction": "ASC",
"ignoreCase": false,
"nullHandling": "NATIVE"
}
],
"content": []
}
I'm using spring boot 3.1.6 and springdoc-openapi-webmvc-ui 2.3.0.
Can you help me figure out if there is a bug or if i'm doing something wrong?
Thanks