6

I'm having trouble getting this line to resolve at the top of my JSON Schema when compiling it with AJV: "$schema": "node_modules/ajv/lib/refs/json-schema-draft-04#"

I've also tried this line to work, to no avail: "$schema": "http://json-schema.org/draft-04/schema#"

(And a lot of other permutations of the above.)

No matter what I put, AJV says: "Error: no schema with key or ref..."

What exactly needs to go in this property?

Thank you (BTW AJV is great, thank you.)

DEzell
  • 83
  • 4
  • 1
    In case you haven't seen this before, there is a *"If you need to continue using draft-04 schemas"* section in the [v5.0.0 release notes](https://github.com/epoberezkin/ajv/releases/tag/5.0.0). It may or may not be useful in your case. – customcommander Dec 05 '18 at 22:36
  • 2
    Thanks - I'm not keen to use 4.0. I'm looking for a way to indicate the version in "$schema" - version 7 is fine, I just can't find ANY string that will not generate an error. The meta schemas are both in my local file system, and I'm connected. But nothing works. What string do you use for $schema? – DEzell Dec 07 '18 at 00:01

1 Answers1

0

For Draft 7, the correct string is "$schema": "http://json-schema.org/draft-07/schema#".

Here's an example, sample.schema.json:

{
  "$id": "https://www.example.com/sample.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Sample",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "uid": {
      "type": "number"
    }
  },
  "additionalProperties": false
}
Patrick Kenny
  • 4,515
  • 7
  • 47
  • 76