Skip to content

Commit

Permalink
Merge pull request #924 from swagger-api/aspnetcore-data-annotation
Browse files Browse the repository at this point in the history
added data annotations on model properties
  • Loading branch information
HugoMario committed Jun 25, 2021
2 parents b840287 + 7f6e7ee commit 2f6b0c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/resources/handlebars/aspnetcore/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ namespace {{packageName}}.Models
{{/description}}
{{#required}}
[Required]
{{/required}}
{{/required}}{{#pattern}}
[RegularExpression("{{{pattern}}}")]{{/pattern}}{{#minLength}}{{#maxLength}}
[StringLength({{maxLength}}, MinimumLength={{minLength}})]{{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}}
[MinLength({{minLength}})]{{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}}
[MaxLength({{maxLength}})]{{/maxLength}}{{/minLength}}{{#minimum}}{{#maximum}}
[Range({{minimum}}, {{maximum}})]{{/maximum}}{{/minimum}}
[DataMember(Name="{{baseName}}")]
{{#isEnum}}
public {{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}?{{/isContainer}}{{/isEnum}} {{name}} { get; set; }
Expand Down

0 comments on commit 2f6b0c8

Please sign in to comment.