Open blacksages opened 5 years ago
Works when "Object properties required by default" is used
@pmk65 Is this intended? It sounds somehow confusing to me.
@pmk65 Is this intended? It sounds somehow confusing to me.
Hard to tell, the documentation isn't very informative about the defaultProperties
property. and in the code there isn't much info either. 😕
It's a JSON-Editor special feature. https://github.com/jdorn/json-editor/issues/220
But it seem to have some issues according to the old repo.
Work as intended on old JDorn version:
and on Interactive Playground (even with required by default: false):
but not on Interactive demo:
Useful when you want some properties required and some optional but shown (on Playground, which seems to be ok):
Is there anyone having the same issue ? I am not able to make defaultProperties work properly
Test schema: { "type": "object", "properties": { "name": {"type": "string"}, "surname": {"type": "string"}, "age": {"type": "integer"} }, "defaultProperties": ["name", "surname"], "required": ["name"] }
My understanding:
"required": Array of properties that must appear in form always and can't be empty to get a valid JSON
"defaultProperties": Array of properties that must appear in form always and can, if not required, be empty to get a valid JSON
others properties: Listed in "Properties" button, optionally appear in form, can be empty to get a valid JSON
Option "Object properties required by default": all properties must be filled to get a valid JSON, does not modify appearance on form
In both demos (interactive and playground), seems to be OK. Setting "required by default" option does not give a valid JSON until "age" (and name and surname) is filled with a value.
@faoFurkanMacit can you please post the use case that shows the issue?
Thank you, and sorry for my English
General information
"defaultProperties" attribute doesn't work.
It's expected for "name" property to be already present, but "name" property must be manually added in "properties tab"
Direct link to live example : https://json-editor.github.io/json-editor/?schema=N4IgLgngDgpiBcID2AjAVjAxmEAaEUATkrIWAJYwDOCoAdgIYC2c8oksCIVYh5dAcxABffAwGt20ViH5gYEwiNEgAJjABmDAK4AbMAAVipCtQQBtEIxYgAusKA==&value=N4XyA===&lib_switcher=&prompt_before_delete&upload=function(a,b,c){console.log(%22Upload%20handler%20required%20for%20upload%20editor%22)}&theme=bootstrap2&iconlib=fontawesome4&object_layout=normal&show_errors=interaction
or see example below :