Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion linking to self as a means of versioning a schema
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Francis Galiegue  
View profile  
 More options Feb 28 2012, 2:15 pm
From: Francis Galiegue <fgalie...@gmail.com>
Date: Tue, 28 Feb 2012 20:15:17 +0100
Local: Tues, Feb 28 2012 2:15 pm
Subject: Re: [json-schema] Re: linking to self as a means of versioning a schema

On Tue, Feb 28, 2012 at 18:31, ps <postsh...@gmail.com> wrote:
> Xample,  thanks for describing these three options.

> I think your option #1  ----  re-using the $schema property in the
> document ----- is best for my purposes.

> This provides the full URL to the schema, so someone can discover it
> by manual inspection
> and figure out what to do with it.  This is more self-documenting.

> I have three questions:

>  1)   What does "$" mean in JSON Schemas?  My understanding is that
> the use of $ is purely a stylistic flourish in JavaScript, so what is
> the meaning in this context?

We are talking JSON here. The $ has no special meaning in any case. If
you are talking about "$ref", it is a special keyword which points to
another JSON document, which should be a schema.

Remind that the JSON spec allows _anything_ as a key value in object
instances. For instance, this is valid JSON:

{
    "": true,
    "/a/b": 1,
    " ": "foo",
    "$^@\~#{\¹fzuih&": "yep"

}

It has nothing to do with JavaScript at all.

>  2)   My primary schema (called stream-item) relies on a couple other
> schemas, so should I be using the "links" attribute in my schemas?  Is
> the purpose of "links" to help a JSON schema validator?

No, $ref serves such a purpose.

>  3)   I would very much appreciate a critical review of these two
> short schemas.  Their purpose is in the description fields, and they
> are pasted below.

>             http://trec-kba.org/schemas/v1.0/content-item

>             http://trec-kba.org/schemas/v1.0/stream-item

> Any opinions, changes, feedback, etc would be very welcome!
> Thanks.

> -John

> http://trec-kba.org/schemas/v1.0/content-item
> {
>    "description": "Raw data, such as text, used by stream-item for
> 'title', 'body', and 'anchor'.",
>    "type": "object",
>    "properties": {
>        "$schema": {
>            "description": "URI of this JSON schema document.",
>            "type": "string",
>            "enum": ["http://trec-kba.org/schemas/v1.0/content-item"],
>            "required": true,
>            "default": "http://trec-kba.org/schemas/v1.0/content-item"
>            },

No, "$schema" is not an object. It helps telling the validator which
version of the JSON Schema draft you use, and its values are URIs. For
instance:

    "$schema": "http://json-schema.org/schema/draft-v3/schema#"

[...]

>        "original_url": {
>            "description": "URL provided by stream_source, only non-
> null if differs from abs_url.",
>            "title": "Original URL",
>            "type": ["string", null],

Should be "null" (with quotes), not null, which is the JSON null value
but does not represent the null type.

[...]

>            "type": ["http://trec-kba.org/schemas/v1.0/news-metadata",
>                     "http://trec-kba.org/schemas/v1.0/social-
> metadata",
>                     "http://trec-kba.org/schemas/v1.0/linking-
> metadata"],

This should be:
    "type": [
        { "$ref": "http://trec-kba.org/schemas/v1.0/news-metadata" },
        { "$ref": "http://trec-kba.org/schemas/v1.0/social-metadata" },
        { "$ref": "http://trec-kba.org/schemas/v1.0/linking-metadata" }
    ]

[...]

This should be:

    "type": [ { "$ref":
"http://trec-kba.org/schemas/v1.0/extracted-metadata" } ]

>            "optional": true

"optional" does not exist anymore (it did in draft v2) -- in draft v3,
it has been replaced with "required" which means the exact opposite.
And false is the default for "required", so you can drop this line
altogether.

>        },
>    },
>    "additionalProperties": true

You might as well remove this line since by default
"additionalProperties" has an empty schema as a value -- meaning any
additional property will have to match the empty schema ({}), which
matches all JSON documents.

Hope this helps,
--
Francis Galiegue, fgalie...@gmail.com
"It seems obvious [...] that at least some 'business intelligence'
tools invest so much intelligence on the business side that they have
nothing left for generating SQL queries" (Stéphane Faroult, in "The
Art of SQL", ISBN 0-596-00894-5)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.