-
Notifications
You must be signed in to change notification settings - Fork 472
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
Singular params with Array[String] in body does not render correct JSON #725
Comments
This is similar or at least related to #721. |
We hit this again today, where is a good place to look in the code base and provide a fix @dblock ? |
I am not sure, @LeFnord might know more. |
will have a look on it … |
More info about this here: #721 (comment) |
I find a PR about my problem, but I don't understand why it is. |
created a sample project to check it out … see how_to_array_params it works as expected |
@LeFnord I used your sample project, and put some pictures about swagger_ui render, you can see the actual effect. {
names: ["aaa", "bbb"]
} |
ah, now I see the point … it will be documented correct as array "parameters": [
{
"in": "body",
"name": "names",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
], but grape accept it only with given name … this way {
"names": [
"a", "b"
]
} 🤔 |
ok, checked it … the documentation above is correct and it must be used for |
You mean that the documentation is correct, and the grape needs to support this form? |
I'm facing the same issue with version 1.3.1
Generate
And
Generate
I guest both above are not correct, it should be something like below: (with the
|
The issue is with the hack added in #553 that screws up the parameter doc generation. e.g. swagger is expecting this |
Right now my fix for this issue is to simply turn off this "auto magic" completely as I NEVER use it, and IMHO it should be opt-in. module GrapeSwagger
module DocMethods
class MoveParams
def self.should_correct_array?(param)
false
end
def self.build_definition(name, _params)
@definitions[name] = object_type
name
end
end
end
end |
I hit a bug when trying to use this param declaration:
Expecting this to create a schema and tag it on the request, it actually did a
formData
instead:I've been using this successfully everywhere else so this threw me off. I experimented and realized that the
requires
withArray[String]
does not work if it's the only one. It immediately works when you add a non array/string param:Results in:
And the schema:
What's also peculiar is that if you add multiple
Array[String]
to params it maintains the same bug, I've only been able to get to work the moment you add a non-array param.The text was updated successfully, but these errors were encountered: