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

URI schema resolver #66

Closed
jwueller opened this issue May 10, 2015 · 1 comment
Closed

URI schema resolver #66

jwueller opened this issue May 10, 2015 · 1 comment

Comments

@jwueller
Copy link

Currently, external schemata are ignored. Example:

{ "$ref": "http://example.org/schema/definitions.json#/definitions/uuid" }

I would propose something along the lines of this:

var validate = validator(schema, {
    schemaUriResolver: function(uri, callback) {
         // uri is "http://example.org/schema/definitions.json", excluding the fragment
         http.get(uri, function(res) {
             callback(JSON.parse(res.body));
         });
    }
});

This would obviously require some restructuring of the code, since it is not async-compatible at the moment.

Alternatively, it would be great if we could accept top-level schemata instead of duplicating all sub-schema paths when providing those up-front.

Any thoughts?

@chrahunt
Copy link
Collaborator

The implementation in #69 doesn't change the current behavior here which I believe would still break your example. Wasn't sure if it would be proper to remove that line since I'm not sure why it is there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants