Skip to content
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

[question] Is relative-path URI allowed with the "uri" format? #310

Closed
erayd opened this issue Apr 21, 2017 · 5 comments
Closed

[question] Is relative-path URI allowed with the "uri" format? #310

erayd opened this issue Apr 21, 2017 · 5 comments

Comments

@erayd
Copy link

erayd commented Apr 21, 2017

RFC-3986 section 4.2 seems to indicate that this is acceptable, and the spec says that RFC-3986 is the format used, however the testsuite considers relative-path URI to be invalid, and based on the description seems to be doing so deliberately.

Is this intended to be a deliberate deviation from RFC-3986, or is the testsuite wrong, or am I misunderstanding something?

@handrews
Copy link
Contributor

handrews commented Apr 21, 2017

@erayd RFC 3986 makes a clear distinction between "URI" and "URI reference". Section 4.2 is defining URI references. While the distinction may not jump out on first read, if you go through knowing this you'll see that it's quite clear.

In the draft-06 meta-schema (for the newly published draft-wright-json-schema-validation-01) you want to use "format": "uri-reference". [edit- fixed with the correct format spelling, thanks @epoberezkin ]

@epoberezkin
Copy link
Member

epoberezkin commented Apr 21, 2017

@handrews The format is "uri-reference"

@erayd
Copy link
Author

erayd commented Apr 21, 2017

@handrews Thanks - I appreciate the clarification; I thought that 'URI Reference' was a kind of URI, rather than something else entirely - it seems that I missed the paragraph which specifies this, but after reading through the RFC again I can see it's definitely there!

What's the story with this for draft-03 and draft-04? I can't help but feel that I'm missing something critical here - those versions of the spec both lack a dedicated format for URI reference, and have a testsuite / meta-schema which looks technically invalid (because of values in "$ref" and / or "id") if references aren't allowed in the URI format, and the full syntax is strictly enforced.

RFC-3986 Section 4 says this:

When applications make reference to a URI, they do not always use the full form of reference defined by the "URI" syntax rule. To save space and take advantage of hierarchical locality, many Internet protocol elements and media type formats allow an abbreviation of a URI, whereas others restrict the syntax to a particular form of URI. We define the most common forms of reference syntax in this specification because they impact and depend upon the design of the generic syntax, requiring a uniform parsing algorithm in order to be interpreted consistently.

Is the intention that older drafts do not allow references, but do allow incomplete URI syntax (in which case, where do I find this definition), or are older drafts intended to allow references as part of the "uri" format, but draft-06 is not?

@erayd
Copy link
Author

erayd commented Apr 22, 2017

This looks like the same issue I'm encountering. If it's a meta-schema bug as per @Julian's comment, that would clear things up somewhat.

@handrews
Copy link
Contributor

@erayd the group working on the JSON Schema specifications now is the (I think) third group to take on the project (hence the three year gap after draft-04 when the second group dropped it). So we usually don't know the reasoning behind the older drafts unless it was clearly documented somewhere. I definitely do not know this particular story, maybe @awwright or @Julian might have some insight?

Julian added a commit to python-jsonschema/jsonschema that referenced this issue Nov 1, 2022
For draft 4 this pulls in upstream fixes which were not present locally,
notably fixing `id` to not have `format: uri` in it, because location
independent identifiers are indeed not URIs (they're URI references as
later metaschemas use).

For enum, on draft 3 and 4, this also *re-adds* constraints that enum
items MUST be unique and the array non-empty. In later drafts, this
restriction was loosened (see
json-schema-org/json-schema-spec@cf0ec72)
as well as json-schema-org/json-schema-spec#717 (comment)
but in drafts 3 and 4 it is present.

The draft 4 metaschema contains these assertions, the draft 3 one is
still buggy and does not, so they're just applied locally here.

Ref: json-schema-org/json-schema-spec#310
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

No branches or pull requests

3 participants