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

Add support for absolute JSON Pointers in the $data reference #285

Closed
HotelDon opened this issue Aug 21, 2016 · 3 comments
Closed

Add support for absolute JSON Pointers in the $data reference #285

HotelDon opened this issue Aug 21, 2016 · 3 comments

Comments

@HotelDon
Copy link
Contributor

What version of Ajv you are you using?
4.5.0
What problem do you want to solve?
The $data reference only supports relative JSON pointers, which limits code reuse for data that is always in one location but $data referenced in multiple places. It also creates problems for more complex schemas; for example, a recursive schema can't reference data in the root of the document because it's relative distance to the root changes depending on how many levels deep you've gone.
What do you think is the correct solution to problem?
Add in support for regular (absolute) JSON pointers to the $data reference. I have an issue open on the JSON-Schema Github for adding this to the v5 proposal (json-schema-org/json-schema-spec#40) that explains the issue in a bit more depth. The short version is, regular JSON pointers start with a / instead of a number, and the pointer is always anchored to the root of the document, which solves the problem. Additionally, since relative pointers ALWAYS start with a number, there's no ambiguity as to which type of pointer you're trying to use.
Will you be able to implement it?
I couldn't find where the code for handling the relative pointers is located, but point me in the right direction and I might be able to. However, the $data reference looks like some of the more complicated parts of the library, so I can't say for sure.

@epoberezkin
Copy link
Member

Yep, good idea.

You can just edit the wiki re $data proposal btw.

It's here btw: https://github.com/epoberezkin/ajv/blob/master/lib/compile/util.js#L218

@HotelDon
Copy link
Contributor Author

The proposals are all on the old repo and haven't been moved over, so I was a bit confused if anyone would have even noticed if I had changed it. Didn't want to ruffle too many feathers.

I'll try to have a pull request/admission of failure ready by tomorrow.

@epoberezkin epoberezkin changed the title Feature Request: Add support for regular JSON Pointers to the $data reference Add support for absolute JSON Pointers in the $data reference Aug 28, 2016
@epoberezkin
Copy link
Member

In 4.6.0

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

No branches or pull requests

2 participants