fastify / ajv-compiler

Build and manage the AJV instances for the fastify framework
Other
18 stars 9 forks source link

breaking: JSON Schema draft-2020-12 #105

Open Eomm opened 1 year ago

Eomm commented 1 year ago

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

jsumners commented 1 year ago

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.

Eomm commented 1 year ago

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...
gurgunday commented 1 year ago

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

bcomnes commented 1 week ago

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?