From 88158f71603da45ab9213261c520fae0fa6d9a6f Mon Sep 17 00:00:00 2001 From: Bryan Aldrich Date: Tue, 3 Dec 2024 19:27:27 -0500 Subject: [PATCH] samples update --- .../src/Org.OpenAPITools.Test/CustomTest.cs | 2 +- .../EchoServerResponseParser.cs | 2 +- .../src/Org.OpenAPITools/Client/ApiClient.cs | 3 + .../Org.OpenAPITools/Client/ClientUtils.cs | 2 + .../src/Org.OpenAPITools/Client/ApiClient.cs | 2 + .../Org.OpenAPITools/Client/ClientUtils.cs | 8 + .../src/Org.OpenAPITools/Api/APIKEYSApi.cs | 13 +- .../src/Org.OpenAPITools/Api/APIKeys0Api.cs | 13 +- .../src/Org.OpenAPITools/Api/ApiKeys1Api.cs | 13 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 22 +- .../Client/HostConfiguration.cs | 2 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 23 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 102 ++++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 317 +++++++++++++-- .../Api/FakeClassnameTags123Api.cs | 23 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 179 +++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 79 +++- .../src/Org.OpenAPITools/Api/UserApi.cs | 119 +++++- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 18 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../Client/HttpSigningConfiguration.cs | 41 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 23 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 102 ++++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 317 +++++++++++++-- .../Api/FakeClassnameTags123Api.cs | 23 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 179 +++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 79 +++- .../src/Org.OpenAPITools/Api/UserApi.cs | 119 +++++- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 18 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../Client/HttpSigningConfiguration.cs | 41 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 23 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 102 ++++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 317 +++++++++++++-- .../Api/FakeClassnameTags123Api.cs | 23 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 179 +++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 79 +++- .../src/Org.OpenAPITools/Api/UserApi.cs | 119 +++++- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 18 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../Client/HttpSigningConfiguration.cs | 41 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 23 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 102 ++++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 317 +++++++++++++-- .../Api/FakeClassnameTags123Api.cs | 23 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 179 +++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 79 +++- .../src/Org.OpenAPITools/Api/UserApi.cs | 119 +++++- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 18 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../Client/HttpSigningConfiguration.cs | 41 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 23 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 26 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 22 +- .../Client/HostConfiguration.cs | 2 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 26 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 22 +- .../Client/HostConfiguration.cs | 2 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 26 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 22 +- .../Client/HostConfiguration.cs | 2 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 116 ++++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 368 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 203 ++++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 91 ++++- .../src/Org.OpenAPITools/Api/UserApi.cs | 139 +++++-- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 18 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 14 +- .../Client/HostConfiguration.cs | 2 +- .../Client/HttpSigningConfiguration.cs | 5 + .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 116 ++++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 368 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 203 ++++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 91 ++++- .../src/Org.OpenAPITools/Api/UserApi.cs | 139 +++++-- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 18 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 22 +- .../Client/HostConfiguration.cs | 2 +- .../Client/HttpSigningConfiguration.cs | 5 + .../src/Org.OpenAPITools/Api/DefaultApi.cs | 26 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 22 +- .../Client/HostConfiguration.cs | 2 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 116 ++++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 368 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 203 ++++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 91 ++++- .../src/Org.OpenAPITools/Api/UserApi.cs | 139 +++++-- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 18 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 14 +- .../Client/HostConfiguration.cs | 2 +- .../Client/HttpSigningConfiguration.cs | 5 + .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 116 ++++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 368 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 203 ++++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 91 ++++- .../src/Org.OpenAPITools/Api/UserApi.cs | 139 +++++-- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 18 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 22 +- .../Client/HostConfiguration.cs | 2 +- .../Client/HttpSigningConfiguration.cs | 5 + .../src/Org.OpenAPITools/Api/DefaultApi.cs | 26 +- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 6 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 22 +- .../Client/HostConfiguration.cs | 2 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 23 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 102 ++++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 317 +++++++++++++-- .../Api/FakeClassnameTags123Api.cs | 23 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 179 +++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 79 +++- .../src/Org.OpenAPITools/Api/UserApi.cs | 119 +++++- .../Org.OpenAPITools/Client/ApiResponse`1.cs | 18 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 16 +- .../Client/HttpSigningConfiguration.cs | 41 ++ .../Org.OpenAPITools/Client/ClientUtils.cs | 8 + .../Client/HttpSigningConfiguration.cs | 41 ++ .../src/Org.OpenAPITools/Client/ApiClient.cs | 2 + .../Org.OpenAPITools/Client/ClientUtils.cs | 8 + .../src/Org.OpenAPITools/Client/ApiClient.cs | 2 + .../Org.OpenAPITools/Client/ClientUtils.cs | 8 + .../Client/HttpSigningConfiguration.cs | 41 ++ .../src/Org.OpenAPITools/Client/ApiClient.cs | 2 + .../Org.OpenAPITools/Client/ClientUtils.cs | 8 + .../Client/HttpSigningConfiguration.cs | 41 ++ .../src/Org.OpenAPITools/Client/ApiClient.cs | 3 + .../Org.OpenAPITools/Client/ClientUtils.cs | 2 + .../src/Org.OpenAPITools/Client/ApiClient.cs | 3 + .../Org.OpenAPITools/Client/ClientUtils.cs | 2 + .../Client/HttpSigningConfiguration.cs | 5 + .../src/Org.OpenAPITools/Client/ApiClient.cs | 3 + .../Org.OpenAPITools/Client/ClientUtils.cs | 2 + .../Client/HttpSigningConfiguration.cs | 5 + .../src/Org.OpenAPITools/Client/ApiClient.cs | 3 + .../Org.OpenAPITools/Client/ClientUtils.cs | 2 + .../src/Org.OpenAPITools/Client/ApiClient.cs | 2 + .../Org.OpenAPITools/Client/ClientUtils.cs | 8 + .../Client/HttpSigningConfiguration.cs | 41 ++ .../src/Org.OpenAPITools/Client/ApiClient.cs | 2 + .../Org.OpenAPITools/Client/ClientUtils.cs | 8 + .../Client/HttpSigningConfiguration.cs | 41 ++ .../Org.OpenAPITools/Client/ClientUtils.cs | 8 + .../Client/HttpSigningConfiguration.cs | 41 ++ 183 files changed, 8367 insertions(+), 1420 deletions(-) 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 06b930205b5cd..433a84504410f 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 f87dae4ed12e9..0f5beeded3c2b 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/Client/ApiClient.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Client/ApiClient.cs index 655b101ecf789..362f3002dd53f 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 116c891b4646b..ac4a12b746dcd 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/others/csharp-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/others/csharp-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs index 91b7422b713e5..7a7b6ef2098db 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 510c80551eb54..407da685293f0 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/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 a69943340cfd4..394f121b3ce2c 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 cfa1ca9243d77..460d35e8eadac 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 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 ffce7ebc04e0d..aea1a62eff64f 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 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 a312a586bfa53..93a27a5b6fa5d 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 c1f92ea60d770..b8a1daa558d96 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/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 4e25fbff57351..c1d9901db861e 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 0d99f099669a4..bde9bce6add4d 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 048a2ccaea859..e3d593f76e02a 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/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index c2a2d862a6211..74252a4062593 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 96bba84678931..0ce5f752eb85a 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 00ce4324ade84..96a62f7df5233 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/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs index c2a2d862a6211..74252a4062593 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 96bba84678931..0ce5f752eb85a 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 c0472474f3834..0984861c0e2c6 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/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 1fd1ffef4feb2..490d20d1a61a6 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 879c3ecdb9ad0..db3d9888945c0 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 38f9362076629..144226daaa883 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 010a227c8b275..99add155ed62b 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 6f1add6153971..a414c4420ddd5 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 2cb0523731c5f..d96b8f3f429f4 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 46a87aed2c07f..30d4f2f1aad1b 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 416f7a04e3d65..bd5767856501f 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 599ba401258a3..a4c5c4a441684 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 5c4159491eecb..cbcebbca10852 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/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs index c2a2d862a6211..74252a4062593 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 96bba84678931..0ce5f752eb85a 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 00ce4324ade84..96a62f7df5233 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/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 1fd1ffef4feb2..490d20d1a61a6 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 879c3ecdb9ad0..db3d9888945c0 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 b3b0cf5352ff5..882649ce655c3 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 010a227c8b275..99add155ed62b 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 e86b55647135d..0f1ebce150756 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 2cb0523731c5f..d96b8f3f429f4 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(); @@ -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/Petstore/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/UserApi.cs index 46a87aed2c07f..30d4f2f1aad1b 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/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/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 416f7a04e3d65..bd5767856501f 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/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/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 231c516c999c7..66f4eb2f50cf2 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/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/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 5c4159491eecb..cbcebbca10852 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/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/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs index 1662385fe8f82..395d3f77aeeab 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -221,13 +221,21 @@ public async Task NowGetAsync(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(); @@ -292,7 +300,12 @@ public Org.OpenAPITools.Model.NowGet200Response 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.NowGet200Response Ok() /// /// /// - public bool TryOk(out Org.OpenAPITools.Model.NowGet200Response result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out Org.OpenAPITools.Model.NowGet200Response result) { result = null; diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs index fe5b2fe67aa25..080ab124dd369 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/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/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs index a8adff38c9197..7ce7e75d5381c 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/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.8/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 4e25fbff57351..c1d9901db861e 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 0d99f099669a4..bde9bce6add4d 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 048a2ccaea859..e3d593f76e02a 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index c2a2d862a6211..74252a4062593 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 96bba84678931..0ce5f752eb85a 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 00ce4324ade84..96a62f7df5233 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs index c2a2d862a6211..74252a4062593 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 96bba84678931..0ce5f752eb85a 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs index c0472474f3834..0984861c0e2c6 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 1fd1ffef4feb2..490d20d1a61a6 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs index 879c3ecdb9ad0..db3d9888945c0 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs index 38f9362076629..144226daaa883 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 010a227c8b275..99add155ed62b 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index 6f1add6153971..a414c4420ddd5 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs index 2cb0523731c5f..d96b8f3f429f4 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/UserApi.cs index 46a87aed2c07f..30d4f2f1aad1b 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 416f7a04e3d65..bd5767856501f 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 599ba401258a3..a4c5c4a441684 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 5c4159491eecb..cbcebbca10852 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs index c2a2d862a6211..74252a4062593 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 96bba84678931..0ce5f752eb85a 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 00ce4324ade84..96a62f7df5233 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 1fd1ffef4feb2..490d20d1a61a6 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs index 879c3ecdb9ad0..db3d9888945c0 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index b3b0cf5352ff5..882649ce655c3 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 010a227c8b275..99add155ed62b 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index e86b55647135d..0f1ebce150756 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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.8/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs index 2cb0523731c5f..d96b8f3f429f4 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/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(); @@ -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.8/Petstore/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/UserApi.cs index 46a87aed2c07f..30d4f2f1aad1b 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/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.8/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 416f7a04e3d65..bd5767856501f 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/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.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 231c516c999c7..66f4eb2f50cf2 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/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.8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 5c4159491eecb..cbcebbca10852 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/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.8/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs index 1662385fe8f82..395d3f77aeeab 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -221,13 +221,21 @@ public async Task NowGetAsync(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(); @@ -292,7 +300,12 @@ public Org.OpenAPITools.Model.NowGet200Response 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.NowGet200Response Ok() /// /// /// - public bool TryOk(out Org.OpenAPITools.Model.NowGet200Response result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out Org.OpenAPITools.Model.NowGet200Response result) { result = null; diff --git a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs index fe5b2fe67aa25..080ab124dd369 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/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.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs index a8adff38c9197..7ce7e75d5381c 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/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/net8/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 910c5c211fba6..d9cc03e765993 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -249,18 +249,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - ListApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/person/display/{personId}", requestedAtLocalVar, _jsonSerializerOptions); + ListApiResponse apiResponseLocalVar = new ListApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/person/display/{personId}", requestedAtLocalVar, _jsonSerializerOptions); AfterListDefaultImplementation(apiResponseLocalVar, personId); @@ -321,7 +328,12 @@ public ListApiResponse(ILogger logger, System.Net.Http.HttpRequ // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -329,7 +341,11 @@ public ListApiResponse(ILogger logger, System.Net.Http.HttpRequ /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 29ca5094b343a..68fa10d5699f2 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -167,6 +167,10 @@ public interface IOk : IApiResponse /// /// /// - bool TryOk([NotNullWhen(true)]out TType? result); + bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } } diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs index ce9f6af2b941c..078e5d5ee0a1a 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -62,7 +62,15 @@ static ClientUtils() /// /// /// - 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 { @@ -84,7 +92,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 { @@ -131,8 +147,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/net8/AllOf/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/HostConfiguration.cs index 89dc36db66657..5a4d0dc811f96 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -46,7 +46,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new AdultJsonConverter()); _jsonOptions.Converters.Add(new ChildJsonConverter()); _jsonOptions.Converters.Add(new PersonJsonConverter()); - JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); _services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(); _services.AddSingleton(); diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 030cc3bf12e07..b69e537e6efe3 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -223,18 +223,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - RootGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); + RootGetApiResponse apiResponseLocalVar = new RootGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); AfterRootGetDefaultImplementation(apiResponseLocalVar); @@ -295,7 +302,12 @@ public RootGetApiResponse(ILogger logger, System.Net.Http.Ht // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -303,7 +315,11 @@ public RootGetApiResponse(ILogger logger, System.Net.Http.Ht /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 2675478b8b4f2..f8b16165c3a25 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -167,6 +167,10 @@ public interface IOk : IApiResponse /// /// /// - bool TryOk([NotNullWhen(true)]out TType? result); + bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } } diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 17060612c0b46..809933a698b45 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -62,7 +62,15 @@ static ClientUtils() /// /// /// - 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 { @@ -84,7 +92,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 { @@ -131,8 +147,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/net8/AnyOf/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/HostConfiguration.cs index 0cffc3195908a..db879aa99f874 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -46,7 +46,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new AppleJsonConverter()); _jsonOptions.Converters.Add(new BananaJsonConverter()); _jsonOptions.Converters.Add(new FruitJsonConverter()); - JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); _services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(); _services.AddSingleton(); diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs index 030cc3bf12e07..b69e537e6efe3 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -223,18 +223,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - RootGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); + RootGetApiResponse apiResponseLocalVar = new RootGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); AfterRootGetDefaultImplementation(apiResponseLocalVar); @@ -295,7 +302,12 @@ public RootGetApiResponse(ILogger logger, System.Net.Http.Ht // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -303,7 +315,11 @@ public RootGetApiResponse(ILogger logger, System.Net.Http.Ht /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 2675478b8b4f2..f8b16165c3a25 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -167,6 +167,10 @@ public interface IOk : IApiResponse /// /// /// - bool TryOk([NotNullWhen(true)]out TType? result); + bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } } diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs index b19e837fb7e6e..eb6bfa539d2f0 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -47,7 +47,15 @@ public static class ClientUtils /// /// /// - 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 { @@ -69,7 +77,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 { @@ -116,8 +132,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/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/HostConfiguration.cs index 0cffc3195908a..db879aa99f874 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -46,7 +46,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new AppleJsonConverter()); _jsonOptions.Converters.Add(new BananaJsonConverter()); _jsonOptions.Converters.Add(new FruitJsonConverter()); - JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); _services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(); _services.AddSingleton(); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 3d7d0c4823394..490d20d1a61a6 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -294,18 +294,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - Call123TestSpecialTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); + Call123TestSpecialTagsApiResponse apiResponseLocalVar = new Call123TestSpecialTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient); @@ -366,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -374,7 +386,11 @@ public Org.OpenAPITools.Model.ModelClient Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs index 84ec2eff6bffe..db3d9888945c0 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -470,18 +470,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FooGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); + FooGetApiResponse apiResponseLocalVar = new FooGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); AfterFooGetDefaultImplementation(apiResponseLocalVar); @@ -542,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -550,7 +562,11 @@ public Org.OpenAPITools.Model.FooGetDefaultResponse Default() /// /// /// - public bool TryDefault([NotNullWhen(true)]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; @@ -698,17 +714,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetCountryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); + GetCountryApiResponse apiResponseLocalVar = new GetCountryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); AfterGetCountryDefaultImplementation(apiResponseLocalVar, country); @@ -859,18 +883,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - HelloApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); + HelloApiResponse apiResponseLocalVar = new HelloApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); AfterHelloDefaultImplementation(apiResponseLocalVar); @@ -931,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -939,7 +975,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -1053,18 +1093,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - RolesReportGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); + RolesReportGetApiResponse apiResponseLocalVar = new RolesReportGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); AfterRolesReportGetDefaultImplementation(apiResponseLocalVar); @@ -1125,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1133,7 +1185,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -1247,18 +1303,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); + TestApiResponse apiResponseLocalVar = new TestApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); AfterTestDefaultImplementation(apiResponseLocalVar); @@ -1319,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1327,7 +1395,11 @@ public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs index 567ffe1fa4d27..2b9131d1f2fd9 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1379,18 +1379,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeHealthGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); + FakeHealthGetApiResponse apiResponseLocalVar = new FakeHealthGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar); @@ -1451,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1459,7 +1471,11 @@ public Org.OpenAPITools.Model.HealthCheckResult Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1597,18 +1613,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new FakeOuterBooleanSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterBooleanSerializeDefaultImplementation(apiResponseLocalVar, body); @@ -1669,7 +1692,12 @@ public FakeOuterBooleanSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1677,7 +1705,11 @@ public FakeOuterBooleanSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out bool? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out bool? result) { result = null; @@ -1828,18 +1860,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new FakeOuterCompositeSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite); @@ -1900,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1908,7 +1952,11 @@ public Org.OpenAPITools.Model.OuterComposite Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2046,18 +2094,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new FakeOuterNumberSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterNumberSerializeDefaultImplementation(apiResponseLocalVar, body); @@ -2118,7 +2173,12 @@ public FakeOuterNumberSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2126,7 +2186,11 @@ public FakeOuterNumberSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out decimal? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out decimal? result) { result = null; @@ -2289,18 +2353,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterStringSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterStringSerializeApiResponse apiResponseLocalVar = new FakeOuterStringSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterStringSerializeDefaultImplementation(apiResponseLocalVar, requiredStringUuid, body); @@ -2361,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2369,7 +2445,11 @@ public string Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out string result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out string result) { result = null; @@ -2483,18 +2563,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetArrayOfEnumsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); + GetArrayOfEnumsApiResponse apiResponseLocalVar = new GetArrayOfEnumsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); AfterGetArrayOfEnumsDefaultImplementation(apiResponseLocalVar); @@ -2555,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2563,7 +2655,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -2677,18 +2773,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetMixedAnyOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + GetMixedAnyOfApiResponse apiResponseLocalVar = new GetMixedAnyOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); @@ -2749,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2757,7 +2865,11 @@ public Org.OpenAPITools.Model.MixedAnyOf Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2871,18 +2983,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetMixedOneOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + GetMixedOneOfApiResponse apiResponseLocalVar = new GetMixedOneOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); @@ -2943,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2951,7 +3075,11 @@ public Org.OpenAPITools.Model.MixedOneOf Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -3093,17 +3221,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); + TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new TestAdditionalPropertiesReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); AfterTestAdditionalPropertiesReferenceDefaultImplementation(apiResponseLocalVar, requestBody); @@ -3282,17 +3418,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); + TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new TestBodyWithFileSchemaApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); AfterTestBodyWithFileSchemaDefaultImplementation(apiResponseLocalVar, fileSchemaTestClass); @@ -3487,17 +3631,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); + TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new TestBodyWithQueryParamsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); AfterTestBodyWithQueryParamsDefaultImplementation(apiResponseLocalVar, query, user); @@ -3684,18 +3836,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestClientModelApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestClientModelApiResponse apiResponseLocalVar = new TestClientModelApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient); @@ -3756,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -3764,7 +3928,11 @@ public Org.OpenAPITools.Model.ModelClient Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -4053,17 +4221,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestEndpointParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestEndpointParametersApiResponse apiResponseLocalVar = new TestEndpointParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestEndpointParametersDefaultImplementation(apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4332,17 +4508,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestEnumParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestEnumParametersApiResponse apiResponseLocalVar = new TestEnumParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestEnumParametersDefaultImplementation(apiResponseLocalVar, enumFormString, enumFormStringArray, enumHeaderString, enumHeaderStringArray, enumQueryDouble, enumQueryInteger, enumQueryString, enumQueryStringArray); @@ -4555,18 +4739,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestGroupParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestGroupParametersApiResponse apiResponseLocalVar = new TestGroupParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestGroupParametersDefaultImplementation(apiResponseLocalVar, requiredBooleanGroup, requiredInt64Group, requiredStringGroup, booleanGroup, int64Group, stringGroup); @@ -4749,17 +4940,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); AfterTestInlineAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, requestBody); @@ -4938,17 +5137,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineFreeformAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); AfterTestInlineFreeformAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, testInlineFreeformAdditionalPropertiesRequest); @@ -5145,17 +5352,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestJsonFormDataApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); + TestJsonFormDataApiResponse apiResponseLocalVar = new TestJsonFormDataApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); AfterTestJsonFormDataDefaultImplementation(apiResponseLocalVar, param, param2); @@ -5410,18 +5625,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); + TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new TestQueryParameterCollectionFormatApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); AfterTestQueryParameterCollectionFormatDefaultImplementation(apiResponseLocalVar, context, http, ioutil, pipe, requiredNotNullable, url, notRequiredNotNullable, notRequiredNullable, requiredNullable); @@ -5600,17 +5822,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestStringMapReferenceApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); + TestStringMapReferenceApiResponse apiResponseLocalVar = new TestStringMapReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); AfterTestStringMapReferenceDefaultImplementation(apiResponseLocalVar, requestBody); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index a12284afb01ba..99add155ed62b 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -303,18 +303,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestClassnameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); + TestClassnameApiResponse apiResponseLocalVar = new TestClassnameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient); @@ -379,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -387,7 +399,11 @@ public Org.OpenAPITools.Model.ModelClient Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index 3361c03e39bfd..a414c4420ddd5 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/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(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -808,17 +812,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - AddPetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + AddPetApiResponse apiResponseLocalVar = new AddPetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); AfterAddPetDefaultImplementation(apiResponseLocalVar, pet); @@ -1004,18 +1016,25 @@ public async Task DeletePetAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeletePetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + DeletePetApiResponse apiResponseLocalVar = new DeletePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeletePetDefaultImplementation(apiResponseLocalVar, petId, apiKey); @@ -1203,7 +1222,11 @@ public async Task FindPetsByStatusAsync(List FindPetsByStatusAsync(List apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FindPetsByStatusApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); + FindPetsByStatusApiResponse apiResponseLocalVar = new FindPetsByStatusApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); AfterFindPetsByStatusDefaultImplementation(apiResponseLocalVar, status); @@ -1293,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1301,7 +1336,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -1480,7 +1519,11 @@ public async Task FindPetsByTagsAsync(List t tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -1494,18 +1537,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FindPetsByTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); + FindPetsByTagsApiResponse apiResponseLocalVar = new FindPetsByTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); AfterFindPetsByTagsDefaultImplementation(apiResponseLocalVar, tags); @@ -1570,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1578,7 +1633,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -1723,18 +1782,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetPetByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + GetPetByIdApiResponse apiResponseLocalVar = new GetPetByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId); @@ -1799,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1807,7 +1878,11 @@ public Org.OpenAPITools.Model.Pet Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1964,7 +2039,11 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -1979,17 +2058,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdatePetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + UpdatePetApiResponse apiResponseLocalVar = new UpdatePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdatePetDefaultImplementation(apiResponseLocalVar, pet); @@ -2216,17 +2303,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdatePetWithFormApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + UpdatePetWithFormApiResponse apiResponseLocalVar = new UpdatePetWithFormApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdatePetWithFormDefaultImplementation(apiResponseLocalVar, petId, name, status); @@ -2449,18 +2544,25 @@ public async Task UploadFileAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UploadFileApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); + UploadFileApiResponse apiResponseLocalVar = new UploadFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, additionalMetadata, file); @@ -2525,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2533,7 +2640,11 @@ public Org.OpenAPITools.Model.ApiResponse Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2715,18 +2826,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); + UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new UploadFileWithRequiredFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2791,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2799,7 +2922,11 @@ public Org.OpenAPITools.Model.ApiResponse Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs index b3cd5adcbcca0..d96b8f3f429f4 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs @@ -460,18 +460,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeleteOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + DeleteOrderApiResponse apiResponseLocalVar = new DeleteOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId); @@ -633,18 +640,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetInventoryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); + GetInventoryApiResponse apiResponseLocalVar = new GetInventoryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); AfterGetInventoryDefaultImplementation(apiResponseLocalVar); @@ -709,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -717,7 +736,11 @@ public Dictionary Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out Dictionary result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out Dictionary result) { result = null; @@ -843,18 +866,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetOrderByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + GetOrderByIdApiResponse apiResponseLocalVar = new GetOrderByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId); @@ -915,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -923,7 +958,11 @@ public Org.OpenAPITools.Model.Order Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1086,18 +1125,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - PlaceOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); + PlaceOrderApiResponse apiResponseLocalVar = new PlaceOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order); @@ -1158,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1166,7 +1217,11 @@ public Org.OpenAPITools.Model.Order Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/FormModels/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/UserApi.cs index 788e681d73c8b..66c54a9949618 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/UserApi.cs @@ -723,17 +723,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); + CreateUserApiResponse apiResponseLocalVar = new CreateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUserDefaultImplementation(apiResponseLocalVar, user); @@ -912,17 +920,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); + CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new CreateUsersWithArrayInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUsersWithArrayInputDefaultImplementation(apiResponseLocalVar, user); @@ -1101,17 +1117,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUsersWithListInputApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); + CreateUsersWithListInputApiResponse apiResponseLocalVar = new CreateUsersWithListInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUsersWithListInputDefaultImplementation(apiResponseLocalVar, user); @@ -1277,18 +1301,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeleteUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + DeleteUserApiResponse apiResponseLocalVar = new DeleteUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeleteUserDefaultImplementation(apiResponseLocalVar, username); @@ -1470,18 +1501,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetUserByNameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + GetUserByNameApiResponse apiResponseLocalVar = new GetUserByNameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username); @@ -1542,7 +1580,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1550,7 +1593,11 @@ public Org.OpenAPITools.Model.User Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1598,7 +1645,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1606,7 +1658,11 @@ public Org.OpenAPITools.Model.User CustomHttpStatusCode599() /// /// /// - public bool TryCustomHttpStatusCode599([NotNullWhen(true)]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; @@ -1761,18 +1817,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - LoginUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); + LoginUserApiResponse apiResponseLocalVar = new LoginUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); AfterLoginUserDefaultImplementation(apiResponseLocalVar, password, username); @@ -1860,7 +1923,12 @@ public string Ok() // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1868,7 +1936,11 @@ public string Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out string result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out string result) { result = null; @@ -1979,18 +2051,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - LogoutUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); + LogoutUserApiResponse apiResponseLocalVar = new LogoutUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); AfterLogoutUserDefaultImplementation(apiResponseLocalVar); @@ -2180,17 +2259,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdateUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + UpdateUserApiResponse apiResponseLocalVar = new UpdateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdateUserDefaultImplementation(apiResponseLocalVar, user, username); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 794b3601c8534..bd5767856501f 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -165,7 +165,11 @@ public interface ICustomHttpStatusCode599 : IApiResponse /// /// /// - bool TryCustomHttpStatusCode599([NotNullWhen(true)]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([NotNullWhen(true)]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([NotNullWhen(true)]out TType result); + bool TryDefault( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType result); } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 32d03988e2d1d..7609cfff60b94 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -91,7 +91,11 @@ 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 result) { try { @@ -113,7 +117,11 @@ 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 result) { try { @@ -160,8 +168,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/net8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs index f35ca51d2d2ad..fc772b9111051 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -190,7 +190,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ZeroBasedEnumClassJsonConverter()); _jsonOptions.Converters.Add(new ZeroBasedEnumClassZeroBasedEnumJsonConverter()); _jsonOptions.Converters.Add(new ZeroBasedEnumClassZeroBasedEnumNullableJsonConverter()); - JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); _services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(); _services.AddSingleton(); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 012e633f989c9..cbcebbca10852 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -276,6 +276,7 @@ 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."); @@ -313,6 +314,10 @@ private string GetECDSASignature(byte[] dataToSign) 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/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index a34c828167b16..1f8d4f80602a0 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -296,18 +296,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - Call123TestSpecialTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); + Call123TestSpecialTagsApiResponse apiResponseLocalVar = new Call123TestSpecialTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient); @@ -368,7 +375,12 @@ public Call123TestSpecialTagsApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -376,7 +388,11 @@ public Call123TestSpecialTagsApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]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/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs index cced9ce3479aa..4a1b787df36b4 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -472,18 +472,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FooGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); + FooGetApiResponse apiResponseLocalVar = new FooGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); AfterFooGetDefaultImplementation(apiResponseLocalVar); @@ -544,7 +551,12 @@ public FooGetApiResponse(ILogger logger, System.Net.Http.Http // This logic may be modified with the AsModel.mustache template return IsDefault ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -552,7 +564,11 @@ public FooGetApiResponse(ILogger logger, System.Net.Http.Http /// /// /// - public bool TryDefault([NotNullWhen(true)]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; @@ -700,17 +716,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetCountryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); + GetCountryApiResponse apiResponseLocalVar = new GetCountryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); AfterGetCountryDefaultImplementation(apiResponseLocalVar, country); @@ -861,18 +885,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - HelloApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); + HelloApiResponse apiResponseLocalVar = new HelloApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); AfterHelloDefaultImplementation(apiResponseLocalVar); @@ -933,7 +964,12 @@ public HelloApiResponse(ILogger logger, System.Net.Http.HttpRe // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -941,7 +977,11 @@ public HelloApiResponse(ILogger logger, System.Net.Http.HttpRe /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -1055,18 +1095,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - RolesReportGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); + RolesReportGetApiResponse apiResponseLocalVar = new RolesReportGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); AfterRolesReportGetDefaultImplementation(apiResponseLocalVar); @@ -1127,7 +1174,12 @@ public RolesReportGetApiResponse(ILogger logger, Syst // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1135,7 +1187,11 @@ public RolesReportGetApiResponse(ILogger logger, Syst /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -1249,18 +1305,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); + TestApiResponse apiResponseLocalVar = new TestApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); AfterTestDefaultImplementation(apiResponseLocalVar); @@ -1321,7 +1384,12 @@ public TestApiResponse(ILogger logger, System.Net.Http.HttpRequ // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1329,7 +1397,11 @@ public TestApiResponse(ILogger logger, System.Net.Http.HttpRequ /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs index 39b422f6f7f75..c6aaaa3ae4fd5 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1381,18 +1381,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeHealthGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); + FakeHealthGetApiResponse apiResponseLocalVar = new FakeHealthGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar); @@ -1453,7 +1460,12 @@ public FakeHealthGetApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1461,7 +1473,11 @@ public FakeHealthGetApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1599,18 +1615,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new FakeOuterBooleanSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterBooleanSerializeDefaultImplementation(apiResponseLocalVar, body); @@ -1671,7 +1694,12 @@ public FakeOuterBooleanSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1679,7 +1707,11 @@ public FakeOuterBooleanSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out bool? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out bool? result) { result = null; @@ -1830,18 +1862,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new FakeOuterCompositeSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite); @@ -1902,7 +1941,12 @@ public FakeOuterCompositeSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1910,7 +1954,11 @@ public FakeOuterCompositeSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2048,18 +2096,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new FakeOuterNumberSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterNumberSerializeDefaultImplementation(apiResponseLocalVar, body); @@ -2120,7 +2175,12 @@ public FakeOuterNumberSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2128,7 +2188,11 @@ public FakeOuterNumberSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out decimal? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out decimal? result) { result = null; @@ -2291,18 +2355,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterStringSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterStringSerializeApiResponse apiResponseLocalVar = new FakeOuterStringSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterStringSerializeDefaultImplementation(apiResponseLocalVar, requiredStringUuid, body); @@ -2363,7 +2434,12 @@ public FakeOuterStringSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2371,7 +2447,11 @@ public FakeOuterStringSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out string? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out string? result) { result = null; @@ -2485,18 +2565,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetArrayOfEnumsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); + GetArrayOfEnumsApiResponse apiResponseLocalVar = new GetArrayOfEnumsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); AfterGetArrayOfEnumsDefaultImplementation(apiResponseLocalVar); @@ -2557,7 +2644,12 @@ public GetArrayOfEnumsApiResponse(ILogger logger, Sy // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2565,7 +2657,11 @@ public GetArrayOfEnumsApiResponse(ILogger logger, Sy /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -2679,18 +2775,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetMixedAnyOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + GetMixedAnyOfApiResponse apiResponseLocalVar = new GetMixedAnyOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); @@ -2751,7 +2854,12 @@ public GetMixedAnyOfApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2759,7 +2867,11 @@ public GetMixedAnyOfApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2873,18 +2985,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetMixedOneOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + GetMixedOneOfApiResponse apiResponseLocalVar = new GetMixedOneOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); @@ -2945,7 +3064,12 @@ public GetMixedOneOfApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2953,7 +3077,11 @@ public GetMixedOneOfApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -3095,17 +3223,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); + TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new TestAdditionalPropertiesReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); AfterTestAdditionalPropertiesReferenceDefaultImplementation(apiResponseLocalVar, requestBody); @@ -3284,17 +3420,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); + TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new TestBodyWithFileSchemaApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); AfterTestBodyWithFileSchemaDefaultImplementation(apiResponseLocalVar, fileSchemaTestClass); @@ -3489,17 +3633,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); + TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new TestBodyWithQueryParamsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); AfterTestBodyWithQueryParamsDefaultImplementation(apiResponseLocalVar, query, user); @@ -3686,18 +3838,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestClientModelApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestClientModelApiResponse apiResponseLocalVar = new TestClientModelApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient); @@ -3758,7 +3917,12 @@ public TestClientModelApiResponse(ILogger logger, Sy // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -3766,7 +3930,11 @@ public TestClientModelApiResponse(ILogger logger, Sy /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -4055,17 +4223,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestEndpointParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestEndpointParametersApiResponse apiResponseLocalVar = new TestEndpointParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestEndpointParametersDefaultImplementation(apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4346,17 +4522,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestEnumParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestEnumParametersApiResponse apiResponseLocalVar = new TestEnumParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestEnumParametersDefaultImplementation(apiResponseLocalVar, enumFormString, enumFormStringArray, enumHeaderString, enumHeaderStringArray, enumQueryDouble, enumQueryInteger, enumQueryString, enumQueryStringArray); @@ -4569,18 +4753,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestGroupParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestGroupParametersApiResponse apiResponseLocalVar = new TestGroupParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestGroupParametersDefaultImplementation(apiResponseLocalVar, requiredBooleanGroup, requiredInt64Group, requiredStringGroup, booleanGroup, int64Group, stringGroup); @@ -4763,17 +4954,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); AfterTestInlineAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, requestBody); @@ -4952,17 +5151,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineFreeformAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); AfterTestInlineFreeformAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, testInlineFreeformAdditionalPropertiesRequest); @@ -5159,17 +5366,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestJsonFormDataApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); + TestJsonFormDataApiResponse apiResponseLocalVar = new TestJsonFormDataApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); AfterTestJsonFormDataDefaultImplementation(apiResponseLocalVar, param, param2); @@ -5424,18 +5639,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); + TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new TestQueryParameterCollectionFormatApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); AfterTestQueryParameterCollectionFormatDefaultImplementation(apiResponseLocalVar, context, http, ioutil, pipe, requiredNotNullable, url, notRequiredNotNullable, notRequiredNullable, requiredNullable); @@ -5614,17 +5836,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestStringMapReferenceApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); + TestStringMapReferenceApiResponse apiResponseLocalVar = new TestStringMapReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); AfterTestStringMapReferenceDefaultImplementation(apiResponseLocalVar, requestBody); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index d70af83c9115a..f2255affdb6bb 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -305,18 +305,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestClassnameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); + TestClassnameApiResponse apiResponseLocalVar = new TestClassnameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient); @@ -381,7 +388,12 @@ public TestClassnameApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -389,7 +401,11 @@ public TestClassnameApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs index 1d959b49106f6..e25fe5ad13cd3 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs @@ -795,7 +795,11 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -810,17 +814,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - AddPetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + AddPetApiResponse apiResponseLocalVar = new AddPetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); AfterAddPetDefaultImplementation(apiResponseLocalVar, pet); @@ -1006,18 +1018,25 @@ public async Task DeletePetAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeletePetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + DeletePetApiResponse apiResponseLocalVar = new DeletePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeletePetDefaultImplementation(apiResponseLocalVar, petId, apiKey); @@ -1205,7 +1224,11 @@ public async Task FindPetsByStatusAsync(List FindPetsByStatusAsync(List apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FindPetsByStatusApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); + FindPetsByStatusApiResponse apiResponseLocalVar = new FindPetsByStatusApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); AfterFindPetsByStatusDefaultImplementation(apiResponseLocalVar, status); @@ -1295,7 +1325,12 @@ public FindPetsByStatusApiResponse(ILogger logger, // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1303,7 +1338,11 @@ public FindPetsByStatusApiResponse(ILogger logger, /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -1482,7 +1521,11 @@ public async Task FindPetsByTagsAsync(List t tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -1496,18 +1539,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FindPetsByTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); + FindPetsByTagsApiResponse apiResponseLocalVar = new FindPetsByTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); AfterFindPetsByTagsDefaultImplementation(apiResponseLocalVar, tags); @@ -1572,7 +1622,12 @@ public FindPetsByTagsApiResponse(ILogger logger, Syst // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1580,7 +1635,11 @@ public FindPetsByTagsApiResponse(ILogger logger, Syst /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -1725,18 +1784,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetPetByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + GetPetByIdApiResponse apiResponseLocalVar = new GetPetByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId); @@ -1801,7 +1867,12 @@ public GetPetByIdApiResponse(ILogger logger, System.Net.H // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1809,7 +1880,11 @@ public GetPetByIdApiResponse(ILogger logger, System.Net.H /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1966,7 +2041,11 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -1981,17 +2060,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdatePetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + UpdatePetApiResponse apiResponseLocalVar = new UpdatePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdatePetDefaultImplementation(apiResponseLocalVar, pet); @@ -2218,17 +2305,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdatePetWithFormApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + UpdatePetWithFormApiResponse apiResponseLocalVar = new UpdatePetWithFormApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdatePetWithFormDefaultImplementation(apiResponseLocalVar, petId, name, status); @@ -2451,18 +2546,25 @@ public async Task UploadFileAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UploadFileApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); + UploadFileApiResponse apiResponseLocalVar = new UploadFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, additionalMetadata, file); @@ -2527,7 +2629,12 @@ public UploadFileApiResponse(ILogger logger, System.Net.H // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2535,7 +2642,11 @@ public UploadFileApiResponse(ILogger logger, System.Net.H /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2717,18 +2828,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); + UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new UploadFileWithRequiredFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2793,7 +2911,12 @@ public UploadFileWithRequiredFileApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2801,7 +2924,11 @@ public UploadFileWithRequiredFileApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]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/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs index 1677ff9901e2b..69bcd9ac1d7e5 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs @@ -462,18 +462,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeleteOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + DeleteOrderApiResponse apiResponseLocalVar = new DeleteOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId); @@ -635,18 +642,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetInventoryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); + GetInventoryApiResponse apiResponseLocalVar = new GetInventoryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); AfterGetInventoryDefaultImplementation(apiResponseLocalVar); @@ -711,7 +725,12 @@ public GetInventoryApiResponse(ILogger logger, System.N // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -719,7 +738,11 @@ public GetInventoryApiResponse(ILogger logger, System.N /// /// /// - public bool TryOk([NotNullWhen(true)]out Dictionary? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out Dictionary? result) { result = null; @@ -845,18 +868,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetOrderByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + GetOrderByIdApiResponse apiResponseLocalVar = new GetOrderByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId); @@ -917,7 +947,12 @@ public GetOrderByIdApiResponse(ILogger logger, System.N // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -925,7 +960,11 @@ public GetOrderByIdApiResponse(ILogger logger, System.N /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1088,18 +1127,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - PlaceOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); + PlaceOrderApiResponse apiResponseLocalVar = new PlaceOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order); @@ -1160,7 +1206,12 @@ public PlaceOrderApiResponse(ILogger logger, System.Net.H // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1168,7 +1219,11 @@ public PlaceOrderApiResponse(ILogger logger, System.Net.H /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs index 0352814ae67dc..6e5832560558d 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs @@ -725,17 +725,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); + CreateUserApiResponse apiResponseLocalVar = new CreateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUserDefaultImplementation(apiResponseLocalVar, user); @@ -914,17 +922,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); + CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new CreateUsersWithArrayInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUsersWithArrayInputDefaultImplementation(apiResponseLocalVar, user); @@ -1103,17 +1119,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUsersWithListInputApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); + CreateUsersWithListInputApiResponse apiResponseLocalVar = new CreateUsersWithListInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUsersWithListInputDefaultImplementation(apiResponseLocalVar, user); @@ -1279,18 +1303,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeleteUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + DeleteUserApiResponse apiResponseLocalVar = new DeleteUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeleteUserDefaultImplementation(apiResponseLocalVar, username); @@ -1472,18 +1503,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetUserByNameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + GetUserByNameApiResponse apiResponseLocalVar = new GetUserByNameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username); @@ -1544,7 +1582,12 @@ public GetUserByNameApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1552,7 +1595,11 @@ public GetUserByNameApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1600,7 +1647,12 @@ public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.User? result) // This logic may be modified with the AsModel.mustache template return IsCustomHttpStatusCode599 ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1608,7 +1660,11 @@ public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.User? result) /// /// /// - public bool TryCustomHttpStatusCode599([NotNullWhen(true)]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; @@ -1763,18 +1819,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - LoginUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); + LoginUserApiResponse apiResponseLocalVar = new LoginUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); AfterLoginUserDefaultImplementation(apiResponseLocalVar, password, username); @@ -1862,7 +1925,12 @@ public LoginUserApiResponse(ILogger logger, System.Net.Htt // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1870,7 +1938,11 @@ public LoginUserApiResponse(ILogger logger, System.Net.Htt /// /// /// - public bool TryOk([NotNullWhen(true)]out string? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out string? result) { result = null; @@ -1981,18 +2053,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - LogoutUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); + LogoutUserApiResponse apiResponseLocalVar = new LogoutUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); AfterLogoutUserDefaultImplementation(apiResponseLocalVar); @@ -2182,17 +2261,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdateUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + UpdateUserApiResponse apiResponseLocalVar = new UpdateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdateUserDefaultImplementation(apiResponseLocalVar, user, username); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 88b4a497394b7..2622f0d2692ec 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -167,7 +167,11 @@ public interface ICustomHttpStatusCode599 : IApiResponse /// /// /// - bool TryCustomHttpStatusCode599([NotNullWhen(true)]out TType? result); + bool TryCustomHttpStatusCode599( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } /// @@ -187,7 +191,11 @@ public interface IOk : IApiResponse /// /// /// - bool TryOk([NotNullWhen(true)]out TType? result); + bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } /// @@ -207,6 +215,10 @@ public interface IDefault : IApiResponse /// /// /// - bool TryDefault([NotNullWhen(true)]out TType? result); + bool TryDefault( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs index ec53dbda4326a..8897fec5bd0fd 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -93,7 +93,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 { @@ -115,7 +123,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 { @@ -162,8 +178,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/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs index 8be0791ee4fbe..f6b757935488a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -146,7 +146,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ZeroBasedEnumJsonConverter()); _jsonOptions.Converters.Add(new ZeroBasedEnumNullableJsonConverter()); _jsonOptions.Converters.Add(new ZeroBasedEnumClassJsonConverter()); - JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); _services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(); _services.AddSingleton(); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 2d8c0b2a52f71..58b15a34c655b 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -278,6 +278,7 @@ 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."); @@ -315,6 +316,10 @@ private string GetECDSASignature(byte[] dataToSign) 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/net8/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 030cc3bf12e07..b69e537e6efe3 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -223,18 +223,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - RootGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); + RootGetApiResponse apiResponseLocalVar = new RootGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); AfterRootGetDefaultImplementation(apiResponseLocalVar); @@ -295,7 +302,12 @@ public RootGetApiResponse(ILogger logger, System.Net.Http.Ht // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -303,7 +315,11 @@ public RootGetApiResponse(ILogger logger, System.Net.Http.Ht /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 2675478b8b4f2..f8b16165c3a25 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -167,6 +167,10 @@ public interface IOk : IApiResponse /// /// /// - bool TryOk([NotNullWhen(true)]out TType? result); + bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } } diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 17060612c0b46..809933a698b45 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -62,7 +62,15 @@ static ClientUtils() /// /// /// - 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 { @@ -84,7 +92,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 { @@ -131,8 +147,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/net8/OneOf/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/HostConfiguration.cs index 0cffc3195908a..db879aa99f874 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -46,7 +46,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new AppleJsonConverter()); _jsonOptions.Converters.Add(new BananaJsonConverter()); _jsonOptions.Converters.Add(new FruitJsonConverter()); - JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); _services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(); _services.AddSingleton(); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 3d7d0c4823394..490d20d1a61a6 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -294,18 +294,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - Call123TestSpecialTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); + Call123TestSpecialTagsApiResponse apiResponseLocalVar = new Call123TestSpecialTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient); @@ -366,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -374,7 +386,11 @@ public Org.OpenAPITools.Model.ModelClient Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs index 84ec2eff6bffe..db3d9888945c0 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -470,18 +470,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FooGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); + FooGetApiResponse apiResponseLocalVar = new FooGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); AfterFooGetDefaultImplementation(apiResponseLocalVar); @@ -542,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -550,7 +562,11 @@ public Org.OpenAPITools.Model.FooGetDefaultResponse Default() /// /// /// - public bool TryDefault([NotNullWhen(true)]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; @@ -698,17 +714,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetCountryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); + GetCountryApiResponse apiResponseLocalVar = new GetCountryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); AfterGetCountryDefaultImplementation(apiResponseLocalVar, country); @@ -859,18 +883,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - HelloApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); + HelloApiResponse apiResponseLocalVar = new HelloApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); AfterHelloDefaultImplementation(apiResponseLocalVar); @@ -931,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -939,7 +975,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -1053,18 +1093,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - RolesReportGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); + RolesReportGetApiResponse apiResponseLocalVar = new RolesReportGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); AfterRolesReportGetDefaultImplementation(apiResponseLocalVar); @@ -1125,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1133,7 +1185,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -1247,18 +1303,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); + TestApiResponse apiResponseLocalVar = new TestApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); AfterTestDefaultImplementation(apiResponseLocalVar); @@ -1319,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1327,7 +1395,11 @@ public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 5512650247895..c83451d5c3abd 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1379,18 +1379,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeHealthGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); + FakeHealthGetApiResponse apiResponseLocalVar = new FakeHealthGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar); @@ -1451,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1459,7 +1471,11 @@ public Org.OpenAPITools.Model.HealthCheckResult Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1597,18 +1613,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new FakeOuterBooleanSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterBooleanSerializeDefaultImplementation(apiResponseLocalVar, body); @@ -1669,7 +1692,12 @@ public FakeOuterBooleanSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1677,7 +1705,11 @@ public FakeOuterBooleanSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out bool? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out bool? result) { result = null; @@ -1828,18 +1860,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new FakeOuterCompositeSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite); @@ -1900,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1908,7 +1952,11 @@ public Org.OpenAPITools.Model.OuterComposite Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2046,18 +2094,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new FakeOuterNumberSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterNumberSerializeDefaultImplementation(apiResponseLocalVar, body); @@ -2118,7 +2173,12 @@ public FakeOuterNumberSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2126,7 +2186,11 @@ public FakeOuterNumberSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out decimal? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out decimal? result) { result = null; @@ -2289,18 +2353,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterStringSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterStringSerializeApiResponse apiResponseLocalVar = new FakeOuterStringSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterStringSerializeDefaultImplementation(apiResponseLocalVar, requiredStringUuid, body); @@ -2361,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2369,7 +2445,11 @@ public string Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out string result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out string result) { result = null; @@ -2483,18 +2563,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetArrayOfEnumsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); + GetArrayOfEnumsApiResponse apiResponseLocalVar = new GetArrayOfEnumsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); AfterGetArrayOfEnumsDefaultImplementation(apiResponseLocalVar); @@ -2555,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2563,7 +2655,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -2677,18 +2773,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetMixedAnyOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + GetMixedAnyOfApiResponse apiResponseLocalVar = new GetMixedAnyOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); @@ -2749,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2757,7 +2865,11 @@ public Org.OpenAPITools.Model.MixedAnyOf Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2871,18 +2983,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetMixedOneOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + GetMixedOneOfApiResponse apiResponseLocalVar = new GetMixedOneOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); @@ -2943,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2951,7 +3075,11 @@ public Org.OpenAPITools.Model.MixedOneOf Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -3093,17 +3221,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); + TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new TestAdditionalPropertiesReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); AfterTestAdditionalPropertiesReferenceDefaultImplementation(apiResponseLocalVar, requestBody); @@ -3282,17 +3418,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); + TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new TestBodyWithFileSchemaApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); AfterTestBodyWithFileSchemaDefaultImplementation(apiResponseLocalVar, fileSchemaTestClass); @@ -3487,17 +3631,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); + TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new TestBodyWithQueryParamsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); AfterTestBodyWithQueryParamsDefaultImplementation(apiResponseLocalVar, query, user); @@ -3684,18 +3836,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestClientModelApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestClientModelApiResponse apiResponseLocalVar = new TestClientModelApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient); @@ -3756,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -3764,7 +3928,11 @@ public Org.OpenAPITools.Model.ModelClient Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -4053,17 +4221,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestEndpointParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestEndpointParametersApiResponse apiResponseLocalVar = new TestEndpointParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestEndpointParametersDefaultImplementation(apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4344,17 +4520,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestEnumParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestEnumParametersApiResponse apiResponseLocalVar = new TestEnumParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestEnumParametersDefaultImplementation(apiResponseLocalVar, enumFormString, enumFormStringArray, enumHeaderString, enumHeaderStringArray, enumQueryDouble, enumQueryInteger, enumQueryString, enumQueryStringArray); @@ -4567,18 +4751,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestGroupParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestGroupParametersApiResponse apiResponseLocalVar = new TestGroupParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestGroupParametersDefaultImplementation(apiResponseLocalVar, requiredBooleanGroup, requiredInt64Group, requiredStringGroup, booleanGroup, int64Group, stringGroup); @@ -4761,17 +4952,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); AfterTestInlineAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, requestBody); @@ -4950,17 +5149,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineFreeformAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); AfterTestInlineFreeformAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, testInlineFreeformAdditionalPropertiesRequest); @@ -5157,17 +5364,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestJsonFormDataApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); + TestJsonFormDataApiResponse apiResponseLocalVar = new TestJsonFormDataApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); AfterTestJsonFormDataDefaultImplementation(apiResponseLocalVar, param, param2); @@ -5422,18 +5637,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); + TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new TestQueryParameterCollectionFormatApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); AfterTestQueryParameterCollectionFormatDefaultImplementation(apiResponseLocalVar, context, http, ioutil, pipe, requiredNotNullable, url, notRequiredNotNullable, notRequiredNullable, requiredNullable); @@ -5612,17 +5834,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestStringMapReferenceApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); + TestStringMapReferenceApiResponse apiResponseLocalVar = new TestStringMapReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); AfterTestStringMapReferenceDefaultImplementation(apiResponseLocalVar, requestBody); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index a12284afb01ba..99add155ed62b 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -303,18 +303,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestClassnameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); + TestClassnameApiResponse apiResponseLocalVar = new TestClassnameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient); @@ -379,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -387,7 +399,11 @@ public Org.OpenAPITools.Model.ModelClient Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index 0350d428124ad..0f1ebce150756 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/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(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -808,17 +812,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - AddPetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + AddPetApiResponse apiResponseLocalVar = new AddPetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); AfterAddPetDefaultImplementation(apiResponseLocalVar, pet); @@ -1004,18 +1016,25 @@ public async Task DeletePetAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeletePetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + DeletePetApiResponse apiResponseLocalVar = new DeletePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeletePetDefaultImplementation(apiResponseLocalVar, petId, apiKey); @@ -1203,7 +1222,11 @@ public async Task FindPetsByStatusAsync(List FindPetsByStatusAsync(List apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FindPetsByStatusApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); + FindPetsByStatusApiResponse apiResponseLocalVar = new FindPetsByStatusApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); AfterFindPetsByStatusDefaultImplementation(apiResponseLocalVar, status); @@ -1293,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1301,7 +1336,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -1480,7 +1519,11 @@ public async Task FindPetsByTagsAsync(List t tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -1494,18 +1537,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FindPetsByTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); + FindPetsByTagsApiResponse apiResponseLocalVar = new FindPetsByTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); AfterFindPetsByTagsDefaultImplementation(apiResponseLocalVar, tags); @@ -1570,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1578,7 +1633,11 @@ public List Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out List result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List result) { result = null; @@ -1723,18 +1782,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetPetByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + GetPetByIdApiResponse apiResponseLocalVar = new GetPetByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId); @@ -1799,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1807,7 +1878,11 @@ public Org.OpenAPITools.Model.Pet Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1964,7 +2039,11 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -1979,17 +2058,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdatePetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + UpdatePetApiResponse apiResponseLocalVar = new UpdatePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdatePetDefaultImplementation(apiResponseLocalVar, pet); @@ -2216,17 +2303,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdatePetWithFormApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + UpdatePetWithFormApiResponse apiResponseLocalVar = new UpdatePetWithFormApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdatePetWithFormDefaultImplementation(apiResponseLocalVar, petId, name, status); @@ -2449,18 +2544,25 @@ public async Task UploadFileAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UploadFileApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); + UploadFileApiResponse apiResponseLocalVar = new UploadFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, additionalMetadata, file); @@ -2525,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2533,7 +2640,11 @@ public Org.OpenAPITools.Model.ApiResponse Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2715,18 +2826,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); + UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new UploadFileWithRequiredFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2791,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2799,7 +2922,11 @@ public Org.OpenAPITools.Model.ApiResponse Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs index b3cd5adcbcca0..d96b8f3f429f4 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs @@ -460,18 +460,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeleteOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + DeleteOrderApiResponse apiResponseLocalVar = new DeleteOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId); @@ -633,18 +640,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetInventoryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); + GetInventoryApiResponse apiResponseLocalVar = new GetInventoryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); AfterGetInventoryDefaultImplementation(apiResponseLocalVar); @@ -709,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -717,7 +736,11 @@ public Dictionary Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out Dictionary result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out Dictionary result) { result = null; @@ -843,18 +866,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetOrderByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + GetOrderByIdApiResponse apiResponseLocalVar = new GetOrderByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId); @@ -915,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -923,7 +958,11 @@ public Org.OpenAPITools.Model.Order Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1086,18 +1125,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - PlaceOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); + PlaceOrderApiResponse apiResponseLocalVar = new PlaceOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order); @@ -1158,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1166,7 +1217,11 @@ public Org.OpenAPITools.Model.Order Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/Petstore/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/UserApi.cs index 788e681d73c8b..66c54a9949618 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/UserApi.cs @@ -723,17 +723,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); + CreateUserApiResponse apiResponseLocalVar = new CreateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUserDefaultImplementation(apiResponseLocalVar, user); @@ -912,17 +920,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); + CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new CreateUsersWithArrayInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUsersWithArrayInputDefaultImplementation(apiResponseLocalVar, user); @@ -1101,17 +1117,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUsersWithListInputApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); + CreateUsersWithListInputApiResponse apiResponseLocalVar = new CreateUsersWithListInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUsersWithListInputDefaultImplementation(apiResponseLocalVar, user); @@ -1277,18 +1301,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeleteUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + DeleteUserApiResponse apiResponseLocalVar = new DeleteUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeleteUserDefaultImplementation(apiResponseLocalVar, username); @@ -1470,18 +1501,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetUserByNameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + GetUserByNameApiResponse apiResponseLocalVar = new GetUserByNameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username); @@ -1542,7 +1580,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1550,7 +1593,11 @@ public Org.OpenAPITools.Model.User Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1598,7 +1645,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) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1606,7 +1658,11 @@ public Org.OpenAPITools.Model.User CustomHttpStatusCode599() /// /// /// - public bool TryCustomHttpStatusCode599([NotNullWhen(true)]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; @@ -1761,18 +1817,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - LoginUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); + LoginUserApiResponse apiResponseLocalVar = new LoginUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); AfterLoginUserDefaultImplementation(apiResponseLocalVar, password, username); @@ -1860,7 +1923,12 @@ public string Ok() // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1868,7 +1936,11 @@ public string Ok() /// /// /// - public bool TryOk([NotNullWhen(true)]out string result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out string result) { result = null; @@ -1979,18 +2051,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - LogoutUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); + LogoutUserApiResponse apiResponseLocalVar = new LogoutUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); AfterLogoutUserDefaultImplementation(apiResponseLocalVar); @@ -2180,17 +2259,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdateUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + UpdateUserApiResponse apiResponseLocalVar = new UpdateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdateUserDefaultImplementation(apiResponseLocalVar, user, username); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 794b3601c8534..bd5767856501f 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -165,7 +165,11 @@ public interface ICustomHttpStatusCode599 : IApiResponse /// /// /// - bool TryCustomHttpStatusCode599([NotNullWhen(true)]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([NotNullWhen(true)]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([NotNullWhen(true)]out TType result); + bool TryDefault( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType result); } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index b8e281efd8bac..19f42fedb4589 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -91,7 +91,11 @@ 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 result) { try { @@ -113,7 +117,11 @@ 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 result) { try { @@ -160,8 +168,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/net8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs index cb0e43c852723..e4e9a61c397eb 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -144,7 +144,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ZeroBasedEnumJsonConverter()); _jsonOptions.Converters.Add(new ZeroBasedEnumNullableJsonConverter()); _jsonOptions.Converters.Add(new ZeroBasedEnumClassJsonConverter()); - JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); _services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(); _services.AddSingleton(); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 012e633f989c9..cbcebbca10852 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -276,6 +276,7 @@ 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."); @@ -313,6 +314,10 @@ private string GetECDSASignature(byte[] dataToSign) 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/net8/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index a34c828167b16..1f8d4f80602a0 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -296,18 +296,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - Call123TestSpecialTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); + Call123TestSpecialTagsApiResponse apiResponseLocalVar = new Call123TestSpecialTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient); @@ -368,7 +375,12 @@ public Call123TestSpecialTagsApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -376,7 +388,11 @@ public Call123TestSpecialTagsApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]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/net8/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs index cced9ce3479aa..4a1b787df36b4 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -472,18 +472,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FooGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); + FooGetApiResponse apiResponseLocalVar = new FooGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); AfterFooGetDefaultImplementation(apiResponseLocalVar); @@ -544,7 +551,12 @@ public FooGetApiResponse(ILogger logger, System.Net.Http.Http // This logic may be modified with the AsModel.mustache template return IsDefault ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -552,7 +564,11 @@ public FooGetApiResponse(ILogger logger, System.Net.Http.Http /// /// /// - public bool TryDefault([NotNullWhen(true)]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; @@ -700,17 +716,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetCountryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); + GetCountryApiResponse apiResponseLocalVar = new GetCountryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); AfterGetCountryDefaultImplementation(apiResponseLocalVar, country); @@ -861,18 +885,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - HelloApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); + HelloApiResponse apiResponseLocalVar = new HelloApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); AfterHelloDefaultImplementation(apiResponseLocalVar); @@ -933,7 +964,12 @@ public HelloApiResponse(ILogger logger, System.Net.Http.HttpRe // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -941,7 +977,11 @@ public HelloApiResponse(ILogger logger, System.Net.Http.HttpRe /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -1055,18 +1095,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - RolesReportGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); + RolesReportGetApiResponse apiResponseLocalVar = new RolesReportGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); AfterRolesReportGetDefaultImplementation(apiResponseLocalVar); @@ -1127,7 +1174,12 @@ public RolesReportGetApiResponse(ILogger logger, Syst // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1135,7 +1187,11 @@ public RolesReportGetApiResponse(ILogger logger, Syst /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -1249,18 +1305,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); + TestApiResponse apiResponseLocalVar = new TestApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); AfterTestDefaultImplementation(apiResponseLocalVar); @@ -1321,7 +1384,12 @@ public TestApiResponse(ILogger logger, System.Net.Http.HttpRequ // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1329,7 +1397,11 @@ public TestApiResponse(ILogger logger, System.Net.Http.HttpRequ /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs index 39b422f6f7f75..c6aaaa3ae4fd5 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1381,18 +1381,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeHealthGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); + FakeHealthGetApiResponse apiResponseLocalVar = new FakeHealthGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar); @@ -1453,7 +1460,12 @@ public FakeHealthGetApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1461,7 +1473,11 @@ public FakeHealthGetApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1599,18 +1615,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new FakeOuterBooleanSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterBooleanSerializeDefaultImplementation(apiResponseLocalVar, body); @@ -1671,7 +1694,12 @@ public FakeOuterBooleanSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1679,7 +1707,11 @@ public FakeOuterBooleanSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out bool? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out bool? result) { result = null; @@ -1830,18 +1862,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new FakeOuterCompositeSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite); @@ -1902,7 +1941,12 @@ public FakeOuterCompositeSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1910,7 +1954,11 @@ public FakeOuterCompositeSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2048,18 +2096,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new FakeOuterNumberSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterNumberSerializeDefaultImplementation(apiResponseLocalVar, body); @@ -2120,7 +2175,12 @@ public FakeOuterNumberSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2128,7 +2188,11 @@ public FakeOuterNumberSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out decimal? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out decimal? result) { result = null; @@ -2291,18 +2355,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FakeOuterStringSerializeApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); + FakeOuterStringSerializeApiResponse apiResponseLocalVar = new FakeOuterStringSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); AfterFakeOuterStringSerializeDefaultImplementation(apiResponseLocalVar, requiredStringUuid, body); @@ -2363,7 +2434,12 @@ public FakeOuterStringSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2371,7 +2447,11 @@ public FakeOuterStringSerializeApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]out string? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out string? result) { result = null; @@ -2485,18 +2565,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetArrayOfEnumsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); + GetArrayOfEnumsApiResponse apiResponseLocalVar = new GetArrayOfEnumsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); AfterGetArrayOfEnumsDefaultImplementation(apiResponseLocalVar); @@ -2557,7 +2644,12 @@ public GetArrayOfEnumsApiResponse(ILogger logger, Sy // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2565,7 +2657,11 @@ public GetArrayOfEnumsApiResponse(ILogger logger, Sy /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -2679,18 +2775,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetMixedAnyOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + GetMixedAnyOfApiResponse apiResponseLocalVar = new GetMixedAnyOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); @@ -2751,7 +2854,12 @@ public GetMixedAnyOfApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2759,7 +2867,11 @@ public GetMixedAnyOfApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2873,18 +2985,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetMixedOneOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + GetMixedOneOfApiResponse apiResponseLocalVar = new GetMixedOneOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); @@ -2945,7 +3064,12 @@ public GetMixedOneOfApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2953,7 +3077,11 @@ public GetMixedOneOfApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -3095,17 +3223,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); + TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new TestAdditionalPropertiesReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); AfterTestAdditionalPropertiesReferenceDefaultImplementation(apiResponseLocalVar, requestBody); @@ -3284,17 +3420,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); + TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new TestBodyWithFileSchemaApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); AfterTestBodyWithFileSchemaDefaultImplementation(apiResponseLocalVar, fileSchemaTestClass); @@ -3489,17 +3633,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); + TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new TestBodyWithQueryParamsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); AfterTestBodyWithQueryParamsDefaultImplementation(apiResponseLocalVar, query, user); @@ -3686,18 +3838,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestClientModelApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestClientModelApiResponse apiResponseLocalVar = new TestClientModelApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient); @@ -3758,7 +3917,12 @@ public TestClientModelApiResponse(ILogger logger, Sy // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -3766,7 +3930,11 @@ public TestClientModelApiResponse(ILogger logger, Sy /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -4055,17 +4223,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestEndpointParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestEndpointParametersApiResponse apiResponseLocalVar = new TestEndpointParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestEndpointParametersDefaultImplementation(apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4346,17 +4522,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestEnumParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestEnumParametersApiResponse apiResponseLocalVar = new TestEnumParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestEnumParametersDefaultImplementation(apiResponseLocalVar, enumFormString, enumFormStringArray, enumHeaderString, enumHeaderStringArray, enumQueryDouble, enumQueryInteger, enumQueryString, enumQueryStringArray); @@ -4569,18 +4753,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestGroupParametersApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + TestGroupParametersApiResponse apiResponseLocalVar = new TestGroupParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); AfterTestGroupParametersDefaultImplementation(apiResponseLocalVar, requiredBooleanGroup, requiredInt64Group, requiredStringGroup, booleanGroup, int64Group, stringGroup); @@ -4763,17 +4954,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); AfterTestInlineAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, requestBody); @@ -4952,17 +5151,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineFreeformAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); AfterTestInlineFreeformAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, testInlineFreeformAdditionalPropertiesRequest); @@ -5159,17 +5366,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestJsonFormDataApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); + TestJsonFormDataApiResponse apiResponseLocalVar = new TestJsonFormDataApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); AfterTestJsonFormDataDefaultImplementation(apiResponseLocalVar, param, param2); @@ -5424,18 +5639,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); + TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new TestQueryParameterCollectionFormatApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); AfterTestQueryParameterCollectionFormatDefaultImplementation(apiResponseLocalVar, context, http, ioutil, pipe, requiredNotNullable, url, notRequiredNotNullable, notRequiredNullable, requiredNullable); @@ -5614,17 +5836,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestStringMapReferenceApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); + TestStringMapReferenceApiResponse apiResponseLocalVar = new TestStringMapReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); AfterTestStringMapReferenceDefaultImplementation(apiResponseLocalVar, requestBody); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index d70af83c9115a..f2255affdb6bb 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -305,18 +305,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - TestClassnameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); + TestClassnameApiResponse apiResponseLocalVar = new TestClassnameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient); @@ -381,7 +388,12 @@ public TestClassnameApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -389,7 +401,11 @@ public TestClassnameApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs index 1d959b49106f6..e25fe5ad13cd3 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs @@ -795,7 +795,11 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -810,17 +814,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - AddPetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + AddPetApiResponse apiResponseLocalVar = new AddPetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); AfterAddPetDefaultImplementation(apiResponseLocalVar, pet); @@ -1006,18 +1018,25 @@ public async Task DeletePetAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeletePetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + DeletePetApiResponse apiResponseLocalVar = new DeletePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeletePetDefaultImplementation(apiResponseLocalVar, petId, apiKey); @@ -1205,7 +1224,11 @@ public async Task FindPetsByStatusAsync(List FindPetsByStatusAsync(List apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FindPetsByStatusApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); + FindPetsByStatusApiResponse apiResponseLocalVar = new FindPetsByStatusApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); AfterFindPetsByStatusDefaultImplementation(apiResponseLocalVar, status); @@ -1295,7 +1325,12 @@ public FindPetsByStatusApiResponse(ILogger logger, // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1303,7 +1338,11 @@ public FindPetsByStatusApiResponse(ILogger logger, /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -1482,7 +1521,11 @@ public async Task FindPetsByTagsAsync(List t tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -1496,18 +1539,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - FindPetsByTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); + FindPetsByTagsApiResponse apiResponseLocalVar = new FindPetsByTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); AfterFindPetsByTagsDefaultImplementation(apiResponseLocalVar, tags); @@ -1572,7 +1622,12 @@ public FindPetsByTagsApiResponse(ILogger logger, Syst // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1580,7 +1635,11 @@ public FindPetsByTagsApiResponse(ILogger logger, Syst /// /// /// - public bool TryOk([NotNullWhen(true)]out List? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out List? result) { result = null; @@ -1725,18 +1784,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetPetByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + GetPetByIdApiResponse apiResponseLocalVar = new GetPetByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId); @@ -1801,7 +1867,12 @@ public GetPetByIdApiResponse(ILogger logger, System.Net.H // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1809,7 +1880,11 @@ public GetPetByIdApiResponse(ILogger logger, System.Net.H /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1966,7 +2041,11 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); if (httpRequestMessageLocalVar.Content != null) { - string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } @@ -1981,17 +2060,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdatePetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + UpdatePetApiResponse apiResponseLocalVar = new UpdatePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdatePetDefaultImplementation(apiResponseLocalVar, pet); @@ -2218,17 +2305,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdatePetWithFormApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + UpdatePetWithFormApiResponse apiResponseLocalVar = new UpdatePetWithFormApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdatePetWithFormDefaultImplementation(apiResponseLocalVar, petId, name, status); @@ -2451,18 +2546,25 @@ public async Task UploadFileAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UploadFileApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); + UploadFileApiResponse apiResponseLocalVar = new UploadFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, additionalMetadata, file); @@ -2527,7 +2629,12 @@ public UploadFileApiResponse(ILogger logger, System.Net.H // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2535,7 +2642,11 @@ public UploadFileApiResponse(ILogger logger, System.Net.H /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -2717,18 +2828,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); + UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new UploadFileWithRequiredFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2793,7 +2911,12 @@ public UploadFileWithRequiredFileApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2801,7 +2924,11 @@ public UploadFileWithRequiredFileApiResponse(ILogger /// /// - public bool TryOk([NotNullWhen(true)]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/net8/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs index 1677ff9901e2b..69bcd9ac1d7e5 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs @@ -462,18 +462,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeleteOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + DeleteOrderApiResponse apiResponseLocalVar = new DeleteOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId); @@ -635,18 +642,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetInventoryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); + GetInventoryApiResponse apiResponseLocalVar = new GetInventoryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); AfterGetInventoryDefaultImplementation(apiResponseLocalVar); @@ -711,7 +725,12 @@ public GetInventoryApiResponse(ILogger logger, System.N // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -719,7 +738,11 @@ public GetInventoryApiResponse(ILogger logger, System.N /// /// /// - public bool TryOk([NotNullWhen(true)]out Dictionary? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out Dictionary? result) { result = null; @@ -845,18 +868,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetOrderByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + GetOrderByIdApiResponse apiResponseLocalVar = new GetOrderByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId); @@ -917,7 +947,12 @@ public GetOrderByIdApiResponse(ILogger logger, System.N // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -925,7 +960,11 @@ public GetOrderByIdApiResponse(ILogger logger, System.N /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1088,18 +1127,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - PlaceOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); + PlaceOrderApiResponse apiResponseLocalVar = new PlaceOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order); @@ -1160,7 +1206,12 @@ public PlaceOrderApiResponse(ILogger logger, System.Net.H // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1168,7 +1219,11 @@ public PlaceOrderApiResponse(ILogger logger, System.Net.H /// /// /// - public bool TryOk([NotNullWhen(true)]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/net8/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs index 0352814ae67dc..6e5832560558d 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs @@ -725,17 +725,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); + CreateUserApiResponse apiResponseLocalVar = new CreateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUserDefaultImplementation(apiResponseLocalVar, user); @@ -914,17 +922,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); + CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new CreateUsersWithArrayInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUsersWithArrayInputDefaultImplementation(apiResponseLocalVar, user); @@ -1103,17 +1119,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - CreateUsersWithListInputApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); + CreateUsersWithListInputApiResponse apiResponseLocalVar = new CreateUsersWithListInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); AfterCreateUsersWithListInputDefaultImplementation(apiResponseLocalVar, user); @@ -1279,18 +1303,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - DeleteUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + DeleteUserApiResponse apiResponseLocalVar = new DeleteUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterDeleteUserDefaultImplementation(apiResponseLocalVar, username); @@ -1472,18 +1503,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - GetUserByNameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + GetUserByNameApiResponse apiResponseLocalVar = new GetUserByNameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username); @@ -1544,7 +1582,12 @@ public GetUserByNameApiResponse(ILogger logger, System // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1552,7 +1595,11 @@ public GetUserByNameApiResponse(ILogger logger, System /// /// /// - public bool TryOk([NotNullWhen(true)]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; @@ -1600,7 +1647,12 @@ public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.User? result) // This logic may be modified with the AsModel.mustache template return IsCustomHttpStatusCode599 ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1608,7 +1660,11 @@ public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.User? result) /// /// /// - public bool TryCustomHttpStatusCode599([NotNullWhen(true)]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; @@ -1763,18 +1819,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - LoginUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); + LoginUserApiResponse apiResponseLocalVar = new LoginUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); AfterLoginUserDefaultImplementation(apiResponseLocalVar, password, username); @@ -1862,7 +1925,12 @@ public LoginUserApiResponse(ILogger logger, System.Net.Htt // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1870,7 +1938,11 @@ public LoginUserApiResponse(ILogger logger, System.Net.Htt /// /// /// - public bool TryOk([NotNullWhen(true)]out string? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out string? result) { result = null; @@ -1981,18 +2053,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - LogoutUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); + LogoutUserApiResponse apiResponseLocalVar = new LogoutUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); AfterLogoutUserDefaultImplementation(apiResponseLocalVar); @@ -2182,17 +2261,25 @@ 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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - UpdateUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + UpdateUserApiResponse apiResponseLocalVar = new UpdateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); AfterUpdateUserDefaultImplementation(apiResponseLocalVar, user, username); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 88b4a497394b7..2622f0d2692ec 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -167,7 +167,11 @@ public interface ICustomHttpStatusCode599 : IApiResponse /// /// /// - bool TryCustomHttpStatusCode599([NotNullWhen(true)]out TType? result); + bool TryCustomHttpStatusCode599( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } /// @@ -187,7 +191,11 @@ public interface IOk : IApiResponse /// /// /// - bool TryOk([NotNullWhen(true)]out TType? result); + bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } /// @@ -207,6 +215,10 @@ public interface IDefault : IApiResponse /// /// /// - bool TryDefault([NotNullWhen(true)]out TType? result); + bool TryDefault( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs index ec53dbda4326a..8897fec5bd0fd 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -93,7 +93,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 { @@ -115,7 +123,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 { @@ -162,8 +178,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/net8/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs index 03e2cd6ecb879..c91be723a3338 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -146,7 +146,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ZeroBasedEnumJsonConverter()); _jsonOptions.Converters.Add(new ZeroBasedEnumNullableJsonConverter()); _jsonOptions.Converters.Add(new ZeroBasedEnumClassJsonConverter()); - JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); _services.AddSingleton(jsonSerializerOptionsProvider); _jsonOptions.TypeInfoResolver = System.Text.Json.Serialization.Metadata.JsonTypeInfoResolver.Combine( diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 2d8c0b2a52f71..58b15a34c655b 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -278,6 +278,7 @@ 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."); @@ -315,6 +316,10 @@ private string GetECDSASignature(byte[] dataToSign) 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/net8/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs index 7782f09b34bfb..3dfef38d490d3 100644 --- a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -223,18 +223,25 @@ public async Task NowGetAsync(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(cancellationToken).ConfigureAwait(false); + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync( +#if NET6_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); - NowGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/now", requestedAtLocalVar, _jsonSerializerOptions); + NowGetApiResponse apiResponseLocalVar = new NowGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/now", requestedAtLocalVar, _jsonSerializerOptions); AfterNowGetDefaultImplementation(apiResponseLocalVar); @@ -295,7 +302,12 @@ public NowGetApiResponse(ILogger logger, System.Net.Http.Http // This logic may be modified with the AsModel.mustache template return IsOk ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) - : null; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -303,7 +315,11 @@ public NowGetApiResponse(ILogger logger, System.Net.Http.Http /// /// /// - public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.NowGet200Response? result) + public bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out Org.OpenAPITools.Model.NowGet200Response? result) { result = null; diff --git a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 0027952859de5..db488eb60ec00 100644 --- a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -167,6 +167,10 @@ public interface IOk : IApiResponse /// /// /// - bool TryOk([NotNullWhen(true)]out TType? result); + bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType? result); } } diff --git a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs index 4cdf0f2061240..88bcd1c8a44df 100644 --- a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -47,7 +47,15 @@ public static class ClientUtils /// /// /// - 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 { @@ -69,7 +77,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 { @@ -116,8 +132,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/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/HostConfiguration.cs index 90dd61c2c492c..fc3406f68f96d 100644 --- a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -42,7 +42,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new DateTimeJsonConverter()); _jsonOptions.Converters.Add(new DateTimeNullableJsonConverter()); _jsonOptions.Converters.Add(new NowGet200ResponseJsonConverter()); - JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); _services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(); _services.AddSingleton(); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 57b7fd8511dfe..74eade0879e45 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -293,13 +293,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(); @@ -364,7 +372,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; } /// @@ -372,7 +385,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/standard2.0/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs index e2f9ed3767b05..75326be2d3b8c 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -469,13 +469,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(); @@ -540,7 +548,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; } /// @@ -548,7 +561,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; @@ -696,13 +713,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(); @@ -857,13 +882,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(); @@ -928,7 +961,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; } /// @@ -936,7 +974,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; @@ -1050,13 +1092,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(); @@ -1121,7 +1171,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; } /// @@ -1129,7 +1184,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; @@ -1243,13 +1302,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(); @@ -1314,7 +1381,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; } /// @@ -1322,7 +1394,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/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 0df3dc21b8d73..3a10ef1a96f5c 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1378,13 +1378,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(); @@ -1449,7 +1457,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; } /// @@ -1457,7 +1470,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; @@ -1595,13 +1612,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(); @@ -1666,7 +1691,12 @@ public FakeOuterBooleanSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : default; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -1674,7 +1704,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; @@ -1825,13 +1859,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(); @@ -1896,7 +1938,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; } /// @@ -1904,7 +1951,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; @@ -2042,13 +2093,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(); @@ -2113,7 +2172,12 @@ public FakeOuterNumberSerializeApiResponse(ILogger(RawContent, _jsonSerializerOptions) - : default; + : + #if NET6_0_OR_GREATER + null + #else + default + #endif; } /// @@ -2121,7 +2185,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; @@ -2284,13 +2352,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(); @@ -2355,7 +2431,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; } /// @@ -2363,7 +2444,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; @@ -2477,13 +2562,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(); @@ -2548,7 +2641,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; } /// @@ -2556,7 +2654,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; @@ -2670,13 +2772,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(); @@ -2741,7 +2851,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; } /// @@ -2749,7 +2864,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; @@ -2863,13 +2982,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(); @@ -2934,7 +3061,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; } /// @@ -2942,7 +3074,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; @@ -3084,13 +3220,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(); @@ -3273,13 +3417,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(); @@ -3478,13 +3630,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(); @@ -3675,13 +3835,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(); @@ -3746,7 +3914,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; } /// @@ -3754,7 +3927,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; @@ -4043,13 +4220,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(); @@ -4334,13 +4519,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(); @@ -4557,13 +4750,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(); @@ -4750,13 +4951,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(); @@ -4939,13 +5148,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(); @@ -5146,13 +5363,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(); @@ -5411,13 +5636,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(); @@ -5600,13 +5833,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/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 6417fde05b994..93e8c0ed7f872 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -302,13 +302,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(); @@ -377,7 +385,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; } /// @@ -385,7 +398,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/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index db54750a432fc..c0069fe749934 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -792,7 +792,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); } @@ -807,13 +811,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(); @@ -1003,13 +1015,21 @@ public async Task DeletePetAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); @@ -1201,7 +1221,11 @@ public async Task FindPetsByStatusAsync(List FindPetsByStatusAsync(List apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); @@ -1290,7 +1322,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; } /// @@ -1298,7 +1335,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; @@ -1477,7 +1518,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); } @@ -1491,13 +1536,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(); @@ -1566,7 +1619,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; } /// @@ -1574,7 +1632,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; @@ -1719,13 +1781,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(); @@ -1794,7 +1864,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; } /// @@ -1802,7 +1877,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; @@ -1959,7 +2038,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); } @@ -1974,13 +2057,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(); @@ -2211,13 +2302,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(); @@ -2444,13 +2543,21 @@ public async Task UploadFileAsync(long petId, Option apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); @@ -2519,7 +2626,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; } /// @@ -2527,7 +2639,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; @@ -2709,13 +2825,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(); @@ -2784,7 +2908,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; } /// @@ -2792,7 +2921,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/standard2.0/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs index 52a7f2d561235..d11d29e6b88d9 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs @@ -459,13 +459,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(); @@ -631,13 +639,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(); @@ -706,7 +722,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; } /// @@ -714,7 +735,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; @@ -840,13 +865,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(); @@ -911,7 +944,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; } /// @@ -919,7 +957,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; @@ -1082,13 +1124,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(); @@ -1153,7 +1203,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; } /// @@ -1161,7 +1216,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/standard2.0/Petstore/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/UserApi.cs index d29929bbd0fd6..8460c13d69a18 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/UserApi.cs @@ -714,13 +714,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(); @@ -903,13 +911,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(); @@ -1092,13 +1108,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(); @@ -1268,13 +1292,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(); @@ -1460,13 +1492,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(); @@ -1531,7 +1571,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; } /// @@ -1539,7 +1584,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; @@ -1587,7 +1636,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; } /// @@ -1595,7 +1649,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; @@ -1750,13 +1808,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(); @@ -1821,7 +1887,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; } /// @@ -1829,7 +1900,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; @@ -1940,13 +2015,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(); @@ -2140,13 +2223,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/standard2.0/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 1a0d0a7183827..3020604121b75 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -164,7 +164,11 @@ public interface ICustomHttpStatusCode599 : IApiResponse /// /// /// - bool TryCustomHttpStatusCode599(out TType result); + bool TryCustomHttpStatusCode599( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType result); } /// @@ -184,7 +188,11 @@ public interface IOk : IApiResponse /// /// /// - bool TryOk(out TType result); + bool TryOk( +#if NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TType result); } /// @@ -204,6 +212,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/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 231c516c999c7..66f4eb2f50cf2 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/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/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 5c4159491eecb..cbcebbca10852 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/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/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 77cb3226ed070..9886721dd2919 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/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/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index a419d35bed484..4ade38370fea2 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -352,7 +352,48 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { +#if NET6_0_OR_GREATER + if (!File.Exists(KeyFilePath) && string.IsNullOrEmpty(KeyString)) + { + throw new Exception("No API key has been provided."); + } + + var keyStr = KeyString; + const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; + const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; + 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); + ecdsa.ImportEncryptedPkcs8PrivateKey(Encoding.UTF8.GetBytes(Marshal.PtrToStringUni(unmanagedString)), keyBytes, out byteCount); + } + finally + { + if (unmanagedString != IntPtr.Zero) + { + Marshal.ZeroFreeBSTR(unmanagedString); + } + } + } + else + ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount); + + var derBytes = ecdsa.SignHash(dataToSign, DSASignatureFormat.Rfc3279DerSequence); + 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 } /// diff --git a/samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks/src/Org.OpenAPITools/Client/ApiClient.cs index 38ba17f24b23c..2f97a82bfbbcb 100644 --- a/samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks/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/petstore/csharp/restsharp/net4.7/MultipleFrameworks/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks/src/Org.OpenAPITools/Client/ClientUtils.cs index ba5c33ca67796..d0283e8d7bdf5 100644 --- a/samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/restsharp/net4.7/MultipleFrameworks/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/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs index a0a43ea74aeb8..4f7265545e1e6 100644 --- a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/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/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 77cb3226ed070..9886721dd2919 100644 --- a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/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/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index a419d35bed484..4ade38370fea2 100644 --- a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -352,7 +352,48 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { +#if NET6_0_OR_GREATER + if (!File.Exists(KeyFilePath) && string.IsNullOrEmpty(KeyString)) + { + throw new Exception("No API key has been provided."); + } + + var keyStr = KeyString; + const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; + const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; + 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); + ecdsa.ImportEncryptedPkcs8PrivateKey(Encoding.UTF8.GetBytes(Marshal.PtrToStringUni(unmanagedString)), keyBytes, out byteCount); + } + finally + { + if (unmanagedString != IntPtr.Zero) + { + Marshal.ZeroFreeBSTR(unmanagedString); + } + } + } + else + ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount); + + var derBytes = ecdsa.SignHash(dataToSign, DSASignatureFormat.Rfc3279DerSequence); + 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 } /// diff --git a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs index a0a43ea74aeb8..4f7265545e1e6 100644 --- a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/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/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 77cb3226ed070..9886721dd2919 100644 --- a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/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/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index a419d35bed484..4ade38370fea2 100644 --- a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -352,7 +352,48 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { +#if NET6_0_OR_GREATER + if (!File.Exists(KeyFilePath) && string.IsNullOrEmpty(KeyString)) + { + throw new Exception("No API key has been provided."); + } + + var keyStr = KeyString; + const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; + const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; + 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); + ecdsa.ImportEncryptedPkcs8PrivateKey(Encoding.UTF8.GetBytes(Marshal.PtrToStringUni(unmanagedString)), keyBytes, out byteCount); + } + finally + { + if (unmanagedString != IntPtr.Zero) + { + Marshal.ZeroFreeBSTR(unmanagedString); + } + } + } + else + ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount); + + var derBytes = ecdsa.SignHash(dataToSign, DSASignatureFormat.Rfc3279DerSequence); + 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 } /// diff --git a/samples/client/petstore/csharp/restsharp/net6/ParameterMappings/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/restsharp/net6/ParameterMappings/src/Org.OpenAPITools/Client/ApiClient.cs index 841ef8cadecee..a415443d94fb7 100644 --- a/samples/client/petstore/csharp/restsharp/net6/ParameterMappings/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/restsharp/net6/ParameterMappings/src/Org.OpenAPITools/Client/ApiClient.cs @@ -22,6 +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/petstore/csharp/restsharp/net6/ParameterMappings/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/restsharp/net6/ParameterMappings/src/Org.OpenAPITools/Client/ClientUtils.cs index 5ebe54e204685..b60b8fdabe910 100644 --- a/samples/client/petstore/csharp/restsharp/net6/ParameterMappings/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/restsharp/net6/ParameterMappings/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -100,12 +100,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/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/ApiClient.cs index 8431e531175d4..4f7265545e1e6 100644 --- a/samples/client/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/ApiClient.cs @@ -22,6 +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/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/ClientUtils.cs index a3765e0022933..2f7f3bab093a6 100644 --- a/samples/client/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -116,12 +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/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index fcf584d1fd258..ce92aa28a5006 100644 --- a/samples/client/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/restsharp/net7/EnumMappings/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -352,6 +352,7 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { +#if NET6_0_OR_GREATER if (!File.Exists(KeyFilePath) && string.IsNullOrEmpty(KeyString)) { throw new Exception("No API key has been provided."); @@ -389,6 +390,10 @@ private string GetECDSASignature(byte[] dataToSign) 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 } /// diff --git a/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs index 8431e531175d4..4f7265545e1e6 100644 --- a/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs @@ -22,6 +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/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index a3765e0022933..2f7f3bab093a6 100644 --- a/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -116,12 +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/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index fcf584d1fd258..ce92aa28a5006 100644 --- a/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -352,6 +352,7 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { +#if NET6_0_OR_GREATER if (!File.Exists(KeyFilePath) && string.IsNullOrEmpty(KeyString)) { throw new Exception("No API key has been provided."); @@ -389,6 +390,10 @@ private string GetECDSASignature(byte[] dataToSign) 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 } /// diff --git a/samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiClient.cs index bc3f8ca8e9817..3e0e887cd4d43 100644 --- a/samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiClient.cs @@ -22,6 +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/petstore/csharp/restsharp/net7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs index 02d02e3629298..f9baf7d551a48 100644 --- a/samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/restsharp/net7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -100,12 +100,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/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/ApiClient.cs index a0a43ea74aeb8..4f7265545e1e6 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/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/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/ClientUtils.cs index 77cb3226ed070..9886721dd2919 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/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/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index a419d35bed484..4ade38370fea2 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -352,7 +352,48 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { +#if NET6_0_OR_GREATER + if (!File.Exists(KeyFilePath) && string.IsNullOrEmpty(KeyString)) + { + throw new Exception("No API key has been provided."); + } + + var keyStr = KeyString; + const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; + const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; + 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); + ecdsa.ImportEncryptedPkcs8PrivateKey(Encoding.UTF8.GetBytes(Marshal.PtrToStringUni(unmanagedString)), keyBytes, out byteCount); + } + finally + { + if (unmanagedString != IntPtr.Zero) + { + Marshal.ZeroFreeBSTR(unmanagedString); + } + } + } + else + ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount); + + var derBytes = ecdsa.SignHash(dataToSign, DSASignatureFormat.Rfc3279DerSequence); + 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 } /// diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs index a0a43ea74aeb8..4f7265545e1e6 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/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/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 77cb3226ed070..9886721dd2919 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/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/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index a419d35bed484..4ade38370fea2 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -352,7 +352,48 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { +#if NET6_0_OR_GREATER + if (!File.Exists(KeyFilePath) && string.IsNullOrEmpty(KeyString)) + { + throw new Exception("No API key has been provided."); + } + + var keyStr = KeyString; + const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; + const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; + 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); + ecdsa.ImportEncryptedPkcs8PrivateKey(Encoding.UTF8.GetBytes(Marshal.PtrToStringUni(unmanagedString)), keyBytes, out byteCount); + } + finally + { + if (unmanagedString != IntPtr.Zero) + { + Marshal.ZeroFreeBSTR(unmanagedString); + } + } + } + else + ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount); + + var derBytes = ecdsa.SignHash(dataToSign, DSASignatureFormat.Rfc3279DerSequence); + 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 } /// diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 12fe4347fc800..20ea961cc15c2 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -100,6 +100,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/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index a419d35bed484..4ade38370fea2 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -352,7 +352,48 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { +#if NET6_0_OR_GREATER + if (!File.Exists(KeyFilePath) && string.IsNullOrEmpty(KeyString)) + { + throw new Exception("No API key has been provided."); + } + + var keyStr = KeyString; + const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; + const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; + 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); + ecdsa.ImportEncryptedPkcs8PrivateKey(Encoding.UTF8.GetBytes(Marshal.PtrToStringUni(unmanagedString)), keyBytes, out byteCount); + } + finally + { + if (unmanagedString != IntPtr.Zero) + { + Marshal.ZeroFreeBSTR(unmanagedString); + } + } + } + else + ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount); + + var derBytes = ecdsa.SignHash(dataToSign, DSASignatureFormat.Rfc3279DerSequence); + 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 } ///