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: Fixed #3744 and another precompiled schema issue #3763

Conversation

heath-freenome
Copy link
Member

Reasons for making this change

Fixes #3744 as well as an issue associated with anyOf/oneOf in precompiled schema

  • In @rjsf/util, fixed part of Odd behaviour of anyOf/oneOf #3744 and the precompiled schema issue as follows:
    • Updated getClosestMatchingOption() to resolve refs in the options before computing the correct index, as well as supporting anyOf and discriminators in calculateIndexScore()
    • Updated getDefaultFormState() to merge in the remaining schema into the selected anyOf/oneOf option prior to computing new defaults
    • Updated retrieveSchema() to merge in the remaining schema into the anyOf/oneOf options when resolving dependencies
    • Added/updated tests to verify all the fixes
  • In @rjsf/core, fixed the rest of Odd behaviour of anyOf/oneOf #3744 by updating MultiSchemaField to merge the remaining schema into the selected anyOf/oneOf selected option
    • Also updated SchemaField to no longer pass in baseType to MultiSchemaField since it is no longer used

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

Fixes rjsf-team#3744 as well as an issue associated with anyOf/oneOf in precompiled schema
- In `@rjsf/util`, fixed part of rjsf-team#3744 and the precompiled schema issue as follows:
  - Updated `getClosestMatchingOption()` to resolve refs in the options before computing the correct index, as well as supporting `anyOf` and discriminators in `calculateIndexScore()`
  - Updated `getDefaultFormState()` to merge in the remaining schema into the selected anyOf/oneOf option prior to computing new defaults
  - Updated `retrieveSchema()` to merge in the remaining schema into the anyOf/oneOf options when resolving dependencies
  - Added/updated tests to verify all the fixes
- In `@rjsf/core`, fixed the rest of rjsf-team#3744 by updating `MultiSchemaField` to merge the remaining schema into the selected anyOf/oneOf selected option
  - Also updated `SchemaField` to no longer pass in `baseType` to `MultiSchemaField` since it is no longer used
Comment on lines +211 to +213
testValidator.setReturnValues({
isValid: [false, false, false, false, false, false, false, true],
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if in some places it might be more readable/maintainable if we stubbed the implementation to return isValid for a specific subschema (in this case the second anyOf) instead of relying on ordering.

Copy link
Member Author

Choose a reason for hiding this comment

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

Most likely... What were you thinking of changing?

Co-authored-by: Nick Grosenbacher <nickgrosenbacher@gmail.com>
@heath-freenome heath-freenome merged commit 62542ca into rjsf-team:main Jul 13, 2023
@heath-freenome heath-freenome deleted the fix-3744-and-precompiled-schema-issue branch July 13, 2023 17:06
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.

Odd behaviour of anyOf/oneOf
2 participants