-
Notifications
You must be signed in to change notification settings - Fork 472
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
Add ignore_defaults
option
#491
Add ignore_defaults
option
#491
Conversation
@pezholio … thanks please run |
Right, that should help 😄 I've also added a separate spec for the behaviour, rather than rolling it into the main |
let(:json) { JSON.parse(last_response.body) } | ||
|
||
it 'only returns one response if ignore_defaults is specified' do | ||
expect(json['paths']['/delay_thing']['post']['responses']).to eq('202' => { 'description' => 'OK' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add also an expectation, which proofs that the default wasn't created:
expect(json['paths']['/delay_thing']['post']['responses'].keys).not_to include '201'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No probs 👍
👍 … cc/ @Bugagazavr, if you are fine with it, I'll cut the next release |
LGTM |
* Add `ignore_defaults` option * Update Changelog * Make Rubocop happy * Add seperate spec for `ignore_defaults` * Make tests more specific * Revert Rubocop-pleasing changes * Increase max line length
As outlined in #490 - it seems that grape-swagger adds a default
201
response forPUT
andPOST
requests. If aPUT
orPOST
request doesn't immediately create a resource, the correct response is202 Accepted
. In this case, we want to ignore the default201
response, and only specify a202
.There may be other use cases as well, so I've added support for an
ignore_defaults
option which only adds user-specified responses, and ignores the default responses specified in https://github.com/ruby-grape/grape-swagger/blob/master/lib/grape-swagger/doc_methods/status_codes.rb