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

Add support for deep oneOf inheritance #36

Merged
merged 5 commits into from
Jan 24, 2024
Merged

Add support for deep oneOf inheritance #36

merged 5 commits into from
Jan 24, 2024

Conversation

glopesdev
Copy link
Member

@glopesdev glopesdev commented Jan 23, 2024

This PR expands discriminator inheritance resolution to support deep inheritance hierarchies. It also resolves several complicated assumptions found in NJsonSchema that would limit future support for complex inheritance schemes.

The core of the approach is to resolve oneOf inheritance in two passes:

  1. for each discriminator schema:
    a. if schema is inline, move the discriminator to a separate type definition
    b. if the discriminator has oneOf declarations, inject the discriminator as allOf schema in each of the derived schemas
  2. remove discriminator properties from all derived schemas

A simple regression test for a deep inheritance schema is added, but more extensive tests will be required in the future to ensure all edge cases are covered.

@glopesdev glopesdev added feature New planned feature fix Pull request that fixes an issue labels Jan 23, 2024
@glopesdev glopesdev merged commit a11b1a8 into main Jan 24, 2024
2 checks passed
@glopesdev glopesdev deleted the discriminator-dev branch January 24, 2024 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New planned feature fix Pull request that fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant