express-openapi-validator
express-openapi-validator copied to clipboard
Support for `discriminator` on deeper levels
At the moment, discriminator is supported at the top level only. This seems to mean that e.g. an endpoint can return a body of schema A or B. Example 8 nicely demonstrates this.
What does not seem to be supported is that an endpoint can return a body containing an array where its items can be of either schema C, D or E.
Is such support planned?
Is the currently limited support due to ajv? I don't see this limitation mentioned on https://ajv.js.org/json-schema.html#discriminator
Thank you!
I would like to second this support.
Currently I have similar requirement in validating requests that accept an array containing several forms of objects.
My workaround is to define an object which have several properties but only allow one property when it's in use.
Look forward to discriminator support at deeper levels, and thanks again to the authors for this awesome tool!
Hi there, is there any news on supporting discriminators in deeper levels?
We could also need support for this.
Scenario: We have a object with an array where each item must be oneOf schema A, B or C. A, B and C have much in common, but should be mapped based on their status property.
# Example
type: object
properties:
events:
type: array
items:
oneOf:
- $ref: '#/components/schemas/A'
- $ref: '#/components/schemas/B'
- $ref: '#/components/schemas/C'
discriminator:
propertyName: status
mapping:
A: '#/components/schemas/A'
B: '#/components/schemas/B'
C: '#/components/schemas/C'