Replace paramType in SpringFox

213 Views Asked by At

I have this @ApiImplicitParam annotation used by SpringFox to document endpoint. I want to migrate to springdoc.

  @ApiImplicitParam(name = "Proxy", value = "Authorization value", required = true, dataType = "string", paramType = "header")
  public .. endpoint(...){
     .....
  }

I replaced it to this:

  @Parameter(name = "Proxy", description = "Authorization value", required = true, dataType = "string", paramType = "header")
  public .. endpoint(...){
     .....
  }

But I get Cannot resolve method 'dataType' and Cannot resolve method 'paramType'. Do you know what should be the proper replacement for these values in springdoc?

1

There are 1 best solutions below

0
Debargha Roy On BEST ANSWER

As you found, dataType isn't supported. Instead we have content, schema, and array (for array elements) fields. It can be used in either of the below ways

  • Using just schema

    @Parameter(name = "Proxy", description = "Authorization Value", required = true, in = ParameterIn.HEADER, schema = @Schema(implementation = String.class))
    
  • Using schema in conjunction with content

    @Parameter(name = "Proxy", description = "Authorization Value", required = true, in = ParameterIn.HEADER, content = @Content(schema = @Schema(implementation = String.class)))
    

I've not tried the first one personally and in fact is the first time I saw it. (Maybe it was introduced in Springdoc 2.x?) But it seems to be cleaner way compared to the second.