Skip to content
11 changes: 7 additions & 4 deletions lib/grape-swagger/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,17 @@ def default_type(params)
end

def expose_params(value)
if value.is_a?(Class) && GrapeSwagger.model_parsers.find(value)
expose_params_from_model(value)
elsif value.is_a?(String)
case value
when Class
expose_params_from_model(value) if GrapeSwagger.model_parsers.find(value)
when String
begin
expose_params(Object.const_get(value.gsub(/\[|\]/, ''))) # try to load class from its name
expose_params(Object.const_get(value))
rescue NameError
nil
end
when Array
expose_params(value.first)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/swagger_v2/api_documentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
'locale' => {
desc: 'Locale of API documentation',
required: false,
type: 'Symbol'
type: Symbol
},
'name' => {
desc: 'Resource name of mounted API',
required: true,
type: 'String'
type: String
}
}
}
Expand Down