Skip to content

Commit

Permalink
Merge pull request #411 from Bugagazavr/add-options
Browse files Browse the repository at this point in the history
Added support for OPTIONS endpoints
  • Loading branch information
dblock committed May 6, 2016
2 parents 819fcc5 + d6ee3e9 commit b7cdab9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [#406](https://github.com/ruby-grape/grape-swagger/pull/406): Force usage of entities for response definition [issue #385](https://github.com/ruby-grape/grape-swagger/issues/385) - [@LeFnord](https://github.com/LeFnord).
* [#405](https://github.com/ruby-grape/grape-swagger/pull/405), [#403](https://github.com/ruby-grape/grape-swagger/issues/403): Added version support matrix - [@LeFnord](https://github.com/LeFnord).
* [#408](https://github.com/ruby-grape/grape-swagger/pull/408): Added support for `HEAD` endpoints - [@Bugagazavr](https://github.com/Bugagazavr).
* [#408](https://github.com/ruby-grape/grape-swagger/pull/411): Added support for `OPTIONS` endpoints - [@Bugagazavr](https://github.com/Bugagazavr).
* [#407](https://github.com/ruby-grape/grape-swagger/issues/407): Added support for Grape 0.15.x - [@dblock](https://github.com/dblock).
* Your contribution here.

Expand Down
3 changes: 2 additions & 1 deletion lib/grape-swagger/doc_methods/status_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def get
put: { code: 200, message: 'updated {item}' },
patch: { code: 200, message: 'patched {item}' },
delete: { code: 200, message: 'deleted {item}' },
head: { code: 200, message: 'head {item}' }
head: { code: 200, message: 'head {item}' },
options: { code: 200, message: 'option {item}' }
}
end
end
Expand Down
37 changes: 34 additions & 3 deletions spec/swagger_v2/simple_mounted_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class SimpleMountedApi < Grape::API
status 200
end

options '/simple-options-test' do
status 200
end

desc 'this gets something else',
headers: {
'XAuthToken' => { description: 'A required header.', required: true },
Expand Down Expand Up @@ -84,7 +88,14 @@ def app
'swagger' => '2.0',
'produces' => ['application/xml', 'application/json', 'application/octet-stream', 'text/plain'],
'host' => 'example.org',
'tags' => [{ 'name' => 'simple', 'description' => 'Operations about simples' }, { 'name' => 'simple-test', 'description' => 'Operations about simple-tests' }, { 'name' => 'simple-head-test', 'description' => 'Operations about simple-head-tests' }, { 'name' => 'simple_with_headers', 'description' => 'Operations about simple_with_headers' }, { 'name' => 'items', 'description' => 'Operations about items' }, { 'name' => 'custom', 'description' => 'Operations about customs' }],
'tags' => [
{ 'name' => 'simple', 'description' => 'Operations about simples' },
{ 'name' => 'simple-test', 'description' => 'Operations about simple-tests' },
{ 'name' => 'simple-head-test', 'description' => 'Operations about simple-head-tests' },
{ 'name' => 'simple-options-test', 'description' => 'Operations about simple-options-tests' },
{ 'name' => 'simple_with_headers', 'description' => 'Operations about simple_with_headers' },
{ 'name' => 'items', 'description' => 'Operations about items' },
{ 'name' => 'custom', 'description' => 'Operations about customs' }],
'paths' => {
'/simple' => {
'get' => {
Expand All @@ -106,6 +117,12 @@ def app
'responses' => { '200' => { 'description' => 'head SimpleHeadTest' } },
'tags' => ['simple-head-test'],
'operationId' => 'headSimpleHeadTest' } },
'/simple-options-test' => {
'options' => {
'produces' => ['application/json'],
'responses' => { '200' => { 'description' => 'option SimpleOptionsTest' } },
'tags' => ['simple-options-test'],
'operationId' => 'optionsSimpleOptionsTest' } },
'/simple_with_headers' => {
'get' => {
'description' => 'this gets something else',
Expand Down Expand Up @@ -154,7 +171,14 @@ def app
'swagger' => '2.0',
'produces' => ['application/xml', 'application/json', 'application/octet-stream', 'text/plain'],
'host' => 'example.org',
'tags' => [{ 'name' => 'simple', 'description' => 'Operations about simples' }, { 'name' => 'simple-test', 'description' => 'Operations about simple-tests' }, { 'name' => 'simple-head-test', 'description' => 'Operations about simple-head-tests' }, { 'name' => 'simple_with_headers', 'description' => 'Operations about simple_with_headers' }, { 'name' => 'items', 'description' => 'Operations about items' }, { 'name' => 'custom', 'description' => 'Operations about customs' }],
'tags' => [
{ 'name' => 'simple', 'description' => 'Operations about simples' },
{ 'name' => 'simple-test', 'description' => 'Operations about simple-tests' },
{ 'name' => 'simple-head-test', 'description' => 'Operations about simple-head-tests' },
{ 'name' => 'simple-options-test', 'description' => 'Operations about simple-options-tests' },
{ 'name' => 'simple_with_headers', 'description' => 'Operations about simple_with_headers' },
{ 'name' => 'items', 'description' => 'Operations about items' },
{ 'name' => 'custom', 'description' => 'Operations about customs' }],
'paths' => {
'/simple' => {
'get' => {
Expand All @@ -180,7 +204,14 @@ def app
'swagger' => '2.0',
'produces' => ['application/xml', 'application/json', 'application/octet-stream', 'text/plain'],
'host' => 'example.org',
'tags' => [{ 'name' => 'simple', 'description' => 'Operations about simples' }, { 'name' => 'simple-test', 'description' => 'Operations about simple-tests' }, { 'name' => 'simple-head-test', 'description' => 'Operations about simple-head-tests' }, { 'name' => 'simple_with_headers', 'description' => 'Operations about simple_with_headers' }, { 'name' => 'items', 'description' => 'Operations about items' }, { 'name' => 'custom', 'description' => 'Operations about customs' }],
'tags' => [
{ 'name' => 'simple', 'description' => 'Operations about simples' },
{ 'name' => 'simple-test', 'description' => 'Operations about simple-tests' },
{ 'name' => 'simple-head-test', 'description' => 'Operations about simple-head-tests' },
{ 'name' => 'simple-options-test', 'description' => 'Operations about simple-options-tests' },
{ 'name' => 'simple_with_headers', 'description' => 'Operations about simple_with_headers' },
{ 'name' => 'items', 'description' => 'Operations about items' },
{ 'name' => 'custom', 'description' => 'Operations about customs' }],
'paths' => {
'/simple-test' => {
'get' => {
Expand Down

0 comments on commit b7cdab9

Please sign in to comment.