Hidden parameter in springdoc-openapi doesn't work

Viewed 5731

I have Spring Boot application with version 2.3.0. and springdoc-openapi-webflux-ui in version 1.4.1.

I have annotated parameter in operation like this.

parameters = {
@Parameter(
    hidden = true, schema = @Schema(implementation = Boolean.class),
    in = ParameterIn.QUERY, name = DO_NOT_FORWARD
)

With hidden = true I expected that this parameter will not be visible in swagger-ui. But it is. Did I misunderstood this parameter or is it not doing what it was supposed to do?

I want this parameter to be in api-docs, to have generated client able to use this parameter, but I want it invisible in swagger-ui

3 Answers

Try

@Parameter(name = "paramName", hidden = true)
@GetMapping("/example")
public Object example(String paramName) {
    return null;
}

instead of

@Operation(
    parameters = {
        @Parameter(name = "paramName", hidden = true)
    }
)
@GetMapping("/example")
public Object example(String paramName) {
    return null;
}

You just make sure that the name of in the @Parameter annotation, is the exact name of the operation parameter you want to hide.

You can have a look at the documentation as well:

If you are still having coniguration issue, you can add the code of sample HelloController that reproduces your problem, or you can add the link to a minimal, reproducible sample in github.

As per the doc

@GetMapping("/example")
fun someCall: Response (
@Parameter(hidden = true) String paramName
) {
    return response;
}
Related