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: Fixes #3808 Duplciate AnyOf/OneOf Description #3841

Merged
merged 3 commits into from
Aug 28, 2023

Conversation

cwendtxealth
Copy link
Contributor

Reasons for making this change

Adding on to this fix, the description of the top level schema still shows in the oneOf/allOf fields.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

Comment on lines +173 to +176
// merge top level required field
const { required } = schema;
// Merge in all the non-oneOf/anyOf properties and also skip the special ADDITIONAL_PROPERTY_FLAG property
unset(remaining, ADDITIONAL_PROPERTY_FLAG);
optionSchema = !isEmpty(remaining) ? (mergeSchemas(remaining, option) as S) : option;
optionSchema = required ? (mergeSchemas({ required }, option) as S) : option;
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to me, I can't think of properties other than required that should be passed through.

Copy link
Contributor

@nickgros nickgros left a comment

Choose a reason for hiding this comment

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

@cwendtxealth can you just add to new or existing tests to ensure properties and description aren't merged, and add a line to the CHANGELOG?

@@ -61,6 +62,8 @@ describe('anyOf', () => {
expect(node.querySelectorAll('select')).to.have.length.of(1);
expect(node.querySelector('select').id).eql('root__anyof_select');
expect(node.querySelectorAll('span.required')).to.have.length.of(1);
expect(node.querySelectorAll('#root__description')).to.have.length.of(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tested without fix these will have length of 2

@@ -62,6 +63,8 @@ describe('oneOf', () => {
expect(node.querySelectorAll('select')).to.have.length.of(1);
expect(node.querySelector('select').id).eql('root__oneof_select');
expect(node.querySelectorAll('span.required')).to.have.length.of(1);
expect(node.querySelectorAll('#root__description')).to.have.length.of(1);
expect(node.querySelectorAll('#root_baz')).to.have.length.of(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tested without fix these will have length of 2

@nickgros nickgros merged commit 89df5cd into rjsf-team:main Aug 28, 2023
4 checks passed
@cwendtxealth cwendtxealth deleted the fix-3808-duplicate-anyOf branch August 28, 2023 17:18
Manish3323 pushed a commit to Manish3323/react-jsonschema-form that referenced this pull request Aug 31, 2023
heath-freenome added a commit that referenced this pull request Sep 8, 2023
* update antd version to v5 from v4

* update playground

* Keep peer dependency of ant to v4

* update package json of playground

* update changelog.md

* update docs for antd

* update docs for antd

* Update uiSchema.md

* incorporate feedback

* fix: Fixes #3808 Duplciate AnyOf/OneOf Description (#3841)

* Update package.json

---------

Co-authored-by: Christian Wendt <[email protected]>
Co-authored-by: Heath C <[email protected]>
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.

2 participants