schema-tools icon indicating copy to clipboard operation
schema-tools copied to clipboard

Support for logic based schema keywords

Open tstackhouse opened this issue 4 years ago • 0 comments

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

tstackhouse avatar Mar 23 '21 15:03 tstackhouse