swagger-api / swagger-api/swagger-core
Explicit schema type specified on `@Parameter` annotation is always ignored
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the @Parameter and nested @Schema annotations are processed for query parameters. Reproduce the example and verify that an explicit schema type or implementation is preserved instead of being replaced by the Java field type; done means the generated OpenAPI schema reports offset as an integer with format int32.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100