ajv-validator / ajv-validator/ajv

Discriminator-Property not working in `allOf`

Aperta
#2,281 4 commenti 1 reazione 0 assegnatari Vedi su GitHub
limitation
Lingua principale
TypeScript
Stelle
14.8k
Fork
1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

**What version of Ajv are you using? Does the issue happen if you use the latest version?**

8.12.0

**JSON Schema**

```json
{
"type": "object",
"discriminator": {
"propertyName": "type"
},
"oneOf": [
{
"allOf": [
{
"$ref": "#/components/schemas/A"
},
{
"type": "object",
"required": ["type"],
"properties": {
"method": {
"type": "string",
"enum": ["a"]
}
}
}
]
},
{
"allOf": [
{
"$ref": "#/components/schemas/B"
},
{
"type": "object",
"required": ["type"],
"properties": {
"method": {
"type": "string",
"enum": ["b"]
}
}
}
]
}
]
}
```

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.