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
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'format, content_type' do
4
- include_context "the api entities"
4
+ include_context 'the api entities'
5
5
 
6
6
  before :all do
7
7
  module TheApi
@@ -9,42 +9,42 @@ describe 'format, content_type' do
9
9
  format :json
10
10
 
11
11
  desc 'This uses json (default) for produces',
12
- failure: [{code: 400, model: Entities::ApiError}],
13
- entity: Entities::UseResponse
12
+ failure: [{ code: 400, model: Entities::ApiError }],
13
+ entity: Entities::UseResponse
14
14
  get '/use_default' do
15
- { "declared_params" => declared(params) }
15
+ { 'declared_params' => declared(params) }
16
16
  end
17
17
 
18
18
  desc 'This uses formats for produces',
19
- failure: [{code: 400, model: Entities::ApiError}],
20
- formats: [:xml, :binary, "application/vdns"],
21
- entity: Entities::UseResponse
19
+ failure: [{ code: 400, model: Entities::ApiError }],
20
+ formats: [:xml, :binary, 'application/vdns'],
21
+ entity: Entities::UseResponse
22
22
  get '/use_formats' do
23
- { "declared_params" => declared(params) }
23
+ { 'declared_params' => declared(params) }
24
24
  end
25
25
 
26
26
  desc 'This uses content_types for produces',
27
- failure: [{code: 400, model: Entities::ApiError}],
28
- content_types: [:xml, :binary, "application/vdns"],
29
- entity: Entities::UseResponse
27
+ failure: [{ code: 400, model: Entities::ApiError }],
28
+ content_types: [:xml, :binary, 'application/vdns'],
29
+ entity: Entities::UseResponse
30
30
  get '/use_content_types' do
31
- { "declared_params" => declared(params) }
31
+ { 'declared_params' => declared(params) }
32
32
  end
33
33
 
34
34
  desc 'This uses produces for produces',
35
- failure: [{code: 400, model: Entities::ApiError}],
36
- produces: [:xml, :binary, "application/vdns"],
37
- entity: Entities::UseResponse
35
+ failure: [{ code: 400, model: Entities::ApiError }],
36
+ produces: [:xml, :binary, 'application/vdns'],
37
+ entity: Entities::UseResponse
38
38
  get '/use_produces' do
39
- { "declared_params" => declared(params) }
39
+ { 'declared_params' => declared(params) }
40
40
  end
41
41
 
42
42
  desc 'This uses produces for produces',
43
- failure: [{code: 400, model: Entities::ApiError}],
44
- consumes: ["application/www_url_encoded"],
45
- entity: Entities::UseResponse
43
+ failure: [{ code: 400, model: Entities::ApiError }],
44
+ consumes: ['application/www_url_encoded'],
45
+ entity: Entities::UseResponse
46
46
  post '/use_consumes' do
47
- { "declared_params" => declared(params) }
47
+ { 'declared_params' => declared(params) }
48
48
  end
49
49
 
50
50
  add_swagger_documentation
@@ -56,13 +56,15 @@ describe 'format, content_type' do
56
56
  TheApi::ProducesApi
57
57
  end
58
58
 
59
- let(:produced) {[
60
- 'application/xml',
61
- 'application/octet-stream',
62
- 'application/vdns'
63
- ]}
59
+ let(:produced) do
60
+ [
61
+ 'application/xml',
62
+ 'application/octet-stream',
63
+ 'application/vdns'
64
+ ]
65
+ end
64
66
 
65
- describe "formats" do
67
+ describe 'formats' do
66
68
  subject do
67
69
  get '/swagger_doc/use_default'
68
70
  JSON.parse(last_response.body)
@@ -74,7 +76,7 @@ describe 'format, content_type' do
74
76
  end
75
77
  end
76
78
 
77
- describe "formats" do
79
+ describe 'formats' do
78
80
  subject do
79
81
  get '/swagger_doc/use_formats'
80
82
  JSON.parse(last_response.body)
@@ -86,7 +88,7 @@ describe 'format, content_type' do
86
88
  end
87
89
  end
88
90
 
89
- describe "content types" do
91
+ describe 'content types' do
90
92
  subject do
91
93
  get '/swagger_doc/use_content_types'
92
94
  JSON.parse(last_response.body)
@@ -95,10 +97,10 @@ describe 'format, content_type' do
95
97
  specify do
96
98
  expect(subject['paths']['/use_content_types']['get']).to include('produces')
97
99
  expect(subject['paths']['/use_content_types']['get']['produces']).to eql(produced)
98
- end
100
+ end
99
101
  end
100
102
 
101
- describe "produces" do
103
+ describe 'produces' do
102
104
  subject do
103
105
  get '/swagger_doc/use_produces'
104
106
  JSON.parse(last_response.body)
@@ -110,7 +112,7 @@ describe 'format, content_type' do
110
112
  end
111
113
  end
112
114
 
113
- describe "consumes" do
115
+ describe 'consumes' do
114
116
  subject do
115
117
  get '/swagger_doc/use_consumes'
116
118
  JSON.parse(last_response.body)
@@ -118,7 +120,7 @@ describe 'format, content_type' do
118
120
 
119
121
  specify do
120
122
  expect(subject['paths']['/use_consumes']['post']).to include('consumes')
121
- expect(subject['paths']['/use_consumes']['post']['consumes']).to eql ["application/www_url_encoded"]
123
+ expect(subject['paths']['/use_consumes']['post']['consumes']).to eql ['application/www_url_encoded']
122
124
  end
123
125
  end
124
126
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'global configuration stuff' do
4
-
5
4
  before :all do
6
5
  module TheApi
7
6
  class ConfigurationApi < Grape::API
@@ -9,23 +8,22 @@ describe 'global configuration stuff' do
9
8
  version 'v3', using: :path
10
9
 
11
10
  desc 'This returns something',
12
- failure: [{code: 400, message: 'NotFound'}]
11
+ failure: [{ code: 400, message: 'NotFound' }]
13
12
  params do
14
13
  requires :foo, type: Integer
15
14
  end
16
15
  get :configuration do
17
- { "declared_params" => declared(params) }
16
+ { 'declared_params' => declared(params) }
18
17
  end
19
18
 
20
19
  add_swagger_documentation format: :json,
21
- api_version: '23',
20
+ doc_version: '23',
22
21
  schemes: 'https',
23
22
  host: -> { 'another.host.com' },
24
23
  base_path: -> { 'somewhere/over/the/rainbow' },
25
24
  mount_path: 'documentation',
26
25
  add_base_path: true,
27
26
  add_version: true
28
-
29
27
  end
30
28
  end
31
29
  end
@@ -34,18 +32,18 @@ describe 'global configuration stuff' do
34
32
  TheApi::ConfigurationApi
35
33
  end
36
34
 
37
- describe "shows documentation paths" do
35
+ describe 'shows documentation paths' do
38
36
  subject do
39
37
  get '/v3/documentation'
40
38
  JSON.parse(last_response.body)
41
39
  end
42
40
 
43
41
  specify do
42
+ expect(subject['info']['version']).to eql '23'
44
43
  expect(subject['host']).to eql 'another.host.com'
45
44
  expect(subject['basePath']).to eql 'somewhere/over/the/rainbow'
46
45
  expect(subject['paths'].keys.first).to eql '/somewhere/over/the/rainbow/v3/configuration'
47
46
  expect(subject['schemes']).to eql ['https']
48
47
  end
49
48
  end
50
-
51
49
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'headers' do
4
- include_context "the api entities"
4
+ include_context 'the api entities'
5
5
 
6
6
  before :all do
7
7
  module TheApi
@@ -9,16 +9,16 @@ describe 'headers' do
9
9
  format :json
10
10
 
11
11
  desc 'This returns something',
12
- failure: [{code: 400, model: Entities::ApiError}],
13
- headers: {
14
- "X-Rate-Limit-Limit" => {
15
- "description" => "The number of allowed requests in the current period",
16
- "type" => "integer"
17
- }},
18
-
19
- entity: Entities::UseResponse
12
+ failure: [{ code: 400, model: Entities::ApiError }],
13
+ headers: {
14
+ 'X-Rate-Limit-Limit' => {
15
+ 'description' => 'The number of allowed requests in the current period',
16
+ 'type' => 'integer'
17
+ } },
18
+
19
+ entity: Entities::UseResponse
20
20
  get '/use_headers' do
21
- { "declared_params" => declared(params) }
21
+ { 'declared_params' => declared(params) }
22
22
  end
23
23
 
24
24
  add_swagger_documentation
@@ -36,13 +36,14 @@ describe 'headers' do
36
36
  end
37
37
 
38
38
  specify do
39
- expect(subject['paths']['/use_headers']['get']['parameters']).to eql([
40
- {"in"=>"header",
41
- "name"=>"X-Rate-Limit-Limit",
42
- "description"=>"The number of allowed requests in the current period",
43
- "type"=>"integer",
44
- "format" => "int32",
45
- "required"=>false},
46
- ])
39
+ expect(subject['paths']['/use_headers']['get']['parameters']).to eql(
40
+ [
41
+ { 'in' => 'header',
42
+ 'name' => 'X-Rate-Limit-Limit',
43
+ 'description' => 'The number of allowed requests in the current period',
44
+ 'type' => 'integer',
45
+ 'format' => 'int32',
46
+ 'required' => false }
47
+ ])
47
48
  end
48
49
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'hide documentation path' do
4
- include_context "the api entities"
4
+ include_context 'the api entities'
5
5
 
6
6
  before :all do
7
7
  module TheApi
@@ -9,24 +9,24 @@ describe 'hide documentation path' do
9
9
  format :json
10
10
 
11
11
  desc 'This returns something',
12
- params: Entities::UseResponse.documentation,
13
- failure: [{code: 400, message: 'NotFound', model: Entities::ApiError}]
12
+ params: Entities::UseResponse.documentation,
13
+ failure: [{ code: 400, message: 'NotFound', model: Entities::ApiError }]
14
14
  params do
15
15
  requires :foo, type: Integer
16
16
  end
17
17
  get '/params_response' do
18
- { "declared_params" => declared(params) }
18
+ { 'declared_params' => declared(params) }
19
19
  end
20
20
 
21
21
  desc 'This returns something',
22
- entity: Entities::UseResponse,
23
- failure: [{code: 400, message: 'NotFound', model: Entities::ApiError}]
22
+ entity: Entities::UseResponse,
23
+ failure: [{ code: 400, message: 'NotFound', model: Entities::ApiError }]
24
24
  get '/entity_response' do
25
- { "declared_params" => declared(params) }
25
+ { 'declared_params' => declared(params) }
26
26
  end
27
27
 
28
28
  desc 'This returns something',
29
- failure: [{code: 400, message: 'NotFound', model: Entities::ApiError}]
29
+ failure: [{ code: 400, message: 'NotFound', model: Entities::ApiError }]
30
30
  get '/present_response' do
31
31
  foo = OpenStruct.new id: 1, name: 'bar'
32
32
  something = OpenStruct.new description: 'something', item: foo
@@ -42,7 +42,7 @@ describe 'hide documentation path' do
42
42
  TheApi::HideDocumentationApi
43
43
  end
44
44
 
45
- describe "shows documentation paths" do
45
+ describe 'shows documentation paths' do
46
46
  subject do
47
47
  get '/swagger_doc'
48
48
  JSON.parse(last_response.body)
@@ -52,5 +52,4 @@ describe 'hide documentation path' do
52
52
  expect(subject['paths'].keys).to include '/swagger_doc', '/swagger_doc/{name}'
53
53
  end
54
54
  end
55
-
56
55
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe 'swagger spec v2.0' do
4
4
  describe 'mounted APIs' do
5
- include_context "swagger example"
5
+ include_context 'swagger example'
6
6
 
7
7
  def app
8
8
  Class.new(Grape::API) do
@@ -11,7 +11,7 @@ describe 'swagger spec v2.0' do
11
11
  # Thing stuff
12
12
  desc 'This gets Things.' do
13
13
  params Entities::Something.documentation
14
- http_codes [ { code: 401, message: 'Unauthorized', model: Entities::ApiError } ]
14
+ http_codes [{ code: 401, message: 'Unauthorized', model: Entities::ApiError }]
15
15
  end
16
16
  get '/thing' do
17
17
  something = OpenStruct.new text: 'something'
@@ -30,7 +30,7 @@ describe 'swagger spec v2.0' do
30
30
  end
31
31
 
32
32
  desc 'This gets Thing.' do
33
- http_codes [ { code: 200, message: 'getting a single thing' }, { code: 401, message: 'Unauthorized' } ]
33
+ http_codes [{ code: 200, message: 'getting a single thing' }, { code: 401, message: 'Unauthorized' }]
34
34
  end
35
35
  params do
36
36
  requires :id, type: Integer
@@ -41,18 +41,18 @@ describe 'swagger spec v2.0' do
41
41
  end
42
42
 
43
43
  desc 'This creates Thing.',
44
- success: Entities::Something
44
+ success: Entities::Something
45
45
  params do
46
46
  requires :text, type: String, documentation: { type: 'string', desc: 'Content of something.' }
47
47
  requires :links, type: Array, documentation: { type: 'link', is_array: true }
48
48
  end
49
- post '/thing', http_codes: [ { code: 422, message: 'Unprocessible Entity' } ] do
49
+ post '/thing', http_codes: [{ code: 422, message: 'Unprocessible Entity' }] do
50
50
  something = OpenStruct.new text: 'something'
51
51
  present something, with: Entities::Something
52
52
  end
53
53
 
54
54
  desc 'This updates Thing.',
55
- success: Entities::Something
55
+ success: Entities::Something
56
56
  params do
57
57
  requires :id, type: Integer
58
58
  optional :text, type: String, desc: 'Content of something.'
@@ -64,7 +64,7 @@ describe 'swagger spec v2.0' do
64
64
  end
65
65
 
66
66
  desc 'This deletes Thing.',
67
- entity: Entities::Something
67
+ entity: Entities::Something
68
68
  params do
69
69
  requires :id, type: Integer
70
70
  end
@@ -74,7 +74,7 @@ describe 'swagger spec v2.0' do
74
74
  end
75
75
 
76
76
  desc 'dummy route.',
77
- failure: [{ code: 401, message: 'Unauthorized' }]
77
+ failure: [{ code: 401, message: 'Unauthorized' }]
78
78
  params do
79
79
  requires :id, type: Integer
80
80
  end
@@ -83,12 +83,11 @@ describe 'swagger spec v2.0' do
83
83
 
84
84
  namespace :other_thing do
85
85
  desc 'nested route inside namespace',
86
- entity: Entities::QueryInput,
87
- x: {
88
- 'amazon-apigateway-auth' => {type: 'none'},
89
- 'amazon-apigateway-integration' => {type: 'aws', uri: 'foo_bar_uri', httpMethod: 'get'}
90
- }
91
-
86
+ entity: Entities::QueryInput,
87
+ x: {
88
+ 'amazon-apigateway-auth' => { type: 'none' },
89
+ 'amazon-apigateway-integration' => { type: 'aws', uri: 'foo_bar_uri', httpMethod: 'get' }
90
+ }
92
91
 
93
92
  params do
94
93
  requires :elements, documentation: {
@@ -108,14 +107,14 @@ describe 'swagger spec v2.0' do
108
107
  add_swagger_documentation hide_format: true,
109
108
  base_path: '/api',
110
109
  info: {
111
- title: "The API title to be displayed on the API homepage.",
112
- description: "A description of the API.",
113
- contact_name: "Contact name",
114
- contact_email: "Contact@email.com",
115
- contact_url: "Contact URL",
116
- license: "The name of the license.",
117
- license_url: "www.The-URL-of-the-license.org",
118
- terms_of_service_url: "www.The-URL-of-the-terms-and-service.com",
110
+ title: 'The API title to be displayed on the API homepage.',
111
+ description: 'A description of the API.',
112
+ contact_name: 'Contact name',
113
+ contact_email: 'Contact@email.com',
114
+ contact_url: 'Contact URL',
115
+ license: 'The name of the license.',
116
+ license_url: 'www.The-URL-of-the-license.org',
117
+ terms_of_service_url: 'www.The-URL-of-the-terms-and-service.com'
119
118
  }
120
119
  end
121
120
  end
@@ -139,8 +138,6 @@ describe 'swagger spec v2.0' do
139
138
  end
140
139
  end
141
140
  end
142
-
143
141
  end
144
-
145
142
  end
146
143
  end
@@ -1,15 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'setting of param type, such as `query`, `path`, `formData`, `body`, `header`' do
4
- include_context "the api entities"
4
+ include_context 'the api entities'
5
5
 
6
6
  before :all do
7
7
  module TheApi
8
8
  class NestedBodyParamTypeApi < Grape::API
9
9
  namespace :simple_nested_params do
10
10
  desc 'post in body with nested parameters',
11
- detail: 'more details description',
12
- success: TheApi::Entities::UseNestedWithAddress
11
+ detail: 'more details description',
12
+ success: TheApi::Entities::UseNestedWithAddress
13
13
  params do
14
14
  requires :name, type: String, documentation: { desc: 'name', in: 'body' }
15
15
  optional :address, type: Hash do
@@ -21,12 +21,12 @@ describe 'setting of param type, such as `query`, `path`, `formData`, `body`, `h
21
21
  end
22
22
 
23
23
  post '/in_body' do
24
- { "declared_params" => declared(params) }
24
+ { 'declared_params' => declared(params) }
25
25
  end
26
26
 
27
27
  desc 'put in body with nested parameters',
28
- detail: 'more details description',
29
- success: TheApi::Entities::UseNestedWithAddress
28
+ detail: 'more details description',
29
+ success: TheApi::Entities::UseNestedWithAddress
30
30
  params do
31
31
  requires :id, type: Integer
32
32
  optional :name, type: String, documentation: { desc: 'name', in: 'body' }
@@ -39,13 +39,13 @@ describe 'setting of param type, such as `query`, `path`, `formData`, `body`, `h
39
39
  end
40
40
 
41
41
  put '/in_body/:id' do
42
- { "declared_params" => declared(params) }
42
+ { 'declared_params' => declared(params) }
43
43
  end
44
44
  end
45
45
 
46
46
  namespace :multiple_nested_params do
47
47
  desc 'put in body with multiple nested parameters',
48
- success: TheApi::Entities::UseNestedWithAddress
48
+ success: TheApi::Entities::UseNestedWithAddress
49
49
  params do
50
50
  requires :id, type: Integer
51
51
  optional :name, type: String, documentation: { desc: 'name', in: 'body' }
@@ -64,7 +64,7 @@ describe 'setting of param type, such as `query`, `path`, `formData`, `body`, `h
64
64
  end
65
65
 
66
66
  put '/in_body/:id' do
67
- { "declared_params" => declared(params) }
67
+ { 'declared_params' => declared(params) }
68
68
  end
69
69
  end
70
70
 
@@ -84,68 +84,66 @@ describe 'setting of param type, such as `query`, `path`, `formData`, `body`, `h
84
84
  end
85
85
 
86
86
  specify do
87
- expect(subject['paths']['/simple_nested_params/in_body']['post']['parameters']).to eql([{
88
- "name"=>"UseNestedWithAddress",
89
- "in"=>"body",
90
- "required"=>true,
91
- "schema"=>{"$ref"=>"#/definitions/postRequestUseNestedWithAddress"}
92
- }])
87
+ expect(subject['paths']['/simple_nested_params/in_body']['post']['parameters']).to eql(
88
+ [{
89
+ 'name' => 'UseNestedWithAddress',
90
+ 'in' => 'body',
91
+ 'required' => true,
92
+ 'schema' => { '$ref' => '#/definitions/postRequestUseNestedWithAddress' }
93
+ }])
93
94
  end
94
95
 
95
96
  specify do
96
- expect(subject['definitions']['postRequestUseNestedWithAddress']).to eql({
97
- "description"=>"post in body with nested parameters\n more details description",
98
- "type"=>"object",
99
- "properties"=>{
100
- "address"=>{"$ref"=>"#/definitions/postRequestUseNestedWithAddressAddress"},
101
- "name"=>{"type"=>"string", "description"=>"name"}
97
+ expect(subject['definitions']['postRequestUseNestedWithAddress']).to eql(
98
+ 'description' => "post in body with nested parameters\n more details description",
99
+ 'type' => 'object',
100
+ 'properties' => {
101
+ 'address' => { '$ref' => '#/definitions/postRequestUseNestedWithAddressAddress' },
102
+ 'name' => { 'type' => 'string', 'description' => 'name' }
102
103
  },
103
- "required"=>["name"]
104
- })
105
- expect(subject['definitions']['postRequestUseNestedWithAddressAddress']).to eql({
106
- "description"=>"postRequestUseNestedWithAddress - address",
107
- "type"=>"object",
108
- "properties"=>{
109
- "street"=>{"type"=>"string", "description"=>"street"},
110
- "postcode"=>{"type"=>"string", "description"=>"postcode"},
111
- "city"=>{"type"=>"string", "description"=>"city"},
112
- "country"=>{"type"=>"string", "description"=>"country"}
104
+ 'required' => ['name'])
105
+ expect(subject['definitions']['postRequestUseNestedWithAddressAddress']).to eql(
106
+ 'description' => 'postRequestUseNestedWithAddress - address',
107
+ 'type' => 'object',
108
+ 'properties' => {
109
+ 'street' => { 'type' => 'string', 'description' => 'street' },
110
+ 'postcode' => { 'type' => 'string', 'description' => 'postcode' },
111
+ 'city' => { 'type' => 'string', 'description' => 'city' },
112
+ 'country' => { 'type' => 'string', 'description' => 'country' }
113
113
  },
114
- "required"=>["street", "postcode", "city"]
115
- })
114
+ 'required' => %w(street postcode city))
116
115
  end
117
116
 
118
117
  specify do
119
- expect(subject['paths']['/simple_nested_params/in_body/{id}']['put']['parameters']).to eql([
120
- {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true},
121
- {
122
- "name"=>"UseNestedWithAddress",
123
- "in"=>"body",
124
- "required"=>true,
125
- "schema"=>{"$ref"=>"#/definitions/putRequestUseNestedWithAddress"}
126
- }
127
- ])
118
+ expect(subject['paths']['/simple_nested_params/in_body/{id}']['put']['parameters']).to eql(
119
+ [
120
+ { 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true },
121
+ {
122
+ 'name' => 'UseNestedWithAddress',
123
+ 'in' => 'body',
124
+ 'required' => true,
125
+ 'schema' => { '$ref' => '#/definitions/putRequestUseNestedWithAddress' }
126
+ }
127
+ ])
128
128
  end
129
129
 
130
130
  specify do
131
- expect(subject['definitions']['putRequestUseNestedWithAddress']).to eql({
132
- "description" => "put in body with nested parameters\n more details description",
133
- "type"=>"object",
134
- "properties"=>{
135
- "address"=>{"$ref"=>"#/definitions/putRequestUseNestedWithAddressAddress"},
136
- "id"=>{"type"=>"integer", "format"=>"int32", "readOnly"=>true},
137
- "name"=>{"type"=>"string", "description"=>"name"}
138
- }
139
- })
140
- expect(subject['definitions']['putRequestUseNestedWithAddressAddress']).to eql({
141
- "description"=>"putRequestUseNestedWithAddress - address",
142
- "type"=>"object",
143
- "properties"=>{
144
- "street"=>{"type"=>"string", "description"=>"street"},
145
- "postcode"=>{"type"=>"string", "description"=>"postcode"},
146
- "city"=>{"type"=>"string", "description"=>"city"},
147
- "country"=>{"type"=>"string", "description"=>"country"}}
148
- })
131
+ expect(subject['definitions']['putRequestUseNestedWithAddress']).to eql(
132
+ 'description' => "put in body with nested parameters\n more details description",
133
+ 'type' => 'object',
134
+ 'properties' => {
135
+ 'address' => { '$ref' => '#/definitions/putRequestUseNestedWithAddressAddress' },
136
+ 'id' => { 'type' => 'integer', 'format' => 'int32', 'readOnly' => true },
137
+ 'name' => { 'type' => 'string', 'description' => 'name' }
138
+ })
139
+ expect(subject['definitions']['putRequestUseNestedWithAddressAddress']).to eql(
140
+ 'description' => 'putRequestUseNestedWithAddress - address',
141
+ 'type' => 'object',
142
+ 'properties' => {
143
+ 'street' => { 'type' => 'string', 'description' => 'street' },
144
+ 'postcode' => { 'type' => 'string', 'description' => 'postcode' },
145
+ 'city' => { 'type' => 'string', 'description' => 'city' },
146
+ 'country' => { 'type' => 'string', 'description' => 'country' } })
149
147
  end
150
148
  end
151
149
 
@@ -156,42 +154,42 @@ describe 'setting of param type, such as `query`, `path`, `formData`, `body`, `h
156
154
  end
157
155
 
158
156
  specify do
159
- expect(subject['paths']['/multiple_nested_params/in_body/{id}']['put']['parameters']).to eql([
160
- {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true},
161
- {"name"=>"UseNestedWithAddress", "in"=>"body", "required"=>true, "schema"=>{"$ref"=>"#/definitions/putRequestUseNestedWithAddress"}}
162
- ])
157
+ expect(subject['paths']['/multiple_nested_params/in_body/{id}']['put']['parameters']).to eql(
158
+ [
159
+ { 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true },
160
+ { 'name' => 'UseNestedWithAddress', 'in' => 'body', 'required' => true, 'schema' => { '$ref' => '#/definitions/putRequestUseNestedWithAddress' } }
161
+ ])
163
162
  end
164
163
 
165
164
  specify do
166
- expect(subject['definitions']['putRequestUseNestedWithAddress']).to eql({
167
- "description" => "put in body with multiple nested parameters",
168
- "type"=>"object",
169
- "properties"=>{
170
- "address"=>{"$ref"=>"#/definitions/putRequestUseNestedWithAddressAddress"},
171
- "delivery_address"=>{"$ref"=>"#/definitions/putRequestUseNestedWithAddressDeliveryAddress"},
172
- "id"=>{"type"=>"integer", "format"=>"int32", "readOnly"=>true},
173
- "name"=>{"type"=>"string", "description"=>"name"}
174
- }})
175
- expect(subject['definitions']['putRequestUseNestedWithAddressAddress']).to eql({
176
- "description" => "putRequestUseNestedWithAddress - address",
177
- "type"=>"object",
178
- "properties"=>{
179
- "street"=>{"type"=>"string", "description"=>"street"},
180
- "postcode"=>{"type"=>"string", "description"=>"postcode"},
181
- "city"=>{"type"=>"string", "description"=>"city"},
182
- "country"=>{"type"=>"string", "description"=>"country"}
165
+ expect(subject['definitions']['putRequestUseNestedWithAddress']).to eql(
166
+ 'description' => 'put in body with multiple nested parameters',
167
+ 'type' => 'object',
168
+ 'properties' => {
169
+ 'address' => { '$ref' => '#/definitions/putRequestUseNestedWithAddressAddress' },
170
+ 'delivery_address' => { '$ref' => '#/definitions/putRequestUseNestedWithAddressDeliveryAddress' },
171
+ 'id' => { 'type' => 'integer', 'format' => 'int32', 'readOnly' => true },
172
+ 'name' => { 'type' => 'string', 'description' => 'name' }
173
+ })
174
+ expect(subject['definitions']['putRequestUseNestedWithAddressAddress']).to eql(
175
+ 'description' => 'putRequestUseNestedWithAddress - address',
176
+ 'type' => 'object',
177
+ 'properties' => {
178
+ 'street' => { 'type' => 'string', 'description' => 'street' },
179
+ 'postcode' => { 'type' => 'string', 'description' => 'postcode' },
180
+ 'city' => { 'type' => 'string', 'description' => 'city' },
181
+ 'country' => { 'type' => 'string', 'description' => 'country' }
183
182
  },
184
- "required"=>["postcode"]
185
- })
186
- expect(subject['definitions']['putRequestUseNestedWithAddressDeliveryAddress']).to eql({
187
- "description" => "putRequestUseNestedWithAddress - delivery_address",
188
- "type"=>"object",
189
- "properties"=>{
190
- "street"=>{"type"=>"string", "description"=>"street"},
191
- "postcode"=>{"type"=>"string", "description"=>"postcode"},
192
- "city"=>{"type"=>"string", "description"=>"city"},
193
- "country"=>{"type"=>"string", "description"=>"country"}
194
- }})
183
+ 'required' => ['postcode'])
184
+ expect(subject['definitions']['putRequestUseNestedWithAddressDeliveryAddress']).to eql(
185
+ 'description' => 'putRequestUseNestedWithAddress - delivery_address',
186
+ 'type' => 'object',
187
+ 'properties' => {
188
+ 'street' => { 'type' => 'string', 'description' => 'street' },
189
+ 'postcode' => { 'type' => 'string', 'description' => 'postcode' },
190
+ 'city' => { 'type' => 'string', 'description' => 'city' },
191
+ 'country' => { 'type' => 'string', 'description' => 'country' }
192
+ })
195
193
  end
196
194
  end
197
195
  end