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

describedby question #131

Closed
Ognian opened this issue Jan 27, 2014 · 3 comments
Closed

describedby question #131

Ognian opened this issue Jan 27, 2014 · 3 comments

Comments

@Ognian
Copy link
Contributor

Ognian commented Jan 27, 2014

I'm having the following schema

"properties": {
                "_id": {
                    "type": "string",
                    "title": "ID"
                },
                "oM":{
                    "type":"object",
                    "name":"object metadata",
                    "properties": {
                        "n":{
                            "type": "string",
                            "title": "collection name"
                        },
                        "u":{
                            "type": "string",
                            "format": "uri",
                            "title": "Schema URL"
                        }
                    }
                },
                "oD":{
                    "type":"object",
                    "name":"object data",
                    "title":"document",
                    // here comes the "magic" to reference the schema by an attribute in the instance of the schema
                    "links": [{
                        "rel": "describedby",
                        "href": "{+(oM.u)}"       //see http://tools.ietf.org/html/rfc6570 and http://json-schema.org/latest/json-schema-hypermedia.html#anchor18
                    }]
                }

what is the correct value of "href" to refer to the "Schema URL"?
Thanks a lot
Ognian

@geraintluff
Copy link
Contributor

Ah - you want to refer to a property that is not an immediate sibling, but instead two levels deep (oM -> u).

That's unfortunately not possible with the v4 version of the spec. :(

It is a [proposed feature for v5](https://github.com/json-schema/json-schema/wiki/Extended-templating-syntax-(v5-proposal\)), however - and when v5 is released then I'll put it into Jsonary immediately.

@Ognian
Copy link
Contributor Author

Ognian commented Jan 28, 2014

Ok, I changed the schema to

 "sche":{
                     "type": "string",
                     "format": "uri",
                     "title": "Schema URL"
            },
"oD":{
                    "type":"object",
                    "name":"object data",
                    "title":"document",
                    "links": [{
                        "rel": "describedby",
                        "href": "{sche}" 
                    }]
                }

but I'm still not able to tell jsonary what schema to use for "oD"...
Is the href syntax wrong or shall I omit type, name titel...

@Ognian
Copy link
Contributor Author

Ognian commented Jan 28, 2014

Ok, I found it:

  1. "sche", the atribute containing the schema must be a property of "oD".
  2. href should be "{+sche}"

Yes indeed the proposed feature for v5 would better solve my problem...
Thanks
Ognian

@Ognian Ognian closed this as completed Jan 28, 2014
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

2 participants