Are URNs legal as values for schema id?

1,128 views
Skip to first unread message

Andrew Biggs

unread,
Jun 13, 2014, 6:55:20 PM6/13/14
to json-...@googlegroups.com
The spec indicates that the value of "id" is a URI so I'm inclined to think URNs are legal, but I haven't seen anyone doing that so far.

So for example, would something like this be legal?

{
    "id": "urn:jsonschema:com:example:Person", 
    "properties": {
        "car": {
            "id": "urn:jsonschema:com:example:Car", 
            "properties": {
                "driver": {
                    "$ref": "urn:jsonschema:com:example:Person"
                }
            }, 
            "type": "object"
        }
    }, 
    "type": "object"
}

Message has been deleted

Andrew Biggs

unread,
Jun 13, 2014, 6:58:57 PM6/13/14
to json-...@googlegroups.com
Btw - I realize it's bad form to invent URN namespace identifiers out of thin air, this is just meant as an example :).

Francis Galiegue

unread,
Jun 16, 2014, 11:09:26 AM6/16/14
to json-...@googlegroups.com
Hello,

On Sat, Jun 14, 2014 at 12:55 AM, Andrew Biggs <balth...@gmail.com> wrote:
> The spec indicates that the value of "id" is a URI so I'm inclined to think
> URNs are legal, but I haven't seen anyone doing that so far.
>
> So for example, would something like this be legal?
>
> {
> "id": "urn:jsonschema:com:example:Person",

Yes, they are. Note that the spec does not specify a mechanism to
dereference this or that URI scheme, so you are completely free;
although it is of course recommended to follow existing specifications
for registered schemes!

Hope this helps,
--
Francis Galiegue, fgal...@gmail.com, https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/parboiled1/grappa (redde
Caesaris: https://github.com/sirthias)

Andrew Biggs

unread,
Jun 17, 2014, 7:00:20 PM6/17/14
to json-...@googlegroups.com
On Monday, June 16, 2014 9:09:26 AM UTC-6, fge wrote:

On Sat, Jun 14, 2014 at 12:55 AM, Andrew Biggs <balth...@gmail.com> wrote:
> The spec indicates that the value of "id" is a URI so I'm inclined to think
> URNs are legal, but I haven't seen anyone doing that so far.
>
> So for example, would something like this be legal?
>
> {
>     "id": "urn:jsonschema:com:example:Person",

Yes, they are. Note that the spec does not specify a mechanism to
dereference this or that URI scheme, so you are completely free;
although it is of course recommended to follow existing specifications
for registered schemes!

Great, thanks Francis.  Since dereferencing is I suppose out of scope in the spec, I'm guessing there hasn't been much consideration yet toward defining a URN namespace identifier (NID) as described in RFC 2141.  I think technically an NID is supposed to be registered if one is going to use URNs, would anyone else besides me see that as useful?

Cheers,
Andrew

Reply all
Reply to author
Forward
0 new messages