-
-
Notifications
You must be signed in to change notification settings - Fork 548
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
We have many existing controller methods in our Spring Boot application that are already annotated with the RequestMapping annotation. When we try using springdoc, the requestBody content for our POST methods is an empty object in the generated /v3/api-docs result.
This:
@RequestMapping(value = "/filter", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public FilterDto filterPost(@RequestBody final FilterDto filter) {
return filter;
}
results in this:
"/filter": {
"post": {
"operationId": "filterPost",
"requestBody": {
"content": {}
},
"responses": {
"200": {
"description": "default response",
"content": {
"application/json;charset=UTF-8": {
"schema": {
"$ref": "#/components/schemas/FilterDto"
}
}
}
}
}
}
}
Eventually, we figured out that switching to use the PostMapping annotation allows the requestBody content to be generated.
This:
@PostMapping("/filter")
@ResponseStatus(value = HttpStatus.OK)
public FilterDto filterPost(@RequestBody final FilterDto filter) {
return filter;
}
results in this:
"/filter": {
"post": {
"operationId": "filterPost",
"requestBody": {
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/FilterDto"
}
}
}
},
"responses": {
"200": {
"description": "default response",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/FilterDto"
}
},
"application/json;charset=UTF-8": {
"schema": {
"$ref": "#/components/schemas/FilterDto"
}
}
}
}
}
}
}
We are hoping there is a way to get springdoc to work with our existing RequestMapping POST annotations, so we don't need to change all of our existing code. Is this possible?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working