Add default responses
See original GitHub issueCurrently, every single operation must declare its’ own responses. This causes a whole bunch of duplication, which would be better served by having a top-level responses
section in the spec. Like the security
construct, operations could override the default responses on their own.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:32
- Comments:18 (9 by maintainers)
Top Results From Across the Web
Describing Responses - Swagger
You can use the default response to describe these errors collectively, not individually. “Default” means this response is used for all HTTP codes...
Read more >Add Default Choices - Qualtrics
While editing your survey, select the question you want to add default choices to. · In the Question behavior of the survey editor,...
Read more >Proposal: Default responses for all endpoints #521 - GitHub
I suggest that we add "default responses" that can be defined as default response for All endpoints. This would avoid copy-paste for some ......
Read more >Add a default 200 response to all API paths - GSoC - Postman
A default response is a response returned for cases not covered for a particular API path. You need to put yourself in the...
Read more >Serving a Default Response - WireMock
Start by creating a stub with ANY as the method. Open the Advanced section and change the URL match type to Any URL...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A simple usecase, status code which apply to all paths: 401, 403, 500, 502, 503, 504. They – in most cases – don’t require any response body. Maybe 500.
Good feedback on this. Two thoughts.
First, @darrelmiller’s suggestion is interesting as it can be used to compose many different types into an operation. It could become very verbose still, as one could potentially have dozens of constructs in the path identifier. I’ll keep thinking about how that could work.
Next, the notion of top-level definitions in the current 2.0 spec is a little confusing. For example as @dolmen pointed out, there is a
responses
section, but they’re not reallyresponses
–they areresponseDefinitions
. But we have a top-levelaccepts
which applies to all operations defined in the spec.I think these are different considerations. To address the 2nd item, in general, we have
definitions
andimplementations
at the root of the specification. Think ofdefinitions
as items which are always referenced elsewhere, andimplementations
as instances of requirements in the definition itself.Some definitions:
Some implementations:
This is very confusing. The purpose for named definitions was that the schema could be used to ensure that all items under the, say, parameters definition were valid.
To simplify the structure, and to make room for reusable components as well as a hierarchial structure, I propose the following:
Proposed structural changes
In the proposed structure, we now have a single
schemas
section which allows us to put all reusable components in a single section. It also makes it possible to have the newparameters
andresponses
section, which will give maximum reusability and readability.If a top-level response is defined, say with
404
as the key, then an operation can override it by defining a new404
response definition. There is no deletion of top-level items inside an operation.