diff --git a/lib/grape-swagger/endpoint.rb b/lib/grape-swagger/endpoint.rb index ba0ec340..d37ba0e1 100644 --- a/lib/grape-swagger/endpoint.rb +++ b/lib/grape-swagger/endpoint.rb @@ -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 diff --git a/spec/swagger_v2/api_documentation_spec.rb b/spec/swagger_v2/api_documentation_spec.rb index ac59f1fb..1a5ff9d1 100644 --- a/spec/swagger_v2/api_documentation_spec.rb +++ b/spec/swagger_v2/api_documentation_spec.rb @@ -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 } } }