Add and remove arbitrary input fields from Swagger UI in Spring Boot

Viewed 153

I have a Spring Boot application with springfox-swagger-ui. I need to:

  • Make Swagger UI display input field for a parameter that does not appear among the request handler params in my controller. For example, the request contains a hashCode parameter, which I verify with a HandlerInterceptorAdapter and then I don't need anymore, thus I don't list it among the request handler params. But I want to have it in Swagger UI.
  • Remove an input field from Swagger UI that corresponds to a parameter that I have in my request handler in my controller. For example, the request contains a userId, which I use to construct an User object with a HandlerMethodArgumentResolver and then inject it into the request handler by adding a parameter of type User. Thus I don't want Swagger UI to create User input field, but instead a userId input field.

To summarize, I need to show an input field in Swagger UI that does not correspond to any request handler parameter, and I need to hide an input field in Swagger UI that corresponds to a request handler parameter. How to do this?

0 Answers
Related