-
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
fix: Fixed 3778 By Resolving all refs in oneOf/AnyOf options #3786
fix: Fixed 3778 By Resolving all refs in oneOf/AnyOf options #3786
Conversation
* @param rootSchema - The root schema that will be forwarded to all the APIs | ||
* @returns - given schema will all references resolved | ||
*/ | ||
export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(schema: S, rootSchema: S): S { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heath-freenome I was debating making this util specifically for oneOf/anyOf options. This is already assuming that the schema went through resolveSchema
and has been evaluated with formData
. Its just getting the defined $ref and updating the schema.
This might not solve the core issue of oneOf/anyOf options not fully being resolved in resolveSchema
but it does solve the existing issue with minimum impact on the whole resolve workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also update the CHANGELOG.md
file for 5.11.1
@@ -258,6 +258,37 @@ export default function sanitizeDataForNewSchemaTest(testValidator: TestValidato | |||
}) | |||
).toEqual({}); | |||
}); | |||
it('returns empty formData after resolving schema refs', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about this test. What prompted you to write it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason the two changes to resolveAnyOrOneOfSchemas
and getClosestMatchingOption
caused lose of coverage in sanitizeDataForNewSchema
. Maybe because the refs were being resolved and it not longer needed to in sanitizeDataForNewSchema
?
Reasons for making this change
fixes #3778 by going through anyOne/oneOf option schema and resolving any $refs.
Checklist
npm run test:update
to update snapshots, if needed.