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
default values for each of the oneOf options are not displayed #1133
Comments
on a side note - we wrote a web-GUI for a cloud-computing based simulator, where JSON editor was a key component in the frontend. This work was was recently published at https://doi.org/10.1117/1.JBO.27.8.083008, where we referenced the json-editor project. here is our web GUI: http://mcx.space/cloud/ json-editor really made our development much simpler, we want to thank the developers for your great works! |
Does this playground example work like intended? https://is.gd/nBRgjo But I also had issues with our default example?! |
@schmunk42, the playground example behaves as expected when choosing the |
We're looking into that and will try to fix it, but it's a complex issue. There are "fitChecks" to see which value fits best to the given Here are two hacky workarounds, but I do not really advise to use them, they are merely for understanding the issue better:
Or 2. you can move the default to the property itself (also not nice)
|
thanks for the above comments and workarounds. the 2nd workaround works for me - although I am not sure if this is a valid from json-schema's perspective - just to test, I changed "default" to a floating-point value (1.5), and it is displayed when the string option is chosen - which seems inappropriate
regardless whether the first type was consciously chosen by the user, or automatically assigned by the editor, to the user, it is the same - that the string value ends up in the JSON output, so I felt that it is more appropriate to use its respective default value - unless the default option is "please choose below" and force users to make a conscious choice. let me know if this makes sense. |
Thank you for the detailed response. I am using workaround no 1, because of a related issue. I choose a subschema in a |
General information
When a property is set as
oneOf
and each of the value option sets a default value, json-editor shows empty values either for the default option or switching to alternative options. Basically the default value settings are not used at all whenoneOf
is set.Additionally, the title of the item is also fixed as the JSON key name, rather than using the title field of the property.
See below direct link to example
2.6.1
Expected behavior
for the default option ("string"), display the string-type default value "DP", when switching to "integer", sets to 5 instead
Actual behavior
choosing either option, the default value stays at empty
Steps to reproduce the behavior
Direct link to example
The text was updated successfully, but these errors were encountered: