question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hide responses node

See original GitHub issue

Usually the developer knows that an endpoint can at least produce HTTP 200 OK, 400 Bad Request and 5xx Server Error.

Therefore I’d like to hide the responses node (or at least any responses beside 200 OK).

But none of the following approaches work:

    @GetMapping(value = "/persons")
    @Operation(summary = "GET Persons",
            responses = {})
    public PersonRsp persons(final Person person) {
       return null;
    }

    @GetMapping(value = "/persons2")
    @Operation(summary = "GET Persons",
            responses = @ApiResponse(responseCode = "200"))
    public PersonRsp persons2(final Person person) {
       return null;
    }

Both endpoints will show:

"responses":{
   "502":{
      "description":"default response",
      "content":{
         "*/*":{
            "schema":{
               "type":"object"
            }
         }
      }
   },
   "400":{
      "description":"default response",
      "content":{
         "*/*":{
            "schema":{
               "type":"object"
            }
         }
      }
   },
   "200":{
      "description":"default response",
      "content":{
         "*/*":{
            "schema":{
               "$ref":"#/components/schemas/PersonRsp"
            }
         },
         "application/json":{
            "schema":{
               "$ref":"#/components/schemas/PersonRsp"
            }
         }
      }
   }
}

springdoc-1.1.33 and spring-boot-2.1.7

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
springdoccommented, Sep 4, 2019

As per OpenAPI 3 specification, your API description needs to specify the responses for all API operations. Each operation must have at least one response defined, usually a successful response. A response is defined by its HTTP status code and the data returned in the response body and/or headers:

If you need to hide HTTP Codes from other configurations (@ControllerAdvice), you can use @Hidden annotation on the methods of your ControllerAdvice.

0reactions
membersoundcommented, Sep 4, 2019

Ok thanks for clarifying this. Let’s leave this issue closed, as my main question “how to hide responses” is solved then.

But I had to create a follow up issue regarding @Hidden on @ControllerAdvise: https://github.com/springdoc/springdoc-openapi/issues/81

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Is there any way I can hide the get request response ...
Short answer, no. Longer answer, depends. You can try to obscure the request with headers or query params, but still clients can always ......
Read more >
Hide properties of Mongoose objects in Node.JS JSON ...
The solution is to define a custom . toJSON() method on the Mongoose schema and delete the properties which you don't want to...
Read more >
How to Hide API Keys with Node JS - YouTube
Learn how to Hide API Keys with Node JS. Hiding API Keys with dotenv environment variables is possible in server-side Node JS.
Read more >
Hide properties of Mongoose objects in Node.JS JSON ...
The solution is to define a custom . toJSON() method on the Mongoose schema and delete the properties which you don't want to...
Read more >
[Node] How can I hide some of the headers from full response ...
Hi, I want to hide the some of the headers from full response that is shown in the transaction trace. Is that possible?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found