From 41012588dd4d7ab4d7ca9c5b050b360c37025c17 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Mon, 5 May 2025 03:06:22 -0400 Subject: [PATCH] ignore date length validation (#21217) --- .../src/main/resources/csharp/validatable.mustache | 6 ++++++ ...ke-endpoints-models-for-testing-with-http-signature.yaml | 2 ++ .../csharp/generichost/net4.7/FormModels/api/openapi.yaml | 2 ++ .../csharp/generichost/net4.7/Petstore/api/openapi.yaml | 2 ++ .../csharp/generichost/net4.8/FormModels/api/openapi.yaml | 2 ++ .../csharp/generichost/net4.8/Petstore/api/openapi.yaml | 2 ++ .../csharp/generichost/net8/FormModels/api/openapi.yaml | 2 ++ .../generichost/net8/NullReferenceTypes/api/openapi.yaml | 2 ++ .../csharp/generichost/net8/Petstore/api/openapi.yaml | 2 ++ .../generichost/net8/SourceGeneration/api/openapi.yaml | 2 ++ .../csharp/generichost/net9/FormModels/api/openapi.yaml | 2 ++ .../generichost/net9/NullReferenceTypes/api/openapi.yaml | 2 ++ .../csharp/generichost/net9/Petstore/api/openapi.yaml | 2 ++ .../generichost/net9/SourceGeneration/api/openapi.yaml | 2 ++ .../generichost/standard2.0/Petstore/api/openapi.yaml | 2 ++ .../csharp/httpclient/net9/Petstore/api/openapi.yaml | 2 ++ .../csharp/httpclient/standard2.0/Petstore/api/openapi.yaml | 2 ++ .../csharp/restsharp/net8/Petstore/api/openapi.yaml | 2 ++ .../standard2.0/ConditionalSerialization/api/openapi.yaml | 2 ++ .../csharp/unityWebRequest/net9/Petstore/api/openapi.yaml | 2 ++ .../unityWebRequest/standard2.0/Petstore/api/openapi.yaml | 2 ++ 21 files changed, 46 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/csharp/validatable.mustache b/modules/openapi-generator/src/main/resources/csharp/validatable.mustache index 429eed118e1..9dd8bb73356 100644 --- a/modules/openapi-generator/src/main/resources/csharp/validatable.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/validatable.mustache @@ -60,6 +60,9 @@ {{#vars}} {{#hasValidation}} {{^isEnum}} + {{^isDateTime}} + {{^isDate}} + {{^isTime}} {{#maxLength}} // {{{name}}} ({{{dataType}}}) maxLength if (this.{{{name}}} != null && this.{{{name}}}.Length > {{maxLength}}) @@ -76,6 +79,9 @@ } {{/minLength}} + {{/isTime}} + {{/isDate}} + {{/isDateTime}} {{#maximum}} // {{{name}}} ({{{dataType}}}) maximum if ({{#useGenericHost}}{{^required}}this.{{{name}}}Option.IsSet && {{/required}}{{/useGenericHost}}this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} {{#exclusiveMaximum}}<={{/exclusiveMaximum}}{{^exclusiveMaximum}}>{{/exclusiveMaximum}} ({{{dataType}}}){{maximum}}) diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 8837f52ee83..d4a570cdb15 100644 --- a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1747,6 +1747,8 @@ components: type: string format: date example: '2020-02-02' + minLength: 1 + maxLength: 1 dateTime: type: string format: date-time diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml index 7bfc0de5a41..9b4f672ec1c 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml @@ -1637,6 +1637,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml index 7bfc0de5a41..9b4f672ec1c 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml @@ -1637,6 +1637,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml index 7bfc0de5a41..9b4f672ec1c 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml @@ -1637,6 +1637,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml index 7bfc0de5a41..9b4f672ec1c 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml @@ -1637,6 +1637,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00 diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml index 4f007819a1a..4219d52759f 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml @@ -1678,6 +1678,8 @@ components: date: example: 2020-02-02 format: date + maxLength: 1 + minLength: 1 type: string dateTime: example: 2007-12-03T10:15:30+01:00