-
Notifications
You must be signed in to change notification settings - Fork 476
Add ignore_defaults
option
#491
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
Merged
LeFnord
merged 7 commits into
ruby-grape:master
from
pezholio:feature-ignore-default-http-responses
Aug 4, 2016
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
935b2dc
Add `ignore_defaults` option
pezholio 89b35e5
Update Changelog
pezholio e672429
Make Rubocop happy
pezholio 7ebdceb
Add seperate spec for `ignore_defaults`
pezholio 1a8daf1
Make tests more specific
pezholio d9f493e
Revert Rubocop-pleasing changes
pezholio 236c582
Increase max line length
pezholio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'spec_helper' | ||
|
||
describe 'swagger spec v2.0' do | ||
include_context "#{MODEL_PARSER} swagger example" | ||
|
||
def app | ||
Class.new(Grape::API) do | ||
format :json | ||
|
||
desc 'This creates Thing after a delay', | ||
success: Entities::Something | ||
params do | ||
requires :text, type: String, documentation: { type: 'string', desc: 'Content of something.' } | ||
requires :links, type: Array, documentation: { type: 'link', is_array: true } | ||
end | ||
post '/delay_thing', http_codes: [{ code: 202, message: 'OK' }], ignore_defaults: true do | ||
status 202 | ||
end | ||
|
||
version 'v3', using: :path | ||
add_swagger_documentation api_version: 'v1', | ||
base_path: '/api', | ||
info: { | ||
title: 'The API title to be displayed on the API homepage.', | ||
description: 'A description of the API.', | ||
contact_name: 'Contact name', | ||
contact_email: '[email protected]', | ||
contact_url: 'Contact URL', | ||
license: 'The name of the license.', | ||
license_url: 'www.The-URL-of-the-license.org', | ||
terms_of_service_url: 'www.The-URL-of-the-terms-and-service.com' | ||
} | ||
end | ||
end | ||
|
||
before do | ||
get '/v3/swagger_doc' | ||
end | ||
|
||
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 commentThe 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:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No probs 👍 |
||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is this a rubocop recommendation? … it is really a very long line … can you change it back?
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.
I couldn't see any other way to cut down the number of lines. A bit of a cheat I know. Happy to change it back, but Rubocop will complain, and I'm not sure there's any way to add the functionality without increasing the number of lines :/
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.
yeap, it is known, change it back and increase the number, please
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.
Cool - done! 😄