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

coerceTypes is all or nothing #243

Closed
jtinbergen opened this issue Feb 25, 2020 · 4 comments
Closed

coerceTypes is all or nothing #243

jtinbergen opened this issue Feb 25, 2020 · 4 comments

Comments

@jtinbergen
Copy link

When you do not want coerceTypes to correct malformed payloads sent into your API you MUST mark your openAPI parameters as String or no API call will succeed.

/test/{number}/detail/{number2}

This call will fail since parameters are always strings (you do not have a choice!).

Ideally you would want to always coerce parameters when possible (since you don't have a choice in sending them as string) and let the body/payload optionally be coerced if desired.

@cdimascio
Copy link
Owner

thanks @jtinbergen. good point. we'll look into it

@cdimascio
Copy link
Owner

this sounds like the same problem as described in #249 (comment). thoughts?

@cdimascio
Copy link
Owner

cdimascio commented Oct 4, 2020

@jtinbergen i've put together a PR which attempts to solve these issues via a behavioral change.

  • type coercion will will continue to apply to query, path,and header params
  • type coercion will not apply to request bodies.

as a result, the coerceTypes option becomes a bit ambiguous. i plan to deprecate the property as it's not clear what its behavior should be. all or nothing is not desired. there is an argument for two options, but believe, the behavior that makes the most sense is what i've outlined above. with this behavior, i don't know that a type coercion option is needed.

thoughts?

@cdimascio
Copy link
Owner

cdimascio commented Oct 4, 2020

fixed in v4.1.0
@jtinbergen i believe this solves this, please reopen if not. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants