grape-swagger 0.20.2 → 0.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -3
  3. data/.rubocop_todo.yml +43 -33
  4. data/.travis.yml +22 -13
  5. data/CHANGELOG.md +29 -53
  6. data/Gemfile +1 -1
  7. data/README.md +24 -24
  8. data/example/api/endpoints.rb +28 -29
  9. data/example/api/entities.rb +1 -1
  10. data/example/config.ru +5 -7
  11. data/grape-swagger.gemspec +1 -1
  12. data/lib/grape-swagger.rb +9 -6
  13. data/lib/grape-swagger/doc_methods.rb +1 -1
  14. data/lib/grape-swagger/doc_methods/extensions.rb +3 -3
  15. data/lib/grape-swagger/doc_methods/headers.rb +1 -1
  16. data/lib/grape-swagger/doc_methods/move_params.rb +25 -16
  17. data/lib/grape-swagger/doc_methods/operation_id.rb +2 -2
  18. data/lib/grape-swagger/doc_methods/parse_params.rb +12 -5
  19. data/lib/grape-swagger/doc_methods/path_string.rb +1 -1
  20. data/lib/grape-swagger/doc_methods/status_codes.rb +3 -1
  21. data/lib/grape-swagger/doc_methods/tag_name_description.rb +1 -1
  22. data/lib/grape-swagger/endpoint.rb +33 -46
  23. data/lib/grape-swagger/grape/route.rb +16 -0
  24. data/lib/grape-swagger/version.rb +1 -1
  25. data/spec/issues/403_versions_spec.rb +158 -0
  26. data/spec/lib/data_type_spec.rb +9 -10
  27. data/spec/lib/endpoint_spec.rb +1 -2
  28. data/spec/lib/extensions_spec.rb +44 -40
  29. data/spec/lib/move_params_spec.rb +113 -93
  30. data/spec/lib/operation_id_spec.rb +42 -12
  31. data/spec/lib/optional_object_spec.rb +3 -4
  32. data/spec/lib/path_string_spec.rb +2 -2
  33. data/spec/lib/produces_consumes_spec.rb +64 -53
  34. data/spec/markdown/redcarpet_adapter_spec.rb +1 -1
  35. data/spec/spec_helper.rb +1 -1
  36. data/spec/support/api_swagger_v2_result.rb +122 -128
  37. data/spec/support/namespace_tags.rb +17 -19
  38. data/spec/support/the_api_entities.rb +1 -3
  39. data/spec/support/the_paths_definitions.rb +95 -85
  40. data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +1 -1
  41. data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +19 -19
  42. data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +21 -21
  43. data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +34 -32
  44. data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +5 -7
  45. data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +19 -18
  46. data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +9 -10
  47. data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +21 -24
  48. data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +90 -92
  49. data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +54 -54
  50. data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +65 -57
  51. data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +17 -14
  52. data/spec/swagger_v2/api_swagger_v2_response_spec.rb +79 -123
  53. data/spec/swagger_v2/api_swagger_v2_spec.rb +33 -34
  54. data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +32 -36
  55. data/spec/swagger_v2/boolean_params_spec.rb +1 -1
  56. data/spec/swagger_v2/default_api_spec.rb +26 -29
  57. data/spec/swagger_v2/description_not_initialized.rb +3 -3
  58. data/spec/swagger_v2/float_api_spec.rb +1 -1
  59. data/spec/swagger_v2/form_params_spec.rb +4 -4
  60. data/spec/swagger_v2/hide_api_spec.rb +48 -51
  61. data/spec/swagger_v2/host.rb +1 -1
  62. data/spec/swagger_v2/mounted_target_class_spec.rb +31 -33
  63. data/spec/swagger_v2/namespace_tags_prefix_spec.rb +23 -21
  64. data/spec/swagger_v2/namespace_tags_spec.rb +23 -20
  65. data/spec/swagger_v2/param_type_spec.rb +5 -6
  66. data/spec/swagger_v2/param_values_spec.rb +31 -37
  67. data/spec/swagger_v2/params_array_spec.rb +17 -15
  68. data/spec/swagger_v2/params_hash_spec.rb +17 -15
  69. data/spec/swagger_v2/params_nested_spec.rb +12 -10
  70. data/spec/swagger_v2/reference_entity.rb +9 -9
  71. data/spec/swagger_v2/response_model_spec.rb +58 -62
  72. data/spec/swagger_v2/simple_mounted_api_spec.rb +179 -147
  73. metadata +5 -10
  74. data/spec/params_entity_spec.rb +0 -49
@@ -7,18 +7,48 @@ describe GrapeSwagger::DocMethods::OperationId do
7
7
  specify { expect(subject).to respond_to :build }
8
8
 
9
9
  describe 'build' do
10
- specify do
11
- expect(subject.build('GET')).to eql 'get'
12
- expect(subject.build('get')).to eql 'get'
13
- expect(subject.build(:get)).to eql 'get'
14
- expect(subject.build('GET', 'foo')).to eql 'getFoo'
15
- expect(subject.build('GET', '/foo')).to eql 'getFoo'
16
- expect(subject.build('GET', 'bar/foo')).to eql 'getBarFoo'
17
- expect(subject.build('GET', 'bar/foo{id}')).to eql 'getBarFooId'
18
- expect(subject.build('GET', '/bar_foo{id}')).to eql 'getBarFooId'
19
- expect(subject.build('GET', '/bar-foo{id}')).to eql 'getBarFooId'
20
- expect(subject.build('GET', '/simple_test/bar-foo{id}')).to eql 'getSimpleTestBarFooId'
10
+ if defined?(Grape::VERSION) && Gem::Version.new(::Grape::VERSION) < Gem::Version.new('0.16.0')
11
+ let(:route) { Grape::Route.new(method: method) }
12
+ else
13
+ let(:route) { Grape::Router::Route.new(method, '/path', requirements: {}) }
21
14
  end
22
- end
23
15
 
16
+ describe 'GET' do
17
+ let(:method) { 'GET' }
18
+ specify { expect(subject.build(route)).to eql 'get' }
19
+ end
20
+ describe 'get' do
21
+ let(:method) { 'get' }
22
+ specify { expect(subject.build(route)).to eql 'get' }
23
+ end
24
+ describe ':get' do
25
+ let(:method) { :get }
26
+ specify { expect(subject.build(route)).to eql 'get' }
27
+ end
28
+
29
+ describe 'path given' do
30
+ let(:method) { 'GET' }
31
+ it 'GET with path foo' do
32
+ expect(subject.build(route, 'foo')).to eql 'getFoo'
33
+ end
34
+ it 'GET with path /foo' do
35
+ expect(subject.build(route, '/foo')).to eql 'getFoo'
36
+ end
37
+ it 'GET with path bar/foo' do
38
+ expect(subject.build(route, 'bar/foo')).to eql 'getBarFoo'
39
+ end
40
+ it 'GET with path bar/foo{id}' do
41
+ expect(subject.build(route, 'bar/foo{id}')).to eql 'getBarFooId'
42
+ end
43
+ it 'GET with path /bar_foo{id}' do
44
+ expect(subject.build(route, '/bar_foo{id}')).to eql 'getBarFooId'
45
+ end
46
+ it 'GET with path /bar-foo{id}' do
47
+ expect(subject.build(route, '/bar-foo{id}')).to eql 'getBarFooId'
48
+ end
49
+ it 'GET with path /simple_test/bar-foo{id}' do
50
+ expect(subject.build(route, '/simple_test/bar-foo{id}')).to eql 'getSimpleTestBarFooId'
51
+ end
52
+ end
53
+ end
24
54
  end
@@ -11,7 +11,7 @@ describe GrapeSwagger::DocMethods::OptionalObject do
11
11
  let(:request) { 'somes/request/string' }
12
12
 
13
13
  describe 'no option given for key' do
14
- let(:options) { {foo: 'foo' }}
14
+ let(:options) { { foo: 'foo' } }
15
15
  specify do
16
16
  expect(subject.build(key, options)).to be_nil
17
17
  expect(subject.build(key, options, request)).to eql request
@@ -21,7 +21,7 @@ describe GrapeSwagger::DocMethods::OptionalObject do
21
21
  let(:value) { 'some optional value' }
22
22
 
23
23
  describe 'option is a string' do
24
- let(:options) { {bar: value }}
24
+ let(:options) { { bar: value } }
25
25
  specify do
26
26
  expect(subject.build(key, options)).to eql value
27
27
  expect(subject.build(key, options, request)).to eql value
@@ -29,12 +29,11 @@ describe GrapeSwagger::DocMethods::OptionalObject do
29
29
  end
30
30
 
31
31
  describe 'option is a proc' do
32
- let(:options) { {bar: -> { value } }}
32
+ let(:options) { { bar: -> { value } } }
33
33
  specify do
34
34
  expect(subject.build(key, options)).to eql value
35
35
  expect(subject.build(key, options, request)).to eql value
36
36
  end
37
37
  end
38
38
  end
39
-
40
39
  end
@@ -9,7 +9,7 @@ describe GrapeSwagger::DocMethods::PathString do
9
9
  describe 'operation_id_object' do
10
10
  describe 'version' do
11
11
  describe 'defaults: not given, false' do
12
- let(:options) {{ add_version: false }}
12
+ let(:options) { { add_version: false } }
13
13
 
14
14
  specify do
15
15
  expect(subject.build('/thing(.json)', options)).to eql ['Thing', '/thing']
@@ -22,7 +22,7 @@ describe GrapeSwagger::DocMethods::PathString do
22
22
  end
23
23
 
24
24
  describe 'defaults: given, true' do
25
- let(:options) {{ version: 'v1', add_version: true }}
25
+ let(:options) { { version: 'v1', add_version: true } }
26
26
 
27
27
  specify do
28
28
  expect(subject.build('/{version}/thing(.json)', options)).to eql ['Thing', '/v1/thing']
@@ -1,98 +1,109 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GrapeSwagger::DocMethods::ProducesConsumes do
4
- describe ":json (default)" do
4
+ describe ':json (default)' do
5
5
  subject { described_class.call }
6
6
 
7
7
  specify do
8
- expect(subject).to eql( ['application/json'] )
8
+ expect(subject).to eql(['application/json'])
9
9
  end
10
10
  end
11
11
 
12
- describe "accept symbols of" do
13
- describe "single" do
12
+ describe 'accept symbols of' do
13
+ describe 'single' do
14
14
  subject { described_class.call(:xml) }
15
15
 
16
16
  specify do
17
- expect(subject).to eql( ['application/xml'] )
17
+ expect(subject).to eql(['application/xml'])
18
18
  end
19
19
  end
20
20
 
21
- describe "multiple" do
21
+ describe 'multiple' do
22
22
  subject { described_class.call(:xml, :serializable_hash, :json, :binary, :txt) }
23
23
 
24
24
  specify do
25
- expect(subject).to eql( [
26
- 'application/xml',
27
- 'application/json',
28
- 'application/octet-stream',
29
- 'text/plain'
30
- ] )
25
+ expect(subject).to eql(
26
+ [
27
+ 'application/xml',
28
+ 'application/json',
29
+ 'application/octet-stream',
30
+ 'text/plain'
31
+ ])
31
32
  end
32
33
  end
33
34
  end
34
35
 
35
- describe "accept mime_types of" do
36
- describe "single" do
36
+ describe 'accept mime_types of' do
37
+ describe 'single' do
37
38
  subject { described_class.call('application/xml') }
38
39
 
39
40
  specify do
40
- expect(subject).to eql( ['application/xml'] )
41
+ expect(subject).to eql(['application/xml'])
41
42
  end
42
43
  end
43
44
 
44
- describe "multiple" do
45
- subject { described_class.call(
46
- 'application/xml',
47
- 'application/json',
48
- 'application/octet-stream',
49
- 'text/plain'
50
- ) }
51
-
52
- specify do
53
- expect(subject).to eql( [
45
+ describe 'multiple' do
46
+ subject do
47
+ described_class.call(
54
48
  'application/xml',
55
49
  'application/json',
56
50
  'application/octet-stream',
57
51
  'text/plain'
58
- ] )
52
+ )
53
+ end
54
+
55
+ specify do
56
+ expect(subject).to eql(
57
+ [
58
+ 'application/xml',
59
+ 'application/json',
60
+ 'application/octet-stream',
61
+ 'text/plain'
62
+ ])
59
63
  end
60
64
  end
61
65
  end
62
66
 
63
- describe "mix it up" do
64
- subject { described_class.call(
65
- :xml,
66
- :serializable_hash,
67
- 'application/json',
68
- 'application/octet-stream',
69
- :txt
70
- ) }
71
-
72
- specify do
73
- expect(subject).to eql( [
74
- 'application/xml',
67
+ describe 'mix it up' do
68
+ subject do
69
+ described_class.call(
70
+ :xml,
71
+ :serializable_hash,
75
72
  'application/json',
76
73
  'application/octet-stream',
77
- 'text/plain'
78
- ] )
74
+ :txt
75
+ )
79
76
  end
80
77
 
81
- subject { described_class.call( [
82
- :xml,
83
- :serializable_hash,
84
- 'application/json',
85
- 'application/octet-stream',
86
- :txt
87
- ] ) }
78
+ specify do
79
+ expect(subject).to eql(
80
+ [
81
+ 'application/xml',
82
+ 'application/json',
83
+ 'application/octet-stream',
84
+ 'text/plain'
85
+ ])
86
+ end
87
+
88
+ subject do
89
+ described_class.call(
90
+ [
91
+ :xml,
92
+ :serializable_hash,
93
+ 'application/json',
94
+ 'application/octet-stream',
95
+ :txt
96
+ ])
97
+ end
88
98
 
89
99
  specify do
90
- expect(subject).to eql( [
91
- 'application/xml',
92
- 'application/json',
93
- 'application/octet-stream',
94
- 'text/plain'
95
- ] )
100
+ expect(subject).to eql(
101
+ [
102
+ 'application/xml',
103
+ 'application/json',
104
+ 'application/octet-stream',
105
+ 'text/plain'
106
+ ])
96
107
  end
97
108
  end
98
109
  end
