-
Notifications
You must be signed in to change notification settings - Fork 407
core: Remove AJV usage from combinator mappers #2413
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
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for jsonforms-examples ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
- Adapt algorithm to determine the fitting schema index for combinators to no longer use AJV - New heuristic uses identifying properties that should match a const value in the schema - Adapt MaterialOneOfRenderer.test.tsx to fit new heuristic - Describe changes and add examples to migration guide - Adapt some of the anyOf and oneOf examples to custom and new identification properties #2371
In contrast to oneOf and anyOf rendererer, allOf renderers do not need the `indexOfFittingSchema` because all schemas apply at once. Thus, remove using mapStateToCombinatorRendererProps from mapStateToAllOfProps and, with this, the unnecessary calculation of the index. Part of #2371
07fe0f7
to
d9b3550
Compare
- remove usage of any number or string property as fallback - choose type, kind default prop based on combinator schema with const entry instead of presence in the data object - Adapt tests - remove usage of id as a default prop
d9b3550
to
cf3f154
Compare
@sdirix The tests are fixed and the review comments applied :) |
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.
- The preselection for primitives fails now (example
#oneOf_1273_simple
). However I think we can add primitive detection to our determinator. - All the
oneOf
validation examples no longer properly work with the new AJV-less approach in case thedata
is set to a valid initial data which is not the first entry. We should think about what we advice users for these cases. - The
oneOf
recursive example detection is also broken, we should addtype/kind
properties there I think.
For migration: We should provide a way to restore the old behavior. For this we can hand over a (by default unused) AJV
to the determination function and show the user how they can customize this function to use AJV to restore the old behavior.
Furthermore, subschemas can no longer automatically be selected based on validation results like | ||
produced by different required properties between subschemas. |
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.
Furthermore, subschemas can no longer automatically be selected based on validation results like | |
produced by different required properties between subschemas. | |
Furthermore, subschemas can no longer automatically be selected based on validation results like produced by different required properties between subschemas. |
@@ -36,6 +36,12 @@ export interface CombinatorSubSchemaRenderInfo { | |||
|
|||
export type CombinatorKeyword = 'anyOf' | 'oneOf' | 'allOf'; | |||
|
|||
/** Custom schema keyword to define the property identifying different combinator schemas. */ | |||
export const COMBINATOR_TYPE_PROPERTY = 'x-jsf-type-property'; |
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 could place these two properties as well as getCombinatorIndexOfFittingSchema
into a Combinators
object. Then in all our code we should always refer to Combinators.COMBINATOR_TYPE_PROPERTY
etc. This would allow adopters to easily globally override these two properties as well the actual determination function for easier customization.
@@ -2,6 +2,116 @@ | |||
|
|||
## Migrating to JSON Forms 3.6 | |||
|
|||
### Combinator (anyOf & oneOf) index selection now uses a heuristic instead of AJV |
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 think we should place this for JSON Forms 4.0 as this will break adopters
In contrast to oneOf and anyOf rendererer, allOf renderers do not need the
indexOfFittingSchema
because all schemas apply at once.Thus, remove using mapStateToCombinatorRendererProps from mapStateToAllOfProps and, with this, the unnecessary calculation of the index.
fix #2371