Open sshishov opened 3 months ago
Thanks for taking the time to go through the source code and providing a fix.
I'll ship it in the next release.
Hi @sshishov, would you like to contribute and open a Pull Request at bhch/react-json-form?
If not, it's still okay and I can make these changes myself. Let me know.
Thanks again.
Any Update? I'd really appreciate this enhancment
In the processing of
oneOf
options we rely that thetitle
should be inside the components, but sometimes theoneOf
is the array of just references, therefore title can be unavailable there.We can replace the current implementation
with this one
or similar. The main point - we should receive the full schema first to make sure that we properly retrieve options.
I would recommend to store the schemas of objects in the internal state of the Container (same list with index acces). In this case we should not retrieve and parse it every time.
Example of the broken schema
```json { "$defs": { "ChoiceModel": { "additionalProperties": false, "properties": { "value": { "title": "Value", "type": "string" }, "label": { "title": "Label", "type": "string" }, }, "required": [ "label" ], "title": "ChoiceModel", "type": "object" }, "CustomFieldNumberMetadataModel": { "additionalProperties": false, "properties": {}, "title": "Metadata", "type": "object" }, "CustomFieldNumberModel": { "additionalProperties": false, "properties": { "field_type": { "const": "NUMBER", "title": "Field Type" }, "metadata": { "$ref": "#/$defs/CustomFieldNumberMetadataModel" } }, "required": [ "field_type" ], "title": "Number", "type": "object" }, "CustomFieldSelectMetadataModel": { "additionalProperties": false, "properties": { "choices": { "items": { "$ref": "#/$defs/ChoiceModel" }, "title": "Choices", "type": "array" } }, "required": [ "choices" ], "title": "Metadata", "type": "object" }, "CustomFieldSelectModel": { "additionalProperties": false, "properties": { "field_type": { "const": "SELECT", "title": "Field Type" }, "metadata": { "$ref": "#/$defs/CustomFieldSelectMetadataModel" } }, "required": [ "field_type", "metadata" ], "title": "Select", "type": "object" }, "CustomFieldTextMetadataModel": { "additionalProperties": false, "properties": {}, "title": "Metadata", "type": "object" }, "CustomFieldTextModel": { "additionalProperties": false, "properties": { "field_type": { "const": "TEXT", "title": "Field Type" }, "metadata": { "$ref": "#/$defs/CustomFieldTextMetadataModel" } }, "required": [ "field_type" ], "title": "Text", "type": "object" } }, "discriminator": { "mapping": { "NUMBER": "#/$defs/CustomFieldNumberModel", "SELECT": "#/$defs/CustomFieldSelectModel", "TEXT": "#/$defs/CustomFieldTextModel" }, "propertyName": "field_type" }, "final": true, "oneOf": [ { "$ref": "#/$defs/CustomFieldSelectModel" }, { "$ref": "#/$defs/CustomFieldNumberModel" }, { "$ref": "#/$defs/CustomFieldTextModel" } ], "title": "Discriminator" } ```Actual and Expected screenshots on playground
NOTE: tested locally, working like a charm.