@@ -36,7 +36,7 @@ describe GrapeSwagger::Markdown::RedcarpetAdapter, unless: RUBY_PLATFORM.eql?('j
36
36
  it 'marks down with the configured options' do
37
37
  text = '# hello world #'
38
38
  extensions = { fenced_code_blocks: true, autolink: true }
39
- render_options = { highlighter: :none, no_links: true, highlighter: :none }
39
+ render_options = { highlighter: :none, no_links: true }
40
40
  expect_any_instance_of(Redcarpet::Markdown).to receive(:render).with(text).and_call_original
41
41
 
42
42
  output = GrapeSwagger::Markdown::RedcarpetAdapter.new(extensions: extensions, render_options: render_options).markdown(text)
data/spec/spec_helper.rb CHANGED
@@ -19,5 +19,5 @@ RSpec.configure do |config|
19
19
  config.raise_errors_for_deprecations!
20
20
 
21
21
  config.order = 'random'
22
- config.seed = 40834
22
+ config.seed = 40_834
23
23
  end
@@ -1,5 +1,4 @@
1
- RSpec.shared_context "swagger example" do
2
-
1
+ RSpec.shared_context 'swagger example' do
3
2
  before :all do
4
3
  module Entities
5
4
  class Something < Grape::Entity
@@ -11,10 +10,9 @@ RSpec.shared_context "swagger example" do
11
10
 
12
11
  class EnumValues < Grape::Entity
13
12
  expose :gender, documentation: { type: 'string', desc: 'Content of something.', values: %w(Male Female) }
14
- expose :number, documentation: { type: 'integer', desc: 'Content of something.', values: [1, 2] }
13
+ expose :number, documentation: { type: 'integer', desc: 'Content of something.', values: [1, 2] }
15
14
  end
16
15
 
17
-
18
16
  class AliasedThing < Grape::Entity
19
17
  expose :something, as: :post, using: Entities::Something, documentation: { type: 'Something', desc: 'Reference to something.' }
20
18
  end
@@ -61,143 +59,139 @@ RSpec.shared_context "swagger example" do
61
59
 
62
60
  let(:swagger_json) do
63
61
  {
64
- "info"=>{
65
- "title"=>"The API title to be displayed on the API homepage.",
66
- "description"=>"A description of the API.",
67
- "termsOfServiceUrl"=>"www.The-URL-of-the-terms-and-service.com",
68
- "contact"=>{"name"=>"Contact name", "email"=>"Contact@email.com", "url"=>"Contact URL"},
69
- "license"=>{"name"=>"The name of the license.", "url"=>"www.The-URL-of-the-license.org"},
70
- "version"=>"v1"
62
+ 'info' => {
63
+ 'title' => 'The API title to be displayed on the API homepage.',
64
+ 'description' => 'A description of the API.',
65
+ 'termsOfServiceUrl' => 'www.The-URL-of-the-terms-and-service.com',
66
+ 'contact' => { 'name' => 'Contact name', 'email' => 'Contact@email.com', 'url' => 'Contact URL' },
67
+ 'license' => { 'name' => 'The name of the license.', 'url' => 'www.The-URL-of-the-license.org' },
68
+ 'version' => '0.0.1'
71
69
  },
72
- "swagger"=>"2.0",
73
- "produces"=>["application/json"],
74
- "host"=>"example.org",
75
- "basePath"=>"/api",
76
- "tags"=>[
77
- {"name"=>"other_thing", "description"=>"Operations about other_things"},
78
- {"name"=>"thing", "description"=>"Operations about things"},
79
- {"name"=>"thing2", "description"=>"Operations about thing2s"},
80
- {"name"=>"dummy", "description"=>"Operations about dummies"}
70
+ 'swagger' => '2.0',
71
+ 'produces' => ['application/json'],
72
+ 'host' => 'example.org',
73
+ 'basePath' => '/api',
74
+ 'tags' => [
75
+ { 'name' => 'other_thing', 'description' => 'Operations about other_things' },
76
+ { 'name' => 'thing', 'description' => 'Operations about things' },
77
+ { 'name' => 'thing2', 'description' => 'Operations about thing2s' },
78
+ { 'name' => 'dummy', 'description' => 'Operations about dummies' }
81
79
  ],
82
- "paths"=>{
83
- "/v3/other_thing/{elements}"=>{
84
- "get"=>{
85
- "description"=>"nested route inside namespace",
86
- "produces"=>["application/json"],
87
- "parameters"=>[{"in"=>"body", "name"=>"elements", "description"=>"Set of configuration", "type"=>"array", "items"=>{"type"=>"string"}, "required"=>true}],
88
- "responses"=>{"200"=>{"description"=>"nested route inside namespace", "schema"=>{"$ref"=>"#/definitions/QueryInput"}}},
89
- "tags"=>["other_thing"],
90
- "operationId"=>"getV3OtherThingElements",
91
- "x-amazon-apigateway-auth"=>{"type"=>"none"},
92
- "x-amazon-apigateway-integration"=>{"type"=>"aws", "uri"=>"foo_bar_uri", "httpMethod"=>"get"}
93
- }
94
- },
95
- "/thing"=>{
96
- "get"=>{
97
- "description"=>"This gets Things.",
98
- "produces"=>["application/json"],
99
- "parameters"=>[
100
- {"in"=>"query", "name"=>"id", "description"=>"Identity of Something", "type"=>"integer", "format"=>"int32", "required"=>false},
101
- {"in"=>"query", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>false},
102
- {"in"=>"formData", "name"=>"links", "description"=>nil, "type"=>"array", "items"=>{"type"=>"link"}, "required"=>false},
103
- {"in"=>"query", "name"=>"others", "description"=>nil, "type"=>"text", "required"=>false}
80
+ 'paths' => {
81
+ '/v3/other_thing/{elements}' => {
82
+ 'get' => {
83
+ 'description' => 'nested route inside namespace',
84
+ 'produces' => ['application/json'],
85
+ 'parameters' => [{ 'in' => 'body', 'name' => 'elements', 'description' => 'Set of configuration', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true }],
86
+ 'responses' => { '200' => { 'description' => 'nested route inside namespace', 'schema' => { '$ref' => '#/definitions/QueryInput' } } },
87
+ 'tags' => ['other_thing'],
88
+ 'operationId' => 'getV3OtherThingElements',
89
+ 'x-amazon-apigateway-auth' => { 'type' => 'none' },
90
+ 'x-amazon-apigateway-integration' => { 'type' => 'aws', 'uri' => 'foo_bar_uri', 'httpMethod' => 'get' }
91
+ } },
92
+ '/thing' => {
93
+ 'get' => {
94
+ 'description' => 'This gets Things.',
95
+ 'produces' => ['application/json'],
96
+ 'parameters' => [
97
+ { 'in' => 'query', 'name' => 'id', 'description' => 'Identity of Something', 'type' => 'integer', 'format' => 'int32', 'required' => false },
98
+ { 'in' => 'query', 'name' => 'text', 'description' => 'Content of something.', 'type' => 'string', 'required' => false },
99
+ { 'in' => 'formData', 'name' => 'links', 'type' => 'array', 'items' => { 'type' => 'link' }, 'required' => false },
100
+ { 'in' => 'query', 'name' => 'others', 'type' => 'text', 'required' => false }
104
101
  ],
105
- "responses"=>{"200"=>{"description"=>"This gets Things.", "schema"=>{"$ref"=>"#/definitions/Thing"}}, "401"=>{"description"=>"Unauthorized", "schema"=>{"$ref"=>"#/definitions/ApiError"}}},
106
- "tags"=>["thing"],
107
- "operationId"=>"getThing"
102
+ 'responses' => { '200' => { 'description' => 'This gets Things.' }, '401' => { 'description' => 'Unauthorized', 'schema' => { '$ref' => '#/definitions/ApiError' } } },
103
+ 'tags' => ['thing'],
104
+ 'operationId' => 'getThing'
108
105
  },
109
- "post"=>{
110
- "description"=>"This creates Thing.",
111
- "produces"=>["application/json"],
112
- "consumes"=>["application/json"],
113
- "parameters"=>[
114
- {"in"=>"formData", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>true},
115
- {"in"=>"formData", "name"=>"links", "description"=>nil, "type"=>"array", "items"=>{"type"=>"string"}, "required"=>true}
106
+ 'post' => {
107
+ 'description' => 'This creates Thing.',
108
+ 'produces' => ['application/json'],
109
+ 'consumes' => ['application/json'],
110
+ 'parameters' => [
111
+ { 'in' => 'formData', 'name' => 'text', 'description' => 'Content of something.', 'type' => 'string', 'required' => true },
112
+ { 'in' => 'formData', 'name' => 'links', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true }
116
113
  ],
117
- "responses"=>{"201"=>{"description"=>"This creates Thing.", "schema"=>{"$ref"=>"#/definitions/Something"}}, "422"=>{"description"=>"Unprocessible Entity"}},
118
- "tags"=>["thing"],
119
- "operationId"=>"postThing"
120
- }
121
- },
122
- "/thing/{id}"=>{
123
- "get"=>{
124
- "description"=>"This gets Thing.",
125
- "produces"=>["application/json"],
126
- "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}],
127
- "responses"=>{"200"=>{"description"=>"getting a single thing", "schema"=>{"$ref"=>"#/definitions/Thing"}}, "401"=>{"description"=>"Unauthorized"}},
128
- "tags"=>["thing"],
129
- "operationId"=>"getThingId"
114
+ 'responses' => { '201' => { 'description' => 'This creates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } }, '422' => { 'description' => 'Unprocessible Entity' } },
115
+ 'tags' => ['thing'],
116
+ 'operationId' => 'postThing'
117
+ } },
118
+ '/thing/{id}' => {
119
+ 'get' => {
120
+ 'description' => 'This gets Thing.',
121
+ 'produces' => ['application/json'],
122
+ 'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
123
+ 'responses' => { '200' => { 'description' => 'getting a single thing' }, '401' => { 'description' => 'Unauthorized' } },
124
+ 'tags' => ['thing'],
125
+ 'operationId' => 'getThingId'
130
126
  },
131
- "put"=>{
132
- "description"=>"This updates Thing.",
133
- "produces"=>["application/json"],
134
- "consumes"=>["application/json"],
135
- "parameters"=>[
136
- {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true},
137
- {"in"=>"formData", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>false},
138
- {"in"=>"formData", "name"=>"links", "description"=>nil, "type"=>"array", "items"=>{"type"=>"string"}, "required"=>false}
127
+ 'put' => {
128
+ 'description' => 'This updates Thing.',
129
+ 'produces' => ['application/json'],
130
+ 'consumes' => ['application/json'],
131
+ 'parameters' => [
132
+ { 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true },
133
+ { 'in' => 'formData', 'name' => 'text', 'description' => 'Content of something.', 'type' => 'string', 'required' => false },
134
+ { 'in' => 'formData', 'name' => 'links', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => false }
139
135
  ],
140
- "responses"=>{"200"=>{"description"=>"This updates Thing.", "schema"=>{"$ref"=>"#/definitions/Something"}}},
141
- "tags"=>["thing"],
142
- "operationId"=>"putThingId"
136
+ 'responses' => { '200' => { 'description' => 'This updates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } } },
137
+ 'tags' => ['thing'],
138
+ 'operationId' => 'putThingId'
143
139
  },
144
- "delete"=>{
145
- "description"=>"This deletes Thing.",
146
- "produces"=>["application/json"],
147
- "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}],
148
- "responses"=>{"200"=>{"description"=>"This deletes Thing.", "schema"=>{"$ref"=>"#/definitions/Something"}}},
149
- "tags"=>["thing"],
150
- "operationId"=>"deleteThingId"
151
- }
140
+ 'delete' => {
141
+ 'description' => 'This deletes Thing.',
142
+ 'produces' => ['application/json'],
143
+ 'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
144
+ 'responses' => { '200' => { 'description' => 'This deletes Thing.', 'schema' => { '$ref' => '#/definitions/Something' } } },
145
+ 'tags' => ['thing'],
146
+ 'operationId' => 'deleteThingId'
147
+ } },
148
+ '/thing2' => {
149
+ 'get' => {
150
+ 'description' => 'This gets Things.',
151
+ 'produces' => ['application/json'],
152
+ 'responses' => { '200' => { 'description' => 'get Horses', 'schema' => { '$ref' => '#/definitions/Something' } }, '401' => { 'description' => 'HorsesOutError', 'schema' => { '$ref' => '#/definitions/ApiError' } } },
153
+ 'tags' => ['thing2'],
154
+ 'operationId' => 'getThing2'
155
+ } },
156
+ '/dummy/{id}' => {
157
+ 'delete' => {
158
+ 'description' => 'dummy route.',
159
+ 'produces' => ['application/json'],
160
+ 'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
161
+ 'responses' => { '204' => { 'description' => 'dummy route.' }, '401' => { 'description' => 'Unauthorized' } },
162
+ 'tags' => ['dummy'],
163
+ 'operationId' => 'deleteDummyId'
164
+ } } },
165
+ 'definitions' => {
166
+ 'QueryInput' => {
167
+ 'type' => 'object',
168
+ 'properties' => { 'elements' => { 'type' => 'array', 'items' => { '$ref' => '#/definitions/QueryInputElement' }, 'description' => 'Set of configuration' } },
169
+ 'description' => 'nested route inside namespace'
152
170
  },
153
- "/thing2"=>{
154
- "get"=>{
155
- "description"=>"This gets Things.",
156
- "produces"=>["application/json"],
157
- "responses"=>{"200"=>{"description"=>"get Horses", "schema"=>{"$ref"=>"#/definitions/Something"}}, "401"=>{"description"=>"HorsesOutError", "schema"=>{"$ref"=>"#/definitions/ApiError"}}},
158
- "tags"=>["thing2"],
159
- "operationId"=>"getThing2"
160
- }
171
+ 'QueryInputElement' => {
172
+ 'type' => 'object',
173
+ 'properties' => { 'key' => { 'type' => 'string', 'description' => 'Name of parameter' }, 'value' => { 'type' => 'string', 'description' => 'Value of parameter' } }
161
174
  },
162
- "/dummy/{id}"=>{
163
- "delete"=>{
164
- "description"=>"dummy route.",
165
- "produces"=>["application/json"],
166
- "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}],
167
- "responses"=>{"204"=>{"description"=>"dummy route."}, "401"=>{"description"=>"Unauthorized"}},
168
- "tags"=>["dummy"],
169
- "operationId"=>"deleteDummyId"
170
- }
171
- }
172
- },
173
- "definitions"=>{
174
- "QueryInput"=>{
175
- "type"=>"object",
176
- "properties"=>{"elements"=>{"type"=>"array", "items"=>{"$ref"=>"#/definitions/QueryInputElement"}, "description"=>"Set of configuration"}},
177
- "description"=>"nested route inside namespace"},
178
- "QueryInputElement"=>{
179
- "type"=>"object",
180
- "properties"=>{"key"=>{"type"=>"string", "description"=>"Name of parameter"}, "value"=>{"type"=>"string", "description"=>"Value of parameter"}}},
181
- "Thing"=>{
182
- "type"=>"object",
183
- "properties"=>{"id"=>{"type"=>"integer", "format"=>"int32"}, "text"=>{"type"=>"string"}, "links"=>{"type"=>"link"}, "others"=>{"type"=>"text"}},
184
- "description"=>"This gets Thing."},
185
- "ApiError"=>{
186
- "type"=>"object",
187
- "properties"=>{"code"=>{"type"=>"integer", "format"=>"int32", "description"=>"status code"}, "message"=>{"type"=>"string", "description"=>"error message"}},
188
- "description"=>"This gets Things."},
189
- "Something"=>{
190
- "type"=>"object",
191
- "properties"=>{"id"=>{"type"=>"integer", "format"=>"int32", "description"=>"Identity of Something"}, "text"=>{"type"=>"string", "description"=>"Content of something."}, "links"=>{"type"=>"link"}, "others"=>{"type"=>"text"}},
192
- "description"=>"This gets Things."
193
- }
194
- }
195
- }
175
+ 'ApiError' => {
176
+ 'type' => 'object',
177
+ 'properties' => { 'code' => { 'type' => 'integer', 'format' => 'int32', 'description' => 'status code' }, 'message' => { 'type' => 'string', 'description' => 'error message' } },
178
+ 'description' => 'This gets Things.'
179
+ },
180
+ 'Something' => {
181
+ 'type' => 'object',
182
+ 'properties' => {
183
+ 'id' => { 'type' => 'integer', 'format' => 'int32', 'description' => 'Identity of Something' },
184
+ 'text' => { 'type' => 'string', 'description' => 'Content of something.' },
185
+ 'links' => { 'type' => 'link' },
186
+ 'others' => { 'type' => 'text' }
187
+ },
188
+ 'description' => 'This gets Things.'
189
+ } } }
196
190
  end
197
191
 
198
- let(:http_verbs) { %w[get post put delete]}
192
+ let(:http_verbs) { %w(get post put delete) }
199
193
  end
200
194
 
201
195
  def mounted_paths
202
- %w[ /thing /other_thing /dummy ]
196
+ %w( /thing /other_thing /dummy )
203
197
  end