Search code examples
springfoxspringdoc

migrate dataType and paramType got Springdoc


I have this SpringFox api description param:

@ApiImplicitParam(value = "token", required = true, dataType = "string",
      paramType = "header")

I migrated it to SpringDoc using:

@Parameter(value = "token", required = true, dataType = "string",
      paramType = "header")

I can't find how to replace dataType and paramType. Do you know what should be the proper way to migrate it?


Solution

  • paramType uses in.
    dataType uses schema.

    example

      @GetMapping
      public String index(@Parameter(name = "token", required = true, in = ParameterIn.HEADER, schema = @Schema(implementation = String.class)) @RequestHeader("token") String header) {
        return header;
      }
    

    If RequestHeader annotation is attached, it can be simplified a little more.

      @GetMapping
      public String index(@Parameter(name = "token", required = true) @RequestHeader("token") String header) {
        return header;
      }
    

    enter image description here