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 preliminary support for the anyOf keyword #1118

Merged
merged 6 commits into from
Jan 14, 2019
Merged

Add preliminary support for the anyOf keyword #1118

merged 6 commits into from
Jan 14, 2019

Conversation

LucianBuzzo
Copy link
Collaborator

@LucianBuzzo LucianBuzzo commented Jan 3, 2019

This change introduces support for the anyOf keyword. Other PRs that add support for anyOf/oneOf exist, but are stale and/or incomplete ( #302, #417, #940 ).
The keyword is NOT supported in arrays (using the items keyword).
Options provided in the anyOf keyword are rendered using a new component called AnyOfField, this can be overridden with a custom field using the fields property.

I'd like to follow-up on this PR with work to add support for anyOf in arrays and oneOf. I decided against submitting that work in this PR to help keep reviews and discussion manageable.

anyof-form

Checklist

  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@LucianBuzzo
Copy link
Collaborator Author

Note that the unit tests are failing due to the New year rollover, which I've fixed/band-aided in a separate PR here #1119

@cyplo
Copy link

cyplo commented Jan 7, 2019

This looks good to me as a change and would be extremely useful if merged. Thanks ! :)

@LucianBuzzo
Copy link
Collaborator Author

@edi9999 Could you review this PR please?

test/anyOf_test.js Outdated Show resolved Hide resolved
test/anyOf_test.js Outdated Show resolved Hide resolved
This change introduces support for the `anyOf` keyword. The keyword is NOT
supported in arrays (using the `items` keyword).
Options provided in the `anyOf` keyword are rendered using a new
component called `AnyOfField` this can be overridden with a custom
field using the `fields` property.

Signed-off-by: Lucian <lucian.buzzo@gmail.com>
@LucianBuzzo
Copy link
Collaborator Author

@edi9999 I've addressed your review comments

Copy link
Contributor

@glasserc glasserc left a comment

Choose a reason for hiding this comment

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

I'm really excited to see this! The code mostly looks good and it's got tests, thank you very much!

Documentation would be great :) In particular, I think it's worth calling out that properties provided by anyOf should not overlap any properties from "outside" the anyOf.

src/components/fields/AnyOfField.js Outdated Show resolved Hide resolved
src/components/fields/AnyOfField.js Outdated Show resolved Hide resolved
src/components/fields/SchemaField.js Show resolved Hide resolved
README.md Show resolved Hide resolved
@glasserc glasserc merged commit 66d800e into rjsf-team:master Jan 14, 2019
@glasserc
Copy link
Contributor

Fantastic, thanks. I'll cut 1.2.0 in a few minutes.

@stathismor
Copy link

Is this missing from the playground?

@LucianBuzzo
Copy link
Collaborator Author

@strahius I think the playground hasn't been updated, you can see it in action if you run the playground from source.

@stathismor
Copy link

You are right, it just hasn't been deployed yet probably. Thanks a lot, good job!

@epicfaace
Copy link
Member

@strahius the playground should be updated now.

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.

None yet

6 participants