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

feature/unions for array or objects #48

Merged
merged 6 commits into from
May 8, 2024

Conversation

xddq
Copy link
Owner

@xddq xddq commented May 8, 2024

originally done by @smeijer
here. just created new PR
cause I somehow could not commit to the original one. I think the reason is
that the pr creator account and the fork live in different accounts. But it is
just an assumption.

Summary

This adds support for unions that have an array or object in them, like in the schema below.

Other unions like [string, null] were already supported. Unions with arrays [array, null] and objects [object, null] were not. Tests covering these new cases are included.

{
  type: "object",
  properties: {
    nullableObject: {
      type: ["object", "null"],
      properties: {
        name: { type: "string" },
      }
    },
    nullableArray: {
      type: ["array", "null"],
      items: {
        type: "string"
      },
    },
  }
});

I'm making this change, because we have schemas with nullable arrays and objects. Without this change, those schemas cannot be parsed.

Fixes #43

@xddq xddq merged commit 3c94ee6 into main May 8, 2024
8 checks passed
@xddq xddq deleted the feature/unions-for-array-or-objects branch May 8, 2024 00:04
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.

throws on nullable objects
2 participants