Open MOHACGCG opened 3 years ago
I am aware of this problem and I need to think about it. Initializing an empty object is built kinda deep in the way the lib works (necessary to bind the children properties on it). But the implementation of model binding and reactivity has changed quite a lot in 1.25 beta, maybe it has become easier to fix.
I have schema workaround for now (use a toggle switch) to turn the object on and off but would be nice to have this built in.
"allOf": [
{
"allOf": [
{
"properties": {
"!__ nestedObj_toggle": {
"title": "NestedObj,
"type": "boolean",
"x-display": "switch",
"default": false
}
},
"if": { "properties": { "!__ nestedObj_toggle": { "const": true } } },
"then": {
"properties": {
"nestedObj": { "$ref": "#/$defs/nestedObj" }
}
},
"else": {}
}
]
},
...]
Issue: A model should be valid with an undefined optional nested obj with required fields (i.,e
{stringProp:"a"}
is a valid model for the schema below).Feature request: Is it possible to remove an optional nested object from the model? in the schema below remove the nestedObj (i.e. set it to undefined). The array type already allows removal of items, so this is to support the same behavior to remove objects.