ajv-validator / ajv-validator/ajv-cli

Improve data type determination for the key words “oneOf” and “allOf”

オープン
#224 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
316
フォーク
77
PR マージ指標
30日以内にマージされた PR はありません

説明

I constructed the following JSON schema file.
```json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Calculation information",
"description": "settings for calculations",
"$id": "https://example.com/schemas/calculation_preferences",
"type": "object",
"required": ["context"],
"properties":
{
"context":
{
"type": "object",
"oneOf":
[
{
"allOf":
[
{
"properties":
{
"label": {"const": "GTIN"}
}
},
{
"type": "array",
"minItems": 1,
"items":
{
"type": "string",
"pattern": "^[0-9]{13}$"
}
}
]
},
{
"allOf":
[
{
"properties":
{
"label": {"const": "selection group"}
}
},
{
"type": "array",
"minItems": 1,
"items":
{
"type": "string",
"minLength": 1
}
}
]
}
]
}
}
}
```

Test data example:
```json
{
"context":
{
"GTIN": [ "1234567890123" ]
}
}
```

:thought_balloon: Now I am wondering about the following error information.
```
Markus_Elfring@…:…> ajv validate --strict=false --spec=draft2020 -s Berechnung-Kontext-Testfragment1-Schema2 -d Context-test_fragment1.json
Context-test_fragment1.json invalid
[
{
instancePath: '/context',
schemaPath: '#/properties/context/oneOf/0/allOf/1/type',
keyword: 'type',
params: { type: 'array' },
message: 'must be array'
},
{
instancePath: '/context',
schemaPath: '#/properties/context/oneOf/1/allOf/1/type',
keyword: 'type',
params: { type: 'array' },
message: 'must be array'
},
{
instancePath: '/context',
schemaPath: '#/properties/context/oneOf',
keyword: 'oneOf',
params: { passingSchemas: null },
message: 'must match exactly one schema in oneOf'
}
]
```

:thinking: I would appreciate further advices and solution ideas for safer data processing.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。