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

Easily resolve type at JSONPath #24

Closed
andyscott opened this issue Jul 30, 2015 · 2 comments
Closed

Easily resolve type at JSONPath #24

andyscott opened this issue Jul 30, 2015 · 2 comments

Comments

@andyscott
Copy link
Contributor

Given a JSONPath (or similar structure) and a schema, is there a good way to determine the type ('string', 'object', etc) for a value at that path?

JSONPath store.book[0].title might resolve to 'string' against a schema for a book store record.

Would the best approach be to just navigate the schema structure directly?

@epoberezkin
Copy link
Member

Not sure if I understood the question correctly.

If you want traversing object using paths, you can use object-path

Or you can use reactive models from milojs framework - it does much more than just that though.

If you want to determine the required type for the value at a given path based on schema, it is not possible, because the schema can have 'anyOf' or 'not' keyword, for example, that would allow multiple types for a given property. Also schema can be written in such a way that the allowed type(s) for a given property would depend on other properties.

If you only use simple keywords then you can answer this question, but in general case there is no definite answer.

@pedroteixeira
Copy link

pedroteixeira commented Feb 27, 2018

Hello, is there currenty a way to "find possible schemas" given a data path (or json pointer of the data) that resolves all $refs along the way (that were added into the Ajv instance)?

I could not find from the docs, I suspect the answer is still no..

Thanks!

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

No branches or pull requests

3 participants