Search code examples
spring-bootreactive-programmingswagger-uiswagger-2.0

Hide internal parameters from Spring interface for Swagger UI


I have an folowing endpoint:

@PostMapping(value = "/home", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public Mono<String> getData(ServerWebExchange exchange) { return Mono.empty(); }

The ServerWebExchange object is implemented in org.springframework.web.server. When I run it, in Swagger all the getters objects are shown. While I only need the body (I want to hide the reqest and the respone objects).

Tried to use

.ignoredParameterTypes(Principal.class, ServerHttpRequest.class, ServerHttpResponse.class)

But, it didn't had any effect. Is there a way to hide those?


Solution

  • Solution found:

    1. Disable the SeverWebExchange interface for swagger

    2. Configure require input.

      @PostMapping(value = "/home", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
      @ApiImplicitParams({
           @ApiImplicitParam(name = "Body Params", paramType = "body")
      })
       public Mono<String> getData(
           @ApiIgnore ServerWebExchange exchange
       ) {
           return Mono.empty();
       }