Closed
Description
It would be nice to have support also for @ModelAttribute annotation used in a parameter of controller method.
Example:
@RestController
public class ExampleController {
@GetMapping("/example")
void get(@ModelAttribute InputDTO input) {
//...
}
}
class InputDTO {
@Schema(required = true, description = "...")
String first;
@Schema(description = "...")
String second;
}
Now is such parameter processed with no special care what leads to false API docs.
For Java example above it would lead to:
//parameters for path /example
"parameters": [
{
"name":"input",
"in":"query",
"required":true,
"schema":{"$ref":"#/components/schemas/InputDTO"}
}
]
//schema for InputDTO
{
"required":["first"],
"type": "object",
"properties": {
"first": {
"type": "string",
"description" :"..."
},
"second": {
"type": "string",
"description": "..."
}
}
}
As a result Spring will handle request parameters in different way than what API doc is declaring and also Swagger UI is unable to call a such endpoint of course.
Expected API docs for the example is following:
"parameters": [
{
"name": "first",
"in": "query",
"description": "...",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "second",
"in": "query",
"description": "...",
"required": true,
"schema": {
"type": "string"
}
}
]