I have the following controller code
@GetMapping("/users")
public ResponseEntity<UserDto> getUsers(Filter filter) {
return ResponseEntity.ok(userService.findUsers(filter));
}
Filter.java:
public class Filter {
private Integer page;
private Integer size;
// Contains 2 fields: "propertyName" and "order"
private Sort sort;
... getters and setters
}
The URL is following: /users?page=1&size=10&sort=+firstName. So I have a custom converter from String to Sort and it works perfectly.
However, the generated swagger documentation is incorrect:
"parameters":[
{
"name":"sort.propertyName",
"in":"query",
"required":false,
"type":"string"
},
{
"name":"sort.order",
"in":"query",
"required":false,
"type":"string",
"enum":[
"+",
"-"
]
},
{
"name":"page",
"in":"query",
"required":false,
"type":"integer",
"format":"int32"
},
{
"name":"size",
"in":"query",
"required":false,
"type":"integer",
"format":"int32"
}
]
As you can see, it has broken down the Sort field of Filter and has generated 2 parameters: sort.propertyName and sort.order. Instead, I want to have one parameter sort with type string.
Is there any way to achieve that? I have tried annotating the sort field with @ApiParam(name = "sort", value = "Sort", type = "string"), but it doesn't work.
Sortas aString