Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use standard meta schema #199

Open
sim642 opened this issue Jan 10, 2022 · 4 comments
Open

Use standard meta schema #199

sim642 opened this issue Jan 10, 2022 · 4 comments

Comments

@sim642
Copy link

sim642 commented Jan 10, 2022

From ajv's documentation I see there are standard meta schemas that can be used, but how to do that from the CLI?

Using -m /usr/share/nodejs/ajv/lib/refs/json-schema-draft-04.json doesn't seem to help at all:

meta-schema /usr/share/nodejs/ajv/lib/refs/json-schema-draft-04.json is invalid
error: no schema with key or ref "http://json-schema.org/draft-04/schema#"
@fharper
Copy link

fharper commented Apr 21, 2022

@sim642: did you find the answer?

@sim642
Copy link
Author

sim642 commented Apr 22, 2022

No, I just ended up removing the meta schema reference before validation in a GitHub Actions workflow where I'm using ajv:

 ​      - ​name​: ​Work around meta-schema missing error ​#​ https://github.com/ajv-validator/ajv-cli/issues/199 
 ​        ​run​: ​| 
 ​          sed -i 's|"$schema": "http://json-schema.org/draft-04/schema#",||' src/util/options.schema.json

It's very ugly and not scalable to actual local usage of ajv-cli conveniently.

@epoberezkin
Copy link
Member

Ajv doesn’t support draft4 in after v6. There is an option “draft” that would include the correct meta schema automatically without referencing it.

@sim642
Copy link
Author

sim642 commented Aug 11, 2022

There is an option “draft” that would include the correct meta schema automatically without referencing it.

What option? There isn't one here.

I did find https://ajv.js.org/json-schema.html#draft-04, but installing ajv-draft-04 made no difference. I guess that cannot be used with ajv-cli?

I also found ajv migrate -s schema to be a nicer workaround than sed-ing the schema...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants