tomcollins / json-schema-static-docs

Quickly generate human friendly documentation from your JSON schema
https://tomcollins.github.io/json-schema-static-docs/
GNU General Public License v3.0
21 stars 7 forks source link

Error(`no schema with key or ref "${schemaKeyRef}"` #103

Closed magick93 closed 1 year ago

magick93 commented 1 year ago

Hello

I'm getting the following error when I try to build the jsonschema docs:

> hr@1.0.0 docs
> node ./scripts/schemadocs.cjs

Loaded 237 schema files from data/common/json/**/*.{yml,json}
/home/anton/git/hr/node_modules/.pnpm/ajv@8.12.0/node_modules/ajv/dist/core.js:147
                throw new Error(`no schema with key or ref "${schemaKeyRef}"`);
                      ^

Error: no schema with key or ref "http://json-schema.org/draft-04/schema#"
    at Ajv2019.validate (/home/anton/git/hr/node_modules/.pnpm/ajv@8.12.0/node_modules/ajv/dist/core.js:147:23)
    at Ajv2019.validateSchema (/home/anton/git/hr/node_modules/.pnpm/ajv@8.12.0/node_modules/ajv/dist/core.js:260:28)
    at Ajv2019._addSchema (/home/anton/git/hr/node_modules/.pnpm/ajv@8.12.0/node_modules/ajv/dist/core.js:460:18)
    at Ajv2019.addSchema (/home/anton/git/hr/node_modules/.pnpm/ajv@8.12.0/node_modules/ajv/dist/core.js:234:34)
    at /home/anton/git/hr/node_modules/.pnpm/json-schema-static-docs@0.23.0/node_modules/json-schema-static-docs/lib/validator.js:15:15
    at Array.forEach (<anonymous>)
    at new Validator (/home/anton/git/hr/node_modules/.pnpm/json-schema-static-docs@0.23.0/node_modules/json-schema-static-docs/lib/validator.js:14:11)
    at JsonSchemaStaticDocs.generate (/home/anton/git/hr/node_modules/.pnpm/json-schema-static-docs@0.23.0/node_modules/json-schema-static-docs/lib/json-schema-static-docs.js:56:21)
    at async /home/anton/git/hr/apps/hr/scripts/schemadocs.cjs:11:3

Do you have any suggestions?

tomcollins commented 1 year ago

Hi @magick93. It looks like you are using a draft-04 schema which is not supported by this library. This is due to a limitation in the underlying AJV validation library.

This library does support draft-06, draft-07 and draft-2019-09. I suggest you switch to draft-07, which may be as simple as editing your schema documents and replacing draft-04 with draft-07.