renke
renke

Reputation: 1230

Swagger2 @ApiParam specifying type

I'm trying to change the type of a parameter on the generated swagger contract, but it looks like the @ApiParam#type property is not working.

ResponseEntity<Void> delete(
        @ApiParam(
                value = "The id of the object",
                required = true,
                type = "java.lang.String") Integer id);

Doing this has no effect in swagger-ui, and id is still being shown as Integer.

Does anyone knows a workaround for this?

Upvotes: 2

Views: 6874

Answers (2)

Chao Jiang
Chao Jiang

Reputation: 493

I think you should use "string" not "java.lang.String".

The annotation is not @ApiParam, you can use @ApiImplicitParam, and use dataType="string"

The supported type as below:

  • integer
  • long
  • float
  • double
  • string
  • byte
  • boolean
  • date
  • dateTime

Upvotes: 0

pvpkiran
pvpkiran

Reputation: 27018

You have to use @ApiImplicitParam

@ApiImplicitParam(dataType = "string", name = "id")
ResponseEntity<Void> delete(Integer id);

Upvotes: 3

Related Questions