Skip to content

Commit

Permalink
A bunch of random changes made by Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
iangreenleaf committed Apr 30, 2015
1 parent b525159 commit 06111a7
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 82 deletions.
4 changes: 2 additions & 2 deletions lib/grape-swagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def standalone_sub_namespaces(name, namespaces)

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

Expand Down Expand Up @@ -599,7 +599,7 @@ def setup(options)
type: route.route_is_array ? 'array' : 'void'
}
operation[:authorizations] = route.route_authorizations unless route.route_authorizations.nil? || route.route_authorizations.empty?
if operation[:parameters].any? { | param | param[:type] == 'File' }
if operation[:parameters].any? { |param| param[:type] == 'File' }
operation.merge!(consumes: ['multipart/form-data'])
end
operation.merge!(responseMessages: http_codes) unless http_codes.empty?
Expand Down
42 changes: 21 additions & 21 deletions spec/api_global_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,35 @@ def app
get '/swagger_doc/thing.json'
json = JSON.parse(last_response.body)
expect(json['models']).to eq(
'Some::Thing' => {
'id' => 'Some::Thing',
'properties' => {
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
'name' => { 'type' => 'string', 'description' => 'Name of something.' }
}
})
'Some::Thing' => {
'id' => 'Some::Thing',
'properties' => {
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
'name' => { 'type' => 'string', 'description' => 'Name of something.' }
}
})
end

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

expect(json['models']).to include(
'Some::Thing' => {
'id' => 'Some::Thing',
'properties' => {
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
'name' => { 'type' => 'string', 'description' => 'Name of something.' }
}
})
'Some::Thing' => {
'id' => 'Some::Thing',
'properties' => {
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
'name' => { 'type' => 'string', 'description' => 'Name of something.' }
}
})

expect(json['models']).to include(
'Some::CombinedThing' => {
'id' => 'Some::CombinedThing',
'properties' => {
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
'created_at' => { 'type' => 'dateTime', 'description' => 'Creation of something.' }
}
})
'Some::CombinedThing' => {
'id' => 'Some::CombinedThing',
'properties' => {
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
'created_at' => { 'type' => 'dateTime', 'description' => 'Creation of something.' }
}
})
end
end
84 changes: 42 additions & 42 deletions spec/api_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,68 +227,68 @@ def app
},
'required' => ['parts']

)
)

expect(result['models']['ComposedOf']).to include(
'id' => 'ComposedOf',
'properties' => {
'part_text' => {
'type' => 'string',
'description' => 'Content of composedof.'
}
}
)
'id' => 'ComposedOf',
'properties' => {
'part_text' => {
'type' => 'string',
'description' => 'Content of composedof.'
}
}
)

expect(result['models']['composed']).to include(
'id' => 'composed',
'properties' => {
'part_text' => {
'type' => 'string',
'description' => 'Content of composedof else.'
}

}
)
'id' => 'composed',
'properties' => {
'part_text' => {
'type' => 'string',
'description' => 'Content of composedof else.'
}

}
)
end

it 'includes enum values in params and documentation.' do
get '/swagger_doc/enum_description_in_entity'
result = JSON.parse(last_response.body)
expect(result['models']['EnumValues']).to eq(
'id' => 'EnumValues',
'properties' => {
'gender' => { 'type' => 'string', 'description' => 'Content of something.', 'enum' => %w(Male Female) },
'number' => { 'type' => 'integer', 'description' => 'Content of something.', 'enum' => [1, 2] }
}
)
'id' => 'EnumValues',
'properties' => {
'gender' => { 'type' => 'string', 'description' => 'Content of something.', 'enum' => %w(Male Female) },
'number' => { 'type' => 'integer', 'description' => 'Content of something.', 'enum' => [1, 2] }
}
)

expect(result['apis'][0]['operations'][0]).to include(
'parameters' =>
[
{ 'paramType' => 'query', 'name' => 'gender', 'description' => 'Content of something.', 'type' => 'string', 'required' => false, 'allowMultiple' => false, 'enum' => %w(Male Female) },
{ 'paramType' => 'query', 'name' => 'number', 'description' => 'Content of something.', 'type' => 'integer', 'required' => false, 'allowMultiple' => false, 'format' => 'int32', 'enum' => [1, 2] }
],
'type' => 'EnumValues'
)
'parameters' =>
[
{ 'paramType' => 'query', 'name' => 'gender', 'description' => 'Content of something.', 'type' => 'string', 'required' => false, 'allowMultiple' => false, 'enum' => %w(Male Female) },
{ 'paramType' => 'query', 'name' => 'number', 'description' => 'Content of something.', 'type' => 'integer', 'required' => false, 'allowMultiple' => false, 'format' => 'int32', 'enum' => [1, 2] }
],
'type' => 'EnumValues'
)
end

it 'includes referenced models in those with aliased references.' do
get '/swagger_doc/aliasedthing'
result = JSON.parse(last_response.body)
expect(result['models']['AliasedThing']).to eq(
'id' => 'AliasedThing',
'properties' => {
'post' => { '$ref' => 'Something', 'description' => 'Reference to something.' }
}
)
'id' => 'AliasedThing',
'properties' => {
'post' => { '$ref' => 'Something', 'description' => 'Reference to something.' }
}
)

expect(result['models']['Something']).to eq(
'id' => 'Something',
'properties' => {
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
'links' => { 'type' => 'array', 'items' => { '$ref' => 'link' } }
}
)
'id' => 'Something',
'properties' => {
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
'links' => { 'type' => 'array', 'items' => { '$ref' => 'link' } }
}
)
end

it 'includes all entities with four levels of nesting' do
Expand Down
32 changes: 16 additions & 16 deletions spec/api_with_standalone_namespace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def app

it 'that contains all api paths' do
expect(json_body['apis']).to eq(
[
{ 'path' => '/store.{format}', 'description' => 'Operations about stores' },
{ 'path' => '/store_orders.{format}', 'description' => 'Operations about store/orders' },
{ 'path' => '/store_orders_actions2.{format}', 'description' => 'Operations about store/orders/actions2s' },
{ 'path' => '/specific-store-orders.{format}', 'description' => 'Operations about store/:store_id/orders' },
{ 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
]
)
[
{ 'path' => '/store.{format}', 'description' => 'Operations about stores' },
{ 'path' => '/store_orders.{format}', 'description' => 'Operations about store/orders' },
{ 'path' => '/store_orders_actions2.{format}', 'description' => 'Operations about store/orders/actions2s' },
{ 'path' => '/specific-store-orders.{format}', 'description' => 'Operations about store/:store_id/orders' },
{ 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
]
)
end
end

Expand Down Expand Up @@ -152,14 +152,14 @@ def app

it 'that contains all api paths' do
expect(json_body['apis']).to eq(
[
{ 'path' => '/store.{format}', 'description' => 'Operations about stores' },
{ 'path' => '/store_orders.{format}', 'description' => 'Operations about store/orders' },
{ 'path' => '/store_orders_actions2.{format}', 'description' => 'Operations about store/orders/actions2s' },
{ 'path' => '/specific-store-orders.{format}', 'description' => 'Operations about store/:store_id/orders' },
{ 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
]
)
[
{ 'path' => '/store.{format}', 'description' => 'Operations about stores' },
{ 'path' => '/store_orders.{format}', 'description' => 'Operations about store/orders' },
{ 'path' => '/store_orders_actions2.{format}', 'description' => 'Operations about store/orders/actions2s' },
{ 'path' => '/specific-store-orders.{format}', 'description' => 'Operations about store/:store_id/orders' },
{ 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
]
)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/mounted_target_class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def app
'info' => {},
'produces' => Grape::ContentTypes::CONTENT_TYPES.values.uniq,
'apis' => [
{ 'path' => '/simple.{format}', 'description' => 'Operations about simples' },
{ 'path' => '/simple.{format}', 'description' => 'Operations about simples' }
]
)
end
Expand Down

0 comments on commit 06111a7

Please sign in to comment.