Overriding any parameter in io.swagger.v3.oas.annotations.media.Schema throws exception

Viewed 2784

I have this open API annotation

    @GET
    @Operation(method = "Get orders", description = "GetOrdersRoute",
            parameters = {
                    @Parameter(in = ParameterIn.QUERY, name = "batchSize", required = true,
                            schema = @Schema(type = "")),
                    @Parameter(in = ParameterIn.QUERY, name = "fromDate", required = true),
                    @Parameter(in = ParameterIn.QUERY, name = "filter", required = true)},
            responses = {
                    @ApiResponse(description = "The order",
                            content = @Content(mediaType = "application/json",
                                    schema = @Schema(implementation = OrderDto.class)))})
    @Override
    public String handle(@Parameter(hidden = true) Request request, @Parameter(hidden = true) Response response) {
        return api.exec();
    }

It works. But when I add to @Parameter to @Schema any value like schema = @Schema(type = "integer")) I get an exception:

java.lang.NoSuchMethodError: org.apache.commons.lang3.math.NumberUtils.isCreatable(Ljava/lang/String;)Z

In other words: @Schema(type = "")) works fine but @Schema(type = "integer")) doesn't work.

And not only type parameter in @Schema annotation. Any override parameter in @Schema annotation throws this exception.

But @Schema in @ApiResponse works fine with any override parameter.

1 Answers

I was getting the same issue today when using

@ApiResponse(
    responseCode = "200", 
    content = @Content(mediaType = "application/json", schema = @Schema(implementation = MyDto.class)), 
    description = "Returns MyDto.")

with io.swagger.v3.oas.annotations.media.Schema from swagger 2.1.9.

After trying different swagger versions (which were producing other errors in my setup), it worked when downgrading to swagger 2.0.10.

Related