swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Explicit schema type specified on `@Parameter` annotation is always ignored

Open adriansuarez opened this issue 1 year ago • 1 comments

I am accepting a query parameter within an object in an opaque form so that I can apply Jakarta validation constraints to it, rather than failing to create the object at all and generating a useless message about dependency injection not being able to build the object.

I'm declaring a query parameter as a String and then parsing it later, as follows:

    @PositiveOrZero
    @Parameter(description = "The offset at which to list items", schema = @Schema(type = "integer", format = "int32"))
    @QueryParam(OFFSET)
    public String offset;

Despite this, the schema for the query parameter continues to have string as its type:

      parameters:
      - name: offset
        in: query
        description: The offset at which to list items
        schema:
          type: string  # should be type: integer
          format: int32

Using schema = @Schema(implementation = Integer.class) also fails to attach the correct type to the query parameter.

adriansuarez avatar Oct 23 '24 14:10 adriansuarez