I am using ajv 8.6.2
I have schemas that validate against draft-07 using the default export
When I use the draft-09 export all of my schemas give me this error:
no schema with key or ref "https://json-schema.org/draft-07/schema"
Same error exists if I use this:
no schema with key or ref "https://json-schema.org/draft-09/schema"
Can't seem to figure out what's going on here?
AJV does not seem to support HTTPs versions of the json-schema identifiers; try using http: instead:
{
"$schema": "http://json-schema.org/draft-07/schema"
}
If you mean by
When I use the draft-09 export all
that you're using Ajv2019 instance
import Ajv2019 from "ajv/dist/2019"
const ajv = new Ajv2019()
then you need to add the draft-07 metaschema:
const draft7MetaSchema = require("ajv/dist/refs/json-schema-draft-07.json")
ajv.addMetaSchema(draft7MetaSchema)
as explained at https://ajv.js.org/guide/schema-language.html#draft-2019-09-and-draft-2020-12
FYI, don't refer to JSON meta schemas with https://, their identifiers do start with http://, ajv doesn't retrieve them, it packages them instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With