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

Formatter coerces types and bypasses request validation #176

Open
bplotnick opened this issue Jun 16, 2017 · 0 comments
Open

Formatter coerces types and bypasses request validation #176

bplotnick opened this issue Jun 16, 2017 · 0 comments

Comments

@bplotnick
Copy link
Contributor

bplotnick commented Jun 16, 2017

When a param has a format, the formatter will coerce the value to that type instead of failing when validate_requests is enabled.

Pet Store example using bravado - petId has an int64 format:

petstore_json = requests.get('http://petstore.swagger.io/v2/swagger.json').json()
c = bravado.client.SwaggerClient.from_spec(spec_dict=petstore_json)
c.pet.getPetById(petId="123") # the string is coerced to a long
petstore_json['paths']['/pet/{petId}']['get']['parameters'][0].pop('format')
c = bravado.client.SwaggerClient.from_spec(spec_dict=petstore_json)
c.pet.getPetById(petId="123") # fails with ValidationError

This seems like a pretty serious issue as it causes unexpected behavior. At the very least, we should document it. I'm not entirely sure how we could fix this behavior at this point without breaking pretty much everyone.

Pinging the usual suspects: @sjaensch @macisamuele @analogue @jnb

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

No branches or pull requests

1 participant