-
-
Notifications
You must be signed in to change notification settings - Fork 887
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
Discriminator-Property not working in allOf
#2281
Comments
Looks like a duplicate of #2261 |
You may need to add the definitions for |
Yes, it's a limitation, as documented. For it to work it should have discriminator tag property defined on the top level in subschema. |
I encountered the same limitation (thanks for explaining these limitations in the documentation) and I understand the complexity of solving this issue. Could it be possible to add an arbitrary property to discriminate ? {
"type": "object",
"discriminator": {
"propertyName": "type"
},
"oneOf": [
{
+ "discriminatorValue": ["a"],
"allOf": [
{
"$ref": "#/components/schemas/A"
},
{
"type": "object",
"required": ["type"],
"properties": {
"method": {
"type": "string",
"enum": ["a"]
}
}
}
]
},
{
+ "discriminatorValue": ["b"],
"allOf": [
{
"$ref": "#/components/schemas/B"
},
{
"type": "object",
"required": ["type"],
"properties": {
"method": {
"type": "string",
"enum": ["b"]
}
}
}
]
}
]
} |
What version of Ajv are you using? Does the issue happen if you use the latest version?
8.12.0
JSON Schema
When accessing the schema from above, I get this error:
Error: discriminator: oneOf subschemas (or referenced schemas) must have "properties/type"
For me this Schema seems to be valid, but there seems to be a problem with this nested oneOf / allOf structure.
Is there a way to solve this, because I would like to stay with this Schema which is autogenerated from the backend.
The text was updated successfully, but these errors were encountered: