Sometimes there's the need to express variant of a schema that apply under certain conditions.
Such variant may
A. only change the representation of the schema (e.g. display/hide fields, change labels, etc.)
B. actually change the schema (e.g. add fields or make additional fields mandatory)
JSON-SCHEMA provides the following options:
Limitations of JSON-SCHEMA based tools:
Current recommendation is to use oneOf for both cases A and B. Once bugs in https://github.com/json-editor/json-editor are fixed, if-then-else is recommended for cases A
Sometimes there's the need to express variant of a schema that apply under certain conditions.
Such variant may
A. only change the representation of the schema (e.g. display/hide fields, change labels, etc.)
B. actually change the schema (e.g. add fields or make additional fields mandatory)
JSON-SCHEMA provides the following options:
dependentRequired: https://json-schema.org/understanding-json-schema/reference/conditionals#dependentRequireddependentSchemas: https://json-schema.org/understanding-json-schema/reference/conditionals#dependentSchemasdependencies: https://json-schema.org/draft-07/draft-handrews-json-schema-validation-01#rfc.section.6.5.7if-then-else: https://json-schema.org/understanding-json-schema/reference/conditionals#ifthenelseoneOf: https://json-schema.org/understanding-json-schema/reference/combining#oneOfdiscriminator, see also: Proposal: Add propertyDependencies keyword (aka discriminator) json-schema-org/json-schema-spec#1082Limitations of JSON-SCHEMA based tools:
dependencies,if-then-else, andoneOfif-then-elsesupport is limited, especially regarding UI modifications (see if-then-else not working in allOf json-editor/json-editor#1440, if-then-else doesn't apply dynamically (at least to nested properties) json-editor/json-editor#1434)oneOfCurrent recommendation is to use
oneOffor both cases A and B. Once bugs in https://github.com/json-editor/json-editor are fixed,if-then-elseis recommended for cases A