-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Dereference option schemas before giving it as props to anyOf and oneOf #2270
Conversation
@@ -132,7 +132,10 @@ class AnyOfField extends Component { | |||
} | |||
|
|||
const enumOptions = options.map((option, index) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to instead just set option = retrieveSchema(option, registry.rootSchema)
earlier in this function, so that everything related to the option
is already dereferenced (this might fix other bugs with oneOf / refs)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I guess I'll update the samples as well then since this will ignore any title that is a sibling to a $ref.
Actually; if you look the reference sample. There you have a reference to the same schema but with different titles. That wouldn't be possible if we changed like above. We could implement your suggestion but still look for title in the $ref schema.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the logic to SchemaField
instead, so props.options are now dereferenced. That also fixes #1819
@epicfaace I've now updated the options so they are all dereferenced from the beginning. I have an issue running
Those |
Thanks. Yeah, it might be a race condition. Try running |
I'll close this in favour of #2272 |
… 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]>
Reasons for making this change
Fixes #2016 and #1819
If this is related to existing tickets, include links to them as well.
Checklist