Skip to content
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

fix: Partially fix #3189 #3200

Merged
merged 2 commits into from Oct 18, 2022

Conversation

heath-freenome
Copy link
Member

Reasons for making this change

Partially fix #3189 by allowing for changing the type of the schema via a new generic S

  • 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

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

- 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
packages/validator-ajv8/src/validator.ts Outdated Show resolved Hide resolved
Fix comment

Co-authored-by: Nick Grosenbacher <nickgrosenbacher@gmail.com>
@heath-freenome heath-freenome merged commit b63ec99 into rjsf-team:main Oct 18, 2022
@heath-freenome heath-freenome deleted the make-schema-generic branch October 18, 2022 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for dependentSchemas and dependentRequired
2 participants