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: anyOf/oneOf not load options with $ref correctly #2245

Closed
wants to merge 1 commit into from

Conversation

bachdx96
Copy link

@bachdx96 bachdx96 commented Feb 22, 2021

Reasons for making this change

This fixes oneOf/anyOf not updating default value and label correctly if $ref is used.

Here is a simple example that show clearly that the default value is not set if the first item is using $ref and the title still shows Option 1 even though it has a title.

#2202

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

NixBiks added a commit to NixBiks/react-jsonschema-form that referenced this pull request Mar 15, 2021
@NixBiks
Copy link
Contributor

NixBiks commented Mar 15, 2021

This could be closed in favour of PR #2272 which also fixes the inferred schema type based on the initial form data

NixBiks added a commit to NixBiks/react-jsonschema-form that referenced this pull request Mar 16, 2021
epicfaace added a commit that referenced this pull request Apr 13, 2021
… contain references (#2272)

* fix: title from refs schema before fallback value

* Added test for #2270

* After review

* Add formData when dereferencing

* Moved logic to SchemaField, so props.options are already dereferenced

* Removed wrong comment

* Fix: refs should be included when determining matching option
based on formData

* Integrated tests from PR #2245

* Added a new test

* Updated tests after review

* Update isValid to take rootSchema

* * use global ajv in isValid
* simplify withIdRefPrefix
* add comments
* improve error handling

* Added test and fixed withIdRefPrefix for arrays

* * Cleaned up
* Fixed bug with $ref being a property
* added tests for withIdRefPrefix

* * Clean up
* Check for # in ref
* update tests

* Added upgrade note

* Change title of test in validate_test

Co-authored-by: Ashwin Ramaswami <[email protected]>

* Change title of test in validate_test

Co-authored-by: Ashwin Ramaswami <[email protected]>

* Added test with ref within properties

Co-authored-by: Ashwin Ramaswami <[email protected]>
@newt10 newt10 added multiSchema $ref All issues related to ref core bug labels Sep 3, 2021
@heath-freenome
Copy link
Member

This could be closed in favour of PR #2272 which also fixes the inferred schema type based on the initial form data

@bachdx96 The other PR was merged... Does this issue still happen for you? I'm inclined to close this PR since most of the code here needs a major refactor in v5

@heath-freenome heath-freenome added the any-one-all-of Related to fixing anyOf, oneOf or allOf label Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
any-one-all-of Related to fixing anyOf, oneOf or allOf bug core $ref All issues related to ref
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants