Skip to content

Commit 06111a7

Browse files
committed
A bunch of random changes made by Rubocop
1 parent b525159 commit 06111a7

File tree

5 files changed

+82
-82
lines changed

5 files changed

+82
-82
lines changed

lib/grape-swagger.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def standalone_sub_namespaces(name, namespaces)
128128

129129
def get_non_nested_params(params)
130130
# Duplicate the params as we are going to modify them
131-
dup_params = params.each_with_object(Hash.new) do |(param, value), dparams|
131+
dup_params = params.each_with_object({}) do |(param, value), dparams|
132132
dparams[param] = value.dup
133133
end
134134

@@ -599,7 +599,7 @@ def setup(options)
599599
type: route.route_is_array ? 'array' : 'void'
600600
}
601601
operation[:authorizations] = route.route_authorizations unless route.route_authorizations.nil? || route.route_authorizations.empty?
602-
if operation[:parameters].any? { | param | param[:type] == 'File' }
602+
if operation[:parameters].any? { |param| param[:type] == 'File' }
603603
operation.merge!(consumes: ['multipart/form-data'])
604604
end
605605
operation.merge!(responseMessages: http_codes) unless http_codes.empty?

spec/api_global_models_spec.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,35 @@ def app
4343
get '/swagger_doc/thing.json'
4444
json = JSON.parse(last_response.body)
4545
expect(json['models']).to eq(
46-
'Some::Thing' => {
47-
'id' => 'Some::Thing',
48-
'properties' => {
49-
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
50-
'name' => { 'type' => 'string', 'description' => 'Name of something.' }
51-
}
52-
})
46+
'Some::Thing' => {
47+
'id' => 'Some::Thing',
48+
'properties' => {
49+
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
50+
'name' => { 'type' => 'string', 'description' => 'Name of something.' }
51+
}
52+
})
5353
end
5454

5555
it 'uses global models and route endpoint specific entities together' do
5656
get '/swagger_doc/combined_thing.json'
5757
json = JSON.parse(last_response.body)
5858

5959
expect(json['models']).to include(
60-
'Some::Thing' => {
61-
'id' => 'Some::Thing',
62-
'properties' => {
63-
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
64-
'name' => { 'type' => 'string', 'description' => 'Name of something.' }
65-
}
66-
})
60+
'Some::Thing' => {
61+
'id' => 'Some::Thing',
62+
'properties' => {
63+
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
64+
'name' => { 'type' => 'string', 'description' => 'Name of something.' }
65+
}
66+
})
6767

6868
expect(json['models']).to include(
69-
'Some::CombinedThing' => {
70-
'id' => 'Some::CombinedThing',
71-
'properties' => {
72-
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
73-
'created_at' => { 'type' => 'dateTime', 'description' => 'Creation of something.' }
74-
}
75-
})
69+
'Some::CombinedThing' => {
70+
'id' => 'Some::CombinedThing',
71+
'properties' => {
72+
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
73+
'created_at' => { 'type' => 'dateTime', 'description' => 'Creation of something.' }
74+
}
75+
})
7676
end
7777
end

spec/api_models_spec.rb

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -227,68 +227,68 @@ def app
227227
},
228228
'required' => ['parts']
229229

230-
)
230+
)
231231

232232
expect(result['models']['ComposedOf']).to include(
233-
'id' => 'ComposedOf',
234-
'properties' => {
235-
'part_text' => {
236-
'type' => 'string',
237-
'description' => 'Content of composedof.'
238-
}
239-
}
240-
)
233+
'id' => 'ComposedOf',
234+
'properties' => {
235+
'part_text' => {
236+
'type' => 'string',
237+
'description' => 'Content of composedof.'
238+
}
239+
}
240+
)
241241

242242
expect(result['models']['composed']).to include(
243-
'id' => 'composed',
244-
'properties' => {
245-
'part_text' => {
246-
'type' => 'string',
247-
'description' => 'Content of composedof else.'
248-
}
249-
250-
}
251-
)
243+
'id' => 'composed',
244+
'properties' => {
245+
'part_text' => {
246+
'type' => 'string',
247+
'description' => 'Content of composedof else.'
248+
}
249+
250+
}
251+
)
252252
end
253253

254254
it 'includes enum values in params and documentation.' do
255255
get '/swagger_doc/enum_description_in_entity'
256256
result = JSON.parse(last_response.body)
257257
expect(result['models']['EnumValues']).to eq(
258-
'id' => 'EnumValues',
259-
'properties' => {
260-
'gender' => { 'type' => 'string', 'description' => 'Content of something.', 'enum' => %w(Male Female) },
261-
'number' => { 'type' => 'integer', 'description' => 'Content of something.', 'enum' => [1, 2] }
262-
}
263-
)
258+
'id' => 'EnumValues',
259+
'properties' => {
260+
'gender' => { 'type' => 'string', 'description' => 'Content of something.', 'enum' => %w(Male Female) },
261+
'number' => { 'type' => 'integer', 'description' => 'Content of something.', 'enum' => [1, 2] }
262+
}
263+
)
264264

265265
expect(result['apis'][0]['operations'][0]).to include(
266-
'parameters' =>
267-
[
268-
{ 'paramType' => 'query', 'name' => 'gender', 'description' => 'Content of something.', 'type' => 'string', 'required' => false, 'allowMultiple' => false, 'enum' => %w(Male Female) },
269-
{ 'paramType' => 'query', 'name' => 'number', 'description' => 'Content of something.', 'type' => 'integer', 'required' => false, 'allowMultiple' => false, 'format' => 'int32', 'enum' => [1, 2] }
270-
],
271-
'type' => 'EnumValues'
272-
)
266+
'parameters' =>
267+
[
268+
{ 'paramType' => 'query', 'name' => 'gender', 'description' => 'Content of something.', 'type' => 'string', 'required' => false, 'allowMultiple' => false, 'enum' => %w(Male Female) },
269+
{ 'paramType' => 'query', 'name' => 'number', 'description' => 'Content of something.', 'type' => 'integer', 'required' => false, 'allowMultiple' => false, 'format' => 'int32', 'enum' => [1, 2] }
270+
],
271+
'type' => 'EnumValues'
272+
)
273273
end
274274

275275
it 'includes referenced models in those with aliased references.' do
276276
get '/swagger_doc/aliasedthing'
277277
result = JSON.parse(last_response.body)
278278
expect(result['models']['AliasedThing']).to eq(
279-
'id' => 'AliasedThing',
280-
'properties' => {
281-
'post' => { '$ref' => 'Something', 'description' => 'Reference to something.' }
282-
}
283-
)
279+
'id' => 'AliasedThing',
280+
'properties' => {
281+
'post' => { '$ref' => 'Something', 'description' => 'Reference to something.' }
282+
}
283+
)
284284

285285
expect(result['models']['Something']).to eq(
286-
'id' => 'Something',
287-
'properties' => {
288-
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
289-
'links' => { 'type' => 'array', 'items' => { '$ref' => 'link' } }
290-
}
291-
)
286+
'id' => 'Something',
287+
'properties' => {
288+
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
289+
'links' => { 'type' => 'array', 'items' => { '$ref' => 'link' } }
290+
}
291+
)
292292
end
293293

294294
it 'includes all entities with four levels of nesting' do

spec/api_with_standalone_namespace_spec.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ def app
4747

4848
it 'that contains all api paths' do
4949
expect(json_body['apis']).to eq(
50-
[
51-
{ 'path' => '/store.{format}', 'description' => 'Operations about stores' },
52-
{ 'path' => '/store_orders.{format}', 'description' => 'Operations about store/orders' },
53-
{ 'path' => '/store_orders_actions2.{format}', 'description' => 'Operations about store/orders/actions2s' },
54-
{ 'path' => '/specific-store-orders.{format}', 'description' => 'Operations about store/:store_id/orders' },
55-
{ 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
56-
]
57-
)
50+
[
51+
{ 'path' => '/store.{format}', 'description' => 'Operations about stores' },
52+
{ 'path' => '/store_orders.{format}', 'description' => 'Operations about store/orders' },
53+
{ 'path' => '/store_orders_actions2.{format}', 'description' => 'Operations about store/orders/actions2s' },
54+
{ 'path' => '/specific-store-orders.{format}', 'description' => 'Operations about store/:store_id/orders' },
55+
{ 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
56+
]
57+
)
5858
end
5959
end
6060

@@ -152,14 +152,14 @@ def app
152152

153153
it 'that contains all api paths' do
154154
expect(json_body['apis']).to eq(
155-
[
156-
{ 'path' => '/store.{format}', 'description' => 'Operations about stores' },
157-
{ 'path' => '/store_orders.{format}', 'description' => 'Operations about store/orders' },
158-
{ 'path' => '/store_orders_actions2.{format}', 'description' => 'Operations about store/orders/actions2s' },
159-
{ 'path' => '/specific-store-orders.{format}', 'description' => 'Operations about store/:store_id/orders' },
160-
{ 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
161-
]
162-
)
155+
[
156+
{ 'path' => '/store.{format}', 'description' => 'Operations about stores' },
157+
{ 'path' => '/store_orders.{format}', 'description' => 'Operations about store/orders' },
158+
{ 'path' => '/store_orders_actions2.{format}', 'description' => 'Operations about store/orders/actions2s' },
159+
{ 'path' => '/specific-store-orders.{format}', 'description' => 'Operations about store/:store_id/orders' },
160+
{ 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
161+
]
162+
)
163163
end
164164
end
165165

spec/mounted_target_class_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def app
3434
'info' => {},
3535
'produces' => Grape::ContentTypes::CONTENT_TYPES.values.uniq,
3636
'apis' => [
37-
{ 'path' => '/simple.{format}', 'description' => 'Operations about simples' },
37+
{ 'path' => '/simple.{format}', 'description' => 'Operations about simples' }
3838
]
3939
)
4040
end

0 commit comments

Comments
 (0)