json-schema-static-docs icon indicating copy to clipboard operation
json-schema-static-docs copied to clipboard

Support for draft 2020-12

Open jat255 opened this issue 1 year ago • 2 comments

Looking through some other issues, it looks like schema version support is dependent on the AJV library. Poking through their docs, it looks like that library now supports 2020-12 (https://ajv.js.org/guide/schema-language.html#draft-2019-09-and-draft-2020-12), but it looks like it requires a different import:

const Ajv2020 = require("ajv/dist/2020")
const ajv = new Ajv2020()

Would it be possible to add this? Looking through the library, it looks like that would need to be changed somewhere around here: https://github.com/tomcollins/json-schema-static-docs/blob/master/lib/validator.js#L1-L5

jat255 avatar Apr 03 '24 15:04 jat255

Changing line 2 of that file to const Ajv = require("ajv/dist/2020"); made the library work with my schema, but I'm not sure if that breaks other things.

jat255 avatar Apr 03 '24 15:04 jat255

It hit me hard today… I tried my best to render a schema with spec 2020-12 and indeed I had to replace by 2019-09 to make it work. But it took me much time to understand why.

Note that I tried to use ajvOptions.schemas to add the schema, but it was saying that schema id already exists, while not able to validate my schema.

alexgarel avatar Jul 18 '24 16:07 alexgarel

Hi @jat255 and @alexgarel. Apologies for the delay in picking this up. I've just release v0.26.0 with support for draft-2020-12 schema. There is an example for this in the README or via https://tomcollins.github.io/json-schema-static-docs/

tomcollins avatar Oct 24 '24 10:10 tomcollins

Closing this issue.

tomcollins avatar Oct 24 '24 10:10 tomcollins