-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
declared_params regression in 1.5.0 with multiple allowed types #2115
Labels
Comments
I suppose there is ambiguity if we have an Array in the possible allowed types: optional :status_code, types: [Integer, String, Array[Integer, String]] But if there's no Do we hack the string parser to look for commas in |
stanhu
added a commit
to stanhu/grape
that referenced
this issue
Oct 9, 2020
Prior to Grape v1.5.0 and ruby-grape#2103, the following would return `nil`: ``` params do optional :status_code, types: [Integer, String] end get '/' do declared_params end ``` However, now it turns an empty `Array`. We restore the previous behavior by not returning an empty `Array` if multiple types are used. Closes ruby-grape#2115
stanhu
added a commit
to stanhu/grape
that referenced
this issue
Oct 9, 2020
Prior to Grape v1.5.0 and ruby-grape#2103, the following would return `nil`: ``` params do optional :status_code, types: [Integer, String] end get '/' do declared_params end ``` However, now it turns an empty `Array`. We restore the previous behavior by not returning an empty `Array` if multiple types are used. Closes ruby-grape#2115
This was referenced Mar 8, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As shown in https://github.com/ruby-grape/grape#multiple-allowed-types, if you use an
optional
type with multiple allowed types:You end up with
status_code: []
instead ofstatus_code: nil
.I think this is a regression due to https://github.com/ruby-grape/grape/pull/2103/files. This test reproduces the problem:
The text was updated successfully, but these errors were encountered: