Closed
Description
Describe the bug
I know it's uncommon for GET requests to have a RequestBody, but sometimes the payload can be quite large for the query parameter in the URL to handle it. Using a RequestBody makes more sense, but the generator does not render it. Instead a query parameter entry is there and when executed in the Swagger UI the following exception is thrown:
org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing:
To Reproduce
Steps to reproduce the behavior:
- Spring Boot 2.4.0
- springdoc-openapi v1.5.2
- modules: springdoc-openapi-ui, springdoc-openapi-security, springdoc-openapi-data-rest
- JSON result (excerpt)
"/api/{domain}/ids/search": {
"get": {
"tags": [
"Get Controller"
],
"summary": "Get a list of all visible documents from a givendomain filtered by the given list of id's",
"description": "Sample Request Body:\n\n{ \"ids\" : [ 1010334, 1010356 ] }",
"operationId": "getDomainDocumentsByListOfIds",
"parameters": [
{
"name": "domain",
"in": "path",
"description": "Name of domain",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "ids",
"in": "query",
"required": true,
"schema": {
"type": "object"
}
},
{
"name": "pageable",
"in": "query",
"required": true,
"schema": {
"$ref": "#/components/schemas/Pageable"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/QueryResult"
}
}
}
}
}
}
},
- SampleController (excerpt)
@RequestMapping(value = "/api/{domain}/ids/search", method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE})
@Transactional(readOnly = true)
@Operation(summary = "Get a list of all visible documents from a given domain filtered by the given list of id's",
description = "Sample Request Body:\n\n"
+ "{ \"ids\" : [ 1010334, 1010356 ] }")
@Parameter(name = "domain", description = "Name of domain", in = ParameterIn.PATH)
public QueryResult getDomainDocumentsByListOfIds(@PathVariable String domain,
@RequestBody Object ids,
final Pageable pageable,
HttpServletRequest request) {
Path path = parser.parsePath(domain, request.getQueryString());
validator.validatePath(path, HttpMethod.GET);
List<Long> fetchIds = parseRequestBody(ids);
path.setSearchIds(fetchIds);
return this.documentService.getByDomain(path.getDomain(),
path.getSearchFilter(), pageable, null);
}
Expected behavior
- Similar to a PUT request, I would expect
- Sample JSON (excerpt)
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object"
}
}
}
},
"required": true
},
Screenshots
Some Swagger UI screenshots from the actual API
Metadata
Metadata
Assignees
Labels
No labels