RicoSuter/NJsonSchema

minlength is impacted by required attribute in json schema

Aperta

#768 aperta il 31 ago 2018

 (2 commenti) (0 reazioni) (0 assegnatari)C# (549 fork)github user discovery
help wantedtype: enhancement

Metriche repository

Star
 (1580 stelle)
Metriche merge PR
 (Merge medio 39g 6h) (1 PR mergiata in 30 g)

Descrizione

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.

Guida contributor