sdaschner / jaxrs-analyzer

Creates REST documentation for JAX-RS projects
Apache License 2.0
319 stars 101 forks source link

@QueryParam() which are not required appear as 'required=true' #176

Closed MGalatioto closed 5 years ago

MGalatioto commented 5 years ago

Hi,

I have Resource with following GET:

...GET - Method ...: public List<Adresse> searchAdresse( @ApiParam(value = "Email to search for the address", required = false) @QueryParam("email") String email, @ApiParam(value = "Street to search for the address", required = false) @QueryParam("strasse") String strasse)

First of all: my Swagger Annotations aren't rendered - does that not work?

  1. my QueryParam, which are not required, appear in the generated json file as 'required=true' - Why?

Am I missing something?

Thanks in advance.

rmpestano commented 5 years ago

Hi @MGalatioto,

First of all: my Swagger Annotations aren't rendered - does that not work?

Yes, the tool only look into JaxRS annotations to avoid duplications (e.g @Path over @Api or @GET over @ApiOperation and so on)

  1. my QueryParam, which are not required, appear in the generated json file as 'required=true' - Why?

All parameters without a default value are marked as required, currently there is no annotation or javadoc tag to tell that a parameter is required or not

You can set blank default values to remove the required, e.g:

  @GET
  public JsonObject list(@QueryParam("param") @DefaultValue("") String myParam)
MGalatioto commented 5 years ago

Great, Thank you!