Skip to content

Conversation

@cstaud
Copy link
Contributor

@cstaud cstaud commented Apr 24, 2019

Hi @mbuhot,
first let me thank you for keep this project running.

I noticed that the range for an integer query param isn't validated.
I wrote a failing test to make it clear what I mean.

Can you confirm?

Cheers.

@mbuhot
Copy link
Collaborator

mbuhot commented Apr 24, 2019

Thanks @cstaud!

Yes I think I can see the problem in https://github.com/open-api-spex/open_api_spex/blob/master/lib/open_api_spex/cast/integer.ex#L13

Query Params are binaries, which the code converts to a Float, then calls cast recursively.

It then hits the clause where the value is rounded to integer and not validated further - it should make a recursive call to perform the range validations.

I’m on mobile for the next few days, but if you can modify the code I linked above to correctly handle casting integers from strings then I’ll be happy to merge it 🙂

@cstaud
Copy link
Contributor Author

cstaud commented Apr 24, 2019

Yes you're right, was writing a comment at the exact same time ;-)
I will go for.

Copy link
Collaborator

@mbuhot mbuhot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

@mbuhot mbuhot merged commit 78a1ec4 into open-api-spex:master Apr 24, 2019
@cstaud cstaud deleted the feature/validate-query-param-integer-range branch April 24, 2019 10:49
@moxley
Copy link
Contributor

moxley commented Apr 26, 2019

Thanks @cstaud!

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

Successfully merging this pull request may close these issues.

3 participants