Add support for @ParameterObject with POST endpoints
See original GitHub issuespringdoc-openapi-ui version: 1.3.9
In my spring web endpoint I have an object which summarise query params
To make it work properly, I see @ParameterObject
was introduced in https://github.com/springdoc/springdoc-openapi/pull/505
It works for GET requests (@GetMapping
) -> all properties of object are parsed as separate query parameters
@GetMapping("/test")
public void testGet(@ParameterObject QueryObject queryObject) {
}
@Getter
@Setter
public class QueryObject {
private String queryParam1;
private String queryParam2;
}
UI:
json:
"parameters": [
{
"name": "queryParam1",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "queryParam2",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
}
]
However I don’t see this behaviour with POST requests And object holding query params is parsed as BODY object Example of my code
@PostMapping("/test")
public void testPost(@ParameterObject QueryObject queryObject) {
}
UI:
json:
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"queryParam1": {
"type": "string"
},
"queryParam2": {
"type": "string"
}
}
}
}
}
}
Expected behavior
Objects in POST endpoints annotated with @ParameterObject
should behave the same way as for GET and all fields of this object are parsed as query params
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
POST body parameter object - Stack Overflow
There is two way to put parameters with POST request. First, you can use the @FieldMap, check out the link Retrofit Javadoc, the...
Read more >REST API Design Best Practices for Parameter and Query ...
The simplest way to add in all parameter data is to put everything in the body. Many APIs work this way. Every endpoint...
Read more >Creating request parameters via REST API - Ivanti Community
I guess one way to do it would be to create the params directly in the Service Req Parameter object and linking them...
Read more >Documenting a Spring REST API Using OpenAPI 3.0 - Baeldung
Learn how to generate OpenAPI 3.0 specifications for a Spring REST API using SpringDoc.
Read more >OpenAPI Specification - Version 3.0.3 - Swagger
The OpenAPI Specification defines a standard interface to RESTful APIs which allows both humans and computers to understand service capabilities without ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jarpz,
Yes, for other methods you mentionned as well. This is already deployed with v1.4.0.
Question?, just for post-method? because for put or patch methods are also possible…
Regards