jhthorsen / json-validator

:cop: Validate data against a JSON schema
https://metacpan.org/release/JSON-Validator
56 stars 57 forks source link

Any plans on supporting draft 2019-09? #181

Closed bpj closed 3 years ago

bpj commented 4 years ago

The title says it all. I'm willing to contribute if/when I can be confident that I can get/have got my head around the spec (and the code, though the spec is much worse, of course! :)

karenetheridge commented 4 years ago

One thing I noticed in the new spec is that other keys are living alongside $ref, which means that JSON::Validator::Ref will need to change how it uses Tie::RefHash (which presently doesn't allow any sibling keys to $ref) -- perhaps by moving the tie one level down and using a literal '$ref' string for the key.

jhthorsen commented 4 years ago

@karenetheridge: I don’t see why it would have to change; but let’s see :)

@bpj: Looks like the new draft has some interesting changes. I would very much like to implement it, but I have very limited time these days, so I’m unsure when I can look at it. Please ping me in a week if there haven’t been any updates.

karenetheridge commented 4 years ago

I don’t see why it would have to change; but let’s see :)

Just try loading a schema document with two keys - a $ref, and anything else (say, description). Then dump the schema and see what you get. :) It's because the entire hashref containing { '$ref' => '...' } is transformed to the tie, and it doesn't allow for any other keys to go in there.

bpj commented 4 years ago

@jhthorsen don't we all have limited time? :) That's why I offered to try to help out, but it seems this needs quite substantial changes so lets see if the time I have right now is enough to familiarize me with the code and the spec.

karenetheridge commented 4 years ago

If anyone wants to assist here, IMO one thing that would be of great help is to write some tests that we would expect to pass with the new spec. That is, a commit that added the new spec into the in-distribution file cache, some validation schemas that demonstrated some of the new syntax, and some datasets that passed (or failed!) the new schemas.

Here is some information on the new version: https://json-schema.org/draft/2019-09/release-notes.html -- there are indeed substantial changes to this version. It's going to take a while to get through it all!

karenetheridge commented 4 years ago

FWIW, this draft is still undergoing changes (I started watching the https://github.com/json-schema-org/json-schema-spec repo to follow the debates), so it may be premature to implement it now, unless users are willing to also fix their schemas constantly to keep pace with the changes (and also that would require someone to keep JV updated for the changes too).

bpj commented 4 years ago

I thought drafts were frozen once published. Good to know that isn't the case. Probably wiser to wait till the next draft comes out or at least till this one stabilizes then. Anyway there is nothing crucial I can't do with draft 7, however uglier (as in more verbose). Thank you very much for looking into this.

Den ons 19 feb. 2020 20:33Karen Etheridge notifications@github.com skrev:

FWIW, this draft is still undergoing changes (I started watching the https://github.com/json-schema-org/json-schema-spec repo to follow the debates), so it may be premature to implement it now, unless users are willing to also fix their schemas constantly to keep pace with the changes (and also that would require someone to keep JV updated for the changes too).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mojolicious/json-validator/issues/181?email_source=notifications&email_token=AAI3OUYMTU3RA2ZS27MV5DDRDWCNJA5CNFSM4KHF5W4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMJF3EA#issuecomment-588406160, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3OU6YOUMPSL4444LLIQLRDWCNJANCNFSM4KHF5W4A .

jhthorsen commented 3 years ago

I've released 4.09 with "basic" support for 2019-09 now. Look at https://github.com/mojolicious/json-validator/blob/master/t/draft2019-09-acceptance.t for an overview for what is not yet supported.

It does not seem exist tests for "$recursiveRef" in the official test suite, so basic support for the keyword is tested here: https://github.com/mojolicious/json-validator/blob/master/t/draft2019-09.t "$recursiveAnchor" is unfortunately not supported yet though.

Keeping this issue open until the last bits are ironed out.

jhthorsen commented 3 years ago

Going to close this issue since #225 and #226 exists.