-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Handle references to deep schema definitions #554
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,6 +229,27 @@ describe("Form", () => { | |
| expect(node.querySelectorAll("input[type=text]")).to.have.length.of(1); | ||
| }); | ||
|
|
||
| it("should handle references to deep schema definitions", () => { | ||
| const schema = { | ||
| definitions: { | ||
| testdef: { | ||
| type: "object", | ||
| properties: { | ||
| bar: { type: "string" }, | ||
| }, | ||
| }, | ||
| }, | ||
| type: "object", | ||
| properties: { | ||
| foo: { $ref: "#/definitions/testdef/properties/bar" }, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I couldn't find any reference in the spec about this capability. The only part of it using nested definitions is this one but I'm not sure about accessing Do you by chance have a link describing how implementations should access nested definitions?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find anything in the spec either, but I tried the given example on https://jsonschemalint.com/ and it works the way you would expect it to. Section 8.2.1 says "Schemas can be identified by any URI that has been given to them, including a JSON Pointer".
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, indeed I could validate the example in #553 as well, I think we're good to go then (well once the prettier formatting issue is addressed). |
||
| }, | ||
| }; | ||
|
|
||
| const { node } = createFormComponent({ schema }); | ||
|
|
||
| expect(node.querySelectorAll("input[type=text]")).to.have.length.of(1); | ||
| }); | ||
|
|
||
| it("should handle referenced definitions for array items", () => { | ||
| const schema = { | ||
| definitions: { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Makes me think of properties containing a
/in their name, which will fail here. I don't want us to cover this edge case, but it may be a good idea to document this limitation, or at least to add a comment about it here.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.
@n1k0: Looking at the JSON Pointer spec, §3. Syntax, names containing
/or~will be escaped as~1and~0respectively. I will update to handle this, but I can't help wondering whether this project might instead use something like json-schema-ref-parser to handle these and other issues?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'd be in favor of that! But if you don't have time, then just a FIXME comment would be fine.
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'd be in favor of it too, though their API being async it may be more work than needed in this specific case. A comment will be fine for now.
Also, please add a test case for this new covered edge case.
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.
@n1k0: Test case added.
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.
@eggyal did you ever add a FIXME comment here?
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.
@epicfaace: Perhaps I had misunderstood what @glasserc was proposing a FIXME comment for—I assumed it was to handle
/s, which I fixed in 95bee41 so comment no longer required?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.
Oh, I assumed that the FIXME comment was supposed to be for using "json-schema-ref-parser to handle ... other issues."
Since you did fix the escaping of
/and~, do you know if there's anything we're missing in this implementation which json-schema-ref-parser does well?