-
Notifications
You must be signed in to change notification settings - Fork 138
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
coerce_*_params
modifies the parameter types passed to the Controller
#294
Comments
coerce_*_params
appears to modify the parameters passed to the Controllercoerce_*_params
modifies the parameter types passed to the Controller
It's not bug but you can avoid this problem (Please read the last part) The committee have two features.
i.e. OpenAPI 3 support integer type in query parameter and query parameters are always set as String by rack, The committee support coerce option to this problem And the committee overwrite request parameter by converted value. When we dose not overwrite the value, we'll get error.
The request are passed committee's validation so 'page' parameter should be Integer, but it is String class... I think when the parameters pass validation it must be equal to the definition. I explain query parameter with integer type, but we are also converting 'format: date-time' for the same reason But I know some people don't want this. The committee overwrite parameter using 'params_key' option. When we set Or, we can stop converting to 'Datetime' class using |
@ota42y Thank you for taking your time to explain how |
@ota42y one question.
Yes, but the default value of For example, this test:
Seems to confirm that I would expect that behavior if the Do you have any comment on that? |
oh... sorry , it's bug, we overwrite query_hash by default 🙇 |
@ota42y This bug is preventing us from moving forward with some refactoring -- so I am happy to help if you can point me to the right direction on where, or how, you would fix this bug. |
I'm sorry, the fix is complete this PR(#310) . |
@ota42y wow, thank you so much. Again, please let me know if there is any new feature or anything I can help with. We are using committee a lot so I want to help with its development 👍 |
Thank you very much for your help!!! |
Hi I am a little bit confused about the issue still being open despite the work done above |
@StochasticSpring you're correct, from my perspective, we don't have this problem anymore, so I am happy to close it! |
I am using Committee in a Rails 5 stack on an application, and I am documenting old API routes (and validating them).
One API accepts a
date
parameter as part of a form submission (content typeapplication/x-www-form-urlencoded
), that is defined in OAS3 like this schema:Suddenly, a test began to fail where the date was being sent as
"2020-12-11"
(to be fair, that would beformat: date
).Committee is coercing the parameter to a
DateTime
object (due tocoerce_form_params
beingtrue
).Imagine a Rails controller implementation like this (not exact, but you will get the point):
After implementing the OAS3 specification for this API route, the behavior is:
My question/bug? is to ask, is modifying the request chain intended behavior for the Committee gem (as a direction for the tool)? My understanding (or, at least how we are using it) is for request/response validation but we want to assume that it will never directly alter the behavior of the API itself, which in this case, it did.
I can create a bug test case and attempt to fix this issue if the maintainers believe it to be a bug (as I do). I have not yet dug into where the bug is happening.
The text was updated successfully, but these errors were encountered: