json-yaml-validate icon indicating copy to clipboard operation
json-yaml-validate copied to clipboard

Attempting to validate a schema against a meta-schema errors out

Open CodeGat opened this issue 5 months ago • 0 comments

Thanks for creating this action - it's been a huge help in a bunch of my projects.

Instead of validating data against a schema, I've been looking to validate a schema against a meta-schema (usually a JSON Standards schema such as http://json-schema.org/draft-07/schema#), but I can't seem to get it to work.

Attempts

Attempting with:

with:
  file: schema.json
  json_schema: meta-schema.json  # `curl` http://json-schema.org/draft-07/schema# into `meta-schema.json`
  # No json_schema_version

fails with:

Error: schema with key or id "http://json-schema.org/draft-07/schema" already exists
    at Ajv._checkUnique (/home/runner/work/_actions/GrantBirki/json-yaml-validate/d7814b94473939c1daaca2c96131b891d4703a3c/node_modules/ajv/dist/core.js:465:1)
    at Ajv._addSchema (/home/runner/work/_actions/GrantBirki/json-yaml-validate/d7814b94473939c1daaca2c96131b891d4703a3c/node_modules/ajv/dist/core.js:456:1)
    at Ajv.compile (/home/runner/work/_actions/GrantBirki/json-yaml-validate/d7814b94473939c1daaca2c96131b891d4703a3c/node_modules/ajv/dist/core.js:158:1)
    at schema (/home/runner/work/_actions/GrantBirki/json-yaml-validate/d7814b94473939c1daaca2c96131b891d4703a3c/src/functions/json-validator.js:81:1)
    at jsonValidator (/home/runner/work/_actions/GrantBirki/json-yaml-validate/d7814b94473939c1daaca2c96131b891d4703a3c/src/functions/json-validator.js:115:1)
    at run (/home/runner/work/_actions/GrantBirki/json-yaml-validate/d7814b94473939c1daaca2c96131b891d4703a3c/src/main.js:7:1)
    at /home/runner/work/_actions/GrantBirki/json-yaml-validate/d7814b94473939c1daaca2c96131b891d4703a3c/src/main.js:14:1
    at /home/runner/work/_actions/GrantBirki/json-yaml-validate/d7814b94473939c1daaca2c96131b891d4703a3c/dist/index.js:68727:3
    at Object.<anonymous> (/home/runner/work/_actions/GrantBirki/json-yaml-validate/d7814b94473939c1daaca2c96131b891d4703a3c/dist/index.js:68730:12)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)

Whereas something like:

with:
  file: schema.json
  json_schema_version: '07-draft'

Doesn't pick up on obvious error with schema.json.

Any help would be appreciated :)

CodeGat avatar Sep 20 '24 03:09 CodeGat