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

Fix array_use_braces for body params #757

Merged

Conversation

bikolya
Copy link
Contributor

@bikolya bikolya commented Sep 2, 2019

Previously this is what was generated:
"attr":{"type":"array","items":{"type":"object","properties":{"":{"type":"string"}}}}
instead of
"attr":{"type":"array","items":{"type":"string"}}
in case this attribute was nested in a Hash attribute with "body" in param_type

Definition:

requires :param_1, type: Hash, documentation: { param_type: 'body' } do
  optional :param_2, type: Integer
  optional :param_3, type: Array[String]
end

Here is how it looked like it Swagger UI:
image

instead of
image

@coveralls
Copy link

coveralls commented Sep 2, 2019

Coverage Status

Coverage increased (+0.0007%) to 99.331% when pulling da68023 on bikolya:fix-array-use-braces-for-body-params into 204ced4 on ruby-grape:master.

@bikolya bikolya force-pushed the fix-array-use-braces-for-body-params branch from 277831b to bf22627 Compare September 2, 2019 19:46
Previously this is what was generated:
`"attr":{"type":"array","items":{"type":"object","properties":{"":{"type":"string"}}}}`
instead of
`"attr":{"type":"array","items":{"type":"string"}}`
in case this attribute was nested in a Hash attribute with "body" in `param_type`
@bikolya bikolya force-pushed the fix-array-use-braces-for-body-params branch from bf22627 to 89f113b Compare September 3, 2019 06:36
def array_use_braces?(options)
settings[:array_use_braces] && !(options[:documentation] && options[:documentation][:param_type] == 'body')
def array_use_braces?
@array_use_braces ||= settings[:array_use_braces] && !includes_body_param?
Copy link
Member

@LeFnord LeFnord Sep 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are the settings come from, is it configurable?
if yes, then it should be described in the README

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LeFnord
Copy link
Member

LeFnord commented Sep 6, 2019

thanks @bikolya

@LeFnord LeFnord merged commit d7bf077 into ruby-grape:master Sep 6, 2019
aka-momo pushed a commit to aka-momo/grape-swagger that referenced this pull request Feb 8, 2023
Previously this is what was generated:
`"attr":{"type":"array","items":{"type":"object","properties":{"":{"type":"string"}}}}`
instead of
`"attr":{"type":"array","items":{"type":"string"}}`
in case this attribute was nested in a Hash attribute with "body" in `param_type`
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

Successfully merging this pull request may close these issues.

3 participants