-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
SwaggerEditor@next: no validation against Incompatible types in schemas using allOf
#3732
Comments
allOf
allOf
Hi @mtovt, Thanks for the report. I've rewritten your JSON Schema into single JSON Schema definition in Draft 5 (Draft 4 respectively): {
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "http://json-schema.org/draft-04/schema#",
"$ref": "#/$defs/Foo",
"$defs": {
"Foo": {
"type": "object",
"properties": {
"property1": {
"type": "object"
}
}
},
"Bar": {
"type": "object",
"properties": {
"property1": {
"type": "array",
"items": {
"type": "string"
}
}
},
"allOf": [
{
"$ref": "#/$defs/Foo"
}
]
}
}
} This is completely valid JSON Schema and there is nothing invalid about it. It will be processed by tools like https://ajv.js.org/, https://www.jsonschemavalidator.net/ or https://extendsclass.com/json-schema-validator.html. There is also a question of validating this JSON Schema agains the instance. It validates as well and it expects Invalid {
"property1": []
} Valid {
"property1": {}
} |
@char0n Thanks for your answer! It makes me partly clear. It seems, it really valid JSON schema. But what about OpenAPI? Also, the following moments are unclear to me:
If the expected type is
class Bar(Foo):
...
swagger_types = {
'property1': 'list[str]'
}
OpenAPI v3.0.1 Schema Object says following
As I understand it should independently validate. It seems it shall not pass validation against |
It is not a bug. This is the case of
This is the case of
IMHO it is. There is nothing invalid I can see about it. The Overall, we have three independent contexts here in play:
For each of this context different tooling is used, and the tooling does it's best and decides how to interpret JSON Schema depending on the context. If you still have concerns, you should file an issue in https://github.com/OAI/OpenAPI-Specification/issues to get clarifications. But even if you get clarifications, it doesn't mean that tooling will accept the interpretation and adapt. Here is also a proof that your OpenAPI definition validates succesfully against OpenAPI 3.0 metaschema: https://www.jsonschemavalidator.net/s/4cQMaEsJ |
Q&A (please complete the following information)
macOS 12.6
Safari
16.0
3.0.1
Content & configuration
Example Swagger/OpenAPI definition:
Swagger-Editor configuration options:
-
Describe the bug you're encountering
Related links in OpenAPI and JSON Schama validation specifications:
Seems there is an OpenAPI validation issue. Seems provided spec is invalid. Because
Foo. property1
has an incompatible type (object
) withBar. property1
which one has typearray
. Swagger Editor does not find this validation issue and threat spec valid.To reproduce...
Steps to reproduce the behavior:
Expected behavior
If I got it correctly it impossible situation since the such schema is not able to validate at the same time against 2 different types (
object
,array
).Screenshots
Additional context or thoughts
Seems https://editor-next.swagger.io behavior is also incorrect.
The text was updated successfully, but these errors were encountered: