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

Support dereferencing of schemas #7

Open
marsteau opened this issue Mar 30, 2013 · 4 comments
Open

Support dereferencing of schemas #7

marsteau opened this issue Mar 30, 2013 · 4 comments

Comments

@marsteau
Copy link

Not an issue, more of a question:

I have a bunch of JSON schema draft3 that contains references to other schemas. Is there a way to actually download the tool locally, so all files can be found by the tool (if all files are relative to root schema), or any way to pass a root schema URI as entry so that all referenced links can be found relative to that URI?

Thank you.

@jonahkagan
Copy link
Owner

Right now there's no support for referenced schemas. One way around this would be to copy the referenced schemas inline in the top-level schema. Would that work in your case?

@marsteau
Copy link
Author

marsteau commented May 2, 2013

That makes the schema much harder to read. One issue specifically we have is with hyper-schemas. That is, JSON schemas, that include hypermedia information (links section). For each documented link definition object (LDO) we specify a link relation type, a method, and optionally a "schema" and "targetSchema" property. Typically, a "schema" will $ref to the schema the JSON input is expected to conform to (request body or query parameters, depending on HTTP method); a "targetSchema" will $ref to the schema the JSON output (response) is expected to conform to. If the request expects no input (no query parameters and no body) no "schema" will be specified (typically, standard "GET" link definitions). Same for output, if no output is expected, no "targetSchema" will be specified (typically, standard "DELETE" link definitions).

For example:
{
"id":"ActorV2-collection",
"properties": {...},
"links": [{
"rel": "self"
"href": "{baseUri}/{version}/actors"
"targetSchema": {
"$ref": "#ActorV2-collection"
}

indicates that following a link relation type "self" will expect no input (no "schema" specified), and user should expect a JSON payload adhering to the definition referred "ActorV2-collection" (linked within this document).

Note that the $ref could link to another file as well.

Now the issue with embedding inline the child/referred schema is you end up with a circular reference. If the self refers to the same document, you end up in an infinite loop inlining the referrered schema (e.g. "$ref" :"./#").

So short answer; no this does not address the need.

@marsteau
Copy link
Author

marsteau commented May 3, 2013

Also, I tried to $ref a schema within same document, and the tool failed to resolve, with "Bad type: "undefined"" error.

@cybertk
Copy link

cybertk commented Aug 22, 2014

+1

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