Forum Discussion

wichers's avatar
wichers
Occasional Contributor
4 years ago
Solved

How to suppress requestBody generation in OpenAPI spec using swagger-maven-plugin

I'm using the swagger-maven-plugin in a Java application with an old school servlet implementation. I'm trying to follow the examples here: https://github.com/swagger-api/swagger-samples/, but unfort...
  • frantuma's avatar
    frantuma
    4 years ago

    you can hide any parameter including request body via @Parameter.hidden annotation, like:

     

        @Override
        @GET
        @Operation (
            summary = "Ask something, get something back.",
            parameters = { @Parameter(in = ParameterIn.QUERY, name="TestParam00020", required = true ) }
        )
        public void doGet(@Parameter(hidden = true) HttpServletRequest request, @Parameter(hidden = true) HttpServletResponse response) throws ServletException, IOException {
        }
  • frantuma's avatar
    frantuma
    4 years ago

    Did you apply the annotation also to the response? and are you using the latest version?

     

    I suspect you didn't hide the response and you're seeing that in your outcome. As mentioned, the reader is targeting JAX-RS methods, therefore it tries to resolve method parameters if not hidden, and response is a method parameter.

     

    I tested with the code above and request body is correctly not resolved