RicoSuter/NJsonSchema

minlength is impacted by required attribute in json schema

オープン

#768 opened on 2018/08/31

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

Repository metrics

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

説明

I used below schema to generate C# code using CSharpGenerator. But there is no validation for the length if the field marked as required. The validation ( [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue, MinimumLength = 1)]) is correctly generated if the field is not marked as required.

{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "files": { "type": "string", "minlength": 1 } }, "required": [ "files" ] }

Is this intentional? I am using version: 9.10.67 on nuget.

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