-
-
Notifications
You must be signed in to change notification settings - Fork 887
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
no schema with key or ref "http://json-schema.org/draft-04/schema#" #472
Comments
@mmc41 I had this issue too, but found the migration guide under the 5.0.0 release notes: https://github.com/epoberezkin/ajv/releases/tag/5.0.0 |
@adamayogo that is correct. @mmc41 this guide explains how to use draft-04 schemas with 5.x.x version. By default it only includes meta-schema for draft-06. |
I do not understand why is the property I fixed the error no schema with key or ref by adding the {
"$id": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-04/schema#"
} I need |
@Domvel $schema is URI of the meta-schema, $id is recommended rather than required, please see JSON schema spec |
@epoberezkin Why is not possible to use ajv without |
It is possible to use ajv without $id, it is only needed if you refer to a schema. |
I 'm also experiencing the issue described at the top of this thread. It seems Ajv doesn't accept the |
@steph643 draft-04 meta-schema has to be added to Ajv instance - please see top of readme. |
@epoberezkin , thanks for your answer. I use draft-06, not draft-04, but the readme says to call Thanks again. |
I have the same problem. Is there a solution |
Ajv v8 no longer supports draft-04, you need to use v6 or migrate your schemas |
As the support for the very old draft-4 was removed from at least one critical tool (ajv), we switch to draft-7 which also happens to be the version used by all the other Ansible related schemas. Related: ajv-validator/ajv#472 Related: ansible/ansible-lint#3079 Related: ansible#397
As the support for the very old draft-4 was removed from at least one critical tool (ajv), we switch to draft-7 which also happens to be the version used by all the other Ansible related schemas. Related: ajv-validator/ajv#472 Related: ansible/ansible-lint#3079 Related: ansible#397 We also include the "examples" extension, which informs ansible-lint about which glob file patters should use this schema.
As the support for the very old draft-4 was removed from at least one critical tool (ajv), we switch to draft-7 which also happens to be the version used by all the other Ansible related schemas. Related: ajv-validator/ajv#472 Related: ansible/ansible-lint#3079 Related: ansible#397 We also include the "examples" extension, which informs ansible-lint about which glob file patters should use this schema.
As the support for the very old draft-4 was removed from at least one critical tool (ajv), we switch to draft-7 which also happens to be the version used by [all the other](https://github.com/ansible/ansible-lint/tree/main/src/ansiblelint/schemas) Ansible related schemas. Related: ajv-validator/ajv#472 Related: ansible/ansible-lint#3079 Related: #397 Co-authored-by: Alex <aizquier@redhat.com>
I spotted another unexpected side effect:
So basically if someone dares to use the HTTPS or to remove the "#" from the url, ajv stops recognizing the schema, even if from the HTTP point of view the schema file is perfectly accessible. Not only this, but that means that AJV users are forced to use the unsecure HTTP protocol for loading the schemas, which opens another can of worms. So far I am inclined to believe that the only way to make it work in all cases is use exactly |
from https://ajv.js.org/json-schema.html#draft-04
|
What am i supposed to do if i get this:
{
"$id": "http://json-schema.org/draft-06/schema#",
"$schema": "http://json-schema.org/draft-06/schema#",
... |
Does anyone know how to both specify I'm doing: {
"$schema": "http://json-schema.org/draft/2019-09/schema#",
"title": "my schema",
"description": "foo",
"type": "object"
} which works fine for the IDE, but ajv gives me the same error as this issue:
when using:
This is on version 8.17.1. Edit: I figured it out. Apparently, now the requirements have been inverted since these issues were posted years back. HTTPS is now required for the schema property, or it doesn't work on the CLI, e.g.: Good:
Bad:
|
I have upgraded from ajv 4.x to ajv 5.0 and I now get above errors when validating json files that I generate using the excellent 'typescript-json-schema' module that generate json schema with
"$schema": "http://json-schema.org/draft-04/schema#"
.What version of Ajv are you using? Does the issue happen if you use the latest version?
5.0
Ajv options object
allErrors: true, verbose: false, addUsedSchema: false, inlineRefs: false,
JSON Schema
Validation result, data AFTER validation, error messages
What results did you expect?
The schema to validate like it did in ajv 4.x
Note, as my schemas are autogenerated they are a little difficult to change, so it would be great if Ajv 5 could accept them (like Ajv 4).
The text was updated successfully, but these errors were encountered: