-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for dependentSchemas and dependentRequired #3189
Comments
@lucaswiman This is definitely something that we'll need to support. There is a non-trivial amount of work needed for this, including:
Are the first two things something you'd be willing to work on if the last item is fixed? |
- Updated `@rjsf/utils` to make the `schema` and `rootSchema` props use a new generic type `S` - Added the new `StrictRJSFSchema` type as the alias to `JSON7Schema` changing `RJSFSchema` to be `StrictRJSFSchema & GenericObjectType` - Deleted the `RJSFSchemaDefinition` type in favor of accessing it indirectly via the `S["<prop-with-definition>"]` syntax - Added the new generic `S extends StrictRJSFSchema = RJSFSchema` to all types that directly or indirectly used `RJSFSchema` after the `T = any` type - Updated `SchemaUtilsType` to add the `F = any` generic to the whole interface, removing it from the definition of the two functions that need it - Updated all functions that used `RJSFSchema` to take the new generic, replacing `RJSFSchema` with `S` - Added missing generics where needed - Updated `@rjsf/core` to insert the `S extends StrictRJSFSchema = RJSFSchema` to every component that needed it, after the `T = any` generic - Updated the `index.ts` for the `ButtonTemplates`, `field`, `templates` and `widgets` to make them functions that take the `T`, `S` and `F` generics - Updated `getDefaultRegistry()` and `templates()` to call the appropriate functions - Replaced all uses of `RJSFSchema` and `RJSFSchemaDefinition` with `S` and `S["<prop-with-definition>"]` - Added missing generics where needed - Fixed a few type casts due the to the change in the `RJSFSchema` type - Updated `@rjsf/validator-ajv6` to fix a few type casts due to the change in the `RJSFSchema` type - Updated `@rjsf/validator-ajv8` to add the `S extends StrictRJSFSchema = RJSFSchema` generic to the `customizeValidator()` function and the `AJV8Validator` class - Replaced all uses of `RJSFSchema` and `RJSFSchemaDefinition` with `S` and `S["<prop-with-definition>"]` - Changed `RJSFSchema` to `S` where applicable - Fixed a few type casts due the to the change in the `RJSFSchema` type
- Updated `@rjsf/utils` to make the `schema` and `rootSchema` props use a new generic type `S` - Added the new `StrictRJSFSchema` type as the alias to `JSON7Schema` changing `RJSFSchema` to be `StrictRJSFSchema & GenericObjectType` - Deleted the `RJSFSchemaDefinition` type in favor of accessing it indirectly via the `S["<prop-with-definition>"]` syntax - Added the new generic `S extends StrictRJSFSchema = RJSFSchema` to all types that directly or indirectly used `RJSFSchema` after the `T = any` type - Updated `SchemaUtilsType` to add the `F = any` generic to the whole interface, removing it from the definition of the two functions that need it - Updated all functions that used `RJSFSchema` to take the new generic, replacing `RJSFSchema` with `S` - Added missing generics where needed - Updated `@rjsf/core` to insert the `S extends StrictRJSFSchema = RJSFSchema` to every component that needed it, after the `T = any` generic - Updated the `index.ts` for the `ButtonTemplates`, `field`, `templates` and `widgets` to make them functions that take the `T`, `S` and `F` generics - Updated `getDefaultRegistry()` and `templates()` to call the appropriate functions - Replaced all uses of `RJSFSchema` and `RJSFSchemaDefinition` with `S` and `S["<prop-with-definition>"]` - Added missing generics where needed - Fixed a few type casts due the to the change in the `RJSFSchema` type - Updated `@rjsf/validator-ajv6` to fix a few type casts due to the change in the `RJSFSchema` type - Updated `@rjsf/validator-ajv8` to add the `S extends StrictRJSFSchema = RJSFSchema` generic to the `customizeValidator()` function and the `AJV8Validator` class - Replaced all uses of `RJSFSchema` and `RJSFSchemaDefinition` with `S` and `S["<prop-with-definition>"]` - Changed `RJSFSchema` to `S` where applicable - Fixed a few type casts due the to the change in the `RJSFSchema` type
* fix: Partially fix #3189 - Updated `@rjsf/utils` to make the `schema` and `rootSchema` props use a new generic type `S` - Added the new `StrictRJSFSchema` type as the alias to `JSON7Schema` changing `RJSFSchema` to be `StrictRJSFSchema & GenericObjectType` - Deleted the `RJSFSchemaDefinition` type in favor of accessing it indirectly via the `S["<prop-with-definition>"]` syntax - Added the new generic `S extends StrictRJSFSchema = RJSFSchema` to all types that directly or indirectly used `RJSFSchema` after the `T = any` type - Updated `SchemaUtilsType` to add the `F = any` generic to the whole interface, removing it from the definition of the two functions that need it - Updated all functions that used `RJSFSchema` to take the new generic, replacing `RJSFSchema` with `S` - Added missing generics where needed - Updated `@rjsf/core` to insert the `S extends StrictRJSFSchema = RJSFSchema` to every component that needed it, after the `T = any` generic - Updated the `index.ts` for the `ButtonTemplates`, `field`, `templates` and `widgets` to make them functions that take the `T`, `S` and `F` generics - Updated `getDefaultRegistry()` and `templates()` to call the appropriate functions - Replaced all uses of `RJSFSchema` and `RJSFSchemaDefinition` with `S` and `S["<prop-with-definition>"]` - Added missing generics where needed - Fixed a few type casts due the to the change in the `RJSFSchema` type - Updated `@rjsf/validator-ajv6` to fix a few type casts due to the change in the `RJSFSchema` type - Updated `@rjsf/validator-ajv8` to add the `S extends StrictRJSFSchema = RJSFSchema` generic to the `customizeValidator()` function and the `AJV8Validator` class - Replaced all uses of `RJSFSchema` and `RJSFSchemaDefinition` with `S` and `S["<prop-with-definition>"]` - Changed `RJSFSchema` to `S` where applicable - Fixed a few type casts due the to the change in the `RJSFSchema` type * Update packages/validator-ajv8/src/validator.ts Fix comment Co-authored-by: Nick Grosenbacher <[email protected]> Co-authored-by: Nick Grosenbacher <[email protected]>
…ma Ajv classes Fix rjsf-team#3189 by extending the `@rjsf/validator-ajv8` to support the `Ajv2019` and `Ajv2020` classes - Updated the `CustomValidatorOptionsType` to add a new `AjvClass` option - Updated the `createAjvInstance()` function to use the `AjvClass` option is provided to create the `Ajv` class instance, falling back to the default `Ajv` - Updated the `AJV8Validator` to extract the `AjvClass` from the options and pass it to the `createAjvInstance()` function - Updated the tests to also test the `Ajv2019` and `Ajv2020` class instances - Updated the `validation.md` file to document the new `AjvClass` options, switching the examples over to `tsx` - Updated the `CHANGELOG.md` file accordingly
I'm still a typescript novice, so I don't think I could commit to making those fixes. I'd be happy to help with updating the documentation to indicate that draft 7 is the version that RJSF uses for now, though it looks like you're changing that quickly. |
…asses (#3201) * fix: #3189 by allowing the ajv 8 validator to alternate schema Ajv classes Fix #3189 by extending the `@rjsf/validator-ajv8` to support the `Ajv2019` and `Ajv2020` classes - Updated the `CustomValidatorOptionsType` to add a new `AjvClass` option - Updated the `createAjvInstance()` function to use the `AjvClass` option is provided to create the `Ajv` class instance, falling back to the default `Ajv` - Updated the `AJV8Validator` to extract the `AjvClass` from the options and pass it to the `createAjvInstance()` function - Updated the tests to also test the `Ajv2019` and `Ajv2020` class instances - Updated the `validation.md` file to document the new `AjvClass` options, switching the examples over to `tsx` - Updated the `CHANGELOG.md` file accordingly * - Added support for the 2019 and 2020 schemas from AJV 8 to the playground
Prerequisites
What theme are you using?
core
Is your feature request related to a problem? Please describe.
Per json-schema.org, the
dependencies
keyword was split into two keywords:dependentSchemas
anddependentRequired
:This means that some schemas behave differently between react-jsonschema-form and e.g. python's
jsonschema
library, which does not support thedependencies
keyword. See https://github.com/python-jsonschema/jsonschema/blob/bf92aed44eb317188fba68e558d0429c68259dee/jsonschema/_legacy_validators.py#L56-L67In this playground, selecting "1" in the
a
dropdown does not produce the "b" dropdown. Withdependencies
instead ofdependentSchemas
, the form works as expected.Using another jsonschema validator on the backend (python's
jsonschema==4.15.0
, with thejsonschema.validate
method) yields opposite behavior, withdependencies
validating{"a": "1"}
anddependentSchemas
doing the opposite. Usingjsonschema.Draft7Validator(schema=schema).validate(...)
instead yields similar behavior to RJSF.Describe the solution you'd like
One of the following:
dependencies
keyword for backwards compatibility or generate a console warning ifdependencies
is used.dependentSchemas
is not supported, and recommend a particular draft validator version to use with RJSF.Describe alternatives you've considered
Using the
dependencies
keyword, and using theDraft7
validator in the Python backend. This works, but was confusing until I figured it out, and means that my schemas may be out of date with other tools using current jsonschema versions.The text was updated successfully, but these errors were encountered: