You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature: Added better support for testing with AJV having discriminator option turned on (#4257)
* feature: Added better support for testing with AJV having discriminator option turned on
A recent issue made it clear that we didn't make it easy for users to turn on `discriminator` support from AJV
- In `@rjsf/utils` improved support for `discriminator` as follows:
- Updated the `ValidatorType` to add support for an optional `reset()` method
- Updated the `ParserValidator` to implement `reset()` to clear the schema map, including a test to verify that
- Updated the tests that used `discriminator` to remove the `mapping` block that AJV doesn't support
- Updated the `getFirstMatchingOption()` test to deal with the situation where AJV doesn't support discriminator for array types
- Updated the `retrieveSchema()` test to call `reset()` on validators that have it in an `afterEach()`
- Updated the `getTestValidator()` implementation to implement a `reset()` that empties the arrays
- In `@rjsf/validator-ajv8` improved support for `discriminator` as follows:
- Updated the `createAjvInstance()` function to denote that we want to make `discriminator: true` the default in v6
- Updated the `AJV8Validator` to make reset do `ajv.removeSchema()` to clear the cached schemas
- Updated the `getTestValidator() implementation to call `reset()` on the validator if it exists
- Updated the `schema.test.ts` file to run a set of test with `discriminator: true` set on the `AJV8Validator`
- Updated the `CHANGELOG.md` file accordingly
* - Added required for `code` to all of the schemas
* - Switched the default Translatable strings to use Markdown
Copy file name to clipboardExpand all lines: CHANGELOG.md
+16
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,22 @@ should change the heading of the (upcoming) version to include a major version b
16
16
17
17
-->
18
18
19
+
# 5.19.4
20
+
21
+
## @rjsf/utils
22
+
23
+
- Updated the `ValidatorType` interface to add an optional `reset?: () => void` prop that can be implemented to reset a validator back to initial constructed state
24
+
- Updated the `ParserValidator` to provide a `reset()` function that clears the schema map
25
+
- Also updated the default translatable string to use `Markdown` rather than HTML tags since we now render them with `Markdown`
26
+
27
+
## @rjsf/validator-ajv8
28
+
29
+
- Updated the `AJV8Validator` to implement the `reset()` function to remove cached schemas in the `ajv` instance
30
+
31
+
## Dev / docs / playground
32
+
33
+
- Updated the `Validator` dropdown to add `AJV8 (discriminator)` which sets the AJV validator [discriminator](https://ajv.js.org/json-schema.html#discriminator) option to `true` to support testing schemas with that option in them
0 commit comments