Proposal: Default responses for all endpoints
See original GitHub issueI suggest that we add “default responses” that can be defined as default response for All endpoints. This would avoid copy-paste for some common responses like:
429 Too Many Requests 405 Method Not Allowed
The format could be
produces:
- application/json
responses:
'429':
description: to many requests in the given timeframe
schema:
$ref: '#/definitions/error'
paths:
...
Or if flexibility is required, we could alter the default response keyword to take a list of responsedefinitions. This could benefit with the response code range proposal (https://github.com/swagger-api/swagger-spec/issues/516).
responseDefinitions:
"success":
description: request successful
code: 200
"request limit":
description: to many requests in the given timeframe
code: 429, 419
schema:
$ref: '#/definitions/error'
"server error":
description: server error
code: 500 - 599
schema:
$ref: '#/definitions/error'
paths
test:
get:
responses:
default:
- "success"
- "request limit"
- "server error"
this would require some changes to the default response keyword.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:165
- Comments:42 (7 by maintainers)
Top Results From Across the Web
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 >Describing Responses - Swagger
Describing Responses. An API specification needs to specify the responses for all API operations. Each operation must have at least one response defined, ......
Read more >Gateway responses in API Gateway - AWS Documentation
Setting up gateway responses to customize error responses By default, the error response contains a short descriptive error message. For example, if you ......
Read more >Stripe API reference – curl
By default, the Stripe API Docs demonstrate using curl to interact with the API ... Stripe uses conventional HTTP response codes to indicate...
Read more >java - Rest api, adding another MediaType, default response
May that cause some problems with user apps that are using this endpoint? For example when they are not specyfing header with response...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
I’m currently looking at the possible need to add a default / override for the JSON Schema,
$schema
$vocabulary
etc keywords in OAS 3.1A design question comes up between simplicity and extensibility of this “default” feature.
Would something like:
address the requirements for people in this issue? Bearing in mind @darrelmiller’s very good advice in this tweet.
+1 dream about this feature