Skip to content
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

operation-2xx-response rule should not be recommended #1273

Closed
krystof-k opened this issue Jul 5, 2020 · 4 comments · Fixed by #1304
Closed

operation-2xx-response rule should not be recommended #1273

krystof-k opened this issue Jul 5, 2020 · 4 comments · Fixed by #1304
Labels
breaking Pull requests that introduce a breaking change enhancement New feature or request

Comments

@krystof-k
Copy link

I suggest to move operation-2xx-response rule out from recommended, as it is reasonable to have endpoints that have no success response but only 3xx redirects. Or maybe change the rule to allow 2xx or 3xx responses.

What do you think?

@krystof-k krystof-k added the chore label Jul 5, 2020
@nulltoken nulltoken added enhancement New feature or request question Further information is requested and removed chore question Further information is requested labels Jul 7, 2020
@philsturgeon
Copy link
Contributor

@krystof-k hey there! Could you explain the use case a little more? What is happening with your API where only 3xx is coming out of it? I seem to remember the YouTube API used to do this, where a successful POST would then say "this worked out and you should follow to the Location to get the content" but this always struct as a weird choice. 204 with a Content-Location would be more correct.

If you want room to be creative, you can turn that rule off, but maybe there is a legit use case I'm forgetting and you could help remind me!

@krystof-k
Copy link
Author

krystof-k commented Jul 8, 2020

We use it for forwarding to pre-signed URL on AWS S3. Client requests GET /files/{file ID} and if authorized, server generates the URL and sends Location: https://bucket.s3.amazonaws.com/file.ext?X-Amz-Signature=blabla header in the response.

Not sure whether this is a best practise, I was doing some research and the only thing I found was Microsoft OneDrive, but maybe there is a better way to do it :)

@philsturgeon
Copy link
Contributor

Ahh nice use case.

Ok, let's change this rule from operation-2xx-response to operation-success and look for anything starting with a 2 or a 3.

@philsturgeon philsturgeon added the breaking Pull requests that introduce a breaking change label Jul 8, 2020
@krystof-k
Copy link
Author

Cool! :)

BTW thanks for mentioning Content-Location header, seems I'm using the Location header for newly created object in 201 Created response wrong :)

philsturgeon pushed a commit that referenced this issue Aug 20, 2020
* BREAKING: removed operation-default-response

The spec says: The default MAY be used as a default response object for all HTTP codes that are not covered individually by the specification.

There's no need to suggest anyone default is any more important than optional.

* chore: remove nvmrc

lets let people run this with whatever version and the CI will confirm it works with versions we care about.

* fixes #1273: allow 2xx or 3xx responses

* BREAKING: Made openapi-tags not recommended

If you want to use it, switch from  to

fixes #1132

* put nvmrc back

Co-authored-by: Phil Sturgeon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Pull requests that introduce a breaking change enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants