spring-bootspring-webfluxspringdoc

@Schema(type = "integer") in @Parameter with @RouterOperation Not Working in Springdoc OpenAPI


I'm using Spring WebFlux with Springdoc OpenAPI and trying to document an API endpoint using @RouterOperation. My code looks like this:

@RouterOperation(
path = "/api/hello",
operation = @Operation(
    security = @SecurityRequirement(name = UtilitiesConstant.OpenApiSecurityName),
    summary = "Get User by ID",
    description = "Fetch a user by their ID",
    operationId = "getHello",
    parameters = {
        @Parameter(
            name = "id",
            in = ParameterIn.QUERY,
            description = "User ID",
            required = true,
            schema = @Schema(type = "integer")
        )
    },
    responses = {
        @ApiResponse(responseCode = "200", description = "Successful operation"),
        @ApiResponse(responseCode = "404", description = "User not found")
    }
)

)

The issue I'm facing is that the schema = @Schema(type = "integer") part of the @Parameter doesn't seem to work as expected. When I check the generated OpenAPI documentation (Swagger UI), the id parameter is not properly recognized as an integer. Instead, it shows up as a string or doesn't apply the required schema at all.

I’m using the following versions:

Springdoc OpenAPI: 2.5.0 Spring Boot: I've tried enabling debug logging with logging.level.org.springdoc=DEBUG, but I couldn't find any useful information in the logs that explains why this is happening.

What might be causing this issue? Is there a known limitation or a bug, or am I missing something in my configuration?

Any insights or suggestions would be greatly appreciated.


Solution

  • schema = @Schema(types = {"integer"})
    

    You can work around the issue by using "types" instead of "type".

    It seems to be a bug with swagger core for OpenAPI 3.1. Here and here are two GitHub issues related to the problem.