-
Notifications
You must be signed in to change notification settings - Fork 325
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
null is not valid against nullable array with typeLoose false #194
Comments
I fixed this by changing: if (!node.isArray() && !config.isTypeLoose()) { to if (!node.isArray()) { in ItemsValidator.java. But now several other tests fail, e.g. {
"description": "an typeLoose array of schemas for items",
"schema": {
"items": [
{"type": "integer"}
]
},
"tests": [
{
"description": "wrong types",
"data": "foo",
"isTypeLoose": true,
"valid": false
}
]
} Funny thing is that IMO this instance is valid against above schema, because |
@chuwy TypeLoose is to handle the OpenAPI specification as it is different than the JSON scheme validation at the moment. The specific flag is to allow the library to treat query parameters, headers and path parameters without worry about the types. In the HTTP context, everything is a string but the schema might indicate that pageNum is an integer. So the library will tolerate the input "20" as an integer although it is a string. That is what TypeLoose works. If you are using pure schema validation, set the TypeLoose to false. |
Thanks @stevehu! So this confirms my understanding and I will change its use in our lib. Then it also means that |
Yes. The change looks good. Just to confirm that we don't need to do anything except to set the TypeLosse to false to handle this use case. If yes, can we close this issue? Or we still need to do something? |
Sorry, by "my fix" I meant one mentioned here: #194 (comment). I'm just not sure what we need to do with other tests that fail because of that fix, IMO those test cases are invalid (also regardless of I still think this is a bug and the fact that it works with |
Let's keep this open as a bug so that we can investigate further. Thanks. |
I ended up reverting back to 1.0.7 to get my case or work. Confirming > "It seems this behavior was introduced in 1.0.8" from above. |
|
This shouldn't be an issue for the latest version 1.4.x |
I have this test case:
I assume this should pass validation, but it fail with following error:
It passes however with
"isTypeLoose": false
or noitems
. I thought this should have been fixed in #183, but I observe this behavior in 1.0.20 as well. It seems this behavior was introduced in 1.0.8 (presumably here)I have several questions about it:
isTypeLoose
is related to OpenAPI specification and goes against official v4 specificationisTypeLoose
should make validation less strict, e.g. make"3"
(string) pass againstinteger
typeisTypeLoose
does something different and it should be considered a bugisTypeLoose
should default tofalse
? At least I'd assume a JSON Schema validator library should be compliant with official specsThe text was updated successfully, but these errors were encountered: