-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 incorrect path selection for oneOf cases in jsonschema #10883
Conversation
if (selectedSchema && typeof selectedSchema !== "boolean") { | ||
return buildYupFormForJsonSchema( | ||
{ type: jsonSchema.type, ...selectedSchema }, | ||
uiConfig, | ||
jsonSchema, | ||
propertyKey, | ||
propertyPath ? `${propertyPath}.${propertyKey}` : propertyKey |
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.
We're having the same logic two times more further down. Once inside an object and once inside the array branch. For the object the propertyKey
we're actually having is not the one passed into this method, but for array it's the same as passed into, and thus the logic the same as here. Could you please explain (and give some example schemas to illustrate it), why the logic needs adjustment in this place, but for the other two calls to buildYupFormForJsonSchema
further down it's the correct behavior?
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.
Because we don't need it for oneOf case and need it for object and array cases, as we handle oneOf same way as object and array based on selected value, so we do not want to add propertyPath for oneOf cases. So we sort of try to get rid of oneOf and continue to working as with a usual schema. That's why we don't need it for oneOf.
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.
@timroes let me know if it's still unclear. I will try to provide a more accurate answer
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.
Tested locally, fixes the linked issue for me. Should this also close #8291 ?
No, it is a bit different problem - I think that one is about state not being reset for oneOf case when you click cancel. |
What
Fixes a problem, when wrong validation schema path was selected for oneOf field. Closes #9980
How
For some reason when we were building validationSchema we were combining current path with property key ( so in oneOf case, instead of
format.compression_codec
it wasformat.format.compression_codec
, as a result always first entry in oneOf was selected.