1

How to make a request on swagger UI in which i can add N amount of query parameters (both name and value of the parameters have to accept any input) using solely swagger annotations (no openApi yaml/json)?

The request should look something like this:

GET swagger/users?name1=value1&name2=value

Swagger UI version is 3.23.0

randomguy
  • 51
  • 7
  • See if this helps: [How to document dynamic query parameter names in OpenAPI (Swagger)?](https://stackoverflow.com/q/49582559/113116) – Helen Jun 14 '22 at 05:24
  • @Helen I have already tried this. It works perfectly in swagger editor using the yaml file, but i need to achieve this using only swagger annotations. I tried writing the code using annotations which seems to be equivalent to the yaml like this: `@Parameter(in=ParameterIn.QUERY, name="params", style=ParameterStyle.FORM, schema=@Schema(type="object", additionalProperties = Schema.AdditionalPropertiesValue.TRUE), explode=Explode.TRUE)` , but it doesn't work, swagger interprets this as a body somehow and shows an error that a GET request can't have a body. – randomguy Jun 14 '22 at 06:40
  • Can you post the complete method declaration with all annotations? – Helen Jun 14 '22 at 18:52
  • @Helen It looks like this: `public String myMethod(@Context Request request,@Context UriInfo uriInfo, @QueryParam("a") Optional a, @QueryParam("b") Optional b, @QueryParam("c") Optional c, @QueryParam("d") Optional d, @QueryParam("e") Optional e, @QueryParam("f") Optional f, @Parameter(in=ParameterIn.QUERY, name="params", style=ParameterStyle.FORM, schema=@Schema(type="object", additionalProperties = Schema.AdditionalPropertiesValue.TRUE), explode=Explode.TRUE) String additionParams ){ //code }` – randomguy Jun 15 '22 at 06:31
  • I have also tried removing the `additionalProperties = Schema.AdditionalPropertiesValue.TRUE` but the result is the same – randomguy Jun 15 '22 at 06:32

0 Answers0