-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do we need to clarify what a response missing content means #3536
Comments
Hi! I need the same clarification:
I'm working on some scaffolding tools that have to extract meaning from these kinds of situations. My original interpretation was "will have a response with something" but that obviously breaks the intention when So:
I saw the discussion at #2236 but that's outside my current scope because we are not intending to support optionally present responses (yet). |
It depends on what you mean...
|
Discussion in TDC this week, we don't think we can infer from an absence of response information in an API description whether this means there is no response expected, or the response information is missing from the API description file. |
I would do that with... responses:
2xx:
content:
*/*:
schema: {} ..but |
Given the questions in this thread, we might need to be more explicit in the specification that absence of a specification does NOT indicate that a particular component must be absent; rather the lack of a specification for a thing means that anything is allowed. I'm sure there is some kind of strict language in RFC-style that can be used here, rather than doing it colloquially. |
Thanks for the detailed response!
So something like: responses:
200:
description: "Everything went OK!"
content:
*/*:
schema: false Right? Is an exception like "A 204 response without schema can be interpreted as a false schema" viable? I know this is ugly, but I saw multiple APIs do: responses:
204:
description: "Don't expect any content from me lol. I'm a 204"
You mean that as a schema for the
Maybe something like:
If we want a
The biggest issue with the exception is that it breaks reusability of responses via de |
I've been writing up guides for contract testing with OpenAPI in a bunch of different languages, and the Ruby on Rails one using https://github.com/mkon/openapi_contracts/ gave this great example, letting me know an empty response has been defined, but a response has been provided by the API implementation.
Here's some OpenAPI for visual people:
Does this mean "There is definitely no content" or "I haven't bothered defining it but dont worry about it"?
There are ways to define a "dont worry about it" thats a bit more specific, like:
Or you can pop an example in instead of worrying about defining a schema but still providing something tangible for docs/mocks to think about.
Scrabbling round the spec I coudn't find anything in 3.0 or 3.1 but the SmartBear Guide on Describing Responses does explicitly say:
This leads me to think all responses missing a
content
should have no body, because otherwise there's going to be some weird logic going "If 204 then missing means definitely no body but otherwise it just means I dunno!"Would that be a breaking change to 3.1.x if its clarifying intent? Or does this have to go to Moonwalk?
The text was updated successfully, but these errors were encountered: