oneOf array not rendering as expected

Hello,

I’m trying to use a oneOf array combined with dependencies keyword to have a dynamic schema, using JSON Forms with React/Material. It’s not rendering as expected (the dependent properties aren’t displaying once the first property value is selected, although there are error messages displaying relating to these invisible properties). Snippet below. Note that I’m doing this in the JSON schema, I haven’t yet looked at UI schema options.

Any advice on how to make this work would be great.

	"softDelete": {
		"description": "",
		"type": "object",
		"properties": {
				"type": {
					"type": "string",
					"enum": [
						"Source Entity",
						"Resolved Entity",
						"Relationship"
					]
				}
		},
		"required": [
			"type"
		],
		"dependencies": {
			"type": {
				"oneOf": [
					{
						"properties": {
							"type": {
								"enum": [
									"Source Entity"
								]
							},
							"sourceName": {
								"type": "string"
							}
						},
						"required": [
							"sourceName"
						]
					},
					{
						"properties": {
							"type": {
								"enum": [
									"Resolved Entity"
								]
							},
							"resName": {
								"type": "string"
							}
						},
						"required": [
							"resName"
						]
					},
					{
						"properties": {
							"type": {
								"enum": [
									"Relationship"
								]
							},
							"relName": {
								"type": "string"
							}
						},
						"required": [
							"relname"
						]
					}
				]
			}
		}
	}

Hi @paddy.hudson,

our off-the-shelf oneOf/anyOf/allOf renderers are very simplistic. We also don’t provide an off-the-shelf renderer to support dependencies (or the newer dependentSchemas). Validation wise you might see some errors for them as we’re internally using AJV for validation which supports the whole spec.

To solve this you will need to add a custom renderer which is able to understand dependencies and what do to with them UI wise. In practice this should be relatively “easy” as usually the actual applications are pretty restricted within a certain domain. A fully featured general support might be more difficult or will be either simplistic or opinionated.

1 Like