ajv-validator / ajv-validator/ajv-cli

Errors validating a document (which happens to be a schema) against the core meta schema

Open
#249 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
316
Forks
77
PR merge metrics
No merged PRs in 30d

Description

I'm struggling to validate a schema I'm developing against the core meta-schema using ajv-cli 5.0.0 (according to the package.json -- I guess there's no version identifier in the cli see #198 )

Imagine I've got a really basic schema named `foo-schema.json`:

```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "a foo schema",
"type": "object",
"properties": {
"bar": {
"type": "string"
},
"additionalProperties": false
}
}
```

and I wish to ensure this is a valid schema according to the `$schema` reference (in this case, the core meta schema).

Initially I was hoping I could just issue an `ajv validate -d ...` and it'd figure out what schema I was trying to use (after all, I put a `$schema` reference in the doc):

```
> ajv validate -d foo-schema.json
error: parameter -s is required
```

Therefore, I issue the following command where `schema.json` is harvested from the url `http://json-schema.org/draft-07/schema`

```
> ajv validate -s schema.json -d foo-schema.json
schema schema.json is invalid
error: schema with key or id "http://json-schema.org/draft-07/schema" already exists
```

So to fix that, I'm removing the `$schema` and `$id` elements from the downloaded `schema.json`. Now I get:

```
> ajv validate -s schema.json -d foo-schema.json
strict mode: use allowUnionTypes to allow union type keyword at "#" (strictTypes)
schema schema.json is invalid
error: unknown format "uri-reference" ignored in schema at path "#/properties/%24id"
```

Well, I'm kinda stumped now. Is there a canonical way to validate that a schema is correct according to the meta-schema?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.