Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert object into multi query parameter Swagger

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  1. Test case 1
    For following code:
    enter image description here
    The following swagger documentation is generated:
    enter image description here

  2. Test case 2:
    For the following code:
    enter image description here
    The following swagger documentation is generated:
    enter image description here

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.

>Solution :

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;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading