schema-tools
schema-tools copied to clipboard
Support for logic based schema keywords
The current JSON schema docs allow for some logic-based keywords, such as allOf, oneOf, and anyOf: https://json-schema.org/draft/2020-12/json-schema-core.html#logic
In my experience, specifically with API Gateway, though it may apply elsewhere, a snippet like so:
property: {
type: ['string', 'null'],
enum: ['foo', 'bar', null]
}
in a schema will fail, requiring a more creative solution like so:
property: {
oneOf: [
{
type: 'string',
enum: ['foo', 'bar']
}.
{
type: 'null'
}
]
}
it would be nice to be able to mirror this kind of schema in the corresponding test cases especially if we are to automatically generate schemas from one to the other