Skip to content

Conversation

@eggyal
Copy link
Contributor

@eggyal eggyal commented Apr 21, 2017

Reasons for making this change

Fixes #553

Checklist

  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style

@glasserc
Copy link
Contributor

Thanks! The code looks good, but the code format check failed, for reasons that aren't related to your change. Maybe this is because we just updated to prettier 1.2.2. Could you rebase onto current master?

},
type: "object",
properties: {
foo: { $ref: "#/definitions/testdef/properties/bar" },
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 properties like your implemention does would actually comply.

Do you by chance have a link describing how implementations should access nested definitions?

Copy link
Contributor

Choose a reason for hiding this comment

The 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".

Copy link
Collaborator

Choose a reason for hiding this comment

The 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).

return definitions[match[1]];
const match = /^#\/definitions\/(.*)$/.exec($ref);
if (match && match[1]) {
const parts = match[1].split("/");
Copy link
Collaborator

@n1k0 n1k0 Apr 21, 2017

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.

Copy link
Contributor Author

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 ~1 and ~0 respectively. 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?

Copy link
Contributor

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n1k0: Test case added.

Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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?

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?

@glasserc glasserc mentioned this pull request Apr 24, 2017
4 tasks
@n1k0 n1k0 merged commit 85f169c into rjsf-team:master Apr 26, 2017
@n1k0
Copy link
Collaborator

n1k0 commented Apr 26, 2017

Thank you 👍

@eggyal eggyal deleted the complex-schema-refs branch April 26, 2017 07:47
n1k0 added a commit that referenced this pull request Apr 28, 2017
New features:

* Handle references to deep schema definitions (#554)

Bugfixes:

* Fix #563: Remove remaining React.PropTypes references.

Internal changes:

* Upgrade prettier to v1.2.2.
* Fix coding style check command.
@n1k0
Copy link
Collaborator

n1k0 commented Apr 28, 2017

Released in v0.48.0.

eeinowski pushed a commit to eeinowski/react-jsonschema-form that referenced this pull request May 23, 2017
* Handle references to deep schema definitions
* Handle JSON Pointer escaping
eeinowski pushed a commit to eeinowski/react-jsonschema-form that referenced this pull request May 23, 2017
New features:

* Handle references to deep schema definitions (rjsf-team#554)

Bugfixes:

* Fix rjsf-team#563: Remove remaining React.PropTypes references.

Internal changes:

* Upgrade prettier to v1.2.2.
* Fix coding style check command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants