-
Notifications
You must be signed in to change notification settings - Fork 373
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
Improve reference resolving #1829
Improve reference resolving #1829
Conversation
c280793
to
d9e9004
Compare
Open points that should be integrated in the PR:
|
d9e9004
to
4571c0f
Compare
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.
Already works much better than before. Please see my detailed comments for further improvements. Please also test against the schema and uischema from:
4571c0f
to
3d07957
Compare
Both examples work. #1491 is covered by the |
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.
Looks good! Added some comments and questions.
3d07957
to
dada0c0
Compare
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.
Thanks for the update! I have some more comments and questions
0f5846a
to
735ce93
Compare
Thank you for for the review, Stefan! I updated the code and integrated your comments. |
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.
Looks good ;) Found one more small detail.
packages/core/src/testers/testers.ts
Outdated
@@ -47,15 +47,17 @@ import { deriveTypes, hasType, resolveSchema } from '../util'; | |||
export const NOT_APPLICABLE = -1; | |||
/** | |||
* A tester is a function that receives an UI schema and a JSON schema and returns a boolean. | |||
* Optionally, a root JSON schema can be provided, which can be used for resolving refs in the schema. |
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.
* Optionally, a root JSON schema can be provided, which can be used for resolving refs in the schema. | |
* The rootSchema is handed over as context. Can be used to resolve references. |
packages/core/src/testers/testers.ts
Outdated
const resolvedSchema = resolveSchema(schema, schemaPath, rootSchema ?? schema); | ||
if (resolvedSchema?.items && (resolvedSchema.items as any).$ref){ | ||
resolvedSchema.items = resolveSchema(resolvedSchema, 'items', rootSchema ?? schema); | ||
} |
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.
Here we are modifying the returned schema and therefore the overall schema stored in the JSON Forms store. Instead of building up a resolved schema we could adapt the checking logic to being able to follow refs.
- resolve items subschema refs for renderers and testers - make rootSchema a required parameter in resolveSchema, as it is needed while resolving - add rootSchema as an optional parameter to Testers and predicates used by Testers, so we can correclty resolve subschemas - use resolved schemas in MaterialOneOfRenderer when computing default value - enable and update tests - remove 'Resolve Remote Schema' example as it's unsupported
- make rootSchema parameter required in testers - update tests - use rootSchema where applicable when resolving
82d0d1e
to
9f2c9f7
Compare
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.
Great work! That's a great improvement to JSON Forms!
while resolving
correclty resolve subschemas in testers
value