From 44a20ed06e7aa44430e1b5e34e0c22cb8dfa4448 Mon Sep 17 00:00:00 2001 From: David Kendall Date: Tue, 21 Apr 2026 08:49:30 +0100 Subject: [PATCH 1/7] fix: Fixed issue where reserved headers were added to the request instead of the content --- .../csharp/libraries/generichost/api.mustache | 53 ++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache index 0d86d73de3c1..0eebd9cf8ed8 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache @@ -160,6 +160,21 @@ namespace {{packageName}}.{{apiPackage}} { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -452,23 +467,6 @@ namespace {{packageName}}.{{apiPackage}} {{/-last}} {{/queryParams}} - {{#constantParams}} - {{#isHeaderParam}} - // Set client side default value of Header Param "{{baseName}}". - httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant header parameter - {{/isHeaderParam}} - {{/constantParams}} - {{#headerParams}} - {{#required}} - httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}})); - - {{/required}} - {{^required}} - if ({{paramName}}.IsSet) - httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value)); - - {{/required}} - {{/headerParams}} {{#formParams}} {{#-first}} {{#isMultipart}} @@ -573,6 +571,25 @@ namespace {{packageName}}.{{apiPackage}} {{/required}} {{/bodyParam}} + + {{/required}} + {{^required}} + if ({{paramName}}.IsSet) + { + // Set client side default value of Header Param "{{baseName}}". + if (_contentHeaders.Contains("{{baseName}}".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value)); + } + } + + {{/required}} + {{/headerParams}} + {{#authMethods}} {{#-first}} List tokenBaseLocalVars = new List(); @@ -907,4 +924,4 @@ namespace {{packageName}}.{{apiPackage}} } {{/operations}} } -{{/lambda.trimLineBreaks}} +{{/lambda.trimLineBreaks}} \ No newline at end of file From 78b3384fbbdd241afbbc16392b7d1a236bac07ac Mon Sep 17 00:00:00 2001 From: David Kendall Date: Tue, 21 Apr 2026 08:50:44 +0100 Subject: [PATCH 2/7] fix: Fixed issue where file parameter object is incorrectly JSON serialised --- .../csharp/libraries/generichost/api.mustache | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache index 0eebd9cf8ed8..4da4ac25838d 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache @@ -559,19 +559,69 @@ namespace {{packageName}}.{{apiPackage}} {{/formParams}} {{#bodyParam}} {{#required}} - httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions)); + if (({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + {{#isFile}} + else if (({{paramName}}{{^required}}.Value{{/required}} as object) is {{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar) + { + httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content); + } + {{/isFile}} + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions)); + } {{/required}} {{^required}} if ({{paramName}}.IsSet) - httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions)); + { + if (({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + {{#isFile}} + else if (({{paramName}}{{^required}}.Value{{/required}} as object) is {{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar) + { + httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content); + } + {{/isFile}} + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions)); + } + } {{/required}} {{/bodyParam}} + {{#constantParams}} + {{#isHeaderParam}} + // Set client side default value of Header Param "{{baseName}}". + if (_contentHeaders.Contains("{{baseName}}".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant header parameter + } + else + { + httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant header parameter + } + + {{/isHeaderParam}} + {{/constantParams}} + {{#headerParams}} + {{#required}} + // Set client side default value of Header Param "{{baseName}}". + if (_contentHeaders.Contains("{{baseName}}".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}})); + } + else + { + httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}})); + } + {{/required}} {{^required}} if ({{paramName}}.IsSet) From b7eee793d2b107b9a030f301db169994e6d39875 Mon Sep 17 00:00:00 2001 From: David Kendall Date: Tue, 21 Apr 2026 09:01:26 +0100 Subject: [PATCH 3/7] chore: Updated samples based on csharp changes --- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 28 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 28 ++- .../src/Org.OpenAPITools/Api/APIKEYSApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/APIKeys0Api.cs | 15 ++ .../src/Org.OpenAPITools/Api/ApiKeys1Api.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 ++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 198 ++++++++++++++---- .../Api/FakeClassnameTags123Api.cs | 26 ++- .../src/Org.OpenAPITools/Api/PetApi.cs | 49 ++++- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 ++- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++++-- 157 files changed, 6425 insertions(+), 1248 deletions(-) diff --git a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Api/DefaultApi.cs index 08bee9e4dc55..2eedc7f13c7c 100644 --- a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -112,6 +112,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -249,9 +264,16 @@ public async Task HelloWorldPostAsync(Option /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Api/DefaultApi.cs index 48a14d7ac8e1..ce0d868a0401 100644 --- a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -106,6 +106,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -230,9 +245,16 @@ public async Task OneOfArrayAsync(Option /// The logger factory /// 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 f20672ad6a9f..9aac8c119f1e 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 @@ -94,6 +94,21 @@ public sealed partial class APIKeysApi : IAPIKeysApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 3ab7b63c69af..28ebaa11cd8e 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 @@ -94,6 +94,21 @@ public sealed partial class ApiKeysApi : IApiKeysApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index e108a9106564..141b67f3b775 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,6 +106,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/DefaultApi.cs index 23e4f720a4b2..67d39c7c2594 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,6 +377,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs index b035dd5c9cd1..cce9152a7b19 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,6 +1227,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1604,9 +1619,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1859,9 +1881,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2101,9 +2130,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2368,9 +2404,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3276,9 +3319,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3489,9 +3537,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3718,9 +3771,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3931,9 +3989,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,12 +4688,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4642,6 +4699,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4882,10 +4965,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5098,9 +5199,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5311,9 +5417,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6037,9 +6148,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index f3ac29a27b3f..d1760f48b2a4 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,6 +106,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -279,9 +294,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs index c780f8623263..a2ec2b7e04a4 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,6 +667,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -836,9 +851,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1085,7 +1105,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,9 +2161,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/StoreApi.cs index f357fb96d092..a8fefc2b05d7 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,6 +293,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1140,9 +1155,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/UserApi.cs index da4e3661c441..1e8125ad13ac 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,6 +536,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -714,9 +729,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -927,9 +947,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1140,9 +1165,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2339,9 +2369,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 6e510044ff6f..922b4b30fef0 100644 --- a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -106,6 +106,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 951a8589ef49..0b638432f4d9 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs index 951a8589ef49..0b638432f4d9 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 374598ad581f..0ad93d9afcbb 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs index 5b43ed103210..b6dd4c9d722e 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs index 8a489ed1f3f3..0f8959c914f9 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1602,9 +1617,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1857,9 +1879,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2099,9 +2128,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2366,9 +2402,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3274,9 +3317,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3487,9 +3535,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3716,9 +3769,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3929,9 +3987,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4611,12 +4674,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4628,6 +4685,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4868,10 +4951,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5084,9 +5185,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5297,9 +5403,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6023,9 +6134,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 802d1fdb2ac1..b32bb89a1c21 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index 47c89d10aaa9..d9b4ec0b495e 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,9 +2159,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs index 036a6d41dfa3..78cadee7b32c 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1138,9 +1153,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/UserApi.cs index c6802990ffc6..d1b7050e5812 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/UserApi.cs @@ -534,6 +534,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -712,9 +727,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -925,9 +945,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1138,9 +1163,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2337,9 +2367,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index e108a9106564..141b67f3b775 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,6 +106,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs index 23e4f720a4b2..67d39c7c2594 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,6 +377,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs index 7504f8b34bca..e24140db416d 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,6 +1227,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1604,9 +1619,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1859,9 +1881,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2101,9 +2130,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2368,9 +2404,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3276,9 +3319,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3489,9 +3537,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3718,9 +3771,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3931,9 +3989,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,12 +4688,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4642,6 +4699,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4882,10 +4965,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5098,9 +5199,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5311,9 +5417,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6037,9 +6148,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index f3ac29a27b3f..d1760f48b2a4 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,6 +106,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -279,9 +294,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs index c780f8623263..a2ec2b7e04a4 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,6 +667,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -836,9 +851,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1085,7 +1105,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,9 +2161,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs index f357fb96d092..a8fefc2b05d7 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,6 +293,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1140,9 +1155,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs index da4e3661c441..1e8125ad13ac 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,6 +536,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -714,9 +729,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -927,9 +947,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1140,9 +1165,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2339,9 +2369,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 951a8589ef49..0b638432f4d9 100644 --- a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 374598ad581f..0ad93d9afcbb 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs index 5b43ed103210..b6dd4c9d722e 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 271fbfea2636..0db2dd9988dc 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1602,9 +1617,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1857,9 +1879,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2099,9 +2128,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2366,9 +2402,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3274,9 +3317,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3487,9 +3535,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3716,9 +3769,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3929,9 +3987,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4623,12 +4686,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4640,6 +4697,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4880,10 +4963,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5096,9 +5197,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5309,9 +5415,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6035,9 +6146,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 802d1fdb2ac1..b32bb89a1c21 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index af5a07843603..d21c0a3733c8 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,9 +2159,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs index 036a6d41dfa3..78cadee7b32c 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1138,9 +1153,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/UserApi.cs index c6802990ffc6..d1b7050e5812 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/UserApi.cs @@ -534,6 +534,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -712,9 +727,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -925,9 +945,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1138,9 +1163,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2337,9 +2367,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index e108a9106564..141b67f3b775 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,6 +106,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs index 23e4f720a4b2..67d39c7c2594 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,6 +377,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs index 7504f8b34bca..e24140db416d 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,6 +1227,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1604,9 +1619,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1859,9 +1881,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2101,9 +2130,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2368,9 +2404,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3276,9 +3319,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3489,9 +3537,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3718,9 +3771,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3931,9 +3989,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,12 +4688,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4642,6 +4699,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4882,10 +4965,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5098,9 +5199,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5311,9 +5417,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6037,9 +6148,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index f3ac29a27b3f..d1760f48b2a4 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,6 +106,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -279,9 +294,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs index c780f8623263..a2ec2b7e04a4 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,6 +667,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -836,9 +851,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1085,7 +1105,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,9 +2161,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs index f357fb96d092..a8fefc2b05d7 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,6 +293,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1140,9 +1155,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs index da4e3661c441..1e8125ad13ac 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,6 +536,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -714,9 +729,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -927,9 +947,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1140,9 +1165,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2339,9 +2369,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs index 5c7e087ff74a..3d4d119956e7 100644 --- a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 3745f6dafbf5..23e446cd0f62 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 @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 24454e8f663a..6b6b480d3dbc 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 @@ -102,6 +102,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 24454e8f663a..6b6b480d3dbc 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 @@ -102,6 +102,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 7eeebe9c25d2..2cadb94807b8 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 @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 9750887d4beb..dda2c802418e 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 @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 98684187061c..8df08c922d16 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 @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1601,9 +1616,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1855,9 +1877,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2096,9 +2125,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2362,9 +2398,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3266,9 +3309,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3479,9 +3527,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3708,9 +3761,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3921,9 +3979,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4602,12 +4665,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4619,6 +4676,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4859,10 +4942,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5074,9 +5175,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5287,9 +5393,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6012,9 +6123,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 da2c72009ed0..36a1d0c77ac8 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 @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 4f546bd46274..9639ce921451 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 @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2125,9 +2155,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c73432cbeadc..72f6c3cd2171 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 @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1135,9 +1150,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 22514301a2c9..300efba150c7 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 @@ -533,6 +533,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -704,9 +719,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -917,9 +937,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1130,9 +1155,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2298,9 +2328,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 24454e8f663a..6b6b480d3dbc 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 @@ -102,6 +102,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 7eeebe9c25d2..2cadb94807b8 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 @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 9750887d4beb..dda2c802418e 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 @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 700574a85fba..cd30e0459176 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 @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1601,9 +1616,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1855,9 +1877,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2096,9 +2125,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2362,9 +2398,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3266,9 +3309,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3479,9 +3527,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3708,9 +3761,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3921,9 +3979,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4614,12 +4677,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4631,6 +4688,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4871,10 +4954,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5086,9 +5187,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5299,9 +5405,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6024,9 +6135,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 da2c72009ed0..36a1d0c77ac8 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 @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 de209e1450ec..8d956005e837 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 @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2125,9 +2155,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c73432cbeadc..72f6c3cd2171 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 @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1135,9 +1150,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 22514301a2c9..300efba150c7 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 @@ -533,6 +533,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -704,9 +719,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -917,9 +937,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1130,9 +1155,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2298,9 +2328,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c07e3e24913e..7dda2df8b15e 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 @@ -102,6 +102,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 3745f6dafbf5..23e446cd0f62 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 @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 24454e8f663a..6b6b480d3dbc 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 @@ -102,6 +102,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 24454e8f663a..6b6b480d3dbc 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 @@ -102,6 +102,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 7eeebe9c25d2..2cadb94807b8 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 @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 9750887d4beb..dda2c802418e 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 @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 98684187061c..8df08c922d16 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 @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1601,9 +1616,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1855,9 +1877,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2096,9 +2125,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2362,9 +2398,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3266,9 +3309,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3479,9 +3527,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3708,9 +3761,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3921,9 +3979,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4602,12 +4665,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4619,6 +4676,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4859,10 +4942,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5074,9 +5175,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5287,9 +5393,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6012,9 +6123,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 da2c72009ed0..36a1d0c77ac8 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 @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 4f546bd46274..9639ce921451 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 @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2125,9 +2155,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c73432cbeadc..72f6c3cd2171 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 @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1135,9 +1150,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 22514301a2c9..300efba150c7 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 @@ -533,6 +533,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -704,9 +719,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -917,9 +937,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1130,9 +1155,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2298,9 +2328,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 24454e8f663a..6b6b480d3dbc 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 @@ -102,6 +102,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 7eeebe9c25d2..2cadb94807b8 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 @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 9750887d4beb..dda2c802418e 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 @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 700574a85fba..cd30e0459176 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 @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1601,9 +1616,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1855,9 +1877,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2096,9 +2125,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2362,9 +2398,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3266,9 +3309,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3479,9 +3527,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3708,9 +3761,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3921,9 +3979,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4614,12 +4677,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4631,6 +4688,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4871,10 +4954,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5086,9 +5187,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5299,9 +5405,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6024,9 +6135,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 da2c72009ed0..36a1d0c77ac8 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 @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 de209e1450ec..8d956005e837 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 @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2125,9 +2155,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c73432cbeadc..72f6c3cd2171 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 @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1135,9 +1150,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 22514301a2c9..300efba150c7 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 @@ -533,6 +533,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -704,9 +719,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -917,9 +937,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1130,9 +1155,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2298,9 +2328,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c07e3e24913e..7dda2df8b15e 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 @@ -102,6 +102,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 6e510044ff6f..922b4b30fef0 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 @@ -106,6 +106,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 951a8589ef49..0b638432f4d9 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 @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 951a8589ef49..0b638432f4d9 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 @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 374598ad581f..0ad93d9afcbb 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 @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 5b43ed103210..b6dd4c9d722e 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 @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 8a489ed1f3f3..0f8959c914f9 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 @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1602,9 +1617,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1857,9 +1879,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2099,9 +2128,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2366,9 +2402,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3274,9 +3317,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3487,9 +3535,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3716,9 +3769,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3929,9 +3987,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4611,12 +4674,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4628,6 +4685,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4868,10 +4951,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5084,9 +5185,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5297,9 +5403,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6023,9 +6134,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 802d1fdb2ac1..b32bb89a1c21 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 @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 47c89d10aaa9..d9b4ec0b495e 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 @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,9 +2159,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 036a6d41dfa3..78cadee7b32c 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 @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1138,9 +1153,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c6802990ffc6..d1b7050e5812 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 @@ -534,6 +534,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -712,9 +727,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -925,9 +945,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1138,9 +1163,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2337,9 +2367,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 e108a9106564..141b67f3b775 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 @@ -106,6 +106,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 23e4f720a4b2..67d39c7c2594 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 @@ -377,6 +377,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 7504f8b34bca..e24140db416d 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 @@ -1227,6 +1227,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1604,9 +1619,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1859,9 +1881,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2101,9 +2130,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2368,9 +2404,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3276,9 +3319,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3489,9 +3537,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3718,9 +3771,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3931,9 +3989,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,12 +4688,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4642,6 +4699,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4882,10 +4965,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5098,9 +5199,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5311,9 +5417,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6037,9 +6148,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f3ac29a27b3f..d1760f48b2a4 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 @@ -106,6 +106,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -279,9 +294,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 c780f8623263..a2ec2b7e04a4 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 @@ -667,6 +667,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -836,9 +851,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1085,7 +1105,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,9 +2161,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f357fb96d092..a8fefc2b05d7 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 @@ -293,6 +293,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1140,9 +1155,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 da4e3661c441..1e8125ad13ac 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 @@ -536,6 +536,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -714,9 +729,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -927,9 +947,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1140,9 +1165,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2339,9 +2369,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 951a8589ef49..0b638432f4d9 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 @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 374598ad581f..0ad93d9afcbb 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 @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 5b43ed103210..b6dd4c9d722e 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 @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 271fbfea2636..0db2dd9988dc 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 @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1602,9 +1617,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1857,9 +1879,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2099,9 +2128,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2366,9 +2402,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3274,9 +3317,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3487,9 +3535,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3716,9 +3769,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3929,9 +3987,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4623,12 +4686,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4640,6 +4697,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4880,10 +4963,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5096,9 +5197,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5309,9 +5415,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6035,9 +6146,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 802d1fdb2ac1..b32bb89a1c21 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 @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 af5a07843603..d21c0a3733c8 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 @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,9 +2159,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 036a6d41dfa3..78cadee7b32c 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 @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1138,9 +1153,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c6802990ffc6..d1b7050e5812 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 @@ -534,6 +534,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -712,9 +727,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -925,9 +945,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1138,9 +1163,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2337,9 +2367,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 e108a9106564..141b67f3b775 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 @@ -106,6 +106,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 23e4f720a4b2..67d39c7c2594 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 @@ -377,6 +377,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 7504f8b34bca..e24140db416d 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 @@ -1227,6 +1227,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1604,9 +1619,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1859,9 +1881,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2101,9 +2130,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2368,9 +2404,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3276,9 +3319,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3489,9 +3537,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3718,9 +3771,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3931,9 +3989,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,12 +4688,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4642,6 +4699,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4882,10 +4965,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5098,9 +5199,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5311,9 +5417,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6037,9 +6148,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f3ac29a27b3f..d1760f48b2a4 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 @@ -106,6 +106,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -279,9 +294,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 c780f8623263..a2ec2b7e04a4 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 @@ -667,6 +667,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -836,9 +851,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1085,7 +1105,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,9 +2161,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f357fb96d092..a8fefc2b05d7 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 @@ -293,6 +293,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1140,9 +1155,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 da4e3661c441..1e8125ad13ac 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 @@ -536,6 +536,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -714,9 +729,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -927,9 +947,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1140,9 +1165,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2339,9 +2369,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 5c7e087ff74a..3d4d119956e7 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 @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 6e510044ff6f..922b4b30fef0 100644 --- a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -106,6 +106,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 951a8589ef49..0b638432f4d9 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs index 951a8589ef49..0b638432f4d9 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 374598ad581f..0ad93d9afcbb 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs index 5b43ed103210..b6dd4c9d722e 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs index 8a489ed1f3f3..0f8959c914f9 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1602,9 +1617,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1857,9 +1879,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2099,9 +2128,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2366,9 +2402,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3274,9 +3317,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3487,9 +3535,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3716,9 +3769,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3929,9 +3987,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4611,12 +4674,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4628,6 +4685,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4868,10 +4951,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5084,9 +5185,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5297,9 +5403,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6023,9 +6134,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 802d1fdb2ac1..b32bb89a1c21 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index 47c89d10aaa9..d9b4ec0b495e 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,9 +2159,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs index 036a6d41dfa3..78cadee7b32c 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1138,9 +1153,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/UserApi.cs index c6802990ffc6..d1b7050e5812 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/UserApi.cs @@ -534,6 +534,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -712,9 +727,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -925,9 +945,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1138,9 +1163,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2337,9 +2367,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index e108a9106564..141b67f3b775 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,6 +106,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs index 23e4f720a4b2..67d39c7c2594 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,6 +377,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs index 7504f8b34bca..e24140db416d 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,6 +1227,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1604,9 +1619,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1859,9 +1881,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2101,9 +2130,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2368,9 +2404,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3276,9 +3319,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3489,9 +3537,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3718,9 +3771,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3931,9 +3989,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,12 +4688,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4642,6 +4699,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4882,10 +4965,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5098,9 +5199,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5311,9 +5417,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6037,9 +6148,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index f3ac29a27b3f..d1760f48b2a4 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,6 +106,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -279,9 +294,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs index c780f8623263..a2ec2b7e04a4 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,6 +667,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -836,9 +851,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1085,7 +1105,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,9 +2161,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs index f357fb96d092..a8fefc2b05d7 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,6 +293,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1140,9 +1155,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs index da4e3661c441..1e8125ad13ac 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,6 +536,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -714,9 +729,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -927,9 +947,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1140,9 +1165,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2339,9 +2369,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 951a8589ef49..0b638432f4d9 100644 --- a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 374598ad581f..0ad93d9afcbb 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -104,6 +104,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -275,9 +290,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs index 5b43ed103210..b6dd4c9d722e 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -375,6 +375,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 271fbfea2636..0db2dd9988dc 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1225,6 +1225,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1602,9 +1617,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1857,9 +1879,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2099,9 +2128,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2366,9 +2402,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3274,9 +3317,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3487,9 +3535,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3716,9 +3769,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3929,9 +3987,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4623,12 +4686,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4640,6 +4697,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4880,10 +4963,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5096,9 +5197,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5309,9 +5415,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6035,9 +6146,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 802d1fdb2ac1..b32bb89a1c21 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -104,6 +104,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index af5a07843603..d21c0a3733c8 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -665,6 +665,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -834,9 +849,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1083,7 +1103,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,9 +2159,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs index 036a6d41dfa3..78cadee7b32c 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs @@ -291,6 +291,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1138,9 +1153,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/UserApi.cs index c6802990ffc6..d1b7050e5812 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/UserApi.cs @@ -534,6 +534,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -712,9 +727,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -925,9 +945,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1138,9 +1163,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2337,9 +2367,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index e108a9106564..141b67f3b775 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,6 +106,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -277,9 +292,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs index 23e4f720a4b2..67d39c7c2594 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,6 +377,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs index 7504f8b34bca..e24140db416d 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,6 +1227,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1604,9 +1619,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1859,9 +1881,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2101,9 +2130,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2368,9 +2404,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3276,9 +3319,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3489,9 +3537,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3718,9 +3771,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3931,9 +3989,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,12 +4688,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4642,6 +4699,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4882,10 +4965,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5098,9 +5199,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5311,9 +5417,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6037,9 +6148,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index f3ac29a27b3f..d1760f48b2a4 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,6 +106,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -279,9 +294,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs index c780f8623263..a2ec2b7e04a4 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,6 +667,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -836,9 +851,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1085,7 +1105,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,9 +2161,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs index f357fb96d092..a8fefc2b05d7 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,6 +293,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1140,9 +1155,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs index da4e3661c441..1e8125ad13ac 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,6 +536,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -714,9 +729,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -927,9 +947,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1140,9 +1165,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2339,9 +2369,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs index 5c7e087ff74a..3d4d119956e7 100644 --- a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,6 +104,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 d5ef07d0af6c..fce65ea3cadb 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 @@ -103,6 +103,21 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -274,9 +289,14 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 dc821468334b..11fbc5083dd3 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 @@ -374,6 +374,21 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// 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 0cde2825a8f0..7cb42e965e29 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 @@ -1224,6 +1224,21 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1600,9 +1615,16 @@ public async Task FakeOuterBooleanSeriali : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/boolean"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1854,9 +1876,16 @@ public async Task FakeOuterCompositeSer : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/composite"); if (outerComposite.IsSet) - httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + { + if ((outerComposite.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2095,9 +2124,16 @@ public async Task FakeOuterNumberSerialize : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/outer/number"); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2361,9 +2397,16 @@ public async Task FakeOuterStringSerialize uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); if (body.IsSet) - httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + { + if ((body.Value as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + } + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3265,9 +3308,14 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3478,9 +3526,14 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + if ((fileSchemaTestClass as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3707,9 +3760,14 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3920,9 +3978,14 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4613,12 +4676,6 @@ public async Task TestEnumParametersAsync(Option uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if (enumHeaderString.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); - - if (enumHeaderStringArray.IsSet) - httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4630,6 +4687,32 @@ public async Task TestEnumParametersAsync(Option if (formParameterLocalVars.Count > 0) httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (enumHeaderString.IsSet) + { + // Set client side default value of Header Param "enum_header_string". + if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + } + } + + if (enumHeaderStringArray.IsSet) + { + // Set client side default value of Header Param "enum_header_string_array". + if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + } + } + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -4870,10 +4953,28 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + // Set client side default value of Header Param "required_boolean_group". + if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + } if (booleanGroup.IsSet) - httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + { + // Set client side default value of Header Param "boolean_group". + if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + { + httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + else + { + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + } + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5085,9 +5186,14 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5298,9 +5404,14 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6023,9 +6134,14 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + if ((requestBody as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 3513619a880c..525a2b0f1299 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 @@ -103,6 +103,21 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -276,9 +291,14 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + if ((modelClient as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 7592e4b8d2fd..efbc696aa27b 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 @@ -664,6 +664,21 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -833,9 +848,14 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1082,7 +1102,17 @@ public async Task DeletePetAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2124,9 +2154,14 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + if ((pet as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + } List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 7c748b85f522..542fe24e16b3 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 @@ -290,6 +290,21 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -1134,9 +1149,14 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + if ((order as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 4f5e5922505b..a754e0af04ae 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 @@ -532,6 +532,21 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private readonly string[] _contentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified", + "extension-header" + ]; + /// /// The logger factory /// @@ -703,9 +718,14 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -916,9 +936,14 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1129,9 +1154,14 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2297,9 +2327,14 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream - ? httpRequestMessageLocalVar.Content = new StreamContent(stream) - : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + if ((user as object) is System.IO.Stream stream) + { + httpRequestMessageLocalVar.Content = new StreamContent(stream); + } + else + { + httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; From 7f890c1b1a21e8334978f4edfed8517682712bef Mon Sep 17 00:00:00 2001 From: David Kendall Date: Wed, 22 Apr 2026 09:27:44 +0100 Subject: [PATCH 4/7] fix: Moved content header checks to client utils --- .../generichost/ClientUtils.mustache | 28 ++++ .../csharp/libraries/generichost/api.mustache | 53 +------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 26 +--- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 26 +--- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/APIKEYSApi.cs | 15 -- .../src/Org.OpenAPITools/Api/APIKeys0Api.cs | 15 -- .../src/Org.OpenAPITools/Api/ApiKeys1Api.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 15 -- .../src/Org.OpenAPITools/Api/FakeApi.cs | 138 +++++------------- .../Api/FakeClassnameTags123Api.cs | 26 +--- .../src/Org.OpenAPITools/Api/PetApi.cs | 37 +---- .../src/Org.OpenAPITools/Api/StoreApi.cs | 26 +--- .../src/Org.OpenAPITools/Api/UserApi.cs | 59 ++------ .../Org.OpenAPITools/Client/ClientUtils.cs | 28 ++++ 207 files changed, 2484 insertions(+), 5314 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache index 6e7f9809f237..25c0d920f68b 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache @@ -407,6 +407,34 @@ using System.Net.Http.Headers; throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache index 4da4ac25838d..68dc0725ee4d 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache @@ -160,21 +160,6 @@ namespace {{packageName}}.{{apiPackage}} { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -559,38 +544,16 @@ namespace {{packageName}}.{{apiPackage}} {{/formParams}} {{#bodyParam}} {{#required}} - if (({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - {{#isFile}} - else if (({{paramName}}{{^required}}.Value{{/required}} as object) is {{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar) - { - httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content); - } - {{/isFile}} - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is {{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions)); {{/required}} {{^required}} if ({{paramName}}.IsSet) { - if (({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - {{#isFile}} - else if (({{paramName}}{{^required}}.Value{{/required}} as object) is {{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar) - { - httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content); - } - {{/isFile}} - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is {{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions)); } {{/required}} @@ -599,7 +562,7 @@ namespace {{packageName}}.{{apiPackage}} {{#constantParams}} {{#isHeaderParam}} // Set client side default value of Header Param "{{baseName}}". - if (_contentHeaders.Contains("{{baseName}}".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("{{baseName}}")) { httpRequestMessageLocalVar.Content.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant header parameter } @@ -613,7 +576,7 @@ namespace {{packageName}}.{{apiPackage}} {{#headerParams}} {{#required}} // Set client side default value of Header Param "{{baseName}}". - if (_contentHeaders.Contains("{{baseName}}".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("{{baseName}}")) { httpRequestMessageLocalVar.Content.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}})); } diff --git a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs index 3c7e3f8809dc..6ff788bd22f7 100644 --- a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -307,6 +307,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Api/DefaultApi.cs index 2eedc7f13c7c..886510d697ba 100644 --- a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -112,21 +112,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -265,14 +250,9 @@ public async Task HelloWorldPostAsync(Option + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index f9c33c3c16f7..5e725e10b2e3 100644 --- a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -106,21 +106,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 3cd28f988823..39629d116f56 100644 --- a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -303,6 +303,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Api/DefaultApi.cs index ce0d868a0401..6c73040ca3cb 100644 --- a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -106,21 +106,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -246,14 +231,9 @@ public async Task OneOfArrayAsync(Option + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 f7ff0fdd334e..7ca4bb0789ed 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 @@ -106,21 +106,6 @@ public sealed partial class APIKEYSApi : IAPIKEYSApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 9aac8c119f1e..f20672ad6a9f 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 @@ -94,21 +94,6 @@ public sealed partial class APIKeysApi : IAPIKeysApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 28ebaa11cd8e..3ab7b63c69af 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 @@ -94,21 +94,6 @@ public sealed partial class ApiKeysApi : IApiKeysApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 48719ee3a820..a170f7169424 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 @@ -327,6 +327,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 141b67f3b775..04b8da36fe38 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,21 +106,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/DefaultApi.cs index 67d39c7c2594..23e4f720a4b2 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,21 +377,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs index cce9152a7b19..24bf1bc6d693 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,21 +1227,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1620,14 +1605,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1882,14 +1862,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,14 +2106,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2405,14 +2375,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3319,14 +3284,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3537,14 +3497,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3771,14 +3726,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3989,14 +3939,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4966,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5199,14 +5144,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5417,14 +5357,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6148,14 +6083,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index d1760f48b2a4..980b7a0c1f89 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,21 +106,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -294,14 +279,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs index a2ec2b7e04a4..11a6bb0179a0 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,21 +667,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -851,14 +836,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2161,14 +2141,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/StoreApi.cs index a8fefc2b05d7..08624b36f6ad 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,21 +293,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1155,14 +1140,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/UserApi.cs index 1e8125ad13ac..c8536386fafb 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,21 +536,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -729,14 +714,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -947,14 +927,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1165,14 +1140,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2369,14 +2339,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Client/ClientUtils.cs index 307e2a2ef3d3..4bbb1edad442 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -402,6 +402,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 922b4b30fef0..6e510044ff6f 100644 --- a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -106,21 +106,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs index c75a26cd1562..d5150a352d8e 100644 --- a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -316,6 +316,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 0b638432f4d9..951a8589ef49 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index e3f39f30bec8..16131f7e8354 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -316,6 +316,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs index 0b638432f4d9..951a8589ef49 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs index 0efabe7ad9a2..2d4c53ec64b9 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -301,6 +301,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 0ad93d9afcbb..0de8a13cdbd7 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs index b6dd4c9d722e..5b43ed103210 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs index 0f8959c914f9..bd655ea3b6c6 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1618,14 +1603,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1880,14 +1860,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,14 +2104,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2403,14 +2373,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3317,14 +3282,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3535,14 +3495,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3769,14 +3724,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3987,14 +3937,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4952,7 +4897,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5185,14 +5130,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5403,14 +5343,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6134,14 +6069,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index b32bb89a1c21..2813dbef14b7 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index d9b4ec0b495e..f56a0b9bbba4 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2159,14 +2139,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs index 78cadee7b32c..f05331998ad1 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1153,14 +1138,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/UserApi.cs index d1b7050e5812..ecdf56916766 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/UserApi.cs @@ -534,21 +534,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -727,14 +712,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -945,14 +925,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1163,14 +1138,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2367,14 +2337,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 97b8745cc47b..84aaed045c18 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -411,6 +411,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 141b67f3b775..04b8da36fe38 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,21 +106,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs index 67d39c7c2594..23e4f720a4b2 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,21 +377,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs index e24140db416d..f36578eb240e 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,21 +1227,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1620,14 +1605,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1882,14 +1862,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,14 +2106,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2405,14 +2375,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3319,14 +3284,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3537,14 +3497,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3771,14 +3726,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3989,14 +3939,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4966,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5199,14 +5144,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5417,14 +5357,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6148,14 +6083,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index d1760f48b2a4..980b7a0c1f89 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,21 +106,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -294,14 +279,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs index a2ec2b7e04a4..11a6bb0179a0 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,21 +667,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -851,14 +836,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2161,14 +2141,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs index a8fefc2b05d7..08624b36f6ad 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,21 +293,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1155,14 +1140,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs index 1e8125ad13ac..c8536386fafb 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,21 +536,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -729,14 +714,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -947,14 +927,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1165,14 +1140,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2369,14 +2339,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs index a66181bb5473..4489c1b34450 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -417,6 +417,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 0b638432f4d9..951a8589ef49 100644 --- a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs index e3f39f30bec8..16131f7e8354 100644 --- a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -316,6 +316,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 0ad93d9afcbb..0de8a13cdbd7 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs index b6dd4c9d722e..5b43ed103210 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 0db2dd9988dc..50a5e8e5fc15 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1618,14 +1603,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1880,14 +1860,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,14 +2104,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2403,14 +2373,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3317,14 +3282,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3535,14 +3495,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3769,14 +3724,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3987,14 +3937,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4964,7 +4909,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5197,14 +5142,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5415,14 +5355,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6146,14 +6081,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index b32bb89a1c21..2813dbef14b7 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index d21c0a3733c8..bc222a110235 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2159,14 +2139,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs index 78cadee7b32c..f05331998ad1 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1153,14 +1138,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/UserApi.cs index d1b7050e5812..ecdf56916766 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/UserApi.cs @@ -534,21 +534,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -727,14 +712,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -945,14 +925,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1163,14 +1138,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2367,14 +2337,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 3dfb7ecffbed..06253126bca7 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -415,6 +415,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 141b67f3b775..04b8da36fe38 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,21 +106,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs index 67d39c7c2594..23e4f720a4b2 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,21 +377,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs index e24140db416d..f36578eb240e 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,21 +1227,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1620,14 +1605,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1882,14 +1862,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,14 +2106,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2405,14 +2375,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3319,14 +3284,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3537,14 +3497,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3771,14 +3726,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3989,14 +3939,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4966,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5199,14 +5144,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5417,14 +5357,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6148,14 +6083,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index d1760f48b2a4..980b7a0c1f89 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,21 +106,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -294,14 +279,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs index a2ec2b7e04a4..11a6bb0179a0 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,21 +667,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -851,14 +836,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2161,14 +2141,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs index a8fefc2b05d7..08624b36f6ad 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,21 +293,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1155,14 +1140,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs index 1e8125ad13ac..c8536386fafb 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,21 +536,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -729,14 +714,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -947,14 +927,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1165,14 +1140,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2369,14 +2339,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs index a66181bb5473..4489c1b34450 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -417,6 +417,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs index 3d4d119956e7..5c7e087ff74a 100644 --- a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs index 55d79ce4b6a8..69c89fe8d7e9 100644 --- a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -301,6 +301,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 23e446cd0f62..3745f6dafbf5 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 @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 edb65b8265db..10077b16352e 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 @@ -311,6 +311,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 6b6b480d3dbc..24454e8f663a 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 @@ -102,21 +102,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 69f7ad2b7116..d64635364f50 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 @@ -311,6 +311,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 6b6b480d3dbc..24454e8f663a 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 @@ -102,21 +102,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 217a64d7d771..d204a74e39dc 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 @@ -296,6 +296,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 2cadb94807b8..1540faaeb1cf 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 @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 dda2c802418e..9750887d4beb 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 @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 8df08c922d16..9db2090409a2 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 @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1617,14 +1602,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1878,14 +1858,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2126,14 +2101,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2399,14 +2369,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3309,14 +3274,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3527,14 +3487,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3761,14 +3716,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3979,14 +3929,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4943,7 +4888,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5175,14 +5120,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5393,14 +5333,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6123,14 +6058,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 36a1d0c77ac8..0fe14400f4d6 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 @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 9639ce921451..3b8cde8db26d 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 @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2155,14 +2135,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 72f6c3cd2171..9c7430992dbb 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 @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1150,14 +1135,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 300efba150c7..4c61cc91448a 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 @@ -533,21 +533,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -719,14 +704,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -937,14 +917,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1155,14 +1130,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2328,14 +2298,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 585f78b2c231..39fc58ce3e62 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 @@ -411,6 +411,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 6b6b480d3dbc..24454e8f663a 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 @@ -102,21 +102,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 69f7ad2b7116..d64635364f50 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 @@ -311,6 +311,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 2cadb94807b8..1540faaeb1cf 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 @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 dda2c802418e..9750887d4beb 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 @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 cd30e0459176..3abe506592a7 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 @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1617,14 +1602,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1878,14 +1858,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2126,14 +2101,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2399,14 +2369,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3309,14 +3274,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3527,14 +3487,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3761,14 +3716,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3979,14 +3929,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4955,7 +4900,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5187,14 +5132,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5405,14 +5345,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6135,14 +6070,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 36a1d0c77ac8..0fe14400f4d6 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 @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 8d956005e837..f611687fd143 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 @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2155,14 +2135,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 72f6c3cd2171..9c7430992dbb 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 @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1150,14 +1135,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 300efba150c7..4c61cc91448a 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 @@ -533,21 +533,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -719,14 +704,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -937,14 +917,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1155,14 +1130,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2328,14 +2298,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c2d90fee7b00..13cc0f472bf3 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 @@ -415,6 +415,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 7dda2df8b15e..c07e3e24913e 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 @@ -102,21 +102,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 f421f6d6c00b..b6913a536e14 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 @@ -296,6 +296,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 23e446cd0f62..3745f6dafbf5 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 @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 edb65b8265db..10077b16352e 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 @@ -311,6 +311,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 6b6b480d3dbc..24454e8f663a 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 @@ -102,21 +102,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 69f7ad2b7116..d64635364f50 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 @@ -311,6 +311,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 6b6b480d3dbc..24454e8f663a 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 @@ -102,21 +102,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 217a64d7d771..d204a74e39dc 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 @@ -296,6 +296,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 2cadb94807b8..1540faaeb1cf 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 @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 dda2c802418e..9750887d4beb 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 @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 8df08c922d16..9db2090409a2 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 @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1617,14 +1602,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1878,14 +1858,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2126,14 +2101,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2399,14 +2369,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3309,14 +3274,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3527,14 +3487,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3761,14 +3716,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3979,14 +3929,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4943,7 +4888,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5175,14 +5120,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5393,14 +5333,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6123,14 +6058,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 36a1d0c77ac8..0fe14400f4d6 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 @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 9639ce921451..3b8cde8db26d 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 @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2155,14 +2135,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 72f6c3cd2171..9c7430992dbb 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 @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1150,14 +1135,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 300efba150c7..4c61cc91448a 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 @@ -533,21 +533,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -719,14 +704,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -937,14 +917,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1155,14 +1130,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2328,14 +2298,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 585f78b2c231..39fc58ce3e62 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 @@ -411,6 +411,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 6b6b480d3dbc..24454e8f663a 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 @@ -102,21 +102,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 69f7ad2b7116..d64635364f50 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 @@ -311,6 +311,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 2cadb94807b8..1540faaeb1cf 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 @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 dda2c802418e..9750887d4beb 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 @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 cd30e0459176..3abe506592a7 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 @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1617,14 +1602,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1878,14 +1858,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2126,14 +2101,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2399,14 +2369,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3309,14 +3274,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3527,14 +3487,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3761,14 +3716,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3979,14 +3929,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4955,7 +4900,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5187,14 +5132,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5405,14 +5345,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6135,14 +6070,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 36a1d0c77ac8..0fe14400f4d6 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 @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 8d956005e837..f611687fd143 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 @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2155,14 +2135,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 72f6c3cd2171..9c7430992dbb 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 @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1150,14 +1135,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 300efba150c7..4c61cc91448a 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 @@ -533,21 +533,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -719,14 +704,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -937,14 +917,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1155,14 +1130,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2328,14 +2298,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c2d90fee7b00..13cc0f472bf3 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 @@ -415,6 +415,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 7dda2df8b15e..c07e3e24913e 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 @@ -102,21 +102,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 f421f6d6c00b..b6913a536e14 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 @@ -296,6 +296,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 922b4b30fef0..6e510044ff6f 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 @@ -106,21 +106,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 c75a26cd1562..d5150a352d8e 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 @@ -316,6 +316,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 0b638432f4d9..951a8589ef49 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 @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 e3f39f30bec8..16131f7e8354 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 @@ -316,6 +316,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 0b638432f4d9..951a8589ef49 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 @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 0efabe7ad9a2..2d4c53ec64b9 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 @@ -301,6 +301,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 0ad93d9afcbb..0de8a13cdbd7 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 @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 b6dd4c9d722e..5b43ed103210 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 @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 0f8959c914f9..bd655ea3b6c6 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 @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1618,14 +1603,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1880,14 +1860,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,14 +2104,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2403,14 +2373,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3317,14 +3282,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3535,14 +3495,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3769,14 +3724,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3987,14 +3937,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4952,7 +4897,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5185,14 +5130,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5403,14 +5343,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6134,14 +6069,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 b32bb89a1c21..2813dbef14b7 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 @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 d9b4ec0b495e..f56a0b9bbba4 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 @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2159,14 +2139,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 78cadee7b32c..f05331998ad1 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 @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1153,14 +1138,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d1b7050e5812..ecdf56916766 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 @@ -534,21 +534,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -727,14 +712,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -945,14 +925,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1163,14 +1138,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2367,14 +2337,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 97b8745cc47b..84aaed045c18 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 @@ -411,6 +411,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 141b67f3b775..04b8da36fe38 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 @@ -106,21 +106,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 67d39c7c2594..23e4f720a4b2 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 @@ -377,21 +377,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 e24140db416d..f36578eb240e 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 @@ -1227,21 +1227,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1620,14 +1605,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1882,14 +1862,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,14 +2106,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2405,14 +2375,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3319,14 +3284,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3537,14 +3497,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3771,14 +3726,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3989,14 +3939,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4966,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5199,14 +5144,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5417,14 +5357,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6148,14 +6083,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d1760f48b2a4..980b7a0c1f89 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 @@ -106,21 +106,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -294,14 +279,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 a2ec2b7e04a4..11a6bb0179a0 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 @@ -667,21 +667,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -851,14 +836,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2161,14 +2141,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 a8fefc2b05d7..08624b36f6ad 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 @@ -293,21 +293,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1155,14 +1140,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 1e8125ad13ac..c8536386fafb 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 @@ -536,21 +536,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -729,14 +714,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -947,14 +927,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1165,14 +1140,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2369,14 +2339,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 a66181bb5473..4489c1b34450 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 @@ -417,6 +417,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 0b638432f4d9..951a8589ef49 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 @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 e3f39f30bec8..16131f7e8354 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 @@ -316,6 +316,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 0ad93d9afcbb..0de8a13cdbd7 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 @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 b6dd4c9d722e..5b43ed103210 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 @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 0db2dd9988dc..50a5e8e5fc15 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 @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1618,14 +1603,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1880,14 +1860,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,14 +2104,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2403,14 +2373,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3317,14 +3282,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3535,14 +3495,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3769,14 +3724,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3987,14 +3937,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4964,7 +4909,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5197,14 +5142,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5415,14 +5355,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6146,14 +6081,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 b32bb89a1c21..2813dbef14b7 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 @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 d21c0a3733c8..bc222a110235 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 @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2159,14 +2139,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 78cadee7b32c..f05331998ad1 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 @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1153,14 +1138,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d1b7050e5812..ecdf56916766 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 @@ -534,21 +534,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -727,14 +712,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -945,14 +925,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1163,14 +1138,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2367,14 +2337,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 3dfb7ecffbed..06253126bca7 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 @@ -415,6 +415,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 141b67f3b775..04b8da36fe38 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 @@ -106,21 +106,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 67d39c7c2594..23e4f720a4b2 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 @@ -377,21 +377,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 e24140db416d..f36578eb240e 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 @@ -1227,21 +1227,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1620,14 +1605,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1882,14 +1862,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,14 +2106,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2405,14 +2375,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3319,14 +3284,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3537,14 +3497,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3771,14 +3726,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3989,14 +3939,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4966,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5199,14 +5144,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5417,14 +5357,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6148,14 +6083,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d1760f48b2a4..980b7a0c1f89 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 @@ -106,21 +106,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -294,14 +279,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 a2ec2b7e04a4..11a6bb0179a0 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 @@ -667,21 +667,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -851,14 +836,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2161,14 +2141,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 a8fefc2b05d7..08624b36f6ad 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 @@ -293,21 +293,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1155,14 +1140,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 1e8125ad13ac..c8536386fafb 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 @@ -536,21 +536,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -729,14 +714,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -947,14 +927,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1165,14 +1140,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2369,14 +2339,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 a66181bb5473..4489c1b34450 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 @@ -417,6 +417,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 3d4d119956e7..5c7e087ff74a 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 @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 55d79ce4b6a8..69c89fe8d7e9 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 @@ -301,6 +301,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 922b4b30fef0..6e510044ff6f 100644 --- a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -106,21 +106,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs index c75a26cd1562..d5150a352d8e 100644 --- a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -316,6 +316,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 0b638432f4d9..951a8589ef49 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index e3f39f30bec8..16131f7e8354 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -316,6 +316,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs index 0b638432f4d9..951a8589ef49 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs index 0efabe7ad9a2..2d4c53ec64b9 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -301,6 +301,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 0ad93d9afcbb..0de8a13cdbd7 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs index b6dd4c9d722e..5b43ed103210 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs index 0f8959c914f9..bd655ea3b6c6 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1618,14 +1603,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1880,14 +1860,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,14 +2104,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2403,14 +2373,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3317,14 +3282,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3535,14 +3495,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3769,14 +3724,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3987,14 +3937,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4952,7 +4897,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5185,14 +5130,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5403,14 +5343,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6134,14 +6069,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index b32bb89a1c21..2813dbef14b7 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index d9b4ec0b495e..f56a0b9bbba4 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2159,14 +2139,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs index 78cadee7b32c..f05331998ad1 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1153,14 +1138,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/UserApi.cs index d1b7050e5812..ecdf56916766 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/UserApi.cs @@ -534,21 +534,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -727,14 +712,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -945,14 +925,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1163,14 +1138,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2367,14 +2337,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 97b8745cc47b..84aaed045c18 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -411,6 +411,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 141b67f3b775..04b8da36fe38 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,21 +106,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs index 67d39c7c2594..23e4f720a4b2 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,21 +377,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs index e24140db416d..f36578eb240e 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,21 +1227,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1620,14 +1605,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1882,14 +1862,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,14 +2106,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2405,14 +2375,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3319,14 +3284,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3537,14 +3497,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3771,14 +3726,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3989,14 +3939,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4966,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5199,14 +5144,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5417,14 +5357,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6148,14 +6083,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index d1760f48b2a4..980b7a0c1f89 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,21 +106,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -294,14 +279,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs index a2ec2b7e04a4..11a6bb0179a0 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,21 +667,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -851,14 +836,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2161,14 +2141,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs index a8fefc2b05d7..08624b36f6ad 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,21 +293,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1155,14 +1140,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs index 1e8125ad13ac..c8536386fafb 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,21 +536,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -729,14 +714,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -947,14 +927,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1165,14 +1140,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2369,14 +2339,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs index a66181bb5473..4489c1b34450 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -417,6 +417,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 0b638432f4d9..951a8589ef49 100644 --- a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs index e3f39f30bec8..16131f7e8354 100644 --- a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -316,6 +316,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 0ad93d9afcbb..0de8a13cdbd7 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -104,21 +104,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -290,14 +275,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs index b6dd4c9d722e..5b43ed103210 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -375,21 +375,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 0db2dd9988dc..50a5e8e5fc15 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1225,21 +1225,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1618,14 +1603,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1880,14 +1860,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2129,14 +2104,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2403,14 +2373,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3317,14 +3282,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3535,14 +3495,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3769,14 +3724,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3987,14 +3937,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4964,7 +4909,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5197,14 +5142,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5415,14 +5355,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6146,14 +6081,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index b32bb89a1c21..2813dbef14b7 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -104,21 +104,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index d21c0a3733c8..bc222a110235 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -665,21 +665,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -849,14 +834,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2159,14 +2139,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs index 78cadee7b32c..f05331998ad1 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs @@ -291,21 +291,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1153,14 +1138,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/UserApi.cs index d1b7050e5812..ecdf56916766 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/UserApi.cs @@ -534,21 +534,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -727,14 +712,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -945,14 +925,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1163,14 +1138,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2367,14 +2337,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 3dfb7ecffbed..06253126bca7 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -415,6 +415,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 141b67f3b775..04b8da36fe38 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -106,21 +106,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -292,14 +277,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs index 67d39c7c2594..23e4f720a4b2 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -377,21 +377,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs index e24140db416d..f36578eb240e 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs @@ -1227,21 +1227,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1620,14 +1605,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1882,14 +1862,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2131,14 +2106,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2405,14 +2375,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3319,14 +3284,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3537,14 +3497,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3771,14 +3726,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3989,14 +3939,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4966,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5199,14 +5144,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5417,14 +5357,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6148,14 +6083,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index d1760f48b2a4..980b7a0c1f89 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -106,21 +106,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -294,14 +279,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs index a2ec2b7e04a4..11a6bb0179a0 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs @@ -667,21 +667,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -851,14 +836,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2161,14 +2141,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs index a8fefc2b05d7..08624b36f6ad 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/StoreApi.cs @@ -293,21 +293,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1155,14 +1140,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs index 1e8125ad13ac..c8536386fafb 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/UserApi.cs @@ -536,21 +536,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -729,14 +714,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -947,14 +927,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1165,14 +1140,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2369,14 +2339,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs index a66181bb5473..4489c1b34450 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -417,6 +417,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// diff --git a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs index 3d4d119956e7..5c7e087ff74a 100644 --- a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -104,21 +104,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// diff --git a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs index 55d79ce4b6a8..69c89fe8d7e9 100644 --- a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -301,6 +301,34 @@ public static bool IsJsonMime(string mime) throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// 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 fce65ea3cadb..6eb8990489ae 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 @@ -103,21 +103,6 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -289,14 +274,9 @@ public async Task Call123TestSpecialTagsAsyn ? "/another-fake/dummy" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 11fbc5083dd3..dc821468334b 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 @@ -374,21 +374,6 @@ public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// 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 7cb42e965e29..fb970455c052 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 @@ -1224,21 +1224,6 @@ public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1616,14 +1601,9 @@ public async Task FakeOuterBooleanSeriali if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1877,14 +1857,9 @@ public async Task FakeOuterCompositeSer if (outerComposite.IsSet) { - if ((outerComposite.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2125,14 +2100,9 @@ public async Task FakeOuterNumberSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2398,14 +2368,9 @@ public async Task FakeOuterStringSerialize if (body.IsSet) { - if ((body.Value as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (body.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); } httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3308,14 +3273,9 @@ public async Task TestAdditionalP ? "/fake/additionalProperties-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/additionalProperties-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3526,14 +3486,9 @@ public async Task TestBodyWithFileSchemaAsyn ? "/fake/body-with-file-schema" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/body-with-file-schema"); - if ((fileSchemaTestClass as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3760,14 +3715,9 @@ public async Task TestBodyWithQueryParamsAs uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3978,14 +3928,9 @@ public async Task TestClientModelAsync(ModelClient ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake"); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4954,7 +4899,7 @@ public async Task TestGroupParametersAsync(bool uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); // Set client side default value of Header Param "required_boolean_group". - if (_contentHeaders.Contains("required_boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("required_boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } @@ -5186,14 +5131,9 @@ public async Task TestInlineAddition ? "/fake/inline-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-additionalProperties"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5404,14 +5344,9 @@ public async Task TestInline ? "/fake/inline-freeform-additionalProperties" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/inline-freeform-additionalProperties"); - if ((testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -6134,14 +6069,9 @@ public async Task TestStringMapReferenceAsyn ? "/fake/stringMap-reference" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/fake/stringMap-reference"); - if ((requestBody as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (requestBody as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 525a2b0f1299..c84e52a5a500 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 @@ -103,21 +103,6 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -291,14 +276,9 @@ public async Task TestClassnameAsync(ModelClient mode System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); - if ((modelClient as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); 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 efbc696aa27b..c34d547f0c2c 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 @@ -664,21 +664,6 @@ public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -848,14 +833,9 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2154,14 +2134,9 @@ public async Task UpdatePetAsync(Pet pet, System.Threadin uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; - if ((pet as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (pet as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 542fe24e16b3..f8551cfa6d00 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 @@ -290,21 +290,6 @@ public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -1149,14 +1134,9 @@ public async Task PlaceOrderAsync(Order order, System.Th ? "/store/order" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/store/order"); - if ((order as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (order as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 a754e0af04ae..6f79c82446ac 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 @@ -532,21 +532,6 @@ public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private readonly string[] _contentHeaders = - [ - "allow", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-md5", - "content-range", - "content-type", - "expires", - "last-modified", - "extension-header" - ]; - /// /// The logger factory /// @@ -718,14 +703,9 @@ public async Task CreateUserAsync(User user, System.Thre ? "/user" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -936,14 +916,9 @@ public async Task CreateUsersWithArrayInp ? "/user/createWithArray" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithArray"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -1154,14 +1129,9 @@ public async Task CreateUsersWithListInput ? "/user/createWithList" : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/createWithList"); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2327,14 +2297,9 @@ public async Task UpdateUserAsync(User user, string user : string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/user/{username}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); - if ((user as object) is System.IO.Stream stream) - { - httpRequestMessageLocalVar.Content = new StreamContent(stream); - } - else - { - httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); - } + httpRequestMessageLocalVar.Content = (user as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar + ? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c2d90fee7b00..13cc0f472bf3 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 @@ -415,6 +415,34 @@ public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string disc throw new JsonException("The specified discriminator was not found."); } + /// + /// Determines if the provided header is a content header + /// + /// The header to check + /// True if a content header; False otherwise + public static bool IsContentHeader(string header) + { + return ContentHeaders.Contains(header.ToLowerInvariant()); + } + + /// + /// The collection of content headers as per + /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers + /// + private static readonly string[] ContentHeaders = + [ + "allow", + "content-encoding", + "content-language", + "content-length", + "content-location", + "content-md5", + "content-range", + "content-type", + "expires", + "last-modified" + ]; + /// /// The base path of the API /// From 210df5094260cdf79fbd0190b64cd0747088d86e Mon Sep 17 00:00:00 2001 From: David Kendall Date: Wed, 22 Apr 2026 11:50:19 +0100 Subject: [PATCH 5/7] fix: Fixed reference to new IsContentHeader static method --- .../resources/csharp/libraries/generichost/api.mustache | 2 +- .../UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net4.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net4.8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net4.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 6 +++--- .../standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- 37 files changed, 73 insertions(+), 73 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache index 68dc0725ee4d..6a487ddbcdcd 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache @@ -590,7 +590,7 @@ namespace {{packageName}}.{{apiPackage}} if ({{paramName}}.IsSet) { // Set client side default value of Header Param "{{baseName}}". - if (_contentHeaders.Contains("{{baseName}}".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("{{baseName}}")) { httpRequestMessageLocalVar.Content.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value)); } diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs index 24bf1bc6d693..63467d008877 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs @@ -4647,7 +4647,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs index 11a6bb0179a0..3d7192880e69 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4646,7 +4646,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4909,7 +4909,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index f56a0b9bbba4..909cc815a5fb 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs index 11a6bb0179a0..3d7192880e69 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4658,7 +4658,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4921,7 +4921,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index bc222a110235..9275821a44d3 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs index 11a6bb0179a0..3d7192880e69 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4637,7 +4637,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4900,7 +4900,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } 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 3b8cde8db26d..cd8756daf008 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 @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4649,7 +4649,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4912,7 +4912,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } 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 f611687fd143..d33227e1afa2 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 @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4637,7 +4637,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4900,7 +4900,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } 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 3b8cde8db26d..cd8756daf008 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 @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4649,7 +4649,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4912,7 +4912,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } 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 f611687fd143..d33227e1afa2 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 @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4646,7 +4646,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4909,7 +4909,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } 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 f56a0b9bbba4..909cc815a5fb 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 @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } 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 11a6bb0179a0..3d7192880e69 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 @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4658,7 +4658,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4921,7 +4921,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } 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 bc222a110235..9275821a44d3 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 @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } 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 11a6bb0179a0..3d7192880e69 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 @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4646,7 +4646,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4909,7 +4909,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index f56a0b9bbba4..909cc815a5fb 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs index 11a6bb0179a0..3d7192880e69 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4658,7 +4658,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4921,7 +4921,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index bc222a110235..9275821a44d3 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -1085,7 +1085,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs index 11a6bb0179a0..3d7192880e69 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option if (enumHeaderString.IsSet) { // Set client side default value of Header Param "enum_header_string". - if (_contentHeaders.Contains("enum_header_string".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } @@ -4648,7 +4648,7 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) { // Set client side default value of Header Param "enum_header_string_array". - if (_contentHeaders.Contains("enum_header_string_array".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("enum_header_string_array")) { httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } @@ -4911,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool if (booleanGroup.IsSet) { // Set client side default value of Header Param "boolean_group". - if (_contentHeaders.Contains("boolean_group".ToLowerInvariant())) + if (ClientUtils.IsContentHeader("boolean_group")) { httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } 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 c34d547f0c2c..cd554d556675 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 @@ -1084,7 +1084,7 @@ public async Task DeletePetAsync(long petId, Option Date: Wed, 22 Apr 2026 16:16:45 +0100 Subject: [PATCH 6/7] chore: Added "content-disposition" to content header check --- .../csharp/libraries/generichost/ClientUtils.mustache | 1 + .../resources/csharp/libraries/generichost/api.mustache | 4 ++-- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../Tags/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net4.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net4.8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net4.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 8 ++++---- .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 2 +- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 1 + 86 files changed, 141 insertions(+), 92 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache index 25c0d920f68b..8a84cc74c096 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache @@ -425,6 +425,7 @@ using System.Net.Http.Headers; [ "allow", "content-encoding", + "content-disposition", "content-language", "content-length", "content-location", diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache index 6a487ddbcdcd..dac3c682f0d3 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache @@ -578,7 +578,7 @@ namespace {{packageName}}.{{apiPackage}} // Set client side default value of Header Param "{{baseName}}". if (ClientUtils.IsContentHeader("{{baseName}}")) { - httpRequestMessageLocalVar.Content.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}})); + httpRequestMessageLocalVar.Content?.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}})); } else { @@ -592,7 +592,7 @@ namespace {{packageName}}.{{apiPackage}} // Set client side default value of Header Param "{{baseName}}". if (ClientUtils.IsContentHeader("{{baseName}}")) { - httpRequestMessageLocalVar.Content.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs index 6ff788bd22f7..eb11c694a97c 100644 --- a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -325,6 +325,7 @@ public static bool IsContentHeader(string header) [ "allow", "content-encoding", + "content-disposition", "content-language", "content-length", "content-location", diff --git a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs index 32b117b8a481..516904c51259 100644 --- a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -319,6 +319,7 @@ public static bool IsContentHeader(string header) [ "allow", "content-encoding", + "content-disposition", "content-language", "content-length", "content-location", diff --git a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 39629d116f56..2d5daef342dc 100644 --- a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -321,6 +321,7 @@ public static bool IsContentHeader(string header) [ "allow", "content-encoding", + "content-disposition", "content-language", "content-length", "content-location", diff --git a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs index 5a28e8eaa172..35016307b187 100644 --- a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -319,6 +319,7 @@ public static bool IsContentHeader(string header) [ "allow", "content-encoding", + "content-disposition", "content-language", "content-length", "content-location", 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 a170f7169424..f3c6adfe1494 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 @@ -345,6 +345,7 @@ public static bool IsContentHeader(string header) [ "allow", "content-encoding", + "content-disposition", "content-language", "content-length", "content-location", diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs index 63467d008877..237406dab61f 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/FakeApi.cs @@ -4649,7 +4649,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4662,7 +4662,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4913,7 +4913,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4925,7 +4925,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs index 3d7192880e69..9d06e1ac4a9e 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs @@ -1089,7 +1089,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4648,7 +4648,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4899,7 +4899,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4911,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index 909cc815a5fb..7a052a90d955 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4662,7 +4662,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4913,7 +4913,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4925,7 +4925,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs index 3d7192880e69..9d06e1ac4a9e 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs @@ -1089,7 +1089,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4911,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index 9275821a44d3..0843443b2ae3 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4662,7 +4662,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4913,7 +4913,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4925,7 +4925,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs index 3d7192880e69..9d06e1ac4a9e 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs @@ -1089,7 +1089,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4639,7 +4639,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4890,7 +4890,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4902,7 +4902,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { 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 cd8756daf008..a7310cdc0f0a 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 @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4651,7 +4651,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4902,7 +4902,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4914,7 +4914,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { 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 d33227e1afa2..d955b80e8761 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 @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4639,7 +4639,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4890,7 +4890,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4902,7 +4902,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { 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 cd8756daf008..a7310cdc0f0a 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 @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4651,7 +4651,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4902,7 +4902,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4914,7 +4914,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { 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 d33227e1afa2..d955b80e8761 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 @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4648,7 +4648,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4899,7 +4899,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4911,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { 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 909cc815a5fb..7a052a90d955 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 @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4662,7 +4662,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4913,7 +4913,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4925,7 +4925,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { 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 3d7192880e69..9d06e1ac4a9e 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 @@ -1089,7 +1089,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4911,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { 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 9275821a44d3..0843443b2ae3 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 @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4662,7 +4662,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4913,7 +4913,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4925,7 +4925,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { 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 3d7192880e69..9d06e1ac4a9e 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 @@ -1089,7 +1089,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4648,7 +4648,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4899,7 +4899,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4911,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs index 909cc815a5fb..7a052a90d955 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4662,7 +4662,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4913,7 +4913,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4925,7 +4925,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs index 3d7192880e69..9d06e1ac4a9e 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs @@ -1089,7 +1089,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4660,7 +4660,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4911,7 +4911,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4923,7 +4923,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index 9275821a44d3..0843443b2ae3 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -1087,7 +1087,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4662,7 +4662,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4913,7 +4913,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4925,7 +4925,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs index 3d7192880e69..9d06e1ac4a9e 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs @@ -1089,7 +1089,7 @@ public async Task DeletePetAsync(long petId, Option TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string". if (ClientUtils.IsContentHeader("enum_header_string")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); } else { @@ -4650,7 +4650,7 @@ public async Task TestEnumParametersAsync(Option // Set client side default value of Header Param "enum_header_string_array". if (ClientUtils.IsContentHeader("enum_header_string_array")) { - httpRequestMessageLocalVar.Content.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); } else { @@ -4901,7 +4901,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "required_boolean_group". if (ClientUtils.IsContentHeader("required_boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + httpRequestMessageLocalVar.Content?.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); } else { @@ -4913,7 +4913,7 @@ public async Task TestGroupParametersAsync(bool // Set client side default value of Header Param "boolean_group". if (ClientUtils.IsContentHeader("boolean_group")) { - httpRequestMessageLocalVar.Content.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + httpRequestMessageLocalVar.Content?.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); } else { 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 cd554d556675..8fd9ec7fe213 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 @@ -1086,7 +1086,7 @@ public async Task DeletePetAsync(long petId, Option Date: Thu, 23 Apr 2026 11:54:01 +0100 Subject: [PATCH 7/7] fix: Updated ContentHeaders to be compatible with older versions of .NET --- .../csharp/libraries/generichost/ClientUtils.mustache | 6 +++--- .../ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../latest/Tags/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net10/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net4.7/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net4.7/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net4.7/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net4.8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net4.8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net4.8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- .../Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs | 6 +++--- 49 files changed, 147 insertions(+), 147 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache index 8a84cc74c096..29043e9ca282 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache @@ -421,8 +421,8 @@ using System.Net.Http.Headers; /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -434,7 +434,7 @@ using System.Net.Http.Headers; "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs index eb11c694a97c..610f4d277860 100644 --- a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -321,8 +321,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -334,7 +334,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs index 516904c51259..b0f1eb910604 100644 --- a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -315,8 +315,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -328,7 +328,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 2d5daef342dc..e901eccefde7 100644 --- a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -317,8 +317,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -330,7 +330,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs index 35016307b187..f0707a1ac4c9 100644 --- a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -315,8 +315,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -328,7 +328,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 f3c6adfe1494..5336e74e8322 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 @@ -341,8 +341,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -354,7 +354,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Client/ClientUtils.cs index 67a1a7588bdb..6f17300f7494 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -416,8 +416,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -429,7 +429,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 884d5e79aef4..2157bc68a4f5 100644 --- a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -330,8 +330,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -343,7 +343,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index e1aba19213a9..64f0a9026639 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -330,8 +330,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -343,7 +343,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs index c04af8e40248..4da07961deed 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -315,8 +315,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -328,7 +328,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index b224aeac33ca..be99808e8e53 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -425,8 +425,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -438,7 +438,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs index e9d8489736b6..f442dd44bfa2 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -431,8 +431,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -444,7 +444,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs index e1aba19213a9..64f0a9026639 100644 --- a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -330,8 +330,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -343,7 +343,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index d9375feccab9..9ea7d8118c3b 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -429,8 +429,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -442,7 +442,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs index e9d8489736b6..f442dd44bfa2 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -431,8 +431,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -444,7 +444,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs index b7df8028de6d..3310db6b99d8 100644 --- a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -315,8 +315,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -328,7 +328,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 95f713d93866..a8017239f2d0 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 @@ -325,8 +325,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -338,7 +338,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 e88661f07181..64f174fb00d2 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 @@ -325,8 +325,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -338,7 +338,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 9e51149eae30..06a270135661 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 @@ -310,8 +310,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -323,7 +323,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 816ac0c256af..965dcceeeeb5 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 @@ -425,8 +425,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -438,7 +438,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 e88661f07181..64f174fb00d2 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 @@ -325,8 +325,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -338,7 +338,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 2015f6f938d1..92d95ba94060 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 @@ -429,8 +429,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -442,7 +442,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 1e3bf39056a5..196d6f474252 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 @@ -310,8 +310,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -323,7 +323,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 95f713d93866..a8017239f2d0 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 @@ -325,8 +325,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -338,7 +338,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 e88661f07181..64f174fb00d2 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 @@ -325,8 +325,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -338,7 +338,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 9e51149eae30..06a270135661 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 @@ -310,8 +310,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -323,7 +323,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 816ac0c256af..965dcceeeeb5 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 @@ -425,8 +425,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -438,7 +438,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 e88661f07181..64f174fb00d2 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 @@ -325,8 +325,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -338,7 +338,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 2015f6f938d1..92d95ba94060 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 @@ -429,8 +429,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -442,7 +442,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 1e3bf39056a5..196d6f474252 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 @@ -310,8 +310,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -323,7 +323,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 884d5e79aef4..2157bc68a4f5 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 @@ -330,8 +330,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -343,7 +343,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 e1aba19213a9..64f0a9026639 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 @@ -330,8 +330,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -343,7 +343,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 c04af8e40248..4da07961deed 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 @@ -315,8 +315,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -328,7 +328,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 b224aeac33ca..be99808e8e53 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 @@ -425,8 +425,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -438,7 +438,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 e9d8489736b6..f442dd44bfa2 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 @@ -431,8 +431,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -444,7 +444,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 e1aba19213a9..64f0a9026639 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 @@ -330,8 +330,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -343,7 +343,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 d9375feccab9..9ea7d8118c3b 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 @@ -429,8 +429,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -442,7 +442,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 e9d8489736b6..f442dd44bfa2 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 @@ -431,8 +431,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -444,7 +444,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 b7df8028de6d..3310db6b99d8 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 @@ -315,8 +315,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -328,7 +328,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 884d5e79aef4..2157bc68a4f5 100644 --- a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -330,8 +330,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -343,7 +343,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index e1aba19213a9..64f0a9026639 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -330,8 +330,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -343,7 +343,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs index c04af8e40248..4da07961deed 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -315,8 +315,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -328,7 +328,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index b224aeac33ca..be99808e8e53 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -425,8 +425,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -438,7 +438,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs index e9d8489736b6..f442dd44bfa2 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -431,8 +431,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -444,7 +444,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs index e1aba19213a9..64f0a9026639 100644 --- a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -330,8 +330,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -343,7 +343,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index d9375feccab9..9ea7d8118c3b 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -429,8 +429,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -442,7 +442,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs index e9d8489736b6..f442dd44bfa2 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -431,8 +431,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -444,7 +444,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API diff --git a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs index b7df8028de6d..3310db6b99d8 100644 --- a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -315,8 +315,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -328,7 +328,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API 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 2015f6f938d1..92d95ba94060 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 @@ -429,8 +429,8 @@ public static bool IsContentHeader(string header) /// The collection of content headers as per /// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers /// - private static readonly string[] ContentHeaders = - [ + private static readonly string[] ContentHeaders = new String[] + { "allow", "content-encoding", "content-disposition", @@ -442,7 +442,7 @@ public static bool IsContentHeader(string header) "content-type", "expires", "last-modified" - ]; + }; /// /// The base path of the API