Re: JSON Hyper Schema newbie questions: Is this schema fine ?

36 views
Skip to first unread message

Geraint

unread,
Mar 20, 2013, 9:10:54 AM3/20/13
to json-...@googlegroups.com, tho...@sauzedde.net
I'll have a more detailed read-through later, but much of it looks good at first glance.

You have mis-used "id", though - your reference {"$ref": "#/gallery"} points to the "gallery" property of the root object - which does not exist.

Don't use "id" here - just leave that property out, and use {"$ref": "#"} to refer back to the root of the document.

You also want to modify your URI Templates.  By default, URI Templates percent-encode all values - so if your value of "id" is "/Gallery1/Gallery1.a", then the resulting URI for "href" will be "%2FGallery1%2FGallery1.a".  You should use "{+id}" - the plus signifies that special characters should not be escaped.

On Wednesday, March 20, 2013 10:39:35 AM UTC, tho...@sauzedde.net wrote:
Hi,

Please find, in attachment, a "draft" hyper schema, I apologize for the following dumb questions, but I'm warmming up with JSON hyper schema, and it would like some advices / opinions from "experts" about this example.
Thanks in advance !

Let me describe my sample, its constraints and what I would like to achieve.
I would like to have a schema for a data structure that represents a photo gallery (hyper schema specs draft #4)

I have 2 kind of data:
* a Gallery, a recursive structure :
    - an id: opaque string, but that should be an URL where its information can be grabbed, required
    - a parent: opaque string, but that should be an URL where its "parent" gallery information can be grabbed, required
    - a name: string, required
    - number of pictures in this gallery or its sub-galleries: integer, mandatory
    - an array of sub-galleries: array of "gallery" objects, from 0 to unlimited items, recursion takes place here ..., required, but could be empty
    - an array of pictures: see below, required but could be empty

* a Picture
    - an id: opaque string, but that should be an URL where its information can be grabbed, required
    - a name: string, required

Now, with this structure in mind, I would like to express with hyper schema the following "links" :
I would like each gallery to have a "link" to itself (self), its direct ancestor (parent) and to each picture it contains.
And then I would like a picture to have a "link" to itself (self) and its binary content.

Let's imagine that
- the 'root' gallery data is reachable here : http://www.gallery.com/data/
- I have the following sub galleries:
    - 'Gallery1', reachable here : http://www/gallery.com/data/Gallery1
       - 'Gallery1.a', reachable here : http://www/gallery.com/data/Gallery1/Gallery1.a
       - 'Gallery1.b', reachable here : http://www/gallery.com/data/Gallery1/Gallery1.b
       - 'Gallery1.c', reachable here : http://www/gallery.com/data/Gallery1/Gallery1.c
    - 'Gallery2', reachable here : http://www/gallery.com/data/Gallery2
       - 'Gallery2.a', reachable here : http://www/gallery.com/data/Gallery2/Gallery2.a
       - 'Gallery2.b', reachable here : http://www/gallery.com/data/Gallery2/Gallery2.b
    - 'Gallery3', reachable here : http://www/gallery.com/data/Gallery3
- Each gallery has 0+ pictures
  - JSON reachable here for example http://www/gallery.com/data/Gallery1/Gallery1.a/pic1

--
Tom
Reply all
Reply to author
Forward
0 new messages