-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Not able to implement Prefer
header behavior.
#2109
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
Comments
Your
|
@rmedaer Since you don't need to correlate the Prefer values, you could just make the response schema oneOf:
- type: string
maxLength: 0
- type: object
required: [..]
properties: {...} |
@rmedaer The |
You could do an enum for the header and, in this case, it's pretty obvious which header value corresponds, but that's definitely not automatically enforced by anything. |
@rmedaer Create one schema that validates both minimal and representation as Henry suggested and then create two examples and use the key of the example to identify the minimal vs the full representation example. |
Looks good to me. Many thanks |
The RFC7240 (Section 4.2) defines how-to indicate to the server the preferred representation to return.
minimal
one: no content, aLocation
header with URI of full resource representation.representation
: returns the resource in response content, (optionalLocation
header?)I implemented this behavior in my API. But I would like to specify it in my OpenAPI specification.
This is the current specification I wrote:
Although this is not 100% correct. Indeed, because I'm not able to specify multiple responses with the same code, I can't define the two behaviors depending on
Prefer
request header.Btw I don't need to express the "switching"
Prefer
behavior, but at least I want to express the two possible behaviors/responses.Maybe related to: #1572
Any thoughts ?
The text was updated successfully, but these errors were encountered: