express-openapi-validator
express-openapi-validator copied to clipboard
`allOf` and `oneOf` don't work as NonArraySchemaObject always requires type property to be defined
trafficstars
https://github.com/cdimascio/express-openapi-validator/blob/a585ba18ac3f613d2669c3c19dbc0097ca6d9659/src/framework/types.ts#L234-L251
As line 249 shows, type property is always required for NonArraySchemaObject however if I'd like to use oneOf keyword what value the type property should be? For example:
properties: {
// this property can be either string or number
stringOrNumber: {
type: '', // this property is always required however in this case I explicitly defined `oneOf` below
oneOf: [{type: 'string'}, {type: 'number'}],
}
}
I ran into this as well; this was my workaround:
{
type: undefined as unknown as "object",
oneOf: [...],
}