ajv-validator / ajv-validator/ajv-cli

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

Aberta
#249 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
316
Forks
77
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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?

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.