You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal: Default responses for all endpoints #521
I 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 (#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.
Reacted by verglor, Mike, marcelion, Pawel, Diego Z., Aleksandr / nishikigoi (錦鯉), Gustavo Perdomo, Tatsuru Kawatsu, Domen Kožar, Novikov Bogdan and 194 more
Reacted by sarangsbabu367, Victor Vieira Barros Leal da Silveira, Alexander Fomin, Lucas Colombo, MaurizioMoreo and Kosta
Just a reminder, please use github reactions, rather than "+1" comments (two recent ones deleted).
Reacted by Ian Sanders, Seiya, Sampo Kivistö, Chris Adams, Andriy Zaleskyy, Ilya Sakharchuk, Ralf Handl, Alysson Malagutte, kennarddh, Rafael Claudino Garcia and 5 more
Reacted by Artem Zaitsev, marmax-esl, Oleg Zhilo, marstona, Christopher Powroznik, Denis Pshenov, jenpet, Jimmy Royer, andybeetz, Vinay Londhe and 7 more
Reacted by Ian Sanders, Seiya, Chris Adams and Karen Etheridge
Not the way that I understand it… https://datatracker.ietf.org/doc/html/rfc7807 Grammar specifically says you can have additional fields.
On Fri 5 May 2023 at 20:42, Jeremy Fiel @.> wrote: RFC7807 error schema allows reuse of the same schema with the flexibility to apply different messages for each error in your service. You can create infinite examples of every possible error but the schema remains the same. On Fri, May 5, 2023, 14:21 Homa Wong @.> wrote: > that comment has a ... in the example just where it would explain what it > is trying to achieve > > Hi, the ... literally means adding anything specific for that usage. > > Using that example, 400.BadRequest only describes the HTTP Status that it > is a bad request. > i.e. the user pass in something that does not recognized or accepted by > the endpoint. > What could they be? That's specific to every usage. > > e.g. customer-id is missing, item-count can't be negative number, etc. > > Without the ability to use allOf at the response level, > none of the response can be reused when we need to do any customization > tailors to each usage. > > — > Reply to this email directly, view it on GitHub > < #521 (comment) >, > or unsubscribe > < https://github.com/notifications/unsubscribe-auth/AHU7MTK7B7VSUMGITXAZAU3XEVAKPANCNFSM4BV5WOKA > > . > You are receiving this because you commented.Message ID: > @.> > — Reply to this email directly, view it on GitHub <#521 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHCBEMMZ7NETJ2BIAZ7PHBDXEVCZPANCNFSM4BV5WOKA . You are receiving this because you are subscribed to this thread.Message ID: @.>
You might not want to give your your phone number and address publicly on Github?
You're basically doxxing yourself here 🤔
Sorry for hijacking the thread, carry on.
You might not want to give your your phone number and address publicly on Github? You're basically doxxing yourself here 🤔 Sorry for hijacking the thread, carry on.
Thanks for pointing this... that's the problem of answering by email. Fixed now. Thanks!!
I'm not sure why this rather simple proposal sparked so much debate. It only took working with OpenAPI for a few days for me to notice this gap when defining my API.
Nonetheless, it's not clear what the idiomatic way is for dealing with errors that are common to all your paths (401/403 is the simplest example). Defining these for every path just doesn't seem right.
If the spec was solely for documentation, I would say that error types that are truly universal to all your endpoints, and thus not surprising to callers of your API, are not even worth defining in your spec. But omitting errors that your API can return can have negative implications as soon as you start generating type safe clients with your spec.
This proposal is already 8 years old - how can we move it forward?
Reacted by Raul Tierno, Jeff May, Jacob Smits and Luis Selvera
@ralfhandl yes, I think we can mark this "Moved to Moonwalk" and close it out here (Features added to Moonwalk will be back-ported to 3.x if it makes sense to do so, so there's no need to track it in both repositories).
I'm not sure why this rather simple proposal sparked so much debate.
This is a standards group, debating things that seem simple is practically a requirement 🙃 It's definitely frustrating at times, but I suspect this didn't get into 3.1 partially because there was a bit of a debate about how much we really even want to document all responses, but mostly because we had big things in 3.1 already and no one realized that the spec work would slow down so much afterwards. But it will find some sort of home in 4.0 (Moonwalk). And possibly to some degree in a future 3.x.
Activity
[-]Proposal: Default error responses for all endpoints[/-][+]Proposal: Default responses for all endpoints[/+]mrname commentedon Dec 31, 2015
👍 to the suggestion. As you mentioned, this would save A LOT of copy/paste.
jharmn commentedon Feb 16, 2016
Link to meta #566
MikeRalphson commentedon Aug 3, 2018
Just a reminder, please use github reactions, rather than "+1" comments (two recent ones deleted).
marmax commentedon Jun 12, 2019
Is there any progress with this? The ticket is open for more than 3 years now... :(
NoiseByNorthwest commentedon Jul 18, 2019
I cannot imagine why this is not fixed yet as this issue just makes impossible to specify an error for an invalid path (404) or method (405).
nogates commentedon Jul 19, 2019
you can reference responses, which is more or less what is being requested here:
I know this is much more verbose, but at least is a workaround....
saturov commentedon Jan 16, 2020
+1 dream about this feature
avsmirnov567 commentedon Jan 16, 2020
+1, will be useful
r3tam commentedon Jan 16, 2020
+1, amazing feature
50 remaining items
piotr-yuxuan commentedon Jun 2, 2023
fyi, this long-standing issue is addressed in: https://github.com/OAI/moonwalk
rockymontana commentedon Oct 11, 2023
You might not want to give your your phone number and address publicly on Github?
You're basically doxxing yourself here 🤔
Sorry for hijacking the thread, carry on.
mxmlnglt commentedon Oct 16, 2023
Thanks for pointing this... that's the problem of answering by email. Fixed now. Thanks!!
andrew-rivera-dev commentedon Mar 14, 2024
I'm not sure why this rather simple proposal sparked so much debate. It only took working with OpenAPI for a few days for me to notice this gap when defining my API.
Nonetheless, it's not clear what the idiomatic way is for dealing with errors that are common to all your paths (401/403 is the simplest example). Defining these for every path just doesn't seem right.
If the spec was solely for documentation, I would say that error types that are truly universal to all your endpoints, and thus not surprising to callers of your API, are not even worth defining in your spec. But omitting errors that your API can return can have negative implications as soon as you start generating type safe clients with your spec.
This proposal is already 8 years old - how can we move it forward?
ralfhandl commentedon Mar 14, 2024
Would this be covered by the suggested
apiResponsesandpathResponsesin the OpenAPI v4 (aka Moonwalk) Proposal?handrews commentedon Mar 14, 2024
@ralfhandl yes, I think we can mark this "Moved to Moonwalk" and close it out here (Features added to Moonwalk will be back-ported to 3.x if it makes sense to do so, so there's no need to track it in both repositories).
@andrew-rivera-dev
This is a standards group, debating things that seem simple is practically a requirement 🙃 It's definitely frustrating at times, but I suspect this didn't get into 3.1 partially because there was a bit of a debate about how much we really even want to document all responses, but mostly because we had big things in 3.1 already and no one realized that the spec work would slow down so much afterwards. But it will find some sort of home in 4.0 (Moonwalk). And possibly to some degree in a future 3.x.
piotr-yuxuan commentedon May 29, 2024
Thanks for clarifying!
xmak commentedon Nov 23, 2024
This is already possible to achieve using
allOf. See here:#563 (comment)