I'm trying to generate swagger documentation with query parameters from an object but I'm not sure if it's possible with springdoc-openapi. I know this is possible with io.springfox.
What I want is to create a single object, add all the fields to this object and then have these fields presented in the swagger documentation as individual query parameters.
E.g of test cases:
Test case 1
For following code:
The following swagger documentation is generated:
Test case 2: For the following code:
The following swagger documentation is generated:
In both situations the services works as expected with query parameters. What I want is to have code from test case 2 to generate the same documentation from test case 1. I know this is possible with springfox but I can not figure out how to do it in springdoc-openapi.
CodePudding user response:
To achieve this, you need to decorate the TestCase class with the @ParameterObject
annotation :
@ParameterObject
public class TestCase {
@Parameter
String field1;
@Parameter
String field2;
@Parameter
String field1;
}