RicoSuter/NJsonSchema

JsconSchema doesn`t validate required property inside anyOf

オープン

#325 opened on 2017/02/24

 (11 件のコメント) (0 件のリアクション) (0 人の担当者)C# (549 件のフォーク)github user discovery
help wantedtype: bug

Repository metrics

Stars
 (1,581 個のスター)
PR merge metrics
 (平均マージ 39d 6h) (30d で 1 merged PR)

説明

I have this json schema which is being used in the code below. { "definitions": { "Test": { "id": "Jsonschemas/", "type": "object", "properties": { "url": { "type": "string" }, "canceledOnDate": { "type": "string" }, "address": { "$ref": "address.json#/definitions/address" }, "coordinates": { "$ref": "coordinates.json#/definitions/coordinates" } }, "additionalProperties": false, "required": ["canceledOnDate" ], "anyOf": [ { "required": [ "address" ] }, { "required": [ "coordinates" ] } ] } } }

I have this C# code which is using JsonSchema4.

JsonSchema4 schema = new JsonSchema4();
schema = await JsonSchema4.FromFileAsync(Path.Combine(HttpContext.Current.Server.MapPath("~"), @"JsonSchema/Test.json")); schema.Validate(actualJsonData);

I am expecting that based on the schema if I dont provide either address or cocrdinates, the Validate method should return me error. But it doesn`t validate the required field in anyOf at all. The validation always passes even if address and coordinates both are not provided.

Is it not supported with JsonSchema4? I am looking for help to fix this problem or a work around to fix this issue.

コントリビューターガイド