Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

override type with documentation parameter #443

Closed
scauglog opened this issue Jun 2, 2016 · 5 comments
Closed

override type with documentation parameter #443

scauglog opened this issue Jun 2, 2016 · 5 comments

Comments

@scauglog
Copy link
Contributor

scauglog commented Jun 2, 2016

multi types seems not well supported, so I would like to use documentation hash to specify which type the documentation should use. for example

params do
  optional :filters, types: [JSON, Hash], desc: "json format", documentation: { type: "json"}
end
   post "private/:module_name/:method_name" do
end

So I modified in lib/grape-swagger/doc_methods/parse_params the "call" method (line 9 to 13)

before

data_type = GrapeSwagger::DocMethods::DataType.call(settings)
additional_documentation = settings[:documentation]
if additional_documentation
  settings = additional_documentation.merge(settings)
end

after

additional_documentation = settings.fetch(:documentation, {})
settings.merge!(additional_documentation)
data_type = GrapeSwagger::DocMethods::DataType.call(settings)

this work for me. But maybe there is a good reason to merge settings in documentation or to do this merge after calling DataType.

(edit: you shouldn't delete the documentation key after merging)

@LeFnord
Copy link
Member

LeFnord commented Jun 2, 2016

@scauglog … yeap, multi types are not supported at the moment
please make a proposal, how it could be documented in with swagger,
and validate it against http://bigstickcarpet.com/swagger-parser/www/index.html

I didn't found a solution yet, but maybe you?

@scauglog
Copy link
Contributor Author

scauglog commented Jun 2, 2016

swagger don't allow multi type. But we could allow user to specify the type they prefer when generating the doc or select the first type provided in the Array as the type or both.

@LeFnord
Copy link
Member

LeFnord commented Jun 2, 2016

@scauglog … yeap I know, that's why again … make a proposal as PR 😉

@scauglog
Copy link
Contributor Author

scauglog commented Jun 3, 2016

I noticed that according to the readme the default value provided in the documentation hash override the grape default Note that the example value will override the Grape default value. currently this doesn't work but with my fix it will.

@LeFnord
Copy link
Member

LeFnord commented Jun 9, 2016

#444 solved it

@LeFnord LeFnord closed this as completed Jun 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants