diff --git a/modules/openapi-generator/src/main/resources/csharp/README.mustache b/modules/openapi-generator/src/main/resources/csharp/README.mustache
index 474bfe829b40..da6053f4aa26 100644
--- a/modules/openapi-generator/src/main/resources/csharp/README.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/README.mustache
@@ -119,9 +119,15 @@ namespace Example
{{#hasAuthMethods}}
{{#authMethods}}
{{#isBasic}}
+ {{#isBasicBasic}}
// Configure HTTP basic authorization: {{{name}}}
Configuration.Default.Username = "YOUR_USERNAME";
Configuration.Default.Password = "YOUR_PASSWORD";
+ {{/isBasicBasic}}
+ {{#isBasicBearer}}
+ // Configure HTTP bearer authorization: {{{name}}}
+ Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
+ {{/isBasicBearer}}
{{/isBasic}}
{{#isApiKey}}
// Configure API key authorization: {{{name}}}
@@ -205,8 +211,14 @@ Authentication schemes defined for the API:
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
{{/isApiKey}}
{{#isBasic}}
+{{#isBasicBasic}}
- **Type**: HTTP basic authentication
+{{/isBasicBasic}}
+{{#isBasicBearer}}
+
+- **Type**: HTTP bearer authentication
+{{/isBasicBearer}}
{{/isBasic}}
{{#isOAuth}}
diff --git a/modules/openapi-generator/src/main/resources/csharp/api.mustache b/modules/openapi-generator/src/main/resources/csharp/api.mustache
index f040c439025d..a03009716943 100644
--- a/modules/openapi-generator/src/main/resources/csharp/api.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/api.mustache
@@ -278,11 +278,20 @@ namespace {{packageName}}.{{apiPackage}}
{{/isKeyInQuery}}
{{/isApiKey}}
{{#isBasic}}
+ {{#isBasicBasic}}
// http basic authentication required
if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
{
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password);
}
+ {{/isBasicBasic}}
+ {{#isBasicBearer}}
+ // http beerer authentication required
+ if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
+ {
+ localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken;
+ }
+ {{/isBasicBearer}}
{{/isBasic}}
{{#isOAuth}}
// oauth required
@@ -414,11 +423,20 @@ namespace {{packageName}}.{{apiPackage}}
{{/isKeyInQuery}}
{{/isApiKey}}
{{#isBasic}}
+ {{#isBasicBasic}}
// http basic authentication required
if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
{
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password);
}
+ {{/isBasicBasic}}
+ {{#isBasicBearer}}
+ // http bearer authentication required
+ if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
+ {
+ localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken;
+ }
+ {{/isBasicBearer}}
{{/isBasic}}
{{#isOAuth}}
// oauth required
diff --git a/modules/openapi-generator/src/main/resources/csharp/api_doc.mustache b/modules/openapi-generator/src/main/resources/csharp/api_doc.mustache
index df59f42415cf..6e4bbf7c9a43 100644
--- a/modules/openapi-generator/src/main/resources/csharp/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/api_doc.mustache
@@ -39,9 +39,15 @@ namespace Example
{{#hasAuthMethods}}
{{#authMethods}}
{{#isBasic}}
+ {{#isBasicBasic}}
// Configure HTTP basic authorization: {{{name}}}
Configuration.Default.Username = "YOUR_USERNAME";
Configuration.Default.Password = "YOUR_PASSWORD";
+ {{/isBasicBasic}}
+ {{#isBasicBearer}}
+ // Configure HTTP bearer authorization: {{{name}}}
+ Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
+ {{/isBasicBearer}}
{{/isBasic}}
{{#isApiKey}}
// Configure API key authorization: {{{name}}}
diff --git a/samples/client/petstore/csharp/OpenAPIClientNet40/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/OpenAPIClientNet40/src/Org.OpenAPITools/Model/FormatTest.cs
index 31193ac39608..eedd4b6236e1 100644
--- a/samples/client/petstore/csharp/OpenAPIClientNet40/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/OpenAPIClientNet40/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -367,6 +367,8 @@ public override int GetHashCode()
/// Validation Result
IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
{
+
+
// Integer (int) maximum
if(this.Integer > (int)100)
{
@@ -379,6 +381,8 @@ public override int GetHashCode()
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" });
}
+
+
// Int32 (int) maximum
if(this.Int32 > (int)200)
{
@@ -391,6 +395,8 @@ public override int GetHashCode()
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" });
}
+
+
// Number (decimal) maximum
if(this.Number > (decimal)543.2)
{
@@ -403,6 +409,8 @@ public override int GetHashCode()
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value greater than or equal to 32.1.", new [] { "Number" });
}
+
+
// Float (float) maximum
if(this.Float > (float)987.6)
{
@@ -415,6 +423,8 @@ public override int GetHashCode()
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Float, must be a value greater than or equal to 54.3.", new [] { "Float" });
}
+
+
// Double (double) maximum
if(this.Double > (double)123.4)
{
@@ -427,6 +437,8 @@ public override int GetHashCode()
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Double, must be a value greater than or equal to 67.8.", new [] { "Double" });
}
+
+
// String (string) pattern
Regex regexString = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
if (false == regexString.Match(this.String).Success)
@@ -434,6 +446,8 @@ public override int GetHashCode()
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for String, must match a pattern of " + regexString, new [] { "String" });
}
+
+
// Password (string) maxLength
if(this.Password != null && this.Password.Length > 64)
{
@@ -445,7 +459,7 @@ public override int GetHashCode()
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" });
}
-
+
yield break;
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClientWithPropertyChanged/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/OpenAPIClientWithPropertyChanged/src/Org.OpenAPITools/Model/FormatTest.cs
index d8452eb07cb6..b3ebc9f373b9 100644
--- a/samples/client/petstore/csharp/OpenAPIClientWithPropertyChanged/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/OpenAPIClientWithPropertyChanged/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -390,6 +390,8 @@ public virtual void OnPropertyChanged(string propertyName)
/// Validation Result
IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
{
+
+
// Integer (int) maximum
if(this.Integer > (int)100)
{
@@ -402,6 +404,8 @@ public virtual void OnPropertyChanged(string propertyName)
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" });
}
+
+
// Int32 (int) maximum
if(this.Int32 > (int)200)
{
@@ -414,6 +418,8 @@ public virtual void OnPropertyChanged(string propertyName)
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" });
}
+
+
// Number (decimal) maximum
if(this.Number > (decimal)543.2)
{
@@ -426,6 +432,8 @@ public virtual void OnPropertyChanged(string propertyName)
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value greater than or equal to 32.1.", new [] { "Number" });
}
+
+
// Float (float) maximum
if(this.Float > (float)987.6)
{
@@ -438,6 +446,8 @@ public virtual void OnPropertyChanged(string propertyName)
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Float, must be a value greater than or equal to 54.3.", new [] { "Float" });
}
+
+
// Double (double) maximum
if(this.Double > (double)123.4)
{
@@ -450,6 +460,8 @@ public virtual void OnPropertyChanged(string propertyName)
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Double, must be a value greater than or equal to 67.8.", new [] { "Double" });
}
+
+
// String (string) pattern
Regex regexString = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
if (false == regexString.Match(this.String).Success)
@@ -457,6 +469,8 @@ public virtual void OnPropertyChanged(string propertyName)
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for String, must match a pattern of " + regexString, new [] { "String" });
}
+
+
// Password (string) maxLength
if(this.Password != null && this.Password.Length > 64)
{
@@ -468,7 +482,7 @@ public virtual void OnPropertyChanged(string propertyName)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" });
}
-
+
yield break;
}
}