-
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
retrieveSchema API no longer resolves references from rootSchema #3761
Comments
@john-prillaman Can you be more clear? The definition of |
In the 5.0.0-beta.1 references in the provided schema would be resolved from the given rootSchema. That functionality is no longer working. |
@john-prillaman Can you provide a reproducible example of this issue using codesandbox.io, jsfiddle or some other tool? As far as I know, passing |
I can work on using a tool but in the meantime this snippet of code should demonstrate the behavior.
Output using the beta version: Output using a newer version (seems to begin with the implementation of retrieveSchemaInternal): As you can see in my testing I find that in the second example the reference to the definition in the rootSchema has not been resolved. |
If you need to see this in codesandbox I have an example of the previous snippet running here: Appears that the last version to provide expected results is @rjsf/[email protected] |
@john-prillaman Thanks for the use case! I'll try to figure it out in the next week or so |
On version 5.13.0, the problem remains. I forked @john-prillaman code, and put definitions inside the schema itself. |
@aiibe Thanks for pointing it out. My company has a slightly different issue that I'm hoping to fix at the beginning of October so I'll also fix this one |
Awesome, thank you! |
…d validator-ajv8 Fixes rjsf-team#3671 by resolving refs inside of `properties` and array `items` and restoring `100%` unit test coverage for `utils` and `validator-ajv8` - Updated `package.json` to add `@types/jest` to the global `devDependencies` - In `@rjsf/utils`, fixed rjsf-team#3671 and restored 100% test coverage as follows: - Updated `jest.config.js` to restore test coverage threshold to 100% - Updated `resolveAllReferences()` to take a new `recurseList: string[]` parameter that is used to prevent recurse `$ref` processing - Return the `schema` directly when it is not an object and also return the original `schema` when the `resolvedSchema` is identical - Updated the `resolveReference()` function to call `resolveAllReferences()` and only call `retrieveSchemaInternal()` when the the `updatedSchema` is different than the original - Updated the `resolveSchema()` function to always call `resolveReference()` and only return the `updatedSchemas` when something was changed - Updated `retrieveSchemaInternal()` to take a new `recurseList: string[] = []` parameter that is passed to `resolveSchema()` and `resolveCondition()` - Updated many of the internal functions to take a `recurseList: string[]` parameter that is forwarded to any function that ultimately calls `retrieveSchemaInternal()` or `resolveAllReferences()` - Updated the `SchemaParser` to properly pass the `recurseList` array to `retrieveSchemaInternal()` and `resolveAnyOrOneOfSchemas()` - Updated the `getClosestMatchingOption()` function to pass an empty array to the `resolveAllReferences()` function for `recurseList` - Updated the `computeDefaults()` function to pass an empty array to the `resolveDependencies()` function for `recurseList` - Also removed an unnecessary `isObject()` check for `formData` in when dealing with `additionalProperties` since it is always guaranteed to be an object - Added/updated tests to ensure that all of the `@rjsf/utils` have 100% test coverage - In `@rjsf/validator-ajv8` to fix tests due to the rjsf-team#3671 changes and restored 100% test coverage as follows: - Updated `jest.config.js` to restore test coverage threshold to 100% - Updated the tests for `precompiledValidator` to call `retrieveSchema()` on the precompiled `rootSchema` to avoid errors caused by the `retrieveSchema()` changes - Updated `validator.ts` to make the `isValid()` call not check if the `rootSchema` already exists (because it doesn't) since the `finally` always removes it - Updated the `validator` tests to restore 100% test coverage - Updated the `CHANGELOG.md` accordingly while also adding the description for rjsf-team#3870
…d validator-ajv8 Fixes rjsf-team#3671 by resolving refs inside of `properties` and array `items` and restoring `100%` unit test coverage for `utils` and `validator-ajv8` - Updated `package.json` to add `@types/jest` to the global `devDependencies` - In `@rjsf/utils`, fixed rjsf-team#3671 and restored 100% test coverage as follows: - Updated `jest.config.js` to restore test coverage threshold to 100% - Updated `resolveAllReferences()` to take a new `recurseList: string[]` parameter that is used to prevent recurse `$ref` processing - Return the `schema` directly when it is not an object and also return the original `schema` when the `resolvedSchema` is identical - Updated the `resolveReference()` function to call `resolveAllReferences()` and only call `retrieveSchemaInternal()` when the the `updatedSchema` is different than the original - Updated the `resolveSchema()` function to always call `resolveReference()` and only return the `updatedSchemas` when something was changed - Updated `retrieveSchemaInternal()` to take a new `recurseList: string[] = []` parameter that is passed to `resolveSchema()` and `resolveCondition()` - Updated many of the internal functions to take a `recurseList: string[]` parameter that is forwarded to any function that ultimately calls `retrieveSchemaInternal()` or `resolveAllReferences()` - Updated the `SchemaParser` to properly pass the `recurseList` array to `retrieveSchemaInternal()` and `resolveAnyOrOneOfSchemas()` - Updated the `getClosestMatchingOption()` function to pass an empty array to the `resolveAllReferences()` function for `recurseList` - Updated the `computeDefaults()` function to pass an empty array to the `resolveDependencies()` function for `recurseList` - Also removed an unnecessary `isObject()` check for `formData` in when dealing with `additionalProperties` since it is always guaranteed to be an object - Added/updated tests to ensure that all of the `@rjsf/utils` have 100% test coverage - In `@rjsf/validator-ajv8` to fix tests due to the rjsf-team#3671 changes and restored 100% test coverage as follows: - Updated `jest.config.js` to restore test coverage threshold to 100% - Updated the tests for `precompiledValidator` to call `retrieveSchema()` on the precompiled `rootSchema` to avoid errors caused by the `retrieveSchema()` changes - Updated `validator.ts` to make the `isValid()` call not check if the `rootSchema` already exists (because it doesn't) since the `finally` always removes it - Updated the `validator` tests to restore 100% test coverage - Updated the `CHANGELOG.md` accordingly while also adding the description for rjsf-team#3870
…or-ajv8 (#3895) Fixes #3671 by resolving refs inside of `properties` and array `items` and restoring `100%` unit test coverage for `utils` and `validator-ajv8` - Updated `package.json` to add `@types/jest` to the global `devDependencies` - In `@rjsf/utils`, fixed #3671 and restored 100% test coverage as follows: - Updated `jest.config.js` to restore test coverage threshold to 100% - Updated `resolveAllReferences()` to take a new `recurseList: string[]` parameter that is used to prevent recurse `$ref` processing - Return the `schema` directly when it is not an object and also return the original `schema` when the `resolvedSchema` is identical - Updated the `resolveReference()` function to call `resolveAllReferences()` and only call `retrieveSchemaInternal()` when the the `updatedSchema` is different than the original - Updated the `resolveSchema()` function to always call `resolveReference()` and only return the `updatedSchemas` when something was changed - Updated `retrieveSchemaInternal()` to take a new `recurseList: string[] = []` parameter that is passed to `resolveSchema()` and `resolveCondition()` - Updated many of the internal functions to take a `recurseList: string[]` parameter that is forwarded to any function that ultimately calls `retrieveSchemaInternal()` or `resolveAllReferences()` - Updated the `SchemaParser` to properly pass the `recurseList` array to `retrieveSchemaInternal()` and `resolveAnyOrOneOfSchemas()` - Updated the `getClosestMatchingOption()` function to pass an empty array to the `resolveAllReferences()` function for `recurseList` - Updated the `computeDefaults()` function to pass an empty array to the `resolveDependencies()` function for `recurseList` - Also removed an unnecessary `isObject()` check for `formData` in when dealing with `additionalProperties` since it is always guaranteed to be an object - Added/updated tests to ensure that all of the `@rjsf/utils` have 100% test coverage - In `@rjsf/validator-ajv8` to fix tests due to the #3671 changes and restored 100% test coverage as follows: - Updated `jest.config.js` to restore test coverage threshold to 100% - Updated the tests for `precompiledValidator` to call `retrieveSchema()` on the precompiled `rootSchema` to avoid errors caused by the `retrieveSchema()` changes - Updated `validator.ts` to make the `isValid()` call not check if the `rootSchema` already exists (because it doesn't) since the `finally` always removes it - Updated the `validator` tests to restore 100% test coverage - Updated the `CHANGELOG.md` accordingly while also adding the description for #3870
@heath-freenome Hello. What about fields, that appears conditionally? I made call this way: retrieveSchema(validator, jsonSchema, schemaWithDefinitions, formData); |
@BlackBerryID can you create a new issue with a reproducible test case... Thanks! |
Prerequisites
What theme are you using?
core
What is your question?
In version 5.0.0-beta.11 of the rjsf utils package the exported retrieveSchema API could be used such that references in the provided schema could be resolved from definitions in the provided rootSchema. With the recent updates which include the retrieveSchemaInternal this functionality no longer works.
I understand that the schema form does not support resolving references from an external schema, however this functionality was available from this utils method and the interface and documentation suggests that it should allow this.
Will this functionality be available in future releases or was this never the intended use?
The text was updated successfully, but these errors were encountered: