We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi!
When I try to document an extension for a parameter like this:
requires :foo, type: String, documentation: { x: { some: 'stuff' }, param_type: 'body' }
It does not work. The documentation is generated without the x-some extension.
x-some
But when param_type is omitted:
param_type
requires :foo, type: String, documentation: { x: { some: 'stuff' } }
The generated documentation includes the x-some extension.
I wrote the following script to help reproduce this problem:
require 'grape' require 'grape-swagger' class API < Grape::API format :json params do requires :foo, type: String, documentation: { x: { some: 'stuff' } } end post :test1 do end params do requires :foo, type: String, documentation: { x: { some: 'stuff' }, param_type: 'body' } end post :test2 do end add_swagger_documentation end
This is the generated documentation:
(I redacted it to keep only the relevant content)
{ ... "paths": { "/test1": { "post": { ... "parameters": [ { "in": "formData", "name": "foo", "type": "string", "required": true, "x-some": "stuff" } ], ... } }, "/test2": { "post": { ... "parameters": [ { "name": "postTest2", "in": "body", "required": true, "schema": { "$ref": "#/definitions/postTest2" } } ], ... } } }, "definitions": { "postTest2": { "type": "object", "properties": { "foo": { "type": "string" } }, "required": [ "foo" ] } } }
As you can see in the JSON, when in is formData, "x-some": "stuff" is present. When in is body, it isn't.
in
formData
"x-some": "stuff"
body
I think this happens because of this method in the MoveParams class, which appears to be used to document body params:
MoveParams
grape-swagger/lib/grape-swagger/doc_methods/move_params.rb
Lines 104 to 115 in 3a5da56
It uses a fixed list of properties from property_keys and documents them if they are present. Anything else that is not in this list gets discarded.
property_keys
Maybe it would be possible to change this method to check for keys that start with x- and document them.
x-
Does that make sense? I can try to make a PR if it does.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi @lenon … thanks for the detailed bug report, and yes I PR would be very welcome … 👍
Sorry, something went wrong.
Fixed by #918. Thanks @numbata 😃
No branches or pull requests
Hi!
When I try to document an extension for a parameter like this:
It does not work. The documentation is generated without the
x-some
extension.But when
param_type
is omitted:The generated documentation includes the
x-some
extension.I wrote the following script to help reproduce this problem:
This is the generated documentation:
(I redacted it to keep only the relevant content)
As you can see in the JSON, when
in
isformData
,"x-some": "stuff"
is present. Whenin
isbody
, it isn't.I think this happens because of this method in the
MoveParams
class, which appears to be used to document body params:grape-swagger/lib/grape-swagger/doc_methods/move_params.rb
Lines 104 to 115 in 3a5da56
It uses a fixed list of properties from
property_keys
and documents them if they are present. Anything else that is not in this list gets discarded.Maybe it would be possible to change this method to check for keys that start with
x-
and document them.Does that make sense? I can try to make a PR if it does.
Thanks!
The text was updated successfully, but these errors were encountered: