-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
select correct oneOf based on specific property #709
Comments
mbknor
added a commit
to mbknor/json-editor
that referenced
this issue
Jan 3, 2017
mbknor
added a commit
to mbknor/json-editor
that referenced
this issue
Jan 3, 2017
mbknor
added a commit
to mbknor/json-editor
that referenced
this issue
Jan 3, 2017
PullRequest with fix: #710 |
mbknor
added a commit
to mbknor/mbknor-jackson-jsonSchema
that referenced
this issue
Jan 3, 2017
This commits adds support for this feature in mbknor-jackson-jsonSchema: |
mbknor
added a commit
to mbknor/json-editor
that referenced
this issue
Jan 3, 2017
This is fantastic and exactly what we needed for our project as well. May I suggest adding support for checking nested properties by integrating a function like this into the check:
|
btsimonh
pushed a commit
to btsimonh/json-editor
that referenced
this issue
May 26, 2021
…00405 npm audit fix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We're using json-editor in combination with schemas generated by https://github.com/mbknor/mbknor-jackson-jsonSchema which uses oneOf to enable polymorphism.
When using polymorphism in json we use a special property to show which subclass the json represents.
Each oneOf-schema has this property embeded as a hidden single enum property with the "type info".
This ensures that the json extracted from the editor has correct type info corresponding with the oneOf which is selected.
When setting data into the editor using setValue, the multiple-editor tries to select the correct oneOf to use. This is done by selecting the one that has no validation errors.
We often need to show the editor with initial data that is not yet 100% valid.
Since the data is not fully valid, the multiple-editor does not know which oneOf to select always ending up with the first one.
Since we always have this special property with the "type info", I'm proposing a new feature to optionally select oneOf based on a custom property and value.
If the (part of) schema (that is "root" for the specific oneOf) has this option:
Then the multiple-editor will look for the property 'myProperty' in the value-object we're setting using setValue. If it is pressent, and has the value 'myValue', then we select this editor.
If not, we fallback to default implementation which selects it if it has no validation errors.
Im soon going to submit a pullRequest with this feature.
The text was updated successfully, but these errors were encountered: