-
Notifications
You must be signed in to change notification settings - Fork 183
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
Add method to extract external schema urls from used $ref's #46
Comments
That would be useful, yeah. When adding a schema, tv4 performs a normalisation pass (to convert A tidy way to collect I'm not quite sure what the issue would be with nested/recursive references, though - if ValidatorContexts have a list of all |
With nested/recursive references I meant a schema that refers to an external schema that refers to another external schema (etc etc). To get at the urls of all of them it would need multiple passes: check a schema and get the urls, load and add the sub schemas, check again for new missing ones, load them, and repeat this until they're all cached. Now I know tv4 will collect the mappings it could have an api like this:
This can then be repeated until no empty uri's show up, after which you can validate synchronously by anyone of these schema. What do you think? |
Sounds about right, yeah. :) |
Ok, cool. Do you feel a need to implement this yourself? Otherwise I'll have a go at it. If I take this I'll create a |
Just to check - what's going into I don't have a particular need to write everything myself, so by all means go for it. |
Yes, only the basic accessor methods like They would just be a clean way to get at the reference data so we can do stuff with it (like loading, but also for debugging). The actual fetching and adding would be external. Once that is stabilised and used in practice we could look at hammering the fetchers I'd write for my own projects into a plugin/addon type of thing. |
Sounds great - look forward to seeing it. ) |
Just now I committed my edits for this to a develop-branch. It's an ugly commit; I tried to clean it up but only got worse: had made the mistake of modifying stuff while I was implementing this (so we learn :) One thing I added besides implementing Issue was source-map support via grunt-concat-sourcemap/sourcemap-support: now node.js stack traces of the core and tests display path to the actual fragment file (instead of the concatenated file). Pretty neat, also works with in Chrome Debugger if you enable it (also breakpoints etc :) Also I cleaned some stuff in the tests. |
@geraintluff I'm mergin this with your recent edits and pushing it to /master |
Optionally only the ones that aren't loaded yet. This methods could then be used to simplify preloading the schema's for tv4.addSchema() and synchronous validation.
I could have a got at this myself but a complications will be to find a way to resolve nested or recursive references. Do you got an idea on how to approach this?
The text was updated successfully, but these errors were encountered: