Skip to content

Add tests for location-independent identifiers #225

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

Merged
merged 2 commits into from
Jun 30, 2019

Conversation

johandorland
Copy link
Contributor

The section in the RFC isn't super detailed about this, so I took the liberty to come up with some edge cases to resolve #221.

@Julian
Copy link
Member

Julian commented Jun 2, 2018

@handrews can I ask you to review this one?

@Julian Julian requested a review from handrews June 2, 2018 17:49
@handrews
Copy link
Contributor

handrews commented Jun 4, 2018

@Julian I'll take a look at it. Just got back from out of town, may take a bit for me to catch up with things.

Copy link
Contributor

@handrews handrews left a comment

Choose a reason for hiding this comment

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

Sorry it's taken me so long to get to this. Overall this is great, I just have nitpicks around some long-standing spec ambiguities, and one question about failure modes.

]
},
{
"description": "Canonical location-independent identifier",
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 like to avoid the word "canonical" due to its role in the confusing draft-04 canonical vs inline mess.

I'm not entirely sure it applies to this case even in draft-04 terms, but TBH none of the current spec team really know what the point of that was AFAIK.

Is the point of this test to use a URI (with scheme) rather than a URI reference? If so, that seems like the thing to note in the description.

"description": "Location-independent identifier with base URI change in subschema",
"schema": {
"id": "http://localhost:1234/root",
"$ref": "http://localhost:1234/nested.json#foo",
Copy link
Contributor

Choose a reason for hiding this comment

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

Does having id adjacent to $ref work? I'd really rather wrap the $ref in an allOf. I know that within the spec we allow adjacent definitions, and I suppose that argument could be extended to id. But really it's a gray area/bug in the spec and implementations are not consistent about whether it's supported.

{
"description": "Location-independent identifiers should take precedent over regular fragments",
"schema": {
"$ref": "#foo",
Copy link
Contributor

Choose a reason for hiding this comment

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

I really want the $refs to all be in allOfs, I've decided. It's such a confusing and underspecified area, when you then start throwing in odd corner cases like an unrecognized "foo" keyword alongside a $ref I have absolutely no idea what should happen, and even less clue what the majority of implementations will do.

Let's avoid gray areas except when explicitly testing around them.

]
},
{
"description": "Location-independent identifiers should take precedent over regular fragments",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to figure out the failure mode of this test case. Is there reason to think that an implementation might insert a / after the # and convert it into a pointer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first I didn't notice the difference between JSON pointers which require a / and a regular plain fragment which doesn't. Now on second glance this test makes no sense and I'll remove it as it is only confusing and has no purpose.

@alvarogzp
Copy link
Contributor

alvarogzp commented Jun 28, 2019

Hello! We are working in python-jsonschema/jsonschema#371 on adding support for Location-independent identifiers on Python's jsonschema implementation, and it would be great to first have some tests in the suite for them. This PR seems to add exactly those tests.

I've been reviewing the comments here, and I'm willing to help fixing the remaining items.

I've identified the following issues to fix before merging this:

  • The "Canonical location-independent identifier" test description (which I can change to something like "Location-independent identifier with absolute URI")
  • The merge conflict
  • Should we add the tests to the new draft2019-06 folder too?

Please, tell if I'm right and if you would like me to contribute those changes. I can push them to my fork for you to merge them here, or we can create a new PR.

@Julian
Copy link
Member

Julian commented Jun 28, 2019

Fantastic! (Thanks again).

On the last point, yes, please do add them to the new draft folder. I think if you fork the repo and then put your commits on top of this branch that's perfect.

@alvarogzp
Copy link
Contributor

Done!

I have pushed the changes to my alvarogzp:location-independent-identifiers-tests branch.

@johandorland
Copy link
Contributor Author

@alvarogzp Thanks for updating it. I'll update this PR this weekend and poke someone with a stick so this is merged.

@Julian
Copy link
Member

Julian commented Jun 30, 2019

I think this looks good to my eyes -- merging!

Thanks to you both @johandorland / @alvarogzp.

(Well, sticking a final commit on top to rename the new draft to $defs, but otherwise think this is good to go).

@Julian Julian merged commit c98ffc3 into json-schema-org:master Jun 30, 2019
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.

Add tests for Location-independent identifiers
4 participants