-
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.
Allow DELETE to have a params schema definition (#923)
- Loading branch information
Showing
5 changed files
with
61 additions
and
3 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
55 changes: 55 additions & 0 deletions
55
spec/issues/923_params_schema_definition_for_delete_action_spec.rb
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,55 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe '#923 Body params for DELETE action' do | ||
let(:app) do | ||
Class.new(Grape::API) do | ||
params do | ||
requires :post_id, type: Integer | ||
requires :query, type: String, documentation: { type: 'string', param_type: 'body' } | ||
end | ||
delete '/posts/:post_id/comments' do | ||
{ 'declared_params' => declared(params) } | ||
end | ||
add_swagger_documentation format: :json | ||
end | ||
end | ||
|
||
describe 'retrieves the documentation for delete parameters as a schema defintion' do | ||
subject do | ||
get '/swagger_doc' | ||
JSON.parse(last_response.body) | ||
end | ||
|
||
specify do | ||
expect(subject['paths']['/posts/{post_id}/comments']['delete']['parameters']).to match( | ||
[ | ||
{ | ||
'format' => 'int32', | ||
'in' => 'path', | ||
'name' => 'post_id', | ||
'type' => 'integer', | ||
'required' => true | ||
}, | ||
{ | ||
'name' => 'deletePostsPostIdComments', | ||
'in' => 'body', | ||
'required' => true, | ||
'schema' => { '$ref' => '#/definitions/deletePostsPostIdComments' } | ||
} | ||
] | ||
) | ||
|
||
expect(subject['definitions']['deletePostsPostIdComments']).to match( | ||
'type' => 'object', | ||
'properties' => { | ||
'query' => { | ||
'type' => 'string' | ||
} | ||
}, | ||
'required' => ['query'] | ||
) | ||
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