ajv-validator / ajv-validator/ajv-cli

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

未關閉
#249 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
316
分支
77
PR 合併指標
30 天內沒有已合併 PR

描述

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?

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。