ajv-validator / ajv-validator/ajv-cli

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

Abierto
#249 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
316
Forks
77
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.