diff --git a/bin/configs/csharp-restsharp-net4.7-multipleFrameworks.yaml b/bin/configs/csharp-restsharp-net4.7-multipleFrameworks.yaml
index bdd64742026c..0b7b6bad3f3f 100644
--- a/bin/configs/csharp-restsharp-net4.7-multipleFrameworks.yaml
+++ b/bin/configs/csharp-restsharp-net4.7-multipleFrameworks.yaml
@@ -4,6 +4,6 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
- targetFramework: netstandard2.1;net47
+ targetFramework: netstandard2.1;net47;net8.0
useCompareNetObjects: "true"
equatable: true
diff --git a/modules/openapi-generator/src/main/resources/csharp-functions/Project.csproj.mustache.bak b/modules/openapi-generator/src/main/resources/csharp-functions/Project.csproj.mustache.bak
deleted file mode 100644
index ab4ad28ede66..000000000000
--- a/modules/openapi-generator/src/main/resources/csharp-functions/Project.csproj.mustache.bak
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
- {{packageDescription}}{{^packageDescription}}{{packageName}}{{/packageDescription}}
- {{packageCopyright}}
- {{packageAuthors}}
- {{targetFramework}}
- true
- true
- {{packageVersion}}
- {{azureFunctionsVersion}}
-{{#nullableReferenceTypes}}
- annotations
-{{/nullableReferenceTypes}}
-{{#isLibrary}}
- Library
-{{/isLibrary}}
- {{packageName}}
- {{packageName}}
- {{userSecretsGuid}}
- Linux
- ..\..
-
-
-
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
- Never
-
-
-
diff --git a/modules/openapi-generator/src/main/resources/csharp-functions/function.mustache.bak b/modules/openapi-generator/src/main/resources/csharp-functions/function.mustache.bak
deleted file mode 100644
index 397ba84eb774..000000000000
--- a/modules/openapi-generator/src/main/resources/csharp-functions/function.mustache.bak
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.IO;
-using System.Net;
-using System.Threading.Tasks;
-using System.ComponentModel.DataAnnotations;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Azure.WebJobs;
-using Microsoft.Azure.WebJobs.Extensions.Http;
-using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
-using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
-using Microsoft.Extensions.Logging;
-using Microsoft.OpenApi.Models;
-using Newtonsoft.Json;
-
-namespace {{apiPackage}}
-{ {{#operations}}
- public partial {{#classModifier}}{{classModifier}} {{/classModifier}}class {{classname}}
- { {{#operation}}
- [FunctionName("{{classname}}_{{operationId}}")]
- public async Task _{{operationId}}([HttpTrigger(AuthorizationLevel.Anonymous, "{{httpMethod}}", Route = "{{{path}}}")]HttpRequest req, ExecutionContext context{{#allParams}}{{#isPathParam}}, {{>pathParam}}{{/isPathParam}}{{/allParams}}){{^generateBody}};{{/generateBody}}
- {{#generateBody}}
- {
- var method = this.GetType().GetMethod("{{operationId}}");
-
- return method != null
- ? (await ((Task)method.Invoke(this, new object[] { req, context{{#allParams}}{{#isPathParam}}, {{>paramName}}{{/isPathParam}}{{/allParams}} })).ConfigureAwait(false))
- : new StatusCodeResult((int)HttpStatusCode.NotImplemented);
- }
- {{/generateBody}}
- {{/operation}}
- }
-{{/operations}}
-}
diff --git a/modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache
index 91ea70055b06..eb4b63f578f9 100644
--- a/modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache
@@ -14,9 +14,9 @@ using System.Text;
using System.Threading;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
-{{^net60OrLater}}
+#if !NET6_0_OR_GREATER
using System.Web;
-{{/net60OrLater}}
+#endif
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using RestSharp;
diff --git a/modules/openapi-generator/src/main/resources/csharp/ApiClient.v790.mustache b/modules/openapi-generator/src/main/resources/csharp/ApiClient.v790.mustache
index a63d1c2be9c1..f47705a8b7f1 100644
--- a/modules/openapi-generator/src/main/resources/csharp/ApiClient.v790.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/ApiClient.v790.mustache
@@ -14,9 +14,9 @@ using System.Text;
using System.Threading;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
-{{^net60OrLater}}
+#if !NET6_0_OR_GREATER
using System.Web;
-{{/net60OrLater}}
+#endif
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using RestSharp;
diff --git a/modules/openapi-generator/src/main/resources/csharp/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp/ClientUtils.mustache
index 5c42d2e4fe33..84e8177e219c 100644
--- a/modules/openapi-generator/src/main/resources/csharp/ClientUtils.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/ClientUtils.mustache
@@ -114,14 +114,14 @@ namespace {{packageName}}.Client
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
-{{#net60OrLater}}
+#if NET6_0_OR_GREATER
if (obj is DateOnly dateOnly)
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15
return dateOnly.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
-{{/net60OrLater}}
+#endif
if (obj is bool boolean)
return boolean ? "true" : "false";
if (obj is ICollection collection) {
diff --git a/modules/openapi-generator/src/main/resources/csharp/HttpSigningConfiguration.mustache b/modules/openapi-generator/src/main/resources/csharp/HttpSigningConfiguration.mustache
index faca675944a3..823d9849a698 100644
--- a/modules/openapi-generator/src/main/resources/csharp/HttpSigningConfiguration.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/HttpSigningConfiguration.mustache
@@ -344,7 +344,7 @@ namespace {{packageName}}.Client
/// ECDSA signature
private string GetECDSASignature(byte[] dataToSign)
{
- {{#net60OrLater}}
+#if NET6_0_OR_GREATER
if (!File.Exists(KeyFilePath) && string.IsNullOrEmpty(KeyString))
{
throw new Exception("No API key has been provided.");
@@ -382,10 +382,10 @@ namespace {{packageName}}.Client
var signedString = System.Convert.ToBase64String(derBytes);
return signedString;
- {{/net60OrLater}}
- {{^net60OrLater}}
+#endif
+#if !NET6_0_OR_GREATER
throw new Exception("ECDSA signing is supported only on NETCOREAPP3_0 and above");
- {{/net60OrLater}}
+#endif
}
///
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache
index 1b12e4173931..634af2d43e7c 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache
@@ -164,7 +164,11 @@ namespace {{packageName}}.{{clientPackage}}
///
///
///
- bool Try{{.}}({{#net60OrLater}}[NotNullWhen(true)]{{/net60OrLater}}out TType{{nrt?}} result);
+ bool Try{{.}}(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out TType{{nrt?}} result);
}
{{/x-http-statuses-with-return}}
}
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache
index 96bedfa464ec..69a673e0c7c3 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache
@@ -1,4 +1,9 @@
// This logic may be modified with the AsModel.mustache template
return Is{{vendorExtensions.x-http-status}}
? System.Text.Json.JsonSerializer.Deserialize<{{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}>(RawContent, _jsonSerializerOptions)
- : {{#net60OrLater}}null{{/net60OrLater}}{{^net60OrLater}}default{{/net60OrLater}};
+ :
+#if NET6_0_OR_GREATER
+ null;
+#else
+ default;
+#endif
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache
index 03d0daf81986..a1f072de3f06 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache
@@ -107,7 +107,15 @@ using System.Runtime.CompilerServices;
///
///
///
- public static bool TryDeserialize(string json, JsonSerializerOptions options, {{#net60OrLater}}[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] {{/net60OrLater}}out T{{#nrt}}{{#net60OrLater}}?{{/net60OrLater}}{{/nrt}} result)
+ public static bool TryDeserialize(string json, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T{{#nrt}}
+#if NET6_0_OR_GREATER
+ ?
+#endif
+ {{/nrt}} result)
{
try
{
@@ -129,7 +137,15 @@ using System.Runtime.CompilerServices;
///
///
///
- public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, {{#net60OrLater}}[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] {{/net60OrLater}}out T{{#nrt}}{{#net60OrLater}}?{{/net60OrLater}}{{/nrt}} result)
+ public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T{{#nrt}}
+#if NET6_0_OR_GREATER
+ ?
+#endif
+ {{/nrt}} result)
{
try
{
@@ -176,10 +192,10 @@ using System.Runtime.CompilerServices;
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString(format);
- {{#net60OrLater}}
+#if NET6_0_OR_GREATER
if (obj is DateOnly dateOnly)
return dateOnly.ToString(format);
- {{/net60OrLater}}
+#endif
if (obj is bool boolean)
return boolean
? "true"
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache
index 1333f0e67ea2..cd8f3ce98d31 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache
@@ -54,7 +54,7 @@ namespace {{packageName}}.{{clientPackage}}
{{/isEnum}}
{{/model}}
{{/models}}
- JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new{{^net60OrLater}} JsonSerializerOptionsProvider{{/net60OrLater}}(_jsonOptions);
+ JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions);
_services.AddSingleton(jsonSerializerOptionsProvider);
{{#useSourceGeneration}}
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HttpSigningConfiguration.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HttpSigningConfiguration.mustache
index 5e0f7739df06..273b70a379be 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HttpSigningConfiguration.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HttpSigningConfiguration.mustache
@@ -272,7 +272,7 @@ namespace {{packageName}}.{{clientPackage}}
///
private string GetECDSASignature(byte[] dataToSign)
{
- {{#net60OrLater}}
+#if NET6_0_OR_GREATER
if (!File.Exists(KeyFilePath))
throw new Exception("key file path does not exist.");
@@ -310,10 +310,10 @@ namespace {{packageName}}.{{clientPackage}}
var signedString = System.Convert.ToBase64String(derBytes);
return signedString;
- {{/net60OrLater}}
- {{^net60OrLater}}
+#endif
+#if !NET6_0_OR_GREATER
throw new Exception("ECDSA signing is supported only on NETCOREAPP3_0 and above");
- {{/net60OrLater}}
+#endif
}
private byte[] ConvertToECDSAANS1Format(byte[] signedBytes)
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache
index b33115f0a5e1..1e5f688a90bf 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache
@@ -562,7 +562,11 @@ namespace {{packageName}}.{{apiPackage}}
tokenBaseLocalVars.Add(httpSignatureTokenLocalVar{{-index}});
if (httpRequestMessageLocalVar.Content != null) {
- string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync({{#net60OrLater}}cancellationToken{{/net60OrLater}}).ConfigureAwait(false);
+ string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
httpSignatureTokenLocalVar{{-index}}.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken);
}
@@ -607,23 +611,25 @@ namespace {{packageName}}.{{apiPackage}}
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
{{/-first}}
{{/produces}}
- {{#net60OrLater}}
-
+#if NET6_0_OR_GREATER
httpRequestMessageLocalVar.Method = HttpMethod.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}};
- {{/net60OrLater}}
- {{^net60OrLater}}
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("{{#lambda.uppercase}}{{httpMethod}}{{/lambda.uppercase}}");
- {{/net60OrLater}}
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync({{#net60OrLater}}cancellationToken{{/net60OrLater}}).ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger<{{#vendorExtensions.x-duplicates}}{{.}}.{{/vendorExtensions.x-duplicates}}{{operationId}}ApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<{{#vendorExtensions.x-duplicates}}{{.}}.{{/vendorExtensions.x-duplicates}}{{operationId}}ApiResponse>();
- {{#vendorExtensions.x-duplicates}}{{.}}.{{/vendorExtensions.x-duplicates}}{{operationId}}ApiResponse apiResponseLocalVar = new{{^net60OrLater}} {{operationId}}ApiResponse{{/net60OrLater}}(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "{{{path}}}", requestedAtLocalVar, _jsonSerializerOptions);
+ {{#vendorExtensions.x-duplicates}}{{.}}.{{/vendorExtensions.x-duplicates}}{{operationId}}ApiResponse apiResponseLocalVar = new {{#vendorExtensions.x-duplicates}}{{.}}.{{/vendorExtensions.x-duplicates}}{{operationId}}ApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "{{{path}}}", requestedAtLocalVar, _jsonSerializerOptions);
After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}});
@@ -761,7 +767,11 @@ namespace {{packageName}}.{{apiPackage}}
///
///
///
- public bool Try{{vendorExtensions.x-http-status}}({{#net60OrLater}}[NotNullWhen(true)]{{/net60OrLater}}out {{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}{{#nrt}}?{{/nrt}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} result)
+ public bool Try{{vendorExtensions.x-http-status}}(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out {{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}{{#nrt}}?{{/nrt}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} result)
{
result = null;
diff --git a/modules/openapi-generator/src/main/resources/csharp/netcore_project.mustache b/modules/openapi-generator/src/main/resources/csharp/netcore_project.mustache
index 5769512aa877..0e551b95b9ab 100644
--- a/modules/openapi-generator/src/main/resources/csharp/netcore_project.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/netcore_project.mustache
@@ -1,5 +1,4 @@
-
{{#useGenericHost}}
true {{/useGenericHost}}{{^useGenericHost}}
false{{/useGenericHost}}
@@ -24,6 +23,16 @@
false
+
+
+ true
+
+
+ true
+
+
+
+
{{#useCompareNetObjects}}
@@ -33,52 +42,42 @@
{{/useGenericHost}}
{{#useRestSharp}}
-
+
+
{{/useRestSharp}}
{{#useGenericHost}}
-
-
+
+
+
{{#supportsRetry}}
-
+
{{/supportsRetry}}
{{#net80OrLater}}
{{/net80OrLater}}
{{^net60OrLater}}
- {{#net47OrLater}}
-
- {{/net47OrLater}}
{{/net60OrLater}}
{{/useGenericHost}}
{{^useGenericHost}}
{{#supportsRetry}}
-
+
{{/supportsRetry}}
{{/useGenericHost}}
- {{#validatable}}
- {{^net60OrLater}}
+
+{{#validatable}}
+
- {{/net60OrLater}}
- {{/validatable}}
+{{/validatable}}
-{{^useGenericHost}}
-
- {{^net60OrLater}}
+
- {{/net60OrLater}}
- {{#net48}}
-
- {{/net48}}
+
+
- {{^net60OrLater}}
-
- {{/net60OrLater}}
- {{#net48}}
-
- {{/net48}}
+
+
-{{/useGenericHost}}
{{>netcore_project.additions}}
diff --git a/modules/openapi-generator/src/main/resources/csharp/netcore_testproject.mustache b/modules/openapi-generator/src/main/resources/csharp/netcore_testproject.mustache
index eb8bd548d1e0..4b108acaa81e 100644
--- a/modules/openapi-generator/src/main/resources/csharp/netcore_testproject.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/netcore_testproject.mustache
@@ -9,9 +9,9 @@
-
-
-
+
+
+
diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/CustomTest.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/CustomTest.cs
index 06b930205b5c..433a84504410 100644
--- a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/CustomTest.cs
+++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/CustomTest.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json.Linq;
+using Newtonsoft.Json.Linq;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
using System;
diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/EchoServerResponseParser.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/EchoServerResponseParser.cs
index f87dae4ed12e..0f5beeded3c2 100644
--- a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/EchoServerResponseParser.cs
+++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/EchoServerResponseParser.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
index a381e6a2f3cf..3bc135471dba 100644
--- a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
@@ -9,8 +9,8 @@
-
-
+
+
diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ApiClient.cs
index 655b101ecf78..362f3002dd53 100644
--- a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ApiClient.cs
+++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ApiClient.cs
@@ -23,6 +23,9 @@
using System.Threading;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
+#if !NET6_0_OR_GREATER
+using System.Web;
+#endif
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using RestSharp;
diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ClientUtils.cs
index 116c891b4646..ac4a12b746dc 100644
--- a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -101,12 +101,14 @@ public static string ParameterToString(object obj, IReadableConfiguration config
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
+#if NET6_0_OR_GREATER
if (obj is DateOnly dateOnly)
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15
return dateOnly.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
+#endif
if (obj is bool boolean)
return boolean ? "true" : "false";
if (obj is ICollection collection) {
diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Org.OpenAPITools.csproj
index a5a6bf6200b9..4a5f5a0cc9c3 100644
--- a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Org.OpenAPITools.csproj
+++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Org.OpenAPITools.csproj
@@ -1,5 +1,4 @@
-
false
net6.0
@@ -21,15 +20,34 @@
false
+
+
+ true
+
+
+ true
+
+
+
+
-
-
+
+
+
-
+
+
+
+
+
+
+
+
+
diff --git a/samples/client/others/csharp-complex-files/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/others/csharp-complex-files/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
index 66dc542c5c2c..8fd7adbef647 100644
--- a/samples/client/others/csharp-complex-files/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+++ b/samples/client/others/csharp-complex-files/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
@@ -8,9 +8,9 @@
-
-
-
+
+
+
diff --git a/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs
index 91b7422b713e..7a7b6ef2098d 100644
--- a/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs
+++ b/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs
@@ -22,7 +22,9 @@
using System.Threading;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
+#if !NET6_0_OR_GREATER
using System.Web;
+#endif
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using RestSharp;
diff --git a/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ClientUtils.cs
index 510c80551eb5..407da685293f 100644
--- a/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -116,6 +116,14 @@ public static string ParameterToString(object obj, IReadableConfiguration config
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
+#if NET6_0_OR_GREATER
+ if (obj is DateOnly dateOnly)
+ // Return a formatted date string - Can be customized with Configuration.DateTimeFormat
+ // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
+ // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
+ // For example: 2009-06-15
+ return dateOnly.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
+#endif
if (obj is bool boolean)
return boolean ? "true" : "false";
if (obj is ICollection collection) {
diff --git a/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Org.OpenAPITools.csproj
index 05f8f0bf135f..ef7e07f7ec0d 100644
--- a/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Org.OpenAPITools.csproj
+++ b/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Org.OpenAPITools.csproj
@@ -1,5 +1,4 @@
-
false
netstandard2.0
@@ -20,19 +19,35 @@
false
+
+
+ true
+
+
+ true
+
+
+
+
-
-
+
+
+
+
+
-
+
+
+
-
+
+
diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
index 05ce7e5830d8..67a08dd23ebd 100644
--- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
@@ -9,8 +9,8 @@
-
-
+
+
diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKEYSApi.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKEYSApi.cs
index a69943340cfd..394f121b3ce2 100644
--- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKEYSApi.cs
+++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKEYSApi.cs
@@ -234,18 +234,25 @@ public async Task GetApiKeysIdAsync(int id, System.Thr
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Bid%7D", Uri.EscapeDataString(id.ToString()));
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
-
+#if NET6_0_OR_GREATER
httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
+ httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
- GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
+ GetApiKeysIdApiResponse apiResponseLocalVar = new GetApiKeysIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
AfterGetApiKeysIdDefaultImplementation(apiResponseLocalVar, id);
diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKeys0Api.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKeys0Api.cs
index cfa1ca9243d7..a94e240b04b0 100644
--- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKeys0Api.cs
+++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/APIKeys0Api.cs
@@ -222,18 +222,25 @@ public async Task GetApiKeysIdAsync(int id, System.Thr
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Bid%7D", Uri.EscapeDataString(id.ToString()));
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
-
+#if NET6_0_OR_GREATER
httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
+ httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
- APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
+ APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new APIKEYSApi.GetApiKeysIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
AfterGetApiKeysIdDefaultImplementation(apiResponseLocalVar, id);
diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/ApiKeys1Api.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/ApiKeys1Api.cs
index ffce7ebc04e0..ffe4572e649e 100644
--- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/ApiKeys1Api.cs
+++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Api/ApiKeys1Api.cs
@@ -222,18 +222,25 @@ public async Task GetApiKeysIdAsync(int id, System.Thr
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Bid%7D", Uri.EscapeDataString(id.ToString()));
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
-
+#if NET6_0_OR_GREATER
httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
+ httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
- APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
+ APIKEYSApi.GetApiKeysIdApiResponse apiResponseLocalVar = new APIKEYSApi.GetApiKeysIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/api_keys/{id}", requestedAtLocalVar, _jsonSerializerOptions);
AfterGetApiKeysIdDefaultImplementation(apiResponseLocalVar, id);
diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/ClientUtils.cs
index a312a586bfa5..93a27a5b6fa5 100644
--- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -73,7 +73,15 @@ public static string ApiKeyHeaderToString(ApiKeyHeader value)
///
///
///
- public static bool TryDeserialize(string json, JsonSerializerOptions options, [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? result)
+ public static bool TryDeserialize(string json, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T
+#if NET6_0_OR_GREATER
+ ?
+#endif
+ result)
{
try
{
@@ -95,7 +103,15 @@ public static bool TryDeserialize(string json, JsonSerializerOptions options,
///
///
///
- public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? result)
+ public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T
+#if NET6_0_OR_GREATER
+ ?
+#endif
+ result)
{
try
{
@@ -142,8 +158,10 @@ public static string SanitizeFilename(string filename)
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString(format);
+#if NET6_0_OR_GREATER
if (obj is DateOnly dateOnly)
return dateOnly.ToString(format);
+#endif
if (obj is bool boolean)
return boolean
? "true"
diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/HostConfiguration.cs
index c1f92ea60d77..b8a1daa558d9 100644
--- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/HostConfiguration.cs
+++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/HostConfiguration.cs
@@ -43,7 +43,7 @@ public HostConfiguration(IServiceCollection services)
_jsonOptions.Converters.Add(new DateTimeNullableJsonConverter());
_jsonOptions.Converters.Add(new DateOnlyJsonConverter());
_jsonOptions.Converters.Add(new DateOnlyNullableJsonConverter());
- JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions);
+ JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions);
_services.AddSingleton(jsonSerializerOptionsProvider);
_services.AddSingleton();
_services.AddSingleton();
diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Org.OpenAPITools.csproj
index 9f99b6957b6d..517c0d87662e 100644
--- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Org.OpenAPITools.csproj
+++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Org.OpenAPITools.csproj
@@ -1,5 +1,4 @@
-
true
net8.0
@@ -21,11 +20,34 @@
false
+
+
+ true
+
+
+ true
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
index 6e2e462b8a72..ef4192ba81be 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs
index 4e25fbff5735..41c6c080c5cb 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs
@@ -247,13 +247,21 @@ public async Task ListAsync(string personId, System.Threading.
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -318,7 +326,12 @@ public Org.OpenAPITools.Model.Person Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -326,7 +339,11 @@ public Org.OpenAPITools.Model.Person Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.Person result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.Person result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs
index 0d99f099669a..bde9bce6add4 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs
@@ -165,6 +165,10 @@ public interface IOk : IApiResponse
///
///
///
- bool TryOk(out TType result);
+ bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out TType result);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs
index 048a2ccaea85..e3d593f76e02 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -60,7 +60,11 @@ static ClientUtils()
///
///
///
- public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(string json, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -82,7 +86,11 @@ public static bool TryDeserialize(string json, JsonSerializerOptions options,
///
///
///
- public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -129,6 +137,10 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString(format);
+#if NET6_0_OR_GREATER
+ if (obj is DateOnly dateOnly)
+ return dateOnly.ToString(format);
+#endif
if (obj is bool boolean)
return boolean
? "true"
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj
index c6529e054024..52391e3b0af2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj
@@ -1,5 +1,4 @@
-
true
net47
@@ -20,14 +19,35 @@
false
+
+
+ true
+
+
+ true
+
+
+
+
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
index 6e2e462b8a72..ef4192ba81be 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs
index c2a2d862a621..7f4f27d1b912 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs
@@ -221,13 +221,21 @@ public async Task RootGetAsync(System.Threading.Cancellatio
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -292,7 +300,12 @@ public Org.OpenAPITools.Model.Fruit Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -300,7 +313,11 @@ public Org.OpenAPITools.Model.Fruit Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.Fruit result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.Fruit result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs
index 96bba8467893..0ce5f752eb85 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs
@@ -165,6 +165,10 @@ public interface IOk : IApiResponse
///
///
///
- bool TryOk(out TType result);
+ bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out TType result);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs
index 00ce4324ade8..96a62f7df523 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -60,7 +60,11 @@ static ClientUtils()
///
///
///
- public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(string json, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -82,7 +86,11 @@ public static bool TryDeserialize(string json, JsonSerializerOptions options,
///
///
///
- public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -129,6 +137,10 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString(format);
+#if NET6_0_OR_GREATER
+ if (obj is DateOnly dateOnly)
+ return dateOnly.ToString(format);
+#endif
if (obj is bool boolean)
return boolean
? "true"
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj
index c6529e054024..52391e3b0af2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj
@@ -1,5 +1,4 @@
-
true
net47
@@ -20,14 +19,35 @@
false
+
+
+ true
+
+
+ true
+
+
+
+
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
index 6e2e462b8a72..ef4192ba81be 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs
index c2a2d862a621..7f4f27d1b912 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs
@@ -221,13 +221,21 @@ public async Task RootGetAsync(System.Threading.Cancellatio
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -292,7 +300,12 @@ public Org.OpenAPITools.Model.Fruit Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -300,7 +313,11 @@ public Org.OpenAPITools.Model.Fruit Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.Fruit result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.Fruit result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs
index 96bba8467893..0ce5f752eb85 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs
@@ -165,6 +165,10 @@ public interface IOk : IApiResponse
///
///
///
- bool TryOk(out TType result);
+ bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out TType result);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs
index c0472474f383..0984861c0e2c 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -45,7 +45,11 @@ public static class ClientUtils
///
///
///
- public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(string json, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -67,7 +71,11 @@ public static bool TryDeserialize(string json, JsonSerializerOptions options,
///
///
///
- public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -114,6 +122,10 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString(format);
+#if NET6_0_OR_GREATER
+ if (obj is DateOnly dateOnly)
+ return dateOnly.ToString(format);
+#endif
if (obj is bool boolean)
return boolean
? "true"
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Org.OpenAPITools.csproj
index 201640a24d33..846c8863b9ad 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Org.OpenAPITools.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Org.OpenAPITools.csproj
@@ -1,5 +1,4 @@
-
true
net47
@@ -20,13 +19,34 @@
false
+
+
+ true
+
+
+ true
+
+
+
+
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
index 6e2e462b8a72..ef4192ba81be 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs
index 1fd1ffef4feb..85bc1aac5dab 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs
@@ -294,13 +294,21 @@ public async Task Call123TestSpecialTagsAsyn
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Patch;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PATCH");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -365,7 +373,12 @@ public Org.OpenAPITools.Model.ModelClient Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -373,7 +386,11 @@ public Org.OpenAPITools.Model.ModelClient Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ModelClient result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ModelClient result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs
index 879c3ecdb9ad..6277311b345b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs
@@ -470,13 +470,21 @@ public async Task FooGetAsync(System.Threading.CancellationT
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -541,7 +549,12 @@ public Org.OpenAPITools.Model.FooGetDefaultResponse Default()
// This logic may be modified with the AsModel.mustache template
return IsDefault
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -549,7 +562,11 @@ public Org.OpenAPITools.Model.FooGetDefaultResponse Default()
///
///
///
- public bool TryDefault(out Org.OpenAPITools.Model.FooGetDefaultResponse result)
+ public bool TryDefault(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.FooGetDefaultResponse result)
{
result = null;
@@ -697,13 +714,21 @@ public async Task GetCountryAsync(string country, System
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -858,13 +883,21 @@ public async Task HelloAsync(System.Threading.CancellationTok
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -929,7 +962,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -937,7 +975,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -1051,13 +1093,21 @@ public async Task RolesReportGetAsync(System.Threadi
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1122,7 +1172,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1130,7 +1185,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -1244,13 +1303,21 @@ public async Task TestAsync(System.Threading.CancellationToken
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1315,7 +1382,12 @@ public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1323,7 +1395,11 @@ public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs
index 38f936207662..4a95c19fae8f 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs
@@ -1379,13 +1379,21 @@ public async Task FakeHealthGetAsync(System.Threading
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1450,7 +1458,12 @@ public Org.OpenAPITools.Model.HealthCheckResult Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1458,7 +1471,11 @@ public Org.OpenAPITools.Model.HealthCheckResult Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.HealthCheckResult result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.HealthCheckResult result)
{
result = null;
@@ -1596,13 +1613,21 @@ public async Task FakeOuterBooleanSeriali
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1667,7 +1692,12 @@ public FakeOuterBooleanSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1675,7 +1705,11 @@ public FakeOuterBooleanSerializeApiResponse(ILogger
///
///
- public bool TryOk(out bool? result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out bool? result)
{
result = null;
@@ -1826,13 +1860,21 @@ public async Task FakeOuterCompositeSer
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1897,7 +1939,12 @@ public Org.OpenAPITools.Model.OuterComposite Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1905,7 +1952,11 @@ public Org.OpenAPITools.Model.OuterComposite Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.OuterComposite result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.OuterComposite result)
{
result = null;
@@ -2043,13 +2094,21 @@ public async Task FakeOuterNumberSerialize
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2114,7 +2173,12 @@ public FakeOuterNumberSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2122,7 +2186,11 @@ public FakeOuterNumberSerializeApiResponse(ILogger
///
///
- public bool TryOk(out decimal? result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out decimal? result)
{
result = null;
@@ -2285,13 +2353,21 @@ public async Task FakeOuterStringSerialize
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2356,7 +2432,12 @@ public string Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2364,7 +2445,11 @@ public string Ok()
///
///
///
- public bool TryOk(out string result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out string result)
{
result = null;
@@ -2478,13 +2563,21 @@ public async Task GetArrayOfEnumsAsync(System.Threa
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2549,7 +2642,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2557,7 +2655,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -2671,13 +2773,21 @@ public async Task GetMixedAnyOfAsync(System.Threading
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2742,7 +2852,12 @@ public Org.OpenAPITools.Model.MixedAnyOf Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2750,7 +2865,11 @@ public Org.OpenAPITools.Model.MixedAnyOf Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.MixedAnyOf result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.MixedAnyOf result)
{
result = null;
@@ -2864,13 +2983,21 @@ public async Task GetMixedOneOfAsync(System.Threading
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2935,7 +3062,12 @@ public Org.OpenAPITools.Model.MixedOneOf Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2943,7 +3075,11 @@ public Org.OpenAPITools.Model.MixedOneOf Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.MixedOneOf result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.MixedOneOf result)
{
result = null;
@@ -3085,13 +3221,21 @@ public async Task TestAdditionalP
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -3274,13 +3418,21 @@ public async Task TestBodyWithFileSchemaAsyn
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Put;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PUT");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -3479,13 +3631,21 @@ public async Task TestBodyWithQueryParamsAs
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Put;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PUT");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -3676,13 +3836,21 @@ public async Task TestClientModelAsync(ModelClient
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Patch;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PATCH");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -3747,7 +3915,12 @@ public Org.OpenAPITools.Model.ModelClient Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -3755,7 +3928,11 @@ public Org.OpenAPITools.Model.ModelClient Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ModelClient result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ModelClient result)
{
result = null;
@@ -4044,13 +4221,21 @@ public async Task TestEndpointParametersAsyn
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -4323,13 +4508,21 @@ public async Task TestEnumParametersAsync(Option
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -4546,13 +4739,21 @@ public async Task TestGroupParametersAsync(bool
tokenBaseLocalVars.Add(bearerTokenLocalVar1);
bearerTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, "");
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Delete;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("DELETE");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -4739,13 +4940,21 @@ public async Task TestInlineAddition
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -4928,13 +5137,21 @@ public async Task TestInline
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -5135,13 +5352,21 @@ public async Task TestJsonFormDataAsync(string par
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -5400,13 +5625,21 @@ public async Task TestQueryParam
uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString();
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Put;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PUT");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -5589,13 +5822,21 @@ public async Task TestStringMapReferenceAsyn
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs
index 010a227c8b27..846351642739 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs
@@ -303,13 +303,21 @@ public async Task TestClassnameAsync(ModelClient mode
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Patch;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PATCH");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -378,7 +386,12 @@ public Org.OpenAPITools.Model.ModelClient Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -386,7 +399,11 @@ public Org.OpenAPITools.Model.ModelClient Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ModelClient result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ModelClient result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs
index 6f1add615397..6c0676ac7785 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs
@@ -793,7 +793,11 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc
tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2);
if (httpRequestMessageLocalVar.Content != null) {
- string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken);
}
@@ -808,13 +812,21 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1004,13 +1016,21 @@ public async Task DeletePetAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1202,7 +1222,11 @@ public async Task FindPetsByStatusAsync(List FindPetsByStatusAsync(List apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1291,7 +1323,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1299,7 +1336,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -1478,7 +1519,11 @@ public async Task FindPetsByTagsAsync(List t
tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2);
if (httpRequestMessageLocalVar.Content != null) {
- string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken);
}
@@ -1492,13 +1537,21 @@ public async Task FindPetsByTagsAsync(List t
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1567,7 +1620,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1575,7 +1633,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -1720,13 +1782,21 @@ public async Task GetPetByIdAsync(long petId, System.Thr
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1795,7 +1865,12 @@ public Org.OpenAPITools.Model.Pet Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1803,7 +1878,11 @@ public Org.OpenAPITools.Model.Pet Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.Pet result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.Pet result)
{
result = null;
@@ -1960,7 +2039,11 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin
tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2);
if (httpRequestMessageLocalVar.Content != null) {
- string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken);
}
@@ -1975,13 +2058,21 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Put;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PUT");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2212,13 +2303,21 @@ public async Task UpdatePetWithFormAsync(long pet
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2445,13 +2544,21 @@ public async Task UploadFileAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2520,7 +2627,12 @@ public Org.OpenAPITools.Model.ApiResponse Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2528,7 +2640,11 @@ public Org.OpenAPITools.Model.ApiResponse Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ApiResponse result)
{
result = null;
@@ -2710,13 +2826,21 @@ public async Task UploadFileWithRequired
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2785,7 +2909,12 @@ public Org.OpenAPITools.Model.ApiResponse Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2793,7 +2922,11 @@ public Org.OpenAPITools.Model.ApiResponse Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ApiResponse result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs
index 2cb0523731c5..19048fd0b3dd 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs
@@ -460,13 +460,21 @@ public async Task DeleteOrderAsync(string orderId, Syst
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Border_id%7D", Uri.EscapeDataString(orderId.ToString()));
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Delete;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("DELETE");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -632,13 +640,21 @@ public async Task GetInventoryAsync(System.Threading.C
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -707,7 +723,12 @@ public Dictionary Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -715,7 +736,11 @@ public Dictionary Ok()
///
///
///
- public bool TryOk(out Dictionary result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Dictionary result)
{
result = null;
@@ -841,13 +866,21 @@ public async Task GetOrderByIdAsync(long orderId, Syst
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -912,7 +945,12 @@ public Org.OpenAPITools.Model.Order Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -920,7 +958,11 @@ public Org.OpenAPITools.Model.Order Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.Order result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.Order result)
{
result = null;
@@ -1083,13 +1125,21 @@ public async Task PlaceOrderAsync(Order order, System.Th
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1154,7 +1204,12 @@ public Org.OpenAPITools.Model.Order Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1162,7 +1217,11 @@ public Org.OpenAPITools.Model.Order Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.Order result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.Order result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/UserApi.cs
index 46a87aed2c07..bb6d746bb65b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/UserApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/UserApi.cs
@@ -715,13 +715,21 @@ public async Task CreateUserAsync(User user, System.Thre
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -904,13 +912,21 @@ public async Task CreateUsersWithArrayInp
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1093,13 +1109,21 @@ public async Task CreateUsersWithListInput
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1269,13 +1293,21 @@ public async Task DeleteUserAsync(string username, Syste
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString()));
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Delete;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("DELETE");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1461,13 +1493,21 @@ public async Task GetUserByNameAsync(string username,
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1532,7 +1572,12 @@ public Org.OpenAPITools.Model.User Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1540,7 +1585,11 @@ public Org.OpenAPITools.Model.User Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.User result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.User result)
{
result = null;
@@ -1588,7 +1637,12 @@ public Org.OpenAPITools.Model.User CustomHttpStatusCode599()
// This logic may be modified with the AsModel.mustache template
return IsCustomHttpStatusCode599
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1596,7 +1650,11 @@ public Org.OpenAPITools.Model.User CustomHttpStatusCode599()
///
///
///
- public bool TryCustomHttpStatusCode599(out Org.OpenAPITools.Model.User result)
+ public bool TryCustomHttpStatusCode599(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.User result)
{
result = null;
@@ -1751,13 +1809,21 @@ public async Task LoginUserAsync(string password, string
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1822,7 +1888,12 @@ public string Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1830,7 +1901,11 @@ public string Ok()
///
///
///
- public bool TryOk(out string result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out string result)
{
result = null;
@@ -1941,13 +2016,21 @@ public async Task LogoutUserAsync(System.Threading.Cance
uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/logout";
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2141,13 +2224,21 @@ public async Task UpdateUserAsync(User user, string user
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Put;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PUT");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs
index 416f7a04e3d6..bd5767856501 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs
@@ -165,7 +165,11 @@ public interface ICustomHttpStatusCode599 : IApiResponse
///
///
///
- bool TryCustomHttpStatusCode599(out TType result);
+ bool TryCustomHttpStatusCode599(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out TType result);
}
///
@@ -185,7 +189,11 @@ public interface IOk : IApiResponse
///
///
///
- bool TryOk(out TType result);
+ bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out TType result);
}
///
@@ -205,6 +213,10 @@ public interface IDefault : IApiResponse
///
///
///
- bool TryDefault(out TType result);
+ bool TryDefault(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out TType result);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs
index 599ba401258a..a4c5c4a44168 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -94,7 +94,11 @@ public static string ApiKeyHeaderToString(ApiKeyHeader value)
///
///
///
- public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(string json, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -116,7 +120,11 @@ public static bool TryDeserialize(string json, JsonSerializerOptions options,
///
///
///
- public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -163,6 +171,10 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString(format);
+#if NET6_0_OR_GREATER
+ if (obj is DateOnly dateOnly)
+ return dateOnly.ToString(format);
+#endif
if (obj is bool boolean)
return boolean
? "true"
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs
index 5c4159491eec..cbcebbca1085 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs
@@ -276,7 +276,48 @@ private string GetRSASignature(byte[] stringToSign)
///
private string GetECDSASignature(byte[] dataToSign)
{
+#if NET6_0_OR_GREATER
+ if (!File.Exists(KeyFilePath))
+ throw new Exception("key file path does not exist.");
+
+ var ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----";
+ var ecKeyFooter = "-----END EC PRIVATE KEY-----";
+ var keyStr = File.ReadAllText(KeyFilePath);
+ var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim();
+ var keyBytes = System.Convert.FromBase64String(ecKeyBase64String);
+ var ecdsa = ECDsa.Create();
+
+ var byteCount = 0;
+ if (KeyPassPhrase != null)
+ {
+ IntPtr unmanagedString = IntPtr.Zero;
+ try
+ {
+ // convert secure string to byte array
+ unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(KeyPassPhrase);
+
+ string ptrToStringUni = Marshal.PtrToStringUni(unmanagedString) ?? throw new NullReferenceException();
+
+ ecdsa.ImportEncryptedPkcs8PrivateKey(Encoding.UTF8.GetBytes(ptrToStringUni), keyBytes, out byteCount);
+ }
+ finally
+ {
+ if (unmanagedString != IntPtr.Zero)
+ Marshal.ZeroFreeBSTR(unmanagedString);
+ }
+ }
+ else
+ ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount);
+
+ var signedBytes = ecdsa.SignHash(dataToSign);
+ var derBytes = ConvertToECDSAANS1Format(signedBytes);
+ var signedString = System.Convert.ToBase64String(derBytes);
+
+ return signedString;
+#endif
+#if !NET6_0_OR_GREATER
throw new Exception("ECDSA signing is supported only on NETCOREAPP3_0 and above");
+#endif
}
private byte[] ConvertToECDSAANS1Format(byte[] signedBytes)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj
index c6529e054024..52391e3b0af2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj
@@ -1,5 +1,4 @@
-
true
net47
@@ -20,14 +19,35 @@
false
+
+
+ true
+
+
+ true
+
+
+
+
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
index 6e2e462b8a72..ef4192ba81be 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs
index c2a2d862a621..7f4f27d1b912 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs
@@ -221,13 +221,21 @@ public async Task RootGetAsync(System.Threading.Cancellatio
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -292,7 +300,12 @@ public Org.OpenAPITools.Model.Fruit Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -300,7 +313,11 @@ public Org.OpenAPITools.Model.Fruit Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.Fruit result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.Fruit result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs
index 96bba8467893..0ce5f752eb85 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs
@@ -165,6 +165,10 @@ public interface IOk : IApiResponse
///
///
///
- bool TryOk(out TType result);
+ bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out TType result);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs
index 00ce4324ade8..96a62f7df523 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs
@@ -60,7 +60,11 @@ static ClientUtils()
///
///
///
- public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(string json, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -82,7 +86,11 @@ public static bool TryDeserialize(string json, JsonSerializerOptions options,
///
///
///
- public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result)
+ public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options,
+#if NET6_0_OR_GREATER
+ [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
+#endif
+ out T result)
{
try
{
@@ -129,6 +137,10 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString(format);
+#if NET6_0_OR_GREATER
+ if (obj is DateOnly dateOnly)
+ return dateOnly.ToString(format);
+#endif
if (obj is bool boolean)
return boolean
? "true"
diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj
index c6529e054024..52391e3b0af2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj
@@ -1,5 +1,4 @@
-
true
net47
@@ -20,14 +19,35 @@
false
+
+
+ true
+
+
+ true
+
+
+
+
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
index 6e2e462b8a72..ef4192ba81be 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs
index 1fd1ffef4feb..85bc1aac5dab 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs
@@ -294,13 +294,21 @@ public async Task Call123TestSpecialTagsAsyn
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Patch;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PATCH");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -365,7 +373,12 @@ public Org.OpenAPITools.Model.ModelClient Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -373,7 +386,11 @@ public Org.OpenAPITools.Model.ModelClient Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ModelClient result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ModelClient result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs
index 879c3ecdb9ad..6277311b345b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs
@@ -470,13 +470,21 @@ public async Task FooGetAsync(System.Threading.CancellationT
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -541,7 +549,12 @@ public Org.OpenAPITools.Model.FooGetDefaultResponse Default()
// This logic may be modified with the AsModel.mustache template
return IsDefault
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -549,7 +562,11 @@ public Org.OpenAPITools.Model.FooGetDefaultResponse Default()
///
///
///
- public bool TryDefault(out Org.OpenAPITools.Model.FooGetDefaultResponse result)
+ public bool TryDefault(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.FooGetDefaultResponse result)
{
result = null;
@@ -697,13 +714,21 @@ public async Task GetCountryAsync(string country, System
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -858,13 +883,21 @@ public async Task HelloAsync(System.Threading.CancellationTok
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -929,7 +962,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -937,7 +975,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -1051,13 +1093,21 @@ public async Task RolesReportGetAsync(System.Threadi
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1122,7 +1172,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1130,7 +1185,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -1244,13 +1303,21 @@ public async Task TestAsync(System.Threading.CancellationToken
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1315,7 +1382,12 @@ public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1323,7 +1395,11 @@ public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs
index b3b0cf5352ff..ca72c476a8bc 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs
@@ -1379,13 +1379,21 @@ public async Task FakeHealthGetAsync(System.Threading
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1450,7 +1458,12 @@ public Org.OpenAPITools.Model.HealthCheckResult Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1458,7 +1471,11 @@ public Org.OpenAPITools.Model.HealthCheckResult Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.HealthCheckResult result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.HealthCheckResult result)
{
result = null;
@@ -1596,13 +1613,21 @@ public async Task FakeOuterBooleanSeriali
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1667,7 +1692,12 @@ public FakeOuterBooleanSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1675,7 +1705,11 @@ public FakeOuterBooleanSerializeApiResponse(ILogger
///
///
- public bool TryOk(out bool? result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out bool? result)
{
result = null;
@@ -1826,13 +1860,21 @@ public async Task FakeOuterCompositeSer
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1897,7 +1939,12 @@ public Org.OpenAPITools.Model.OuterComposite Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1905,7 +1952,11 @@ public Org.OpenAPITools.Model.OuterComposite Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.OuterComposite result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.OuterComposite result)
{
result = null;
@@ -2043,13 +2094,21 @@ public async Task FakeOuterNumberSerialize
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2114,7 +2173,12 @@ public FakeOuterNumberSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2122,7 +2186,11 @@ public FakeOuterNumberSerializeApiResponse(ILogger
///
///
- public bool TryOk(out decimal? result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out decimal? result)
{
result = null;
@@ -2285,13 +2353,21 @@ public async Task FakeOuterStringSerialize
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2356,7 +2432,12 @@ public string Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2364,7 +2445,11 @@ public string Ok()
///
///
///
- public bool TryOk(out string result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out string result)
{
result = null;
@@ -2478,13 +2563,21 @@ public async Task GetArrayOfEnumsAsync(System.Threa
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2549,7 +2642,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2557,7 +2655,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -2671,13 +2773,21 @@ public async Task GetMixedAnyOfAsync(System.Threading
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2742,7 +2852,12 @@ public Org.OpenAPITools.Model.MixedAnyOf Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2750,7 +2865,11 @@ public Org.OpenAPITools.Model.MixedAnyOf Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.MixedAnyOf result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.MixedAnyOf result)
{
result = null;
@@ -2864,13 +2983,21 @@ public async Task GetMixedOneOfAsync(System.Threading
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2935,7 +3062,12 @@ public Org.OpenAPITools.Model.MixedOneOf Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2943,7 +3075,11 @@ public Org.OpenAPITools.Model.MixedOneOf Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.MixedOneOf result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.MixedOneOf result)
{
result = null;
@@ -3085,13 +3221,21 @@ public async Task TestAdditionalP
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -3274,13 +3418,21 @@ public async Task TestBodyWithFileSchemaAsyn
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Put;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PUT");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -3479,13 +3631,21 @@ public async Task TestBodyWithQueryParamsAs
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Put;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PUT");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -3676,13 +3836,21 @@ public async Task TestClientModelAsync(ModelClient
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Patch;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PATCH");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -3747,7 +3915,12 @@ public Org.OpenAPITools.Model.ModelClient Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -3755,7 +3928,11 @@ public Org.OpenAPITools.Model.ModelClient Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ModelClient result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ModelClient result)
{
result = null;
@@ -4044,13 +4221,21 @@ public async Task TestEndpointParametersAsyn
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -4335,13 +4520,21 @@ public async Task TestEnumParametersAsync(Option
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -4558,13 +4751,21 @@ public async Task TestGroupParametersAsync(bool
tokenBaseLocalVars.Add(bearerTokenLocalVar1);
bearerTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, "");
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Delete;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("DELETE");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -4751,13 +4952,21 @@ public async Task TestInlineAddition
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -4940,13 +5149,21 @@ public async Task TestInline
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -5147,13 +5364,21 @@ public async Task TestJsonFormDataAsync(string par
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -5412,13 +5637,21 @@ public async Task TestQueryParam
uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString();
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Put;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PUT");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -5601,13 +5834,21 @@ public async Task TestStringMapReferenceAsyn
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs
index 010a227c8b27..846351642739 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs
@@ -303,13 +303,21 @@ public async Task TestClassnameAsync(ModelClient mode
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Patch;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PATCH");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -378,7 +386,12 @@ public Org.OpenAPITools.Model.ModelClient Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -386,7 +399,11 @@ public Org.OpenAPITools.Model.ModelClient Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ModelClient result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ModelClient result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs
index e86b55647135..9cbf2bbd0852 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs
@@ -793,7 +793,11 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc
tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2);
if (httpRequestMessageLocalVar.Content != null) {
- string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken);
}
@@ -808,13 +812,21 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1004,13 +1016,21 @@ public async Task DeletePetAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1202,7 +1222,11 @@ public async Task FindPetsByStatusAsync(List FindPetsByStatusAsync(List apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1291,7 +1323,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1299,7 +1336,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -1478,7 +1519,11 @@ public async Task FindPetsByTagsAsync(List t
tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2);
if (httpRequestMessageLocalVar.Content != null) {
- string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken);
}
@@ -1492,13 +1537,21 @@ public async Task FindPetsByTagsAsync(List t
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1567,7 +1620,12 @@ public List Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1575,7 +1633,11 @@ public List Ok()
///
///
///
- public bool TryOk(out List result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out List result)
{
result = null;
@@ -1720,13 +1782,21 @@ public async Task GetPetByIdAsync(long petId, System.Thr
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -1795,7 +1865,12 @@ public Org.OpenAPITools.Model.Pet Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -1803,7 +1878,11 @@ public Org.OpenAPITools.Model.Pet Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.Pet result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.Pet result)
{
result = null;
@@ -1960,7 +2039,11 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin
tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2);
if (httpRequestMessageLocalVar.Content != null) {
- string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken);
}
@@ -1975,13 +2058,21 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Put;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("PUT");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2212,13 +2303,21 @@ public async Task UpdatePetWithFormAsync(long pet
if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2445,13 +2544,21 @@ public async Task UploadFileAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2520,7 +2627,12 @@ public Org.OpenAPITools.Model.ApiResponse Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2528,7 +2640,11 @@ public Org.OpenAPITools.Model.ApiResponse Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ApiResponse result)
{
result = null;
@@ -2710,13 +2826,21 @@ public async Task UploadFileWithRequired
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Post;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("POST");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -2785,7 +2909,12 @@ public Org.OpenAPITools.Model.ApiResponse Ok()
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions)
- : default;
+ :
+ #if NET6_0_OR_GREATER
+ null;
+ #else
+ default;
+ #endif
}
///
@@ -2793,7 +2922,11 @@ public Org.OpenAPITools.Model.ApiResponse Ok()
///
///
///
- public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result)
+ public bool TryOk(
+#if NET6_0_OR_GREATER
+ [NotNullWhen(true)]
+#endif
+ out Org.OpenAPITools.Model.ApiResponse result)
{
result = null;
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs
index 2cb0523731c5..19048fd0b3dd 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs
@@ -460,13 +460,21 @@ public async Task DeleteOrderAsync(string orderId, Syst
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Border_id%7D", Uri.EscapeDataString(orderId.ToString()));
httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Delete;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("DELETE");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger();
@@ -632,13 +640,21 @@ public async Task GetInventoryAsync(System.Threading.C
if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));
+#if NET6_0_OR_GREATER
+ httpRequestMessageLocalVar.Method = HttpMethod.Get;
+#else
httpRequestMessageLocalVar.Method = new HttpMethod("GET");
+#endif
DateTime requestedAtLocalVar = DateTime.UtcNow;
using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
- string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
+ string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(
+#if NET6_0_OR_GREATER
+ cancellationToken
+#endif
+ ).ConfigureAwait(false);
ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger