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

Default success codes to be excluded when http_codes define one already #641

Merged
merged 2 commits into from
Oct 23, 2017

Conversation

anakinj
Copy link
Contributor

@anakinj anakinj commented Oct 17, 2017

It was not possible to override a POSTs default 201 status code. This change will prevent the default success code to be added if the http_codes array already include a success code.

@anakinj anakinj force-pushed the endpoint-status-codes branch from 1f65109 to 35ca182 Compare October 17, 2017 07:39
@coveralls
Copy link

Coverage Status

Coverage increased (+2.3%) to 99.643% when pulling 35ca182 on anakinj:endpoint-status-codes into 6dac1ae on ruby-grape:master.

@ruby-grape ruby-grape deleted a comment from coveralls Oct 22, 2017
@ruby-grape ruby-grape deleted a comment from coveralls Oct 22, 2017
@ruby-grape ruby-grape deleted a comment from coveralls Oct 22, 2017
@ruby-grape ruby-grape deleted a comment from coveralls Oct 22, 2017
Copy link
Member

@LeFnord LeFnord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @anakinj … but have one question, see comment

let(:app) do
Class.new(Grape::API) do
desc 'Has explicit http_codes defined' do
http_codes [{ code: 202, message: 'We got it!' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's happened if we have mixed codes, something like this:

http_codes [
  { code: 200, message: 'all fine' },
  { code: 404, message: 'Not found' }
]

maybe adding a spec to document the behaviour

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some more status codes combinations to the specs

@anakinj anakinj force-pushed the endpoint-status-codes branch from 35ca182 to a38c704 Compare October 22, 2017 17:05
@anakinj anakinj force-pushed the endpoint-status-codes branch from a38c704 to 1aab0ee Compare October 22, 2017 17:07
@coveralls
Copy link

coveralls commented Oct 22, 2017

Coverage Status

Coverage increased (+0.007%) to 97.895% when pulling a38c704 on anakinj:endpoint-status-codes into 8ec91db on ruby-grape:master.

@coveralls
Copy link

coveralls commented Oct 22, 2017

Coverage Status

Coverage increased (+0.007%) to 97.895% when pulling 1aab0ee on anakinj:endpoint-status-codes into 8ec91db on ruby-grape:master.

@LeFnord
Copy link
Member

LeFnord commented Oct 23, 2017

thanks @anakinj

@LeFnord LeFnord merged commit 7cc5e22 into ruby-grape:master Oct 23, 2017
@anakinj anakinj deleted the endpoint-status-codes branch October 23, 2017 19:21
hara-y-u pushed a commit to hara-y-u/grape-swagger that referenced this pull request Dec 8, 2017
…dy (ruby-grape#641)

* Do not include the default success codes to the responses if http_codes define one already

* Added spec with success and error codes
LeFnord pushed a commit to LeFnord/grape-swagger that referenced this pull request Feb 9, 2019
…dy (ruby-grape#641)

* Do not include the default success codes to the responses if http_codes define one already

* Added spec with success and error codes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants