Are there plans to add support for global responses? #5006
Replies: 3 comments 4 replies
-
|
There are no plans to support this in the 3.x specification series, but it's a fairly common use case. The Overlay standard supports this pattern pretty well, and I'd recommend you look at that for a solution. |
Beta Was this translation helpful? Give feedback.
-
|
I believe this came up as a moonwalk discussion -- the idea of having global responses for various response codes like 500, 503 which would apply to all endpoints in the document unless they were overridden at a specific operation level, much as we have a global As it is a new concept that doesn't change existing parts of the document, it could conceivably be added in a 3.x release. |
Beta Was this translation helpful? Give feedback.
-
|
@lornajane Thanks for reporting on the current plans and for mentioning alternative solutions. I am curious why you are not considering it for future OpenAPI versions as the concept of having some global definitions is already present with the
This is a use case that every team is facing when designing OpenAPI specs, so it would also have a high impact. I also looked in the Overlay Spec and I think it is only a partial solution to the problem. You can use the Overlay to generate a generic error code on every endpoint. That way you save some manual labor. But the result will still be a bloated OpenAPI Spec file where the error code is added to every endpoint instead of having a global section with common error codes. I am curious to hear your thoughts on this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be helpful if OpenAPI specification allowed me to specify certain responses that will be returned for every endpoint in the specification, rather than having to document every response on every endpoint. (Although I would imagine people might want to apply those default responses to some sort of pattern matching, either by path or tag or other...)
For instance, if my API requires authentication on every endpoint, applies rate limiting to every endpoint, and can return a
500 Internal Server Errorfor every endpoint, then it would be nice to define a default set of responses for 401, 403, 429 and 500. Those responses would also include e.g. rate limit headers.When following a design-first approach, this would significantly reduce the amount of copy-pasting of response references, reduce the chance of making errors, and reduce size of a fully-documented OpenAPI specification, which then decreases the resources required to process one when generating client-side docs.
Beta Was this translation helpful? Give feedback.
All reactions