ajv-compiler icon indicating copy to clipboard operation
ajv-compiler copied to clipboard

breaking: JSON Schema draft-2020-12

Open Eomm opened this issue 2 years ago • 5 comments

Evaluate if the next major version should set the JSON schema draft-2020-12 as default

Ref: https://github.com/fastify/fastify/issues/4549 AJV docs: https://ajv.js.org/guide/schema-language.html#draft-2019-09-and-draft-2020-12

Eomm avatar Aug 26 '23 17:08 Eomm

The AJV docs recommend sticking with 07 if you don't need the two new properties as all schemas will be affected by the reduced performance required to support them.

jsumners avatar Aug 27 '23 11:08 jsumners

I'm not too much into it tbh - I think we can provide:

  1. an option to let the user switch the json version
  2. release a npm tagged version that is equal to main but loads the other json schema standard
  3. other ideas...

Eomm avatar Aug 27 '23 16:08 Eomm

The AJV docs recommend sticking with 07 if you don't need the two new properties as all schemas will be affected by the reduced performance required to support them.

Wow, I just discovered this:

Draft-2019-09 features performance cost (even when not used)

+1 for keeping 07 the default and letting the user choose

gurgunday avatar Sep 17 '23 09:09 gurgunday

Somewhat related, is there a way to opt into the 2019 or 2020 version without having to re-implement a ValidatorCompiler? (Like opt into the defaults, but with a few more of the keywords).

If you register 2019, and add the 07 spec, can you pick which one you use with the $schema field?

bcomnes avatar Oct 09 '24 22:10 bcomnes