-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
[0.16.2 regression] {"key": null}
fails to validate as {"type": "object"}
#442
Comments
The openapi-schema-validator update introduced this https://github.com/p1c2u/openapi-schema-validator/blob/553d606ad0289e81564b7c60aed05fd0e745f6bd/openapi_schema_validator/validators.py#L62 The problem is that openapi-core creates a little dummy schema for the "additionalProperties" -- for any key not present in the schema -- like so: But now that little schema will have a "nullable: false" check, and it incorrectly raises exceptions for this. The above line should be updated to additional_prop_schema = Spec.from_dict({"nullable": True}) Or perhaps a little refactor is in place to not create any schema and just take the value as is. It feels a bit wasteful to constantly create these little schemas and do null-validation checks for something which isn't even defined in the schema in the first place. |
I must admit it was silly. I will change that . EDIT: Now I remember why I made this change. It was to unmarshall additional properties to objects instead of just returning pure python dict. |
@p1c2u Update: ah yes, I see my commit got merged: e017634 I guess we can close this issue (and related still open PRs). I'll leave it to you. |
Yes it was merged hence closing |
In 0.16.1,
{"key": null}
validated successfully against{"type": "object"}
—an object that includes anull
value is still an object. But in 0.16.2 this incorrectly raisesopenapi_core.unmarshalling.schemas.exceptions.InvalidSchemaValue: Value None not valid for schema of type any: (<ValidationError: 'None for not nullable'>,)
.This regression was introduced by commit 692a915 (#434).
Full reproducible example:
The text was updated successfully, but these errors were encountered: