oxidecomputer/typify

handling of `not` is incorrect in the general case

ahl opened this issue · 0 comments

ahl commented

Currently we don't properly handle the general case of not. We do (pretty much) properly address cases such as this:

{
  "allOf": [
    { "$ref": "#/$defs/foo" },
    {
      "not": {
        "required": [ "bar" ]
      }
    }
  ]
}

However, we don't handle

{
  "allOf": [
    { "$ref": "#/$defs/foo" },
    {
      "not": {
        "required": [ "bar", "baz" ]
      }
    }
  ]
}

We also don't handle properties in the not schema.

We can think of the various components of a not schema as independent constraints. So if a not schema contains independent constraints X, Y, and Z, we could rewrite that as not: allOf: [X, Y Z]. Then we can transform that into anyOf: [ not: X, not: Y, not: Z]. While we don't currently properly handle anyOf(see #414), once we do, that will turn into aoneOf` power set of those.