-
Notifications
You must be signed in to change notification settings - Fork 53
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
Constraints on numbers do not validate against proper type|format #46
Comments
I think it's important to note that we have to work within the constraints of multiple languages. Compliance to the constraints with integer bounds are checked by another validator. The spec is a json document, and json-schema is described in json, not go. |
Thanks for your comment. This, I believe, is important when using Swagger format extensions for numbers|integers such as: uint32 etc.. |
As we discuss this point, I have 2 questions:
|
Fixing #44 did help to support this feature on default values. We just miss the actual call to these validations for schemas bereft of default value That would come naturally with support of example values, but would require some additional effort to validate constraints boundaries/factor in cases whitout default value nor example (that is, the simplest case... 😀 ). Also think I will downgrade these checks to the "warning" level. I guess it is also a good opportunity to check numbers against the JSON SAFE INTEGER and spew a warning. |
Here is the full story of what I've currently on the workbench:
Nothing to do with bignum here |
@fredbi @casualjim I would claim it is related. OpenAPI seems to be incompatible with https://tools.ietf.org/html/rfc7493 written by the current JSON editor: I have adopted this RFC and here is my take on how to deal with int64, BigNum, etc.: |
Applies to: numbers or integers with constraints
Constraints such as Maximum, Minimum, MultipleOf are not validated against the proper type and format.
Instead, the constraint operand (boundary or factor) is systematically (and silently) converted as float64, with a risk of information loss.
We should provide spec consistency check between object/param types and constraints,
and avoid possible loss of information when casting int64 to float64.
Don't be mistaken, this one is not about providing bigint arithmetics.
Incompatible operands (e.g. constraining a uint32 with a negative value in Maxium) should be detected.
This kind of error could trigger a warning (please advise), since it is not illegal to specify a constraint with a different type than the constrained value.
NOTE: PR #42 make it work on inline params (validator.go) in presence of default values [a default value will trigger the check, but schemas without default remain skipped].
This should be generalized to all situations (objects, arrays).
Also refered by:
The text was updated successfully, but these errors were encountered: