Skip to content

Commit 21d33c4

Browse files
authored
skip pattern check for byte array in C# (#6048)
1 parent d20537b commit 21d33c4

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,15 @@ this.{{name}} = {{name}};
241241

242242
{{/minimum}}
243243
{{#pattern}}
244+
{{^isByteArray}}
244245
// {{{name}}} ({{{datatype}}}) pattern
245246
Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}});
246247
if (false == regex{{{name}}}.Match(this.{{{name}}}).Success)
247248
{
248-
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of {{{pattern}}}.", new [] { "{{{name}}}" });
249+
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" });
249250
}
250251

252+
{{/isByteArray}}
251253
{{/pattern}}
252254
{{/hasValidation}}
253255
{{/vars}}

samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public override int GetHashCode()
415415
Regex regex_String = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
416416
if (false == regex_String.Match(this._String).Success)
417417
{
418-
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _String, must match a pattern of /[a-z]/i.", new [] { "_String" });
418+
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _String, must match a pattern of " + regex_String, new [] { "_String" });
419419
}
420420

421421
// _Byte (byte[]) pattern

samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/FormatTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public virtual void OnPropertyChanged(string propertyName)
438438
Regex regex_String = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
439439
if (false == regex_String.Match(this._String).Success)
440440
{
441-
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _String, must match a pattern of /[a-z]/i.", new [] { "_String" });
441+
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _String, must match a pattern of " + regex_String, new [] { "_String" });
442442
}
443443

444444
// _Byte (byte[]) pattern

0 commit comments

Comments
 (0)