-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix logic for mapping Hash and Array objects to refs * Add tests to account for documented Hashes and Arrays * Do not include readOnly params in request definitions * Test for new documentation behavior * Update changelog [ci skip] * Use respond_to? instead of try for earlier compliance * Use proper url for changelog
- Loading branch information
1 parent
6ef800c
commit 611572f
Showing
12 changed files
with
97 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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,60 @@ | ||
require 'spec_helper' | ||
|
||
describe 'document hash and array' do | ||
include_context "#{MODEL_PARSER} swagger example" | ||
|
||
before :all do | ||
module TheApi | ||
class TestApi < Grape::API | ||
format :json | ||
|
||
documentation = ::Entities::DocumentedHashAndArrayModel.documentation if ::Entities::DocumentedHashAndArrayModel.respond_to?(:documentation) | ||
|
||
desc 'This returns something' | ||
namespace :arbitrary do | ||
params do | ||
requires :id, type: Integer | ||
end | ||
route_param :id do | ||
desc 'Timeless treasure' | ||
params do | ||
requires :body, using: documentation unless documentation.nil? | ||
requires :raw_hash, type: Hash, documentation: { param_type: 'body' } if documentation.nil? | ||
requires :raw_array, type: Array, documentation: { param_type: 'body' } if documentation.nil? | ||
end | ||
put '/id_and_hash' do | ||
{} | ||
end | ||
end | ||
end | ||
|
||
add_swagger_documentation | ||
end | ||
end | ||
end | ||
|
||
def app | ||
TheApi::TestApi | ||
end | ||
|
||
subject do | ||
get '/swagger_doc' | ||
JSON.parse(last_response.body) | ||
end | ||
describe 'generated request definition' do | ||
it 'has hash' do | ||
expect(subject['definitions'].keys).to include('putArbitraryIdIdAndHash') | ||
expect(subject['definitions']['putArbitraryIdIdAndHash']['properties'].keys).to include('raw_hash') | ||
end | ||
|
||
it 'has array' do | ||
expect(subject['definitions'].keys).to include('putArbitraryIdIdAndHash') | ||
expect(subject['definitions']['putArbitraryIdIdAndHash']['properties'].keys).to include('raw_array') | ||
end | ||
|
||
it 'does not have the path parameter' do | ||
expect(subject['definitions'].keys).to include('putArbitraryIdIdAndHash') | ||
expect(subject['definitions']['putArbitraryIdIdAndHash']).to_not include('id') | ||
end | ||
end | ||
end |
This file contains 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 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