Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix stack overflow; improve not subschema handling #410

Merged
merged 3 commits into from
Sep 24, 2023
Merged

fix stack overflow; improve not subschema handling #410

merged 3 commits into from
Sep 24, 2023

Conversation

ahl
Copy link
Collaborator

@ahl ahl commented Sep 24, 2023

A schema like this will recur infinitely:

    {
      "type": "object",
      "properties": {
        "this": {},
        "that": {}
      },
      "not": {
        "required": [
          "that"
        ]
      }
    }

This includes logic to handle this type of not by "subtracting" it out from the other schema.

In addition, we now handle constructs like this:

    {
      "type": "object",
      "properties": {
        "a": {},
        "b": {},
        "c": {}
      },
      "required": [
        "a"
      ],
      "not": {
        "anyOf": [
          {
            "required": [
              "b"
            ]
          },
          {
            "required": [
              "c"
            ]
          }
        ]
      }
    }

We reduce a not of anyOf to an allOf of not which we can then "subtract" out as above.

}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of ... not great. It makes sense though as we have to do a bunch of processing on each variant to make them comprehensible. To address this (i.e. in the future) we can do a deeper processing of the variant schemas rather than applying the light heuristics we currently do...

... on the other hand, this construction seems needlessly baroque and there might be situations where we are happy with doing our best on weird schemas.

@ahl ahl merged commit 6b2a360 into main Sep 24, 2023
4 checks passed
@ahl ahl deleted the overflow branch September 24, 2023 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant