-
Notifications
You must be signed in to change notification settings - Fork 21
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
Problem with passing string type parameters using numbers in path #51
Comments
The schema states |
I agree with your point, especially from a strict interpretation. |
validating a string is pretty pointless when, from a library perspective, you do not know what it is supposed to contain, as a string can more or less contain anything. |
I don't want to take away this strictness from the validator, in my opinion - it's doing the right thing. What you need is more flexibility to relax the rules right? |
I don't agree. The job of the validator is to check if If the schema states 'string' and you pass in anything other than a
There is always the option to tell the validator to 'pretend they are not numbers for a second', but saying this is 'pointless' isn't accurate at all. The whole purpose of this code is to validate as best it can. |
my point is: validading that it is not a number does not imply that it is a string, as it could be a boolean or anything else that you do not know. |
To me, this makes perfect logical sense.
If the schema is defined as a string, an object or an array.. check if it's numeric, if it is.. its no good. If the schema is defined as numeric, check the input is numeric, if it's not, it is no good. Why is this pointless? |
if you only look at those two cases and if there are and always will be only these two cases: To some degree it makes sense that the (positive) validation logic of the numbers-case is inversed (negative) in the other case. Imo, it would be better if the first case was also a "positive" validation, meaning it is a string, it is an object, it is an array contrary to it not a number and not whatever else may be added in the future. That would lead to the positive check: Maybe my assumption is incorrect what this code is exactly targeting, is it the format of a string type or is it the actual string type itself? |
Yes, having a function that does not require validation, or one that allows for custom validation logic, would better suit my use case. |
For example, in this schema, the username is defined as a string type. If called in this way, it will lead to the inability to find the route:
libopenapi-validator/test_specs/petstorev3.json
Lines 818 to 836 in 657229e
is it possible to remove the string validation here since numbers can be safely used as strings?
libopenapi-validator/paths/paths.go
Lines 284 to 288 in 657229e
The text was updated successfully, but these errors were encountered: