From ea0251647c4cb04e1f46933bb0847627755bda19 Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 25 Jan 2026 16:53:18 -0500 Subject: [PATCH 01/15] better file support --- .../csharp/libraries/generichost/api.mustache | 41 +- ...odels-for-testing-with-http-signature.yaml | 40 ++ .../net10/FormModels/api/openapi.yaml | 44 +++ .../net10/FormModels/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net10/NullReferenceTypes/api/openapi.yaml | 44 +++ .../NullReferenceTypes/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net10/Petstore/api/openapi.yaml | 44 +++ .../net10/Petstore/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net10/SourceGeneration/api/openapi.yaml | 44 +++ .../SourceGeneration/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net4.7/FormModels/api/openapi.yaml | 44 +++ .../net4.7/FormModels/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 366 ++++++++++++++++- .../net4.7/Petstore/api/openapi.yaml | 44 +++ .../net4.7/Petstore/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 366 ++++++++++++++++- .../net4.8/FormModels/api/openapi.yaml | 44 +++ .../net4.8/FormModels/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 366 ++++++++++++++++- .../net4.8/Petstore/api/openapi.yaml | 44 +++ .../net4.8/Petstore/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 366 ++++++++++++++++- .../net8/FormModels/api/openapi.yaml | 44 +++ .../net8/FormModels/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net8/NullReferenceTypes/api/openapi.yaml | 44 +++ .../NullReferenceTypes/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net8/Petstore/api/openapi.yaml | 44 +++ .../net8/Petstore/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net8/SourceGeneration/api/openapi.yaml | 44 +++ .../net8/SourceGeneration/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net9/FormModels/api/openapi.yaml | 44 +++ .../net9/FormModels/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net9/NullReferenceTypes/api/openapi.yaml | 44 +++ .../NullReferenceTypes/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net9/Petstore/api/openapi.yaml | 44 +++ .../net9/Petstore/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../net9/SourceGeneration/api/openapi.yaml | 44 +++ .../net9/SourceGeneration/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 367 +++++++++++++++++- .../standard2.0/Petstore/api/openapi.yaml | 44 +++ .../standard2.0/Petstore/docs/apis/PetApi.md | 36 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 366 ++++++++++++++++- .../httpclient/net10/Petstore/README.md | 1 + .../net10/Petstore/api/openapi.yaml | 44 +++ .../httpclient/net10/Petstore/docs/PetApi.md | 99 +++++ .../src/Org.OpenAPITools/Api/PetApi.cs | 180 +++++++++ .../csharp/httpclient/net9/Petstore/README.md | 1 + .../httpclient/net9/Petstore/api/openapi.yaml | 44 +++ .../httpclient/net9/Petstore/docs/PetApi.md | 99 +++++ .../src/Org.OpenAPITools/Api/PetApi.cs | 180 +++++++++ .../httpclient/standard2.0/Petstore/README.md | 1 + .../standard2.0/Petstore/api/openapi.yaml | 44 +++ .../standard2.0/Petstore/docs/PetApi.md | 99 +++++ .../src/Org.OpenAPITools/Api/PetApi.cs | 180 +++++++++ .../csharp/restsharp/net8/Petstore/README.md | 1 + .../restsharp/net8/Petstore/api/openapi.yaml | 44 +++ .../restsharp/net8/Petstore/docs/PetApi.md | 95 +++++ .../src/Org.OpenAPITools/Api/PetApi.cs | 240 ++++++++++++ .../ConditionalSerialization/README.md | 1 + .../ConditionalSerialization/api/openapi.yaml | 44 +++ .../ConditionalSerialization/docs/PetApi.md | 95 +++++ .../src/Org.OpenAPITools/Api/PetApi.cs | 240 ++++++++++++ .../unityWebRequest/net10/Petstore/README.md | 1 + .../net10/Petstore/api/openapi.yaml | 44 +++ .../net10/Petstore/docs/PetApi.md | 95 +++++ .../src/Org.OpenAPITools/Api/PetApi.cs | 189 +++++++++ .../unityWebRequest/net9/Petstore/README.md | 1 + .../net9/Petstore/api/openapi.yaml | 44 +++ .../net9/Petstore/docs/PetApi.md | 95 +++++ .../src/Org.OpenAPITools/Api/PetApi.cs | 189 +++++++++ .../standard2.0/Petstore/README.md | 1 + .../standard2.0/Petstore/api/openapi.yaml | 44 +++ .../standard2.0/Petstore/docs/PetApi.md | 95 +++++ .../src/Org.OpenAPITools/Api/PetApi.cs | 189 +++++++++ 119 files changed, 10627 insertions(+), 328 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 f75235833fbe..29153e6e9040 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 @@ -471,14 +471,15 @@ namespace {{packageName}}.{{apiPackage}} {{/headerParams}} {{#formParams}} {{#-first}} - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars));{{/-first}}{{^isFile}}{{#required}} - + {{/-first}} + {{^isFile}} + {{#required}} formParameterLocalVars.Add(new KeyValuePair("{{baseName}}", ClientUtils.ParameterToString({{paramName}}))); {{/required}} @@ -490,16 +491,46 @@ namespace {{packageName}}.{{apiPackage}} {{/isFile}} {{#isFile}} {{#required}} - multipartContentLocalVar.Add(new StreamContent({{paramName}})); + {{#isContainer}} + foreach (global::System.IO.Stream streamLocalVar in {{paramName}}) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}"); + } + + {{/isContainer}} + {{^isContainer}} + var streamContentLocalVar = new StreamContent({{paramName}}); + multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}"); + {{/isContainer}} {{/required}} {{^required}} if ({{paramName}}.IsSet) - multipartContentLocalVar.Add(new StreamContent({{paramName}}.Value)); + { + {{#isContainer}} + foreach (global::System.IO.Stream streamLocalVar in {{paramName}}.Value) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}"); + } + {{/isContainer}} + {{^isContainer}} + var streamContentLocalVar = new StreamContent({{paramName}}.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}"); + {{/isContainer}} + } {{/required}} {{/isFile}} {{/formParams}} + {{#formParams}} + {{#-first}} + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + {{/-first}} + {{/formParams}} {{#bodyParam}} {{#required}} httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 1c9e901ad0dd..2edf96c9c3c3 100644 --- a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -316,6 +316,46 @@ paths: description: file to upload type: string format: binary + '/pet/{petId}/uploadImages': + post: + tags: + - pet + summary: uploads an images + description: '' + operationId: uploadFiles + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + required: true + content: + multipart/form-data: + schema: + type: object + properties: + files: + type: array + items: + type: string + format: binary + required: + - files /store/inventory: get: tags: diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/FormModels/api/openapi.yaml index a9ab8dd51c13..7017affc0b9c 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/api/openapi.yaml @@ -326,6 +326,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2748,6 +2782,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request_enum_form_string_array_inner: default: $ enum: diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net10/FormModels/docs/apis/PetApi.md index e32c1e31e089..59d4ef8e6df0 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 3c26a27185e6..66211422bf81 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 @@ -764,16 +764,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 2a332dbf1eb9..bb4069b491a3 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 @@ -4281,14 +4281,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4298,7 +4296,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4327,6 +4328,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,18 +4629,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5534,18 +5541,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 d07d16c30828..34ddd104a52e 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2330,18 +2387,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2579,17 +2639,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2869,17 +2935,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3038,5 +3108,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 2391c7e1ee03..629302a4d2da 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 @@ -766,16 +766,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 262a94ef2520..fdd57d8cb1df 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 @@ -4283,14 +4283,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4300,7 +4298,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4329,6 +4330,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,18 +4643,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5548,18 +5555,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 2d7e4dab0b84..6cc527fa0dc1 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 @@ -259,6 +259,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <?> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <?> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -417,6 +442,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -601,6 +638,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler? OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2332,18 +2389,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2581,17 +2641,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2871,17 +2937,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3040,5 +3110,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net10/Petstore/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 3c26a27185e6..66211422bf81 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 @@ -764,16 +764,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 01aaf0ccbd85..aa95f6cb4b32 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 @@ -4281,14 +4281,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4298,7 +4296,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4327,6 +4328,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4637,18 +4641,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5546,18 +5553,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 a1817e3df697..79a8214463d3 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2330,18 +2387,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2579,17 +2639,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2869,17 +2935,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3038,5 +3108,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 2391c7e1ee03..629302a4d2da 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 @@ -766,16 +766,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 262a94ef2520..fdd57d8cb1df 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 @@ -4283,14 +4283,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4300,7 +4298,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4329,6 +4330,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,18 +4643,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5548,18 +5555,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 2d7e4dab0b84..6cc527fa0dc1 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 @@ -259,6 +259,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <?> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <?> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -417,6 +442,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -601,6 +638,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler? OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2332,18 +2389,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2581,17 +2641,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2871,17 +2937,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3040,5 +3110,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml index a9ab8dd51c13..7017affc0b9c 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml @@ -326,6 +326,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2748,6 +2782,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request_enum_form_string_array_inner: default: $ enum: diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/PetApi.md index e32c1e31e089..59d4ef8e6df0 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 1bbf43279f7c..942454324c21 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 @@ -763,16 +763,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 ed9c440bd2b8..023e16226228 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 @@ -4272,14 +4272,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4289,7 +4287,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4318,6 +4319,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4616,18 +4620,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5524,18 +5531,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 0eaf83e1f41e..bae78e0a8e62 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2326,18 +2383,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2575,17 +2635,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2864,17 +2930,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3032,5 +3102,287 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + apiResponseLocalVar = new UploadFilesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 1bbf43279f7c..942454324c21 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 @@ -763,16 +763,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 feec543b8c1f..b85cf1d91ef4 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 @@ -4272,14 +4272,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4289,7 +4287,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4318,6 +4319,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4628,18 +4632,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,18 +5543,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 7fe162b51bfb..95cd8163eca3 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2326,18 +2383,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2575,17 +2635,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2864,17 +2930,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3032,5 +3102,287 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + apiResponseLocalVar = new UploadFilesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml index a9ab8dd51c13..7017affc0b9c 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml @@ -326,6 +326,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2748,6 +2782,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request_enum_form_string_array_inner: default: $ enum: diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/apis/PetApi.md index e32c1e31e089..59d4ef8e6df0 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 1bbf43279f7c..942454324c21 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 @@ -763,16 +763,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 ed9c440bd2b8..023e16226228 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 @@ -4272,14 +4272,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4289,7 +4287,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4318,6 +4319,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4616,18 +4620,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5524,18 +5531,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 0eaf83e1f41e..bae78e0a8e62 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2326,18 +2383,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2575,17 +2635,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2864,17 +2930,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3032,5 +3102,287 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + apiResponseLocalVar = new UploadFilesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 1bbf43279f7c..942454324c21 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 @@ -763,16 +763,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 feec543b8c1f..b85cf1d91ef4 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 @@ -4272,14 +4272,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4289,7 +4287,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4318,6 +4319,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4628,18 +4632,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,18 +5543,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 7fe162b51bfb..95cd8163eca3 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2326,18 +2383,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2575,17 +2635,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2864,17 +2930,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3032,5 +3102,287 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + apiResponseLocalVar = new UploadFilesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml index a9ab8dd51c13..7017affc0b9c 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml @@ -326,6 +326,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2748,6 +2782,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request_enum_form_string_array_inner: default: $ enum: diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/apis/PetApi.md index e32c1e31e089..59d4ef8e6df0 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 3c26a27185e6..66211422bf81 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 @@ -764,16 +764,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 2a332dbf1eb9..bb4069b491a3 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 @@ -4281,14 +4281,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4298,7 +4296,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4327,6 +4328,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,18 +4629,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5534,18 +5541,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 d07d16c30828..34ddd104a52e 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2330,18 +2387,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2579,17 +2639,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2869,17 +2935,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3038,5 +3108,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 2391c7e1ee03..629302a4d2da 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 @@ -766,16 +766,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 262a94ef2520..fdd57d8cb1df 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 @@ -4283,14 +4283,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4300,7 +4298,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4329,6 +4330,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,18 +4643,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5548,18 +5555,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 2d7e4dab0b84..6cc527fa0dc1 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 @@ -259,6 +259,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <?> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <?> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -417,6 +442,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -601,6 +638,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler? OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2332,18 +2389,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2581,17 +2641,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2871,17 +2937,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3040,5 +3110,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 3c26a27185e6..66211422bf81 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 @@ -764,16 +764,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 01aaf0ccbd85..aa95f6cb4b32 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 @@ -4281,14 +4281,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4298,7 +4296,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4327,6 +4328,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4637,18 +4641,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5546,18 +5553,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 a1817e3df697..79a8214463d3 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2330,18 +2387,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2579,17 +2639,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2869,17 +2935,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3038,5 +3108,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 2391c7e1ee03..629302a4d2da 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 @@ -766,16 +766,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 262a94ef2520..fdd57d8cb1df 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 @@ -4283,14 +4283,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4300,7 +4298,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4329,6 +4330,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,18 +4643,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5548,18 +5555,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 2d7e4dab0b84..6cc527fa0dc1 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 @@ -259,6 +259,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <?> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <?> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -417,6 +442,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -601,6 +638,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler? OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2332,18 +2389,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2581,17 +2641,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2871,17 +2937,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3040,5 +3110,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml index a9ab8dd51c13..7017affc0b9c 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml @@ -326,6 +326,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2748,6 +2782,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request_enum_form_string_array_inner: default: $ enum: diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/apis/PetApi.md index e32c1e31e089..59d4ef8e6df0 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 3c26a27185e6..66211422bf81 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 @@ -764,16 +764,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 2a332dbf1eb9..bb4069b491a3 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 @@ -4281,14 +4281,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4298,7 +4296,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4327,6 +4328,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,18 +4629,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5534,18 +5541,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 d07d16c30828..34ddd104a52e 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2330,18 +2387,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2579,17 +2639,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2869,17 +2935,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3038,5 +3108,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 2391c7e1ee03..629302a4d2da 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 @@ -766,16 +766,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 262a94ef2520..fdd57d8cb1df 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 @@ -4283,14 +4283,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4300,7 +4298,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4329,6 +4330,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,18 +4643,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5548,18 +5555,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 2d7e4dab0b84..6cc527fa0dc1 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 @@ -259,6 +259,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <?> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <?> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -417,6 +442,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -601,6 +638,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler? OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2332,18 +2389,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2581,17 +2641,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2871,17 +2937,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3040,5 +3110,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 3c26a27185e6..66211422bf81 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 @@ -764,16 +764,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 01aaf0ccbd85..aa95f6cb4b32 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 @@ -4281,14 +4281,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4298,7 +4296,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4327,6 +4328,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4637,18 +4641,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5546,18 +5553,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 a1817e3df697..79a8214463d3 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 @@ -257,6 +257,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -415,6 +440,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -599,6 +636,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2330,18 +2387,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2579,17 +2639,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2869,17 +2935,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3038,5 +3108,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 2391c7e1ee03..629302a4d2da 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 @@ -766,16 +766,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 262a94ef2520..fdd57d8cb1df 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 @@ -4283,14 +4283,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4300,7 +4298,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4329,6 +4330,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,18 +4643,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5548,18 +5555,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 2d7e4dab0b84..6cc527fa0dc1 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 @@ -259,6 +259,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <?> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <?> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -417,6 +442,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -601,6 +638,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler? OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2332,18 +2389,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2581,17 +2641,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2871,17 +2937,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3040,5 +3110,288 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + + httpRequestMessageLocalVar.Method = HttpMethod.Post; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ApiResponse? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/apis/PetApi.md index 2826ea00f728..b42ee516b313 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/apis/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -341,3 +342,38 @@ uploads an image (required) [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (List files, long petId) + +uploads an images + + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **files** | **List<System.IO.Stream>** | | | +| **petId** | **long** | ID of pet to update | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + 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 8f794c9ca7c8..0e0e7300d209 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 @@ -762,16 +762,17 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 0d878f64abf2..857caf21eb9b 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 @@ -4271,14 +4271,12 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); @@ -4288,7 +4286,10 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - multipartContentLocalVar.Add(new StreamContent(binary.Value)); + { + var streamContentLocalVar = new StreamContent(binary.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + } if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4317,6 +4318,9 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,18 +4631,21 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormString.IsSet) + if (enumFormString.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5535,18 +5542,19 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 00c695ffd700..5f56473ddd75 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 @@ -256,6 +256,31 @@ public interface IPetApi : IApi /// Cancellation Token to cancel the request. /// <> Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -414,6 +439,18 @@ public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Clien bool IsOk { get; } } + /// + /// The + /// + public interface IUploadFilesApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// Represents a collection of functions to interact with the API endpoints /// @@ -598,6 +635,26 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) { OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFiles; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFiles; + + internal void ExecuteOnUploadFiles(PetApi.UploadFilesApiResponse apiResponse) + { + OnUploadFiles?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFiles(Exception exception) + { + OnErrorUploadFiles?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -2325,18 +2382,21 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + if (name.IsSet) formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2574,17 +2634,23 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (additionalMetadata.IsSet) + if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) - multipartContentLocalVar.Add(new StreamContent(file.Value)); + { + var streamContentLocalVar = new StreamContent(file.Value); + multipartContentLocalVar.Add(streamContentLocalVar, "file"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2863,17 +2929,21 @@ public async Task UploadFileWithRequired : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/{petId}/uploadImageWithRequiredFile"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartContent multipartContentLocalVar = new MultipartContent(); + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; List> formParameterLocalVars = new List>(); - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + var streamContentLocalVar = new StreamContent(requiredFile); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3031,5 +3101,287 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + + partial void FormatUploadFiles(List files, ref long petId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUploadFiles(List files) + { + if (files == null) + throw new ArgumentNullException(nameof(files)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + { + bool suppressDefaultLog = false; + AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {2}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + { + bool suppressDefaultLogLocalVar = false; + OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); + if (!suppressDefaultLogLocalVar) + Logger.LogError(exceptionLocalVar, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + + /// + /// uploads an images + /// + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFilesAsync(files, petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// + /// ID of pet to update + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFiles(files); + + FormatUploadFiles(files, ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/" + ? "/pet/{petId}/uploadImages" + : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}/uploadImages"); + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + foreach (global::System.IO.Stream streamLocalVar in files) + { + var streamContentLocalVar = new StreamContent(streamLocalVar); + multipartContentLocalVar.Add(streamContentLocalVar, "files"); + } + + if (formParameterLocalVars.Count > 0) + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + IEnumerable acceptHeaderValuesLocalVar = ClientUtils.SelectHeaderAcceptArray(acceptLocalVars); + + foreach (var acceptLocalVar in acceptHeaderValuesLocalVar) + httpRequestMessageLocalVar.Headers.Accept.Add(acceptLocalVar); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + UploadFilesApiResponse apiResponseLocalVar; + + switch ((int)httpResponseMessageLocalVar.StatusCode) { + default: { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + apiResponseLocalVar = new UploadFilesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImages", requestedAtLocalVar, _jsonSerializerOptions); + + break; + } + } + + AfterUploadFilesDefaultImplementation(apiResponseLocalVar, files, petId); + + Events.ExecuteOnUploadFiles(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFilesDefaultImplementation(e, "/pet/{petId}/uploadImages", uriBuilderLocalVar.Path, files, petId); + Events.ExecuteOnErrorUploadFiles(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFilesApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFilesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFilesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, System.IO.Stream contentStream, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, contentStream, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(global::System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } } } diff --git a/samples/client/petstore/csharp/httpclient/net10/Petstore/README.md b/samples/client/petstore/csharp/httpclient/net10/Petstore/README.md index 73a7b83f20ce..1797a4d9ca09 100644 --- a/samples/client/petstore/csharp/httpclient/net10/Petstore/README.md +++ b/samples/client/petstore/csharp/httpclient/net10/Petstore/README.md @@ -178,6 +178,7 @@ Class | Method | HTTP request | Description *PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *PetApi* | [**UploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*PetApi* | [**UploadFiles**](docs/PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images *StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/httpclient/net10/Petstore/docs/PetApi.md b/samples/client/petstore/csharp/httpclient/net10/Petstore/docs/PetApi.md index e8c203c040bd..934a829307a0 100644 --- a/samples/client/petstore/csharp/httpclient/net10/Petstore/docs/PetApi.md +++ b/samples/client/petstore/csharp/httpclient/net10/Petstore/docs/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -896,3 +897,101 @@ catch (ApiException e) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (long petId, List files) + +uploads an images + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using System.Net.Http; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFilesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); + var petId = 789L; // long | ID of pet to update + var files = new List(); // List | + + try + { + // uploads an images + ApiResponse result = apiInstance.UploadFiles(petId, files); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFiles: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFilesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an images + ApiResponse response = apiInstance.UploadFilesWithHttpInfo(petId, files); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFilesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **files** | **List<FileParameter>** | | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index c76f3f3b7dfe..c84a19eb0d8e 100644 --- a/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -214,6 +214,26 @@ public interface IPetApiSync : IApiAccessor /// Additional data to pass to server (optional) /// ApiResponse of ApiResponse ApiResponse UploadFileWithRequiredFileWithHttpInfo(long petId, FileParameter requiredFile, string? additionalMetadata = default); + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + ApiResponse UploadFiles(long petId, List files); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + ApiResponse UploadFilesWithHttpInfo(long petId, List files); #endregion Synchronous Operations } @@ -446,6 +466,31 @@ public interface IPetApiAsync : IApiAccessor /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, FileParameter requiredFile, string? additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); #endregion Asynchronous Operations } @@ -1994,5 +2039,140 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile return localVarResponse; } + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + public ApiResponse UploadFiles(long petId, List files) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFilesWithHttpInfo(petId, files); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + public Org.OpenAPITools.Client.ApiResponse UploadFilesWithHttpInfo(long petId, List files) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + localVarRequestOptions.FileParameters.Add("files", files); + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + var localVarResponse = this.Client.Post("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await UploadFilesWithHttpInfoAsync(petId, files, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + public async System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + localVarRequestOptions.FileParameters.Add("files", files); + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + + var localVarResponse = await this.AsynchronousClient.PostAsync("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md b/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md index 73a7b83f20ce..1797a4d9ca09 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md @@ -178,6 +178,7 @@ Class | Method | HTTP request | Description *PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *PetApi* | [**UploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*PetApi* | [**UploadFiles**](docs/PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images *StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/PetApi.md b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/PetApi.md index e8c203c040bd..934a829307a0 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/PetApi.md +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -896,3 +897,101 @@ catch (ApiException e) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (long petId, List files) + +uploads an images + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using System.Net.Http; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFilesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); + var petId = 789L; // long | ID of pet to update + var files = new List(); // List | + + try + { + // uploads an images + ApiResponse result = apiInstance.UploadFiles(petId, files); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFiles: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFilesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an images + ApiResponse response = apiInstance.UploadFilesWithHttpInfo(petId, files); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFilesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **files** | **List<FileParameter>** | | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index c76f3f3b7dfe..c84a19eb0d8e 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -214,6 +214,26 @@ public interface IPetApiSync : IApiAccessor /// Additional data to pass to server (optional) /// ApiResponse of ApiResponse ApiResponse UploadFileWithRequiredFileWithHttpInfo(long petId, FileParameter requiredFile, string? additionalMetadata = default); + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + ApiResponse UploadFiles(long petId, List files); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + ApiResponse UploadFilesWithHttpInfo(long petId, List files); #endregion Synchronous Operations } @@ -446,6 +466,31 @@ public interface IPetApiAsync : IApiAccessor /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, FileParameter requiredFile, string? additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); #endregion Asynchronous Operations } @@ -1994,5 +2039,140 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile return localVarResponse; } + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + public ApiResponse UploadFiles(long petId, List files) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFilesWithHttpInfo(petId, files); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + public Org.OpenAPITools.Client.ApiResponse UploadFilesWithHttpInfo(long petId, List files) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + localVarRequestOptions.FileParameters.Add("files", files); + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + var localVarResponse = this.Client.Post("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await UploadFilesWithHttpInfoAsync(petId, files, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + public async System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + localVarRequestOptions.FileParameters.Add("files", files); + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + + var localVarResponse = await this.AsynchronousClient.PostAsync("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md index 0a0407f2aa98..50e735052990 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md @@ -166,6 +166,7 @@ Class | Method | HTTP request | Description *PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *PetApi* | [**UploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*PetApi* | [**UploadFiles**](docs/PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images *StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/PetApi.md b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/PetApi.md index b7d549524b65..eb03434c366b 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/PetApi.md +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -896,3 +897,101 @@ catch (ApiException e) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (long petId, List files) + +uploads an images + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using System.Net.Http; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFilesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); + var petId = 789L; // long | ID of pet to update + var files = new List(); // List | + + try + { + // uploads an images + ApiResponse result = apiInstance.UploadFiles(petId, files); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFiles: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFilesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an images + ApiResponse response = apiInstance.UploadFilesWithHttpInfo(petId, files); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFilesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **files** | **List<FileParameter>** | | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index ec2d209ced03..fb1604fe0013 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -214,6 +214,26 @@ public interface IPetApiSync : IApiAccessor /// Additional data to pass to server (optional) /// ApiResponse of ApiResponse ApiResponse UploadFileWithRequiredFileWithHttpInfo(long petId, FileParameter requiredFile, string additionalMetadata = default); + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + ApiResponse UploadFiles(long petId, List files); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + ApiResponse UploadFilesWithHttpInfo(long petId, List files); #endregion Synchronous Operations } @@ -446,6 +466,31 @@ public interface IPetApiAsync : IApiAccessor /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, FileParameter requiredFile, string additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); #endregion Asynchronous Operations } @@ -1994,5 +2039,140 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile return localVarResponse; } + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + public ApiResponse UploadFiles(long petId, List files) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFilesWithHttpInfo(petId, files); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + public Org.OpenAPITools.Client.ApiResponse UploadFilesWithHttpInfo(long petId, List files) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + localVarRequestOptions.FileParameters.Add("files", files); + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + var localVarResponse = this.Client.Post("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await UploadFilesWithHttpInfoAsync(petId, files, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + public async System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + localVarRequestOptions.FileParameters.Add("files", files); + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + + var localVarResponse = await this.AsynchronousClient.PostAsync("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md b/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md index 1db3095f8f3b..ded19553c295 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md @@ -153,6 +153,7 @@ Class | Method | HTTP request | Description *PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *PetApi* | [**UploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*PetApi* | [**UploadFiles**](docs/PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images *StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/PetApi.md b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/PetApi.md index 5272a0b102c3..829ca6d25184 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/PetApi.md +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -860,3 +861,97 @@ catch (ApiException e) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (long petId, List files) + +uploads an images + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFilesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet to update + var files = new List(); // List | + + try + { + // uploads an images + ApiResponse result = apiInstance.UploadFiles(petId, files); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFiles: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFilesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an images + ApiResponse response = apiInstance.UploadFilesWithHttpInfo(petId, files); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFilesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **files** | **List<System.IO.Stream>** | | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index 86b40ec17eb1..1ea79a1c545a 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -232,6 +232,28 @@ public interface IPetApiSync : IApiAccessor /// Index associated with the operation. /// ApiResponse of ApiResponse ApiResponse UploadFileWithRequiredFileWithHttpInfo(long petId, System.IO.Stream requiredFile, string? additionalMetadata = default, int operationIndex = 0); + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// ApiResponse + ApiResponse UploadFiles(long petId, List files, int operationIndex = 0); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// ApiResponse of ApiResponse + ApiResponse UploadFilesWithHttpInfo(long petId, List files, int operationIndex = 0); #endregion Synchronous Operations } @@ -482,6 +504,33 @@ public interface IPetApiAsync : IApiAccessor /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, System.IO.Stream requiredFile, string? additionalMetadata = default, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default); + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default); #endregion Asynchronous Operations } @@ -2351,5 +2400,196 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile return localVarResponse; } + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// ApiResponse + public ApiResponse UploadFiles(long petId, List files, int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFilesWithHttpInfo(petId, files); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// ApiResponse of ApiResponse + public Org.OpenAPITools.Client.ApiResponse UploadFilesWithHttpInfo(long petId, List files, int operationIndex = 0) + { + // verify the required parameter 'files' is set + if (files == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + } + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + var localVarMultipartFormData = localVarContentType == "multipart/form-data"; + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + foreach (var file in files) + { + localVarRequestOptions.FileParameters.Add("files", file); + } + + localVarRequestOptions.Operation = "PetApi.UploadFiles"; + localVarRequestOptions.OperationIndex = operationIndex; + + // authentication (petstore_auth) required + // oauth required + if (!localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + else if (!string.IsNullOrEmpty(this.Configuration.OAuthTokenUrl) && + !string.IsNullOrEmpty(this.Configuration.OAuthClientId) && + !string.IsNullOrEmpty(this.Configuration.OAuthClientSecret) && + this.Configuration.OAuthFlow != null) + { + localVarRequestOptions.OAuth = true; + } + } + + // make the HTTP request + var localVarResponse = this.Client.Post("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await UploadFilesWithHttpInfoAsync(petId, files, operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + public async System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default) + { + // verify the required parameter 'files' is set + if (files == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + } + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + foreach (var file in files) + { + localVarRequestOptions.FileParameters.Add("files", file); + } + + localVarRequestOptions.Operation = "PetApi.UploadFiles"; + localVarRequestOptions.OperationIndex = operationIndex; + + // authentication (petstore_auth) required + // oauth required + if (!localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + else if (!string.IsNullOrEmpty(this.Configuration.OAuthTokenUrl) && + !string.IsNullOrEmpty(this.Configuration.OAuthClientId) && + !string.IsNullOrEmpty(this.Configuration.OAuthClientSecret) && + this.Configuration.OAuthFlow != null) + { + localVarRequestOptions.OAuth = true; + } + } + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.PostAsync("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md index f7f95f4a3abf..af9ad0d78405 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md @@ -141,6 +141,7 @@ Class | Method | HTTP request | Description *PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *PetApi* | [**UploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*PetApi* | [**UploadFiles**](docs/PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images *StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/PetApi.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/PetApi.md index 3db7da1cd2fa..cb3a65d239b4 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/PetApi.md +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -860,3 +861,97 @@ catch (ApiException e) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (long petId, List files) + +uploads an images + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFilesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet to update + var files = new List(); // List | + + try + { + // uploads an images + ApiResponse result = apiInstance.UploadFiles(petId, files); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFiles: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFilesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an images + ApiResponse response = apiInstance.UploadFilesWithHttpInfo(petId, files); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFilesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **files** | **List<System.IO.Stream>** | | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Api/PetApi.cs index d6cbbc5133ed..8e0e14cc18dc 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Api/PetApi.cs @@ -232,6 +232,28 @@ public interface IPetApiSync : IApiAccessor /// Index associated with the operation. /// ApiResponse of ApiResponse ApiResponse UploadFileWithRequiredFileWithHttpInfo(long petId, System.IO.Stream requiredFile, string additionalMetadata = default, int operationIndex = 0); + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// ApiResponse + ApiResponse UploadFiles(long petId, List files, int operationIndex = 0); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// ApiResponse of ApiResponse + ApiResponse UploadFilesWithHttpInfo(long petId, List files, int operationIndex = 0); #endregion Synchronous Operations } @@ -482,6 +504,33 @@ public interface IPetApiAsync : IApiAccessor /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, System.IO.Stream requiredFile, string additionalMetadata = default, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default); + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default); #endregion Asynchronous Operations } @@ -2351,5 +2400,196 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile return localVarResponse; } + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// ApiResponse + public ApiResponse UploadFiles(long petId, List files, int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFilesWithHttpInfo(petId, files); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// ApiResponse of ApiResponse + public Org.OpenAPITools.Client.ApiResponse UploadFilesWithHttpInfo(long petId, List files, int operationIndex = 0) + { + // verify the required parameter 'files' is set + if (files == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + } + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + var localVarMultipartFormData = localVarContentType == "multipart/form-data"; + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + foreach (var file in files) + { + localVarRequestOptions.FileParameters.Add("files", file); + } + + localVarRequestOptions.Operation = "PetApi.UploadFiles"; + localVarRequestOptions.OperationIndex = operationIndex; + + // authentication (petstore_auth) required + // oauth required + if (!localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + else if (!string.IsNullOrEmpty(this.Configuration.OAuthTokenUrl) && + !string.IsNullOrEmpty(this.Configuration.OAuthClientId) && + !string.IsNullOrEmpty(this.Configuration.OAuthClientSecret) && + this.Configuration.OAuthFlow != null) + { + localVarRequestOptions.OAuth = true; + } + } + + // make the HTTP request + var localVarResponse = this.Client.Post("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await UploadFilesWithHttpInfoAsync(petId, files, operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + public async System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default) + { + // verify the required parameter 'files' is set + if (files == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + } + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + foreach (var file in files) + { + localVarRequestOptions.FileParameters.Add("files", file); + } + + localVarRequestOptions.Operation = "PetApi.UploadFiles"; + localVarRequestOptions.OperationIndex = operationIndex; + + // authentication (petstore_auth) required + // oauth required + if (!localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + if (!string.IsNullOrEmpty(this.Configuration.AccessToken)) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + else if (!string.IsNullOrEmpty(this.Configuration.OAuthTokenUrl) && + !string.IsNullOrEmpty(this.Configuration.OAuthClientId) && + !string.IsNullOrEmpty(this.Configuration.OAuthClientSecret) && + this.Configuration.OAuthFlow != null) + { + localVarRequestOptions.OAuth = true; + } + } + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.PostAsync("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/README.md b/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/README.md index 3e2173e6db41..f3a7c402bb1a 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/README.md +++ b/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/README.md @@ -127,6 +127,7 @@ Class | Method | HTTP request | Description *PetApi* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *PetApi* | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*PetApi* | [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images *StoreApi* | [**DeleteOrder**](StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**GetInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**GetOrderById**](StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/docs/PetApi.md b/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/docs/PetApi.md index 5272a0b102c3..829ca6d25184 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/docs/PetApi.md +++ b/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/docs/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -860,3 +861,97 @@ catch (ApiException e) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (long petId, List files) + +uploads an images + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFilesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet to update + var files = new List(); // List | + + try + { + // uploads an images + ApiResponse result = apiInstance.UploadFiles(petId, files); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFiles: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFilesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an images + ApiResponse response = apiInstance.UploadFilesWithHttpInfo(petId, files); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFilesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **files** | **List<System.IO.Stream>** | | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index 2c624280f114..d23685664bc2 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/unityWebRequest/net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -213,6 +213,26 @@ public interface IPetApiSync : IApiAccessor /// Additional data to pass to server (optional) /// ApiResponse of ApiResponse ApiResponse UploadFileWithRequiredFileWithHttpInfo(long petId, System.IO.Stream requiredFile, string? additionalMetadata = default); + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + ApiResponse UploadFiles(long petId, List files); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + ApiResponse UploadFilesWithHttpInfo(long petId, List files); #endregion Synchronous Operations } @@ -445,6 +465,31 @@ public interface IPetApiAsync : IApiAccessor /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, System.IO.Stream requiredFile, string? additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); #endregion Asynchronous Operations } @@ -2019,5 +2064,149 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile return localVarResponse; } + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + public ApiResponse UploadFiles(long petId, List files) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFilesWithHttpInfo(petId, files); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + public Org.OpenAPITools.Client.ApiResponse UploadFilesWithHttpInfo(long petId, List files) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + var localVarResponse = this.Client.Post("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + var task = UploadFilesWithHttpInfoAsync(petId, files, cancellationToken); +#if UNITY_EDITOR || !UNITY_WEBGL + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task.ConfigureAwait(false); +#else + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task; +#endif + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + public async System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + + var task = this.AsynchronousClient.PostAsync("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration, cancellationToken); + +#if UNITY_EDITOR || !UNITY_WEBGL + var localVarResponse = await task.ConfigureAwait(false); +#else + var localVarResponse = await task; +#endif + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md index 3e2173e6db41..f3a7c402bb1a 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md @@ -127,6 +127,7 @@ Class | Method | HTTP request | Description *PetApi* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *PetApi* | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*PetApi* | [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images *StoreApi* | [**DeleteOrder**](StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**GetInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**GetOrderById**](StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/PetApi.md b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/PetApi.md index 5272a0b102c3..829ca6d25184 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/PetApi.md +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -860,3 +861,97 @@ catch (ApiException e) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (long petId, List files) + +uploads an images + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFilesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet to update + var files = new List(); // List | + + try + { + // uploads an images + ApiResponse result = apiInstance.UploadFiles(petId, files); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFiles: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFilesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an images + ApiResponse response = apiInstance.UploadFilesWithHttpInfo(petId, files); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFilesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **files** | **List<System.IO.Stream>** | | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index 2c624280f114..d23685664bc2 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -213,6 +213,26 @@ public interface IPetApiSync : IApiAccessor /// Additional data to pass to server (optional) /// ApiResponse of ApiResponse ApiResponse UploadFileWithRequiredFileWithHttpInfo(long petId, System.IO.Stream requiredFile, string? additionalMetadata = default); + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + ApiResponse UploadFiles(long petId, List files); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + ApiResponse UploadFilesWithHttpInfo(long petId, List files); #endregion Synchronous Operations } @@ -445,6 +465,31 @@ public interface IPetApiAsync : IApiAccessor /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, System.IO.Stream requiredFile, string? additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); #endregion Asynchronous Operations } @@ -2019,5 +2064,149 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile return localVarResponse; } + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + public ApiResponse UploadFiles(long petId, List files) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFilesWithHttpInfo(petId, files); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + public Org.OpenAPITools.Client.ApiResponse UploadFilesWithHttpInfo(long petId, List files) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + var localVarResponse = this.Client.Post("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + var task = UploadFilesWithHttpInfoAsync(petId, files, cancellationToken); +#if UNITY_EDITOR || !UNITY_WEBGL + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task.ConfigureAwait(false); +#else + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task; +#endif + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + public async System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + + var task = this.AsynchronousClient.PostAsync("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration, cancellationToken); + +#if UNITY_EDITOR || !UNITY_WEBGL + var localVarResponse = await task.ConfigureAwait(false); +#else + var localVarResponse = await task; +#endif + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md index 3e2173e6db41..f3a7c402bb1a 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md @@ -127,6 +127,7 @@ Class | Method | HTTP request | Description *PetApi* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *PetApi* | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*PetApi* | [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images *StoreApi* | [**DeleteOrder**](StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**GetInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**GetOrderById**](StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml index d8106a5755fc..ca451f3fb832 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml @@ -331,6 +331,40 @@ paths: summary: uploads an image tags: - pet + /pet/{petId}/uploadImages: + post: + description: "" + operationId: uploadFiles + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/uploadFiles_request" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an images + tags: + - pet /store/inventory: get: description: Returns a map of status codes to quantities @@ -2924,6 +2958,16 @@ components: format: binary type: string type: object + uploadFiles_request: + properties: + files: + items: + format: binary + type: string + type: array + required: + - files + type: object testEnumParameters_request: properties: enum_form_string_array: diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/PetApi.md b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/PetApi.md index 3db7da1cd2fa..cb3a65d239b4 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/PetApi.md +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/PetApi.md @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | | [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | +| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images | # **AddPet** @@ -860,3 +861,97 @@ catch (ApiException e) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **UploadFiles** +> ApiResponse UploadFiles (long petId, List files) + +uploads an images + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFilesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet to update + var files = new List(); // List | + + try + { + // uploads an images + ApiResponse result = apiInstance.UploadFiles(petId, files); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFiles: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFilesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an images + ApiResponse response = apiInstance.UploadFilesWithHttpInfo(petId, files); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFilesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **files** | **List<System.IO.Stream>** | | | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs index 91f1a9769b50..767573545c91 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -213,6 +213,26 @@ public interface IPetApiSync : IApiAccessor /// Additional data to pass to server (optional) /// ApiResponse of ApiResponse ApiResponse UploadFileWithRequiredFileWithHttpInfo(long petId, System.IO.Stream requiredFile, string additionalMetadata = default); + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + ApiResponse UploadFiles(long petId, List files); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + ApiResponse UploadFilesWithHttpInfo(long petId, List files); #endregion Synchronous Operations } @@ -445,6 +465,31 @@ public interface IPetApiAsync : IApiAccessor /// Cancellation Token to cancel the request. /// Task of ApiResponse (ApiResponse) System.Threading.Tasks.Task> UploadFileWithRequiredFileWithHttpInfoAsync(long petId, System.IO.Stream requiredFile, string additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an images + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default); #endregion Asynchronous Operations } @@ -2019,5 +2064,149 @@ public async System.Threading.Tasks.Task UploadFileWithRequiredFile return localVarResponse; } + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse + public ApiResponse UploadFiles(long petId, List files) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = UploadFilesWithHttpInfo(petId, files); + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// ApiResponse of ApiResponse + public Org.OpenAPITools.Client.ApiResponse UploadFilesWithHttpInfo(long petId, List files) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + var localVarResponse = this.Client.Post("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task UploadFilesAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + var task = UploadFilesWithHttpInfoAsync(petId, files, cancellationToken); +#if UNITY_EDITOR || !UNITY_WEBGL + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task.ConfigureAwait(false); +#else + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task; +#endif + return localVarResponse.Data; + } + + /// + /// uploads an images + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ApiResponse) + public async System.Threading.Tasks.Task> UploadFilesWithHttpInfoAsync(long petId, List files, System.Threading.CancellationToken cancellationToken = default) + { + // verify the required parameter 'files' is set + if (files == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'files' when calling PetApi->UploadFiles"); + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "multipart/form-data" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.PathParameters.Add("petId", Org.OpenAPITools.Client.ClientUtils.ParameterToString(petId)); // path parameter + + // authentication (petstore_auth) required + // oauth required + if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); + } + + // make the HTTP request + + var task = this.AsynchronousClient.PostAsync("/pet/{petId}/uploadImages", localVarRequestOptions, this.Configuration, cancellationToken); + +#if UNITY_EDITOR || !UNITY_WEBGL + var localVarResponse = await task.ConfigureAwait(false); +#else + var localVarResponse = await task; +#endif + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("UploadFiles", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + } } From ff5bd0bd6226539f2be47775223f8671012f9732 Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 25 Jan 2026 17:42:07 -0500 Subject: [PATCH 02/15] build tests --- .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ .../src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 13 +++++++++++++ 17 files changed, 221 insertions(+) diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 1f1d7f6c4576..5ce22922ba57 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 49e7b21b53c2..a275bfac9b85 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default!; + long petId = default!; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 215e88093797..c9b30a54e4d7 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 49e7b21b53c2..a275bfac9b85 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default!; + long petId = default!; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 1f1d7f6c4576..5ce22922ba57 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 215e88093797..c9b30a54e4d7 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 1f1d7f6c4576..5ce22922ba57 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 215e88093797..c9b30a54e4d7 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 1f1d7f6c4576..5ce22922ba57 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 49e7b21b53c2..a275bfac9b85 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default!; + long petId = default!; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 215e88093797..c9b30a54e4d7 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 49e7b21b53c2..a275bfac9b85 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default!; + long petId = default!; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 1f1d7f6c4576..5ce22922ba57 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 49e7b21b53c2..a275bfac9b85 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default!; + long petId = default!; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 215e88093797..c9b30a54e4d7 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 49e7b21b53c2..a275bfac9b85 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default!; + long petId = default!; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 215e88093797..c9b30a54e4d7 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -156,5 +156,18 @@ public async Task UploadFileWithRequiredFileAsyncTest() var model = response.Ok(); Assert.IsType(model); } + + /// + /// Test UploadFiles + /// + [Fact (Skip = "not implemented")] + public async Task UploadFilesAsyncTest() + { + List files = default; + long petId = default; + var response = await _instance.UploadFilesAsync(files, petId); + var model = response.Ok(); + Assert.IsType(model); + } } } From aee233f458a8283930f8a3b54f1d99378d66819a Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 17:27:55 -0400 Subject: [PATCH 03/15] use copilot to write manual tests --- .../csharp/libraries/generichost/api.mustache | 2 + .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../MultipartContentTypeTests.cs | 189 ++++++++++++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 5 - .../src/Org.OpenAPITools/Api/FakeApi.cs | 15 -- .../src/Org.OpenAPITools/Api/PetApi.cs | 20 -- 53 files changed, 191 insertions(+), 680 deletions(-) create mode 100644 samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs 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 29153e6e9040..1ec8e5d51686 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 @@ -618,10 +618,12 @@ namespace {{packageName}}.{{apiPackage}} {{#consumes}} {{#-first}} + {{^formParams}} string{{nrt?}} contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + {{/formParams}} {{/-first}} {{/consumes}} 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 66211422bf81..848ed4f84743 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 @@ -781,11 +781,6 @@ public async Task GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 bb4069b491a3..0628cb174fa5 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 @@ -4344,11 +4344,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4650,11 +4645,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5560,11 +5550,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 34ddd104a52e..53f3208c5183 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 @@ -2415,11 +2415,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2670,11 +2665,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3247,11 +3232,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 fdd57d8cb1df..954aeb4e622d 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 @@ -4346,11 +4346,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4664,11 +4659,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5574,11 +5564,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 6cc527fa0dc1..be0a9f2307c4 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 @@ -2417,11 +2417,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2672,11 +2667,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3249,11 +3234,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 aa95f6cb4b32..31aa204f3294 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 @@ -4344,11 +4344,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4662,11 +4657,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5572,11 +5562,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 79a8214463d3..ff0b07f65145 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 @@ -2415,11 +2415,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2670,11 +2665,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3247,11 +3232,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 fdd57d8cb1df..954aeb4e622d 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 @@ -4346,11 +4346,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4664,11 +4659,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5574,11 +5564,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 6cc527fa0dc1..be0a9f2307c4 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 @@ -2417,11 +2417,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2672,11 +2667,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3249,11 +3234,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 023e16226228..01bee92c4f27 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 @@ -4335,11 +4335,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4641,11 +4636,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5550,11 +5540,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 bae78e0a8e62..5583825ae85e 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 @@ -2411,11 +2411,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2666,11 +2661,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3241,11 +3226,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 b85cf1d91ef4..35e7cd4bc0fc 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 @@ -4335,11 +4335,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4653,11 +4648,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5562,11 +5552,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 95cd8163eca3..83e85e41b900 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 @@ -2411,11 +2411,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2666,11 +2661,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3241,11 +3226,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 023e16226228..01bee92c4f27 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 @@ -4335,11 +4335,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4641,11 +4636,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5550,11 +5540,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 bae78e0a8e62..5583825ae85e 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 @@ -2411,11 +2411,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2666,11 +2661,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3241,11 +3226,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 b85cf1d91ef4..35e7cd4bc0fc 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 @@ -4335,11 +4335,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4653,11 +4648,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5562,11 +5552,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 95cd8163eca3..83e85e41b900 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 @@ -2411,11 +2411,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2666,11 +2661,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3241,11 +3226,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 bb4069b491a3..0628cb174fa5 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 @@ -4344,11 +4344,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4650,11 +4645,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5560,11 +5550,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 34ddd104a52e..53f3208c5183 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 @@ -2415,11 +2415,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2670,11 +2665,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3247,11 +3232,6 @@ public async Task UploadFilesAsync(List + /// Tests that multipart/form-data requests preserve the boundary in their Content-Type header. + /// Regression test for https://github.com/OpenAPITools/openapi-generator/issues/21384 + /// + [TestClass] + public sealed class MultipartContentTypeTests + { + /// + /// Captures the outgoing HttpRequestMessage and returns a minimal fake response, + /// so tests can inspect what the generated client actually sends without a real server. + /// + private sealed class CapturingHandler : HttpMessageHandler + { + public HttpRequestMessage? CapturedRequest { get; private set; } + public string? CapturedContentType { get; private set; } + public string? CapturedBody { get; private set; } + + protected override async Task SendAsync( + HttpRequestMessage request, CancellationToken cancellationToken) + { + CapturedRequest = request; + CapturedContentType = request.Content?.Headers.ContentType?.ToString(); + CapturedBody = request.Content is not null + ? await request.Content.ReadAsStringAsync(cancellationToken) + : null; + + var response = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent( + """{"code":200,"type":"ok","message":"ok"}""", + System.Text.Encoding.UTF8, + "application/json") + }; + + return response; + } + } + + private IHost _host = null!; + private CapturingHandler _capturingHandler = null!; + + [TestInitialize] + public void Setup() + { + _capturingHandler = new CapturingHandler(); + + IHostBuilder hostBuilder = Host.CreateDefaultBuilder(Array.Empty()) + .ConfigureApi((context, services, options) => + { + options.AddTokens(new ApiKeyToken("test-key", ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1))); + options.AddTokens(new BearerToken("test-bearer", timeout: TimeSpan.FromSeconds(1))); + options.AddTokens(new BasicToken("user", "pass", timeout: TimeSpan.FromSeconds(1))); + options.AddTokens(new OAuthToken("test-oauth", timeout: TimeSpan.FromSeconds(1))); + + HttpSigningConfiguration signingConfig = new("", "", null, + new List(), System.Security.Cryptography.HashAlgorithmName.SHA256, "", 0); + options.AddTokens(new HttpSignatureToken(signingConfig, timeout: TimeSpan.FromSeconds(1))); + + options.AddApiHttpClients( + client: c => c.BaseAddress = new Uri("http://localhost/"), + builder: b => b.ConfigurePrimaryHttpMessageHandler(() => _capturingHandler)); + }); + + _host = hostBuilder.Build(); + } + + [TestCleanup] + public void Cleanup() + { + _host.Dispose(); + _capturingHandler.Dispose(); + } + + [TestMethod] + public async Task UploadFile_SingleOptionalFile_ContentTypeHasBoundary() + { + var petApi = _host.Services.GetRequiredService(); + using var stream = new MemoryStream(new byte[] { 1, 2, 3 }); + + await petApi.UploadFileAsync(petId: 1, file: new Option(stream)); + + Assert.IsNotNull(_capturingHandler.CapturedContentType, + "Content-Type header should not be null for a multipart/form-data request."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "multipart/form-data", + "Content-Type should be multipart/form-data."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "boundary=", + "Content-Type must include a boundary parameter so the server can parse the body."); + } + + [TestMethod] + public async Task UploadFile_SingleOptionalFile_BodyContainsFileWithCorrectFieldName() + { + var petApi = _host.Services.GetRequiredService(); + using var stream = new MemoryStream(new byte[] { 1, 2, 3 }); + + await petApi.UploadFileAsync(petId: 1, file: new Option(stream)); + + Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); + // .NET's MultipartFormDataContent writes unquoted names: name=file (valid per RFC 7578) + StringAssert.Contains(_capturingHandler.CapturedBody, "name=file", + "Multipart part should use the field name 'file' as defined in the spec."); + } + + [TestMethod] + public async Task UploadFiles_MultipleRequiredFiles_ContentTypeHasBoundary() + { + var petApi = _host.Services.GetRequiredService(); + using var stream1 = new MemoryStream(new byte[] { 1, 2, 3 }); + using var stream2 = new MemoryStream(new byte[] { 4, 5, 6 }); + + await petApi.UploadFilesAsync( + files: new List { stream1, stream2 }, + petId: 1); + + Assert.IsNotNull(_capturingHandler.CapturedContentType, + "Content-Type header should not be null for a multipart/form-data request."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "multipart/form-data", + "Content-Type should be multipart/form-data."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "boundary=", + "Content-Type must include a boundary parameter so the server can parse the body."); + } + + [TestMethod] + public async Task UploadFiles_MultipleRequiredFiles_BodyContainsBothFilesWithCorrectFieldName() + { + var petApi = _host.Services.GetRequiredService(); + using var stream1 = new MemoryStream(new byte[] { 10, 20, 30 }); + using var stream2 = new MemoryStream(new byte[] { 40, 50, 60 }); + + await petApi.UploadFilesAsync( + files: new List { stream1, stream2 }, + petId: 1); + + Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); + + // .NET's MultipartFormDataContent writes unquoted names: name=files (valid per RFC 7578) + // Split on the boundary marker between parts; each file should appear as a separate part + var parts = _capturingHandler.CapturedBody!.Split("name=files"); + Assert.AreEqual(3, parts.Length, + "Body should contain exactly two parts named 'files' (one per stream), " + + $"but found {parts.Length - 1}. Body:\n{_capturingHandler.CapturedBody}"); + } + + [TestMethod] + public async Task UpdatePetWithForm_FormFieldsOnly_ContentTypeHasBoundary() + { + var petApi = _host.Services.GetRequiredService(); + + await petApi.UpdatePetWithFormAsync( + petId: 1, + name: new Option("Fido"), + status: new Option("available")); + + Assert.IsNotNull(_capturingHandler.CapturedContentType, + "Content-Type header should not be null for a multipart/form-data request."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "multipart/form-data", + "Content-Type should be multipart/form-data."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "boundary=", + "Content-Type must include a boundary parameter so the server can parse the body."); + } + + [TestMethod] + public async Task UpdatePetWithForm_FormFieldsOnly_BodyContainsFormValues() + { + var petApi = _host.Services.GetRequiredService(); + + await petApi.UpdatePetWithFormAsync( + petId: 1, + name: new Option("Fido"), + status: new Option("available")); + + Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); + StringAssert.Contains(_capturingHandler.CapturedBody, "Fido", + "Body should contain the name value."); + StringAssert.Contains(_capturingHandler.CapturedBody, "available", + "Body should contain the status value."); + } + } +} 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 629302a4d2da..2ba0f738c611 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 @@ -783,11 +783,6 @@ public async Task GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 fdd57d8cb1df..954aeb4e622d 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 @@ -4346,11 +4346,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4664,11 +4659,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5574,11 +5564,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 6cc527fa0dc1..be0a9f2307c4 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 @@ -2417,11 +2417,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2672,11 +2667,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3249,11 +3234,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 aa95f6cb4b32..31aa204f3294 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 @@ -4344,11 +4344,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4662,11 +4657,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5572,11 +5562,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 79a8214463d3..ff0b07f65145 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 @@ -2415,11 +2415,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2670,11 +2665,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3247,11 +3232,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 fdd57d8cb1df..954aeb4e622d 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 @@ -4346,11 +4346,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4664,11 +4659,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5574,11 +5564,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 6cc527fa0dc1..be0a9f2307c4 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 @@ -2417,11 +2417,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2672,11 +2667,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3249,11 +3234,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 bb4069b491a3..0628cb174fa5 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 @@ -4344,11 +4344,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4650,11 +4645,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5560,11 +5550,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 34ddd104a52e..53f3208c5183 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 @@ -2415,11 +2415,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2670,11 +2665,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3247,11 +3232,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 fdd57d8cb1df..954aeb4e622d 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 @@ -4346,11 +4346,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4664,11 +4659,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5574,11 +5564,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 6cc527fa0dc1..be0a9f2307c4 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 @@ -2417,11 +2417,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2672,11 +2667,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3249,11 +3234,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 aa95f6cb4b32..31aa204f3294 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 @@ -4344,11 +4344,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4662,11 +4657,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5572,11 +5562,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 79a8214463d3..ff0b07f65145 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 @@ -2415,11 +2415,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2670,11 +2665,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3247,11 +3232,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 fdd57d8cb1df..954aeb4e622d 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 @@ -4346,11 +4346,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4664,11 +4659,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5574,11 +5564,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Get; DateTime requestedAtLocalVar = DateTime.UtcNow; 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 6cc527fa0dc1..be0a9f2307c4 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 @@ -2417,11 +2417,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = HttpMethod.Post; DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2672,11 +2667,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string? contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3249,11 +3234,6 @@ public async Task UploadFilesAsync(List GetCountryAsync(string country, System "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 857caf21eb9b..2b33949ce4df 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 @@ -4334,11 +4334,6 @@ public async Task TestEndpointParametersAsyn "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -4652,11 +4647,6 @@ public async Task TestEnumParametersAsync(Option "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -5561,11 +5551,6 @@ public async Task TestJsonFormDataAsync(string par "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("GET"); DateTime requestedAtLocalVar = DateTime.UtcNow; 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 5f56473ddd75..559ce21ec325 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 @@ -2410,11 +2410,6 @@ public async Task UpdatePetWithFormAsync(long pet "application/x-www-form-urlencoded" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - httpRequestMessageLocalVar.Method = new HttpMethod("POST"); DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -2665,11 +2660,6 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired "multipart/form-data" }; - string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); - - if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) - httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); - string[] acceptLocalVars = new string[] { "application/json", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @@ -3240,11 +3225,6 @@ public async Task UploadFilesAsync(List Date: Sun, 8 Mar 2026 17:40:51 -0400 Subject: [PATCH 04/15] use copilot to write manual tests --- .../MultipartContentTypeTests.cs | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs b/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs index 9c13b1185282..177f3d322020 100644 --- a/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs @@ -151,15 +151,19 @@ await petApi.UploadFilesAsync( $"but found {parts.Length - 1}. Body:\n{_capturingHandler.CapturedBody}"); } + /// + /// Covers issue #21384: multipart/form-data with only text form fields (no file) + /// must still include the boundary in Content-Type so the server can parse the body. + /// Uses UploadFileAsync with only the optional additionalMetadata text field, no file. + /// [TestMethod] - public async Task UpdatePetWithForm_FormFieldsOnly_ContentTypeHasBoundary() + public async Task UploadFile_TextFieldOnly_NoFile_ContentTypeHasBoundary() { var petApi = _host.Services.GetRequiredService(); - await petApi.UpdatePetWithFormAsync( + await petApi.UploadFileAsync( petId: 1, - name: new Option("Fido"), - status: new Option("available")); + additionalMetadata: new Option("some metadata")); Assert.IsNotNull(_capturingHandler.CapturedContentType, "Content-Type header should not be null for a multipart/form-data request."); @@ -170,20 +174,17 @@ await petApi.UpdatePetWithFormAsync( } [TestMethod] - public async Task UpdatePetWithForm_FormFieldsOnly_BodyContainsFormValues() + public async Task UploadFile_TextFieldOnly_NoFile_BodyContainsTextValue() { var petApi = _host.Services.GetRequiredService(); - await petApi.UpdatePetWithFormAsync( + await petApi.UploadFileAsync( petId: 1, - name: new Option("Fido"), - status: new Option("available")); + additionalMetadata: new Option("testmetadata")); Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); - StringAssert.Contains(_capturingHandler.CapturedBody, "Fido", - "Body should contain the name value."); - StringAssert.Contains(_capturingHandler.CapturedBody, "available", - "Body should contain the status value."); + StringAssert.Contains(_capturingHandler.CapturedBody, "testmetadata", + "Body should contain the additionalMetadata value."); } } } From 05776d64a2496a5cac58d5f6ec31449df8cf4fda Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 17:52:34 -0400 Subject: [PATCH 05/15] use copilot to write manual tests --- .../MultipartContentTypeTests.cs | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs b/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs index 177f3d322020..ccb11c5406e7 100644 --- a/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs @@ -186,5 +186,116 @@ await petApi.UploadFileAsync( StringAssert.Contains(_capturingHandler.CapturedBody, "testmetadata", "Body should contain the additionalMetadata value."); } + + /// + /// Covers the case where an optional file and an optional text field are both supplied. + /// Ensures that adding text alongside a file does not strip the boundary. + /// + [TestMethod] + public async Task UploadFile_WithBothFileAndText_ContentTypeHasBoundary() + { + var petApi = _host.Services.GetRequiredService(); + using var stream = new MemoryStream(new byte[] { 1, 2, 3 }); + + await petApi.UploadFileAsync( + petId: 1, + file: new Option(stream), + additionalMetadata: new Option("testmetadata")); + + Assert.IsNotNull(_capturingHandler.CapturedContentType, + "Content-Type header should not be null."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "multipart/form-data", + "Content-Type should be multipart/form-data."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "boundary=", + "Content-Type must include a boundary parameter."); + } + + [TestMethod] + public async Task UploadFile_WithBothFileAndText_BodyContainsBothFields() + { + var petApi = _host.Services.GetRequiredService(); + using var stream = new MemoryStream(new byte[] { 1, 2, 3 }); + + await petApi.UploadFileAsync( + petId: 1, + file: new Option(stream), + additionalMetadata: new Option("testmetadata")); + + Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); + StringAssert.Contains(_capturingHandler.CapturedBody, "name=file", + "Body should contain a part named 'file'."); + StringAssert.Contains(_capturingHandler.CapturedBody, "testmetadata", + "Body should contain the additionalMetadata value."); + } + + /// + /// Covers UploadFileWithRequiredFile: a required (non-optional) binary file param. + /// Tests the required-file code path in the template, which differs from optional files. + /// + [TestMethod] + public async Task UploadFileWithRequiredFile_RequiredFileOnly_ContentTypeHasBoundary() + { + var petApi = _host.Services.GetRequiredService(); + using var stream = new MemoryStream(new byte[] { 7, 8, 9 }); + + await petApi.UploadFileWithRequiredFileAsync(petId: 1, requiredFile: stream); + + Assert.IsNotNull(_capturingHandler.CapturedContentType, + "Content-Type header should not be null."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "multipart/form-data", + "Content-Type should be multipart/form-data."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "boundary=", + "Content-Type must include a boundary parameter."); + } + + [TestMethod] + public async Task UploadFileWithRequiredFile_RequiredFileOnly_BodyContainsCorrectFieldName() + { + var petApi = _host.Services.GetRequiredService(); + using var stream = new MemoryStream(new byte[] { 7, 8, 9 }); + + await petApi.UploadFileWithRequiredFileAsync(petId: 1, requiredFile: stream); + + Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); + StringAssert.Contains(_capturingHandler.CapturedBody, "name=requiredFile", + "Multipart part should use the field name 'requiredFile' as defined in the spec."); + } + + [TestMethod] + public async Task UploadFileWithRequiredFile_WithTextAndFile_ContentTypeHasBoundary() + { + var petApi = _host.Services.GetRequiredService(); + using var stream = new MemoryStream(new byte[] { 7, 8, 9 }); + + await petApi.UploadFileWithRequiredFileAsync( + petId: 1, + requiredFile: stream, + additionalMetadata: new Option("testmetadata")); + + Assert.IsNotNull(_capturingHandler.CapturedContentType, + "Content-Type header should not be null."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "multipart/form-data", + "Content-Type should be multipart/form-data."); + StringAssert.Contains(_capturingHandler.CapturedContentType, "boundary=", + "Adding text fields alongside binary fields must not strip the boundary."); + } + + [TestMethod] + public async Task UploadFileWithRequiredFile_WithTextAndFile_BodyContainsBothFields() + { + var petApi = _host.Services.GetRequiredService(); + using var stream = new MemoryStream(new byte[] { 7, 8, 9 }); + + await petApi.UploadFileWithRequiredFileAsync( + petId: 1, + requiredFile: stream, + additionalMetadata: new Option("testmetadata")); + + Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); + StringAssert.Contains(_capturingHandler.CapturedBody, "name=requiredFile", + "Body should contain a part named 'requiredFile'."); + StringAssert.Contains(_capturingHandler.CapturedBody, "testmetadata", + "Body should contain the additionalMetadata value."); + } } } From e6207d5ec9ea9685c89d7dc300aa9100c353a418 Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 20:02:55 -0400 Subject: [PATCH 06/15] address issue one --- .../languages/CSharpClientCodegen.java | 1 + .../generichost/FileParameter.mustache | 37 ++++++++++ .../generichost/OperationDataType.mustache | 1 + .../generichost/OperationSignature.mustache | 2 +- .../csharp/libraries/generichost/api.mustache | 32 ++++---- .../ComposedEnum/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../HelloWorld/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../InlineEnumAnyOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../latest/OneOfList/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../latest/Tags/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 43 +++++++++++ .../net10/AllOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net10/AnyOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../AnyOfNoCompare/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net10/FormModels/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net10/OneOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net10/Petstore/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../SourceGeneration/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net4.7/AllOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../net4.7/AnyOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../AnyOfNoCompare/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../FormModels/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../net4.7/OneOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../net4.7/Petstore/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../net4.8/AllOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../net4.8/AnyOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../AnyOfNoCompare/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../FormModels/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../net4.8/OneOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../net4.8/Petstore/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../net8/AllOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net8/AnyOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../AnyOfNoCompare/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net8/FormModels/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../MultipartContentTypeTests.cs | 27 +++---- .../.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net8/OneOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net8/Petstore/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../SourceGeneration/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net9/AllOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net9/AnyOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../AnyOfNoCompare/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net9/FormModels/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net9/OneOf/.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../net9/Petstore/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ .../SourceGeneration/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Client/FileParameter.cs | 42 +++++++++++ .../Petstore/.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/FakeApi.cs | 24 +++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 74 +++++++++---------- .../Org.OpenAPITools/Client/FileParameter.cs | 40 ++++++++++ 134 files changed, 2883 insertions(+), 863 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/csharp/libraries/generichost/FileParameter.mustache create mode 100644 modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationDataType.mustache create mode 100644 samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java index 7d9b56b846e9..e087bfda2a25 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java @@ -1126,6 +1126,7 @@ public void addGenericHostSupportingFiles(final String clientPackageDir, final S supportingFiles.add(new SupportingFile("JsonSerializerOptionsProvider.mustache", clientPackageDir, "JsonSerializerOptionsProvider.cs")); supportingFiles.add(new SupportingFile("CookieContainer.mustache", clientPackageDir, "CookieContainer.cs")); supportingFiles.add(new SupportingFile("Option.mustache", clientPackageDir, "Option.cs")); + supportingFiles.add(new SupportingFile("FileParameter.mustache", clientPackageDir, "FileParameter.cs")); supportingFiles.add(new SupportingFile("IApi.mustache", sourceFolder + File.separator + packageName + File.separator + apiPackage(), getInterfacePrefix() + "Api.cs")); diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/FileParameter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/FileParameter.mustache new file mode 100644 index 000000000000..6ebbfa231fec --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/FileParameter.mustache @@ -0,0 +1,37 @@ +// +{{>partial_header}} + +{{#nrt}} +#nullable enable + +{{/nrt}} +namespace {{packageName}}.{{clientPackage}} +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + {{>visibility}} sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string{{nrt?}} FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string{{nrt?}} fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationDataType.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationDataType.mustache new file mode 100644 index 000000000000..7fc41573fde5 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationDataType.mustache @@ -0,0 +1 @@ +{{#isFile}}{{#isContainer}}List<{{packageName}}.{{clientPackage}}.FileParameter>{{/isContainer}}{{^isContainer}}{{packageName}}.{{clientPackage}}.FileParameter{{>NullConditionalParameter}}{{/isContainer}}{{/isFile}}{{^isFile}}{{{dataType}}}{{>NullConditionalParameter}}{{/isFile}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationSignature.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationSignature.mustache index caa9d144c52d..1d03c47e332c 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationSignature.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationSignature.mustache @@ -1 +1 @@ -{{#lambda.joinWithComma}}{{#allParams}}{{#required}}{{{dataType}}}{{>NullConditionalParameter}}{{/required}}{{^required}}Option<{{{dataType}}}{{>NullConditionalParameter}}>{{/required}} {{paramName}}{{#notRequiredOrIsNullable}} = default{{/notRequiredOrIsNullable}} {{/allParams}}System.Threading.CancellationToken cancellationToken = default{{^netstandard20OrLater}}(global::System.Threading.CancellationToken){{/netstandard20OrLater}}{{/lambda.joinWithComma}} \ No newline at end of file +{{#lambda.joinWithComma}}{{#allParams}}{{#required}}{{>OperationDataType}}{{/required}}{{^required}}Option<{{>OperationDataType}}>{{/required}} {{paramName}}{{#notRequiredOrIsNullable}} = default{{/notRequiredOrIsNullable}} {{/allParams}}System.Threading.CancellationToken cancellationToken = default{{^netstandard20OrLater}}(global::System.Threading.CancellationToken){{/netstandard20OrLater}}{{/lambda.joinWithComma}} \ No newline at end of file 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 1ec8e5d51686..344a9126d391 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 @@ -246,7 +246,7 @@ namespace {{packageName}}.{{apiPackage}} {{#allParams}} {{#-first}} - partial void Format{{operationId}}({{#allParams}}{{#isPrimitiveType}}ref {{/isPrimitiveType}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + partial void Format{{operationId}}({{#allParams}}{{#isPrimitiveType}}ref {{/isPrimitiveType}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); {{/-first}} {{/allParams}} @@ -258,7 +258,7 @@ namespace {{packageName}}.{{apiPackage}} /// {{/vendorExtensions.x-not-nullable-reference-types}} /// - private void Validate{{operationId}}({{#vendorExtensions.x-not-nullable-reference-types}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-not-nullable-reference-types}}) + private void Validate{{operationId}}({{#vendorExtensions.x-not-nullable-reference-types}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-not-nullable-reference-types}}) { {{#lambda.trimTrailingWithNewLine}} {{#vendorExtensions.x-not-nullable-reference-types}} @@ -288,7 +288,7 @@ namespace {{packageName}}.{{apiPackage}} {{#allParams}} /// {{/allParams}} - private void After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}{{interfacePrefix}}{{operationId}}ApiResponse apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}) + private void After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}{{interfacePrefix}}{{operationId}}ApiResponse apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}) { bool suppressDefaultLog = false; After{{operationId}}({{#lambda.joinWithComma}}ref suppressDefaultLog apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); @@ -303,7 +303,7 @@ namespace {{packageName}}.{{apiPackage}} {{#allParams}} /// {{/allParams}} - partial void After{{operationId}}({{#lambda.joinWithComma}}ref bool suppressDefaultLog {{interfacePrefix}}{{operationId}}ApiResponse apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); + partial void After{{operationId}}({{#lambda.joinWithComma}}ref bool suppressDefaultLog {{interfacePrefix}}{{operationId}}ApiResponse apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); /// /// Logs exceptions that occur while retrieving the server response @@ -314,7 +314,7 @@ namespace {{packageName}}.{{apiPackage}} {{#allParams}} /// {{/allParams}} - private void OnError{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}Exception exceptionLocalVar string pathFormatLocalVar string pathLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}) + private void OnError{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}Exception exceptionLocalVar string pathFormatLocalVar string pathLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}) { bool suppressDefaultLogLocalVar = false; OnError{{operationId}}({{#lambda.joinWithComma}}ref suppressDefaultLogLocalVar exceptionLocalVar pathFormatLocalVar pathLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); @@ -332,7 +332,7 @@ namespace {{packageName}}.{{apiPackage}} {{#allParams}} /// {{/allParams}} - partial void OnError{{operationId}}({{#lambda.joinWithComma}}ref bool suppressDefaultLogLocalVar Exception exceptionLocalVar string pathFormatLocalVar string pathLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); + partial void OnError{{operationId}}({{#lambda.joinWithComma}}ref bool suppressDefaultLogLocalVar Exception exceptionLocalVar string pathFormatLocalVar string pathLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); /// /// {{summary}} {{notes}} @@ -492,16 +492,16 @@ namespace {{packageName}}.{{apiPackage}} {{#isFile}} {{#required}} {{#isContainer}} - foreach (global::System.IO.Stream streamLocalVar in {{paramName}}) + foreach ({{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar in {{paramName}}) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", fileParameterLocalVar.FileName ?? "{{baseName}}"); } {{/isContainer}} {{^isContainer}} - var streamContentLocalVar = new StreamContent({{paramName}}); - multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}"); + var streamContentLocalVar = new StreamContent({{paramName}}.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.FileName ?? "{{baseName}}"); {{/isContainer}} {{/required}} @@ -509,15 +509,15 @@ namespace {{packageName}}.{{apiPackage}} if ({{paramName}}.IsSet) { {{#isContainer}} - foreach (global::System.IO.Stream streamLocalVar in {{paramName}}.Value) + foreach ({{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar in {{paramName}}.Value) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", fileParameterLocalVar.FileName ?? "{{baseName}}"); } {{/isContainer}} {{^isContainer}} - var streamContentLocalVar = new StreamContent({{paramName}}.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}"); + var streamContentLocalVar = new StreamContent({{paramName}}.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.Value.FileName ?? "{{baseName}}"); {{/isContainer}} } diff --git a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/.openapi-generator/FILES index a0b893ad3a65..088165b19c1d 100644 --- a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..42e3a7879497 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI + * + * OpenAPI + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/latest/HelloWorld/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/latest/HelloWorld/.openapi-generator/FILES index 479e2c02cc5c..7e49740eadbb 100644 --- a/samples/client/petstore/csharp/generichost/latest/HelloWorld/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/latest/HelloWorld/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..edb0bd0479a5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * Minimal reproduction for csharp webhook bug + * + * This is an example API to reproduce a bug with webhooks in csharp codegen + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/.openapi-generator/FILES index 8f168c503eca..7c3137c1b51f 100644 --- a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/.openapi-generator/FILES @@ -26,6 +26,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..77779fe7d75a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/latest/OneOfList/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/latest/OneOfList/.openapi-generator/FILES index c3094ea1e371..54155a05db81 100644 --- a/samples/client/petstore/csharp/generichost/latest/OneOfList/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/latest/OneOfList/.openapi-generator/FILES @@ -24,6 +24,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..f5b898e16331 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * Oneof array test + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/latest/Tags/.openapi-generator/FILES index b08037a54926..27397861417c 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/latest/Tags/.openapi-generator/FILES @@ -27,6 +27,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..1e3e3f9f418f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,43 @@ +// +/* + * Files.com API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: support@files.com + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net10/AllOf/.openapi-generator/FILES index b9ab612bd8b5..46a8286dea29 100644 --- a/samples/client/petstore/csharp/generichost/net10/AllOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net10/AllOf/.openapi-generator/FILES @@ -25,6 +25,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..1913a3a0f2d9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net10/AnyOf/.openapi-generator/FILES index dc42a5d47091..072cc8408121 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/.openapi-generator/FILES @@ -25,6 +25,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..e629f4afdaec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/.openapi-generator/FILES index dc42a5d47091..072cc8408121 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/.openapi-generator/FILES @@ -25,6 +25,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..e629f4afdaec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net10/FormModels/.openapi-generator/FILES index a9823b3075fd..737d53400248 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/.openapi-generator/FILES @@ -165,6 +165,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 0628cb174fa5..ac8ab93f6ea7 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4080,7 +4080,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4092,7 +4092,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4131,7 +4131,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4158,7 +4158,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4180,7 +4180,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4209,7 +4209,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4230,7 +4230,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4262,7 +4262,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4297,8 +4297,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 53f3208c5183..20f113c7dad1 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2514,7 +2514,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2522,7 +2522,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2538,7 +2538,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2554,7 +2554,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2565,7 +2565,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2583,7 +2583,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2593,7 +2593,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2614,7 +2614,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2805,7 +2805,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2813,7 +2813,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2829,7 +2829,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2845,7 +2845,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2856,7 +2856,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2874,7 +2874,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2884,7 +2884,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2905,7 +2905,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2931,8 +2931,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3094,14 +3094,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3113,7 +3113,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3128,7 +3128,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3138,7 +3138,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3155,7 +3155,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3164,7 +3164,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3184,7 +3184,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3210,10 +3210,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/.openapi-generator/FILES index ab28c754b4b1..a3e02b328e0a 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/.openapi-generator/FILES @@ -140,6 +140,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 954aeb4e622d..d5131e55a597 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 @@ -332,7 +332,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -356,7 +356,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <?> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4082,7 +4082,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4094,7 +4094,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4133,7 +4133,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4160,7 +4160,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4182,7 +4182,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4211,7 +4211,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4232,7 +4232,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4264,7 +4264,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4299,8 +4299,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 be0a9f2307c4..905a601d5916 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 @@ -218,7 +218,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -231,7 +231,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -245,7 +245,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -258,7 +258,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -271,7 +271,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -283,7 +283,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <?> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2516,7 +2516,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2524,7 +2524,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2540,7 +2540,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2556,7 +2556,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2567,7 +2567,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2585,7 +2585,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2595,7 +2595,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2616,7 +2616,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2647,8 +2647,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2807,7 +2807,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2815,7 +2815,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2831,7 +2831,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2847,7 +2847,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2858,7 +2858,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2876,7 +2876,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2886,7 +2886,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2907,7 +2907,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2933,8 +2933,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3096,14 +3096,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3115,7 +3115,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3130,7 +3130,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3140,7 +3140,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3157,7 +3157,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3166,7 +3166,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3186,7 +3186,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3212,10 +3212,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..77779fe7d75a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net10/OneOf/.openapi-generator/FILES index a36efde4422e..cfb76c7ed0ac 100644 --- a/samples/client/petstore/csharp/generichost/net10/OneOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net10/OneOf/.openapi-generator/FILES @@ -26,6 +26,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..e629f4afdaec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net10/Petstore/.openapi-generator/FILES index ab28c754b4b1..a3e02b328e0a 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/.openapi-generator/FILES @@ -140,6 +140,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 31aa204f3294..b9abc142de44 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4080,7 +4080,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4092,7 +4092,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4131,7 +4131,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4158,7 +4158,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4180,7 +4180,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4209,7 +4209,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4230,7 +4230,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4262,7 +4262,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4297,8 +4297,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 ff0b07f65145..1dd1633edb94 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2514,7 +2514,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2522,7 +2522,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2538,7 +2538,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2554,7 +2554,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2565,7 +2565,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2583,7 +2583,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2593,7 +2593,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2614,7 +2614,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2805,7 +2805,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2813,7 +2813,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2829,7 +2829,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2845,7 +2845,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2856,7 +2856,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2874,7 +2874,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2884,7 +2884,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2905,7 +2905,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2931,8 +2931,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3094,14 +3094,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3113,7 +3113,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3128,7 +3128,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3138,7 +3138,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3155,7 +3155,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3164,7 +3164,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3184,7 +3184,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3210,10 +3210,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/.openapi-generator/FILES index ab28c754b4b1..a3e02b328e0a 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/.openapi-generator/FILES @@ -140,6 +140,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 954aeb4e622d..d5131e55a597 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 @@ -332,7 +332,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -356,7 +356,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <?> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4082,7 +4082,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4094,7 +4094,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4133,7 +4133,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4160,7 +4160,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4182,7 +4182,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4211,7 +4211,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4232,7 +4232,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4264,7 +4264,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4299,8 +4299,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 be0a9f2307c4..905a601d5916 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 @@ -218,7 +218,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -231,7 +231,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -245,7 +245,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -258,7 +258,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -271,7 +271,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -283,7 +283,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <?> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2516,7 +2516,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2524,7 +2524,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2540,7 +2540,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2556,7 +2556,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2567,7 +2567,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2585,7 +2585,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2595,7 +2595,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2616,7 +2616,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2647,8 +2647,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2807,7 +2807,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2815,7 +2815,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2831,7 +2831,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2847,7 +2847,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2858,7 +2858,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2876,7 +2876,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2886,7 +2886,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2907,7 +2907,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2933,8 +2933,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3096,14 +3096,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3115,7 +3115,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3130,7 +3130,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3140,7 +3140,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3157,7 +3157,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3166,7 +3166,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3186,7 +3186,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3212,10 +3212,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..77779fe7d75a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/.openapi-generator/FILES index 5abbcf46f35c..e28da391730f 100644 --- a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/.openapi-generator/FILES @@ -21,6 +21,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..11da1d925144 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/FILES index 47b2b9b5c4f4..1c80f1449c66 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..936f8415fda6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/FILES index 59cc1ea25a08..5e82fcb80ae5 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..5c8e0767f76a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/FILES index 59cc1ea25a08..5e82fcb80ae5 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..5c8e0767f76a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES index 3c592107ec19..4d9b3d8248d3 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES @@ -163,6 +163,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 01bee92c4f27..ba52b27d5413 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4071,7 +4071,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4083,7 +4083,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4122,7 +4122,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4149,7 +4149,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4171,7 +4171,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4200,7 +4200,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4221,7 +4221,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4253,7 +4253,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4288,8 +4288,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 5583825ae85e..2afc48aa9388 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2510,7 +2510,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2518,7 +2518,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2534,7 +2534,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2550,7 +2550,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2561,7 +2561,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2579,7 +2579,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2589,7 +2589,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2610,7 +2610,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2641,8 +2641,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2800,7 +2800,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2808,7 +2808,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2824,7 +2824,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2840,7 +2840,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2851,7 +2851,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2869,7 +2869,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2879,7 +2879,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2900,7 +2900,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2926,8 +2926,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3088,14 +3088,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3107,7 +3107,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3122,7 +3122,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3132,7 +3132,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3149,7 +3149,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3158,7 +3158,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3178,7 +3178,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3204,10 +3204,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/FILES index 47a388f55336..ef946be5e2fb 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/FILES @@ -24,6 +24,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..5c8e0767f76a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES index a6635c9d8351..82501a149e01 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES @@ -138,6 +138,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 35e7cd4bc0fc..f09345c8c4d2 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4071,7 +4071,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4083,7 +4083,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4122,7 +4122,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4149,7 +4149,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4171,7 +4171,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4200,7 +4200,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4221,7 +4221,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4253,7 +4253,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4288,8 +4288,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 83e85e41b900..4fd8f1637da1 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2510,7 +2510,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2518,7 +2518,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2534,7 +2534,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2550,7 +2550,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2561,7 +2561,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2579,7 +2579,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2589,7 +2589,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2610,7 +2610,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2641,8 +2641,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2800,7 +2800,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2808,7 +2808,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2824,7 +2824,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2840,7 +2840,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2851,7 +2851,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2869,7 +2869,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2879,7 +2879,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2900,7 +2900,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2926,8 +2926,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3088,14 +3088,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3107,7 +3107,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3122,7 +3122,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3132,7 +3132,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3149,7 +3149,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3158,7 +3158,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3178,7 +3178,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3204,10 +3204,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/FILES index 5abbcf46f35c..e28da391730f 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/FILES @@ -21,6 +21,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..253a70bc8053 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/AllOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.8/AllOf/.openapi-generator/FILES index 47b2b9b5c4f4..1c80f1449c66 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AllOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.8/AllOf/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..936f8415fda6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/.openapi-generator/FILES index 59cc1ea25a08..5e82fcb80ae5 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..5c8e0767f76a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/.openapi-generator/FILES index 59cc1ea25a08..5e82fcb80ae5 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..5c8e0767f76a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.8/FormModels/.openapi-generator/FILES index 3c592107ec19..4d9b3d8248d3 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/.openapi-generator/FILES @@ -163,6 +163,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 01bee92c4f27..ba52b27d5413 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4071,7 +4071,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4083,7 +4083,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4122,7 +4122,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4149,7 +4149,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4171,7 +4171,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4200,7 +4200,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4221,7 +4221,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4253,7 +4253,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4288,8 +4288,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 5583825ae85e..2afc48aa9388 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2510,7 +2510,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2518,7 +2518,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2534,7 +2534,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2550,7 +2550,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2561,7 +2561,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2579,7 +2579,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2589,7 +2589,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2610,7 +2610,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2641,8 +2641,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2800,7 +2800,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2808,7 +2808,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2824,7 +2824,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2840,7 +2840,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2851,7 +2851,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2869,7 +2869,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2879,7 +2879,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2900,7 +2900,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2926,8 +2926,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3088,14 +3088,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3107,7 +3107,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3122,7 +3122,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3132,7 +3132,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3149,7 +3149,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3158,7 +3158,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3178,7 +3178,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3204,10 +3204,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/OneOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.8/OneOf/.openapi-generator/FILES index 47a388f55336..ef946be5e2fb 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/OneOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.8/OneOf/.openapi-generator/FILES @@ -24,6 +24,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..5c8e0767f76a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.8/Petstore/.openapi-generator/FILES index a6635c9d8351..82501a149e01 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/.openapi-generator/FILES @@ -138,6 +138,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 35e7cd4bc0fc..f09345c8c4d2 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4071,7 +4071,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4083,7 +4083,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4122,7 +4122,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4149,7 +4149,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4171,7 +4171,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4200,7 +4200,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4221,7 +4221,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4253,7 +4253,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4288,8 +4288,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 83e85e41b900..4fd8f1637da1 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2510,7 +2510,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2518,7 +2518,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2534,7 +2534,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2550,7 +2550,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2561,7 +2561,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2579,7 +2579,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2589,7 +2589,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2610,7 +2610,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2641,8 +2641,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2800,7 +2800,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2808,7 +2808,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2824,7 +2824,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2840,7 +2840,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2851,7 +2851,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2869,7 +2869,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2879,7 +2879,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2900,7 +2900,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2926,8 +2926,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3088,14 +3088,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3107,7 +3107,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3122,7 +3122,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3132,7 +3132,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3149,7 +3149,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3158,7 +3158,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3178,7 +3178,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3204,10 +3204,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/.openapi-generator/FILES index 5abbcf46f35c..e28da391730f 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/.openapi-generator/FILES @@ -21,6 +21,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..253a70bc8053 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/AllOf/.openapi-generator/FILES index b9ab612bd8b5..46a8286dea29 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/.openapi-generator/FILES @@ -25,6 +25,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..1913a3a0f2d9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/AnyOf/.openapi-generator/FILES index dc42a5d47091..072cc8408121 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/.openapi-generator/FILES @@ -25,6 +25,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..e629f4afdaec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/.openapi-generator/FILES index dc42a5d47091..072cc8408121 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/.openapi-generator/FILES @@ -25,6 +25,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..e629f4afdaec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES index a9823b3075fd..737d53400248 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES @@ -165,6 +165,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 0628cb174fa5..ac8ab93f6ea7 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4080,7 +4080,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4092,7 +4092,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4131,7 +4131,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4158,7 +4158,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4180,7 +4180,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4209,7 +4209,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4230,7 +4230,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4262,7 +4262,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4297,8 +4297,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 53f3208c5183..20f113c7dad1 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2514,7 +2514,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2522,7 +2522,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2538,7 +2538,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2554,7 +2554,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2565,7 +2565,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2583,7 +2583,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2593,7 +2593,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2614,7 +2614,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2805,7 +2805,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2813,7 +2813,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2829,7 +2829,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2845,7 +2845,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2856,7 +2856,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2874,7 +2874,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2884,7 +2884,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2905,7 +2905,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2931,8 +2931,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3094,14 +3094,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3113,7 +3113,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3128,7 +3128,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3138,7 +3138,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3155,7 +3155,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3164,7 +3164,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3184,7 +3184,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3210,10 +3210,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs b/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs index ccb11c5406e7..11b7f610913a 100644 --- a/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs @@ -87,7 +87,7 @@ public async Task UploadFile_SingleOptionalFile_ContentTypeHasBoundary() var petApi = _host.Services.GetRequiredService(); using var stream = new MemoryStream(new byte[] { 1, 2, 3 }); - await petApi.UploadFileAsync(petId: 1, file: new Option(stream)); + await petApi.UploadFileAsync(petId: 1, file: new Option(new FileParameter(stream))); Assert.IsNotNull(_capturingHandler.CapturedContentType, "Content-Type header should not be null for a multipart/form-data request."); @@ -103,7 +103,7 @@ public async Task UploadFile_SingleOptionalFile_BodyContainsFileWithCorrectField var petApi = _host.Services.GetRequiredService(); using var stream = new MemoryStream(new byte[] { 1, 2, 3 }); - await petApi.UploadFileAsync(petId: 1, file: new Option(stream)); + await petApi.UploadFileAsync(petId: 1, file: new Option(new FileParameter(stream))); Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); // .NET's MultipartFormDataContent writes unquoted names: name=file (valid per RFC 7578) @@ -119,7 +119,7 @@ public async Task UploadFiles_MultipleRequiredFiles_ContentTypeHasBoundary() using var stream2 = new MemoryStream(new byte[] { 4, 5, 6 }); await petApi.UploadFilesAsync( - files: new List { stream1, stream2 }, + files: new List { new FileParameter(stream1), new FileParameter(stream2) }, petId: 1); Assert.IsNotNull(_capturingHandler.CapturedContentType, @@ -138,14 +138,15 @@ public async Task UploadFiles_MultipleRequiredFiles_BodyContainsBothFilesWithCor using var stream2 = new MemoryStream(new byte[] { 40, 50, 60 }); await petApi.UploadFilesAsync( - files: new List { stream1, stream2 }, + files: new List { new FileParameter(stream1), new FileParameter(stream2) }, petId: 1); Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); - // .NET's MultipartFormDataContent writes unquoted names: name=files (valid per RFC 7578) - // Split on the boundary marker between parts; each file should appear as a separate part - var parts = _capturingHandler.CapturedBody!.Split("name=files"); + // Count Content-Disposition headers for the "files" field. Each stream must appear as + // its own named part. Matching the full header prefix avoids false positives from + // "filename=files" which also contains "name=files" as a substring. + var parts = _capturingHandler.CapturedBody!.Split("Content-Disposition: form-data; name=files"); Assert.AreEqual(3, parts.Length, "Body should contain exactly two parts named 'files' (one per stream), " + $"but found {parts.Length - 1}. Body:\n{_capturingHandler.CapturedBody}"); @@ -199,7 +200,7 @@ public async Task UploadFile_WithBothFileAndText_ContentTypeHasBoundary() await petApi.UploadFileAsync( petId: 1, - file: new Option(stream), + file: new Option(new FileParameter(stream)), additionalMetadata: new Option("testmetadata")); Assert.IsNotNull(_capturingHandler.CapturedContentType, @@ -218,7 +219,7 @@ public async Task UploadFile_WithBothFileAndText_BodyContainsBothFields() await petApi.UploadFileAsync( petId: 1, - file: new Option(stream), + file: new Option(new FileParameter(stream)), additionalMetadata: new Option("testmetadata")); Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); @@ -238,7 +239,7 @@ public async Task UploadFileWithRequiredFile_RequiredFileOnly_ContentTypeHasBoun var petApi = _host.Services.GetRequiredService(); using var stream = new MemoryStream(new byte[] { 7, 8, 9 }); - await petApi.UploadFileWithRequiredFileAsync(petId: 1, requiredFile: stream); + await petApi.UploadFileWithRequiredFileAsync(petId: 1, requiredFile: new FileParameter(stream)); Assert.IsNotNull(_capturingHandler.CapturedContentType, "Content-Type header should not be null."); @@ -254,7 +255,7 @@ public async Task UploadFileWithRequiredFile_RequiredFileOnly_BodyContainsCorrec var petApi = _host.Services.GetRequiredService(); using var stream = new MemoryStream(new byte[] { 7, 8, 9 }); - await petApi.UploadFileWithRequiredFileAsync(petId: 1, requiredFile: stream); + await petApi.UploadFileWithRequiredFileAsync(petId: 1, requiredFile: new FileParameter(stream)); Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); StringAssert.Contains(_capturingHandler.CapturedBody, "name=requiredFile", @@ -269,7 +270,7 @@ public async Task UploadFileWithRequiredFile_WithTextAndFile_ContentTypeHasBound await petApi.UploadFileWithRequiredFileAsync( petId: 1, - requiredFile: stream, + requiredFile: new FileParameter(stream), additionalMetadata: new Option("testmetadata")); Assert.IsNotNull(_capturingHandler.CapturedContentType, @@ -288,7 +289,7 @@ public async Task UploadFileWithRequiredFile_WithTextAndFile_BodyContainsBothFie await petApi.UploadFileWithRequiredFileAsync( petId: 1, - requiredFile: stream, + requiredFile: new FileParameter(stream), additionalMetadata: new Option("testmetadata")); Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES index ab28c754b4b1..a3e02b328e0a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES @@ -140,6 +140,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 954aeb4e622d..d5131e55a597 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 @@ -332,7 +332,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -356,7 +356,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <?> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4082,7 +4082,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4094,7 +4094,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4133,7 +4133,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4160,7 +4160,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4182,7 +4182,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4211,7 +4211,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4232,7 +4232,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4264,7 +4264,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4299,8 +4299,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 be0a9f2307c4..905a601d5916 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 @@ -218,7 +218,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -231,7 +231,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -245,7 +245,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -258,7 +258,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -271,7 +271,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -283,7 +283,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <?> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2516,7 +2516,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2524,7 +2524,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2540,7 +2540,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2556,7 +2556,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2567,7 +2567,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2585,7 +2585,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2595,7 +2595,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2616,7 +2616,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2647,8 +2647,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2807,7 +2807,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2815,7 +2815,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2831,7 +2831,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2847,7 +2847,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2858,7 +2858,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2876,7 +2876,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2886,7 +2886,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2907,7 +2907,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2933,8 +2933,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3096,14 +3096,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3115,7 +3115,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3130,7 +3130,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3140,7 +3140,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3157,7 +3157,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3166,7 +3166,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3186,7 +3186,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3212,10 +3212,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..77779fe7d75a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/OneOf/.openapi-generator/FILES index a36efde4422e..cfb76c7ed0ac 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/.openapi-generator/FILES @@ -26,6 +26,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..e629f4afdaec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES index ab28c754b4b1..a3e02b328e0a 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES @@ -140,6 +140,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 31aa204f3294..b9abc142de44 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4080,7 +4080,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4092,7 +4092,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4131,7 +4131,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4158,7 +4158,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4180,7 +4180,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4209,7 +4209,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4230,7 +4230,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4262,7 +4262,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4297,8 +4297,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 ff0b07f65145..1dd1633edb94 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2514,7 +2514,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2522,7 +2522,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2538,7 +2538,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2554,7 +2554,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2565,7 +2565,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2583,7 +2583,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2593,7 +2593,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2614,7 +2614,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2805,7 +2805,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2813,7 +2813,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2829,7 +2829,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2845,7 +2845,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2856,7 +2856,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2874,7 +2874,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2884,7 +2884,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2905,7 +2905,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2931,8 +2931,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3094,14 +3094,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3113,7 +3113,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3128,7 +3128,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3138,7 +3138,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3155,7 +3155,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3164,7 +3164,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3184,7 +3184,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3210,10 +3210,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES index ab28c754b4b1..a3e02b328e0a 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES @@ -140,6 +140,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 954aeb4e622d..d5131e55a597 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 @@ -332,7 +332,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -356,7 +356,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <?> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4082,7 +4082,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4094,7 +4094,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4133,7 +4133,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4160,7 +4160,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4182,7 +4182,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4211,7 +4211,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4232,7 +4232,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4264,7 +4264,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4299,8 +4299,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 be0a9f2307c4..905a601d5916 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 @@ -218,7 +218,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -231,7 +231,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -245,7 +245,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -258,7 +258,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -271,7 +271,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -283,7 +283,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <?> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2516,7 +2516,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2524,7 +2524,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2540,7 +2540,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2556,7 +2556,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2567,7 +2567,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2585,7 +2585,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2595,7 +2595,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2616,7 +2616,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2647,8 +2647,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2807,7 +2807,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2815,7 +2815,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2831,7 +2831,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2847,7 +2847,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2858,7 +2858,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2876,7 +2876,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2886,7 +2886,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2907,7 +2907,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2933,8 +2933,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3096,14 +3096,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3115,7 +3115,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3130,7 +3130,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3140,7 +3140,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3157,7 +3157,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3166,7 +3166,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3186,7 +3186,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3212,10 +3212,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..77779fe7d75a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/.openapi-generator/FILES index 5abbcf46f35c..e28da391730f 100644 --- a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/.openapi-generator/FILES @@ -21,6 +21,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..11da1d925144 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/AllOf/.openapi-generator/FILES index b9ab612bd8b5..46a8286dea29 100644 --- a/samples/client/petstore/csharp/generichost/net9/AllOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/AllOf/.openapi-generator/FILES @@ -25,6 +25,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..1913a3a0f2d9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/AnyOf/.openapi-generator/FILES index dc42a5d47091..072cc8408121 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/.openapi-generator/FILES @@ -25,6 +25,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..e629f4afdaec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/.openapi-generator/FILES index dc42a5d47091..072cc8408121 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/.openapi-generator/FILES @@ -25,6 +25,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..e629f4afdaec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES index a9823b3075fd..737d53400248 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES @@ -165,6 +165,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 0628cb174fa5..ac8ab93f6ea7 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4080,7 +4080,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4092,7 +4092,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4131,7 +4131,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4158,7 +4158,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4180,7 +4180,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4209,7 +4209,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4230,7 +4230,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4262,7 +4262,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4297,8 +4297,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 53f3208c5183..20f113c7dad1 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2514,7 +2514,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2522,7 +2522,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2538,7 +2538,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2554,7 +2554,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2565,7 +2565,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2583,7 +2583,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2593,7 +2593,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2614,7 +2614,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2805,7 +2805,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2813,7 +2813,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2829,7 +2829,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2845,7 +2845,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2856,7 +2856,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2874,7 +2874,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2884,7 +2884,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2905,7 +2905,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2931,8 +2931,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3094,14 +3094,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3113,7 +3113,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3128,7 +3128,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3138,7 +3138,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3155,7 +3155,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3164,7 +3164,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3184,7 +3184,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3210,10 +3210,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES index ab28c754b4b1..a3e02b328e0a 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES @@ -140,6 +140,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 954aeb4e622d..d5131e55a597 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 @@ -332,7 +332,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -356,7 +356,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <?> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4082,7 +4082,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4094,7 +4094,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4133,7 +4133,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4160,7 +4160,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4182,7 +4182,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4211,7 +4211,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4232,7 +4232,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4264,7 +4264,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4299,8 +4299,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 be0a9f2307c4..905a601d5916 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 @@ -218,7 +218,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -231,7 +231,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -245,7 +245,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -258,7 +258,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -271,7 +271,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -283,7 +283,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <?> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2516,7 +2516,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2524,7 +2524,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2540,7 +2540,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2556,7 +2556,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2567,7 +2567,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2585,7 +2585,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2595,7 +2595,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2616,7 +2616,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2647,8 +2647,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2807,7 +2807,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2815,7 +2815,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2831,7 +2831,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2847,7 +2847,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2858,7 +2858,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2876,7 +2876,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2886,7 +2886,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2907,7 +2907,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2933,8 +2933,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3096,14 +3096,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3115,7 +3115,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3130,7 +3130,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3140,7 +3140,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3157,7 +3157,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3166,7 +3166,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3186,7 +3186,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3212,10 +3212,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..77779fe7d75a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/OneOf/.openapi-generator/FILES index a36efde4422e..cfb76c7ed0ac 100644 --- a/samples/client/petstore/csharp/generichost/net9/OneOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/OneOf/.openapi-generator/FILES @@ -26,6 +26,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..e629f4afdaec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES index ab28c754b4b1..a3e02b328e0a 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES @@ -140,6 +140,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 31aa204f3294..b9abc142de44 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 @@ -330,7 +330,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -354,7 +354,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4080,7 +4080,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4092,7 +4092,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4131,7 +4131,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4158,7 +4158,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4180,7 +4180,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4209,7 +4209,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4230,7 +4230,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4262,7 +4262,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4297,8 +4297,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 ff0b07f65145..1dd1633edb94 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 @@ -216,7 +216,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -229,7 +229,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -243,7 +243,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -256,7 +256,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -269,7 +269,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -281,7 +281,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2514,7 +2514,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2522,7 +2522,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2538,7 +2538,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2554,7 +2554,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2565,7 +2565,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2583,7 +2583,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2593,7 +2593,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2614,7 +2614,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2805,7 +2805,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2813,7 +2813,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2829,7 +2829,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2845,7 +2845,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2856,7 +2856,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2874,7 +2874,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2884,7 +2884,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2905,7 +2905,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2931,8 +2931,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3094,14 +3094,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3113,7 +3113,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3128,7 +3128,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3138,7 +3138,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3155,7 +3155,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3164,7 +3164,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3184,7 +3184,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3210,10 +3210,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES index ab28c754b4b1..a3e02b328e0a 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES @@ -140,6 +140,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 954aeb4e622d..d5131e55a597 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 @@ -332,7 +332,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -356,7 +356,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <?> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4082,7 +4082,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4094,7 +4094,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4133,7 +4133,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4160,7 +4160,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4182,7 +4182,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4211,7 +4211,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4232,7 +4232,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4264,7 +4264,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4299,8 +4299,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 be0a9f2307c4..905a601d5916 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 @@ -218,7 +218,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -231,7 +231,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -245,7 +245,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -258,7 +258,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <?> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -271,7 +271,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -283,7 +283,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <?> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2516,7 +2516,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2524,7 +2524,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2540,7 +2540,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2556,7 +2556,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2567,7 +2567,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2585,7 +2585,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2595,7 +2595,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2616,7 +2616,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2647,8 +2647,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2807,7 +2807,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2815,7 +2815,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2831,7 +2831,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2847,7 +2847,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2858,7 +2858,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2876,7 +2876,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2886,7 +2886,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2907,7 +2907,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2933,8 +2933,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3096,14 +3096,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3115,7 +3115,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3130,7 +3130,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3140,7 +3140,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3157,7 +3157,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3166,7 +3166,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3186,7 +3186,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3212,10 +3212,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..77779fe7d75a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/.openapi-generator/FILES index 5abbcf46f35c..e28da391730f 100644 --- a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/.openapi-generator/FILES @@ -21,6 +21,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..11da1d925144 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string? FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string? fileName = null) + { + Content = content; + FileName = fileName; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/.openapi-generator/FILES index a6635c9d8351..82501a149e01 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/.openapi-generator/FILES @@ -138,6 +138,7 @@ src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/FileParameter.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs 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 2b33949ce4df..f01f7c930f97 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 @@ -329,7 +329,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -353,7 +353,7 @@ public interface IFakeApi : IApi /// None (optional) /// Cancellation Token to cancel the request. /// <> - Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); + Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default); /// /// To test enum parameters @@ -4070,7 +4070,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); + partial void FormatTestEndpointParameters(ref decimal number, ref string patternWithoutDelimiter, ref byte[] varByte, ref double varDouble, ref Option binary, ref Option callback, ref Option date, ref Option dateTime, ref Option int32, ref Option int64, ref Option integer, ref Option password, ref Option varFloat, ref Option varString); /// /// Validates the request parameters @@ -4082,7 +4082,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) + private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte[] varByte, Option binary, Option callback, Option password, Option varString) { if (patternWithoutDelimiter == null) throw new ArgumentNullException(nameof(patternWithoutDelimiter)); @@ -4121,7 +4121,7 @@ private void ValidateTestEndpointParameters(string patternWithoutDelimiter, byte /// /// /// - private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLog = false; AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4148,7 +4148,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Logs exceptions that occur while retrieving the server response @@ -4170,7 +4170,7 @@ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParam /// /// /// - private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString) { bool suppressDefaultLogLocalVar = false; OnErrorTestEndpointParameters(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, number, patternWithoutDelimiter, varByte, varDouble, binary, callback, date, dateTime, int32, int64, integer, password, varFloat, varString); @@ -4199,7 +4199,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// /// /// - partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary, Option callback, Option date, Option dateTime, Option int32, Option int64, Option integer, Option password, Option varFloat, Option varString); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -4220,7 +4220,7 @@ private void OnErrorTestEndpointParametersDefaultImplementation(Exception except /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersOrDefaultAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -4252,7 +4252,7 @@ public async Task TestEndpointParametersOrDe /// None (optional) /// Cancellation Token to cancel the request. /// <> - public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) + public async Task TestEndpointParametersAsync(decimal number, string patternWithoutDelimiter, byte[] varByte, double varDouble, Option binary = default, Option callback = default, Option date = default, Option dateTime = default, Option int32 = default, Option int64 = default, Option integer = default, Option password = default, Option varFloat = default, Option varString = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -4287,8 +4287,8 @@ public async Task TestEndpointParametersAsyn if (binary.IsSet) { - var streamContentLocalVar = new StreamContent(binary.Value); - multipartContentLocalVar.Add(streamContentLocalVar, "binary"); + var streamContentLocalVar = new StreamContent(binary.Value.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); } if (callback.IsSet) 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 559ce21ec325..f38a31ddf951 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 @@ -215,7 +215,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image @@ -228,7 +228,7 @@ public interface IPetApi : IApi /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -242,7 +242,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an image (required) @@ -255,7 +255,7 @@ public interface IPetApi : IApi /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -268,7 +268,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); /// /// uploads an images @@ -280,7 +280,7 @@ public interface IPetApi : IApi /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); + Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default); } /// @@ -2509,7 +2509,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); + partial void FormatUploadFile(ref long petId, ref Option additionalMetadata, ref Option file); /// /// Validates the request parameters @@ -2517,7 +2517,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFile(Option additionalMetadata, Option file) + private void ValidateUploadFile(Option additionalMetadata, Option file) { if (additionalMetadata.IsSet && additionalMetadata.Value == null) throw new ArgumentNullException(nameof(additionalMetadata)); @@ -2533,7 +2533,7 @@ private void ValidateUploadFile(Option additionalMetadata, Option /// /// - private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLog = false; AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, additionalMetadata, file); @@ -2549,7 +2549,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option additionalMetadata, Option file); /// /// Logs exceptions that occur while retrieving the server response @@ -2560,7 +2560,7 @@ private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResp /// /// /// - private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) + private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, additionalMetadata, file); @@ -2578,7 +2578,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// /// /// - partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); + partial void OnErrorUploadFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Option additionalMetadata, Option file); /// /// uploads an image @@ -2588,7 +2588,7 @@ private void OnErrorUploadFileDefaultImplementation(Exception exceptionLocalVar, /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileOrDefaultAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2609,7 +2609,7 @@ public async Task UploadFileOrDefaultAsync(long petId, O /// file to upload (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileAsync(long petId, Option additionalMetadata = default, Option file = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2640,8 +2640,8 @@ public async Task UploadFileAsync(long petId, Option 0) @@ -2799,7 +2799,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFileWithRequiredFile(ref long petId, ref System.IO.Stream requiredFile, ref Option additionalMetadata); + partial void FormatUploadFileWithRequiredFile(ref long petId, ref Org.OpenAPITools.Client.FileParameter requiredFile, ref Option additionalMetadata); /// /// Validates the request parameters @@ -2807,7 +2807,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht /// /// /// - private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + private void ValidateUploadFileWithRequiredFile(Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { if (requiredFile == null) throw new ArgumentNullException(nameof(requiredFile)); @@ -2823,7 +2823,7 @@ private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, O /// /// /// - private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLog = false; AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, petId, requiredFile, additionalMetadata); @@ -2839,7 +2839,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// Logs exceptions that occur while retrieving the server response @@ -2850,7 +2850,7 @@ private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWit /// /// /// - private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata) + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFileWithRequiredFile(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, petId, requiredFile, additionalMetadata); @@ -2868,7 +2868,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// /// /// - partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, System.IO.Stream requiredFile, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata); /// /// uploads an image (required) @@ -2878,7 +2878,7 @@ private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception ex /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileOrDefaultAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { try { @@ -2899,7 +2899,7 @@ public async Task UploadFileWithRequired /// Additional data to pass to server (optional) /// Cancellation Token to cancel the request. /// <> - public async Task UploadFileWithRequiredFileAsync(long petId, System.IO.Stream requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFileWithRequiredFileAsync(long petId, Org.OpenAPITools.Client.FileParameter requiredFile, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -2925,8 +2925,8 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile"); + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); @@ -3087,14 +3087,14 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } - partial void FormatUploadFiles(List files, ref long petId); + partial void FormatUploadFiles(List files, ref long petId); /// /// Validates the request parameters /// /// /// - private void ValidateUploadFiles(List files) + private void ValidateUploadFiles(List files) { if (files == null) throw new ArgumentNullException(nameof(files)); @@ -3106,7 +3106,7 @@ private void ValidateUploadFiles(List files) /// /// /// - private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) + private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiResponseLocalVar, List files, long petId) { bool suppressDefaultLog = false; AfterUploadFiles(ref suppressDefaultLog, apiResponseLocalVar, files, petId); @@ -3121,7 +3121,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); + partial void AfterUploadFiles(ref bool suppressDefaultLog, IUploadFilesApiResponse apiResponseLocalVar, List files, long petId); /// /// Logs exceptions that occur while retrieving the server response @@ -3131,7 +3131,7 @@ private void AfterUploadFilesDefaultImplementation(IUploadFilesApiResponse apiRe /// /// /// - private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) + private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId) { bool suppressDefaultLogLocalVar = false; OnErrorUploadFiles(ref suppressDefaultLogLocalVar, exceptionLocalVar, pathFormatLocalVar, pathLocalVar, files, petId); @@ -3148,7 +3148,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// /// /// - partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); + partial void OnErrorUploadFiles(ref bool suppressDefaultLogLocalVar, Exception exceptionLocalVar, string pathFormatLocalVar, string pathLocalVar, List files, long petId); /// /// uploads an images @@ -3157,7 +3157,7 @@ private void OnErrorUploadFilesDefaultImplementation(Exception exceptionLocalVar /// ID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesOrDefaultAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { try { @@ -3177,7 +3177,7 @@ public async Task UploadFilesOrDefaultAsync(ListID of pet to update /// Cancellation Token to cancel the request. /// <> - public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) + public async Task UploadFilesAsync(List files, long petId, System.Threading.CancellationToken cancellationToken = default) { UriBuilder uriBuilderLocalVar = new UriBuilder(); @@ -3203,10 +3203,10 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); - foreach (global::System.IO.Stream streamLocalVar in files) + foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { - var streamContentLocalVar = new StreamContent(streamLocalVar); - multipartContentLocalVar.Add(streamContentLocalVar, "files"); + var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "files", fileParameterLocalVar.FileName ?? "files"); } if (formParameterLocalVars.Count > 0) diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs new file mode 100644 index 000000000000..6150dbcf4774 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/FileParameter.cs @@ -0,0 +1,40 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +namespace Org.OpenAPITools.Client +{ + /// + /// Represents a file to be uploaded as part of a multipart/form-data request. + /// + public sealed class FileParameter + { + /// + /// The file content stream. + /// + public global::System.IO.Stream Content { get; } + + /// + /// The filename sent in the Content-Disposition header. + /// When null the parameter name from the spec is used as a fallback. + /// + public string FileName { get; } + + /// + /// Creates a new . + /// + /// The file content stream. + /// Optional filename for the Content-Disposition header. + public FileParameter(global::System.IO.Stream content, string fileName = null) + { + Content = content; + FileName = fileName; + } + } +} From fb1985380886873bc3fca814bfbb19ae023c8ead Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 20:16:02 -0400 Subject: [PATCH 07/15] address issue two --- .../resources/csharp/libraries/generichost/api.mustache | 6 ++++-- .../net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../net4.8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../net4.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../NullReferenceTypes/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- .../standard2.0/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 6 ++++-- 18 files changed, 72 insertions(+), 36 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 344a9126d391..eafafc1db7e4 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 @@ -500,8 +500,10 @@ namespace {{packageName}}.{{apiPackage}} {{/isContainer}} {{^isContainer}} - var streamContentLocalVar = new StreamContent({{paramName}}.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.FileName ?? "{{baseName}}"); + { + var streamContentLocalVar = new StreamContent({{paramName}}.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.FileName ?? "{{baseName}}"); + } {{/isContainer}} {{/required}} 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 20f113c7dad1..8cb6e7891a92 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 @@ -2931,8 +2931,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 905a601d5916..d14ba87732d2 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 @@ -2933,8 +2933,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 1dd1633edb94..e5aea115505a 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 @@ -2931,8 +2931,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 905a601d5916..d14ba87732d2 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 @@ -2933,8 +2933,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 2afc48aa9388..a0c82d84ee92 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 @@ -2926,8 +2926,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 4fd8f1637da1..363cb0273a53 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 @@ -2926,8 +2926,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 2afc48aa9388..a0c82d84ee92 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 @@ -2926,8 +2926,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 4fd8f1637da1..363cb0273a53 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 @@ -2926,8 +2926,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 20f113c7dad1..8cb6e7891a92 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 @@ -2931,8 +2931,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 905a601d5916..d14ba87732d2 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 @@ -2933,8 +2933,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 1dd1633edb94..e5aea115505a 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 @@ -2931,8 +2931,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 905a601d5916..d14ba87732d2 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 @@ -2933,8 +2933,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 20f113c7dad1..8cb6e7891a92 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 @@ -2931,8 +2931,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 905a601d5916..d14ba87732d2 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 @@ -2933,8 +2933,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 1dd1633edb94..e5aea115505a 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 @@ -2931,8 +2931,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 905a601d5916..d14ba87732d2 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 @@ -2933,8 +2933,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.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 f38a31ddf951..450db3c8ab6a 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 @@ -2925,8 +2925,10 @@ public async Task UploadFileWithRequired List> formParameterLocalVars = new List>(); - var streamContentLocalVar = new StreamContent(requiredFile.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + { + var streamContentLocalVar = new StreamContent(requiredFile.Content); + multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); + } if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); From 6309b34d4845a8fd2bd582ed74588a4c03b8483e Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 20:27:02 -0400 Subject: [PATCH 08/15] address issue three --- .../csharp/libraries/generichost/api.mustache | 4 ++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 4 ++-- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 12 ++++++------ .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 16 ++++++++-------- 52 files changed, 274 insertions(+), 274 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 eafafc1db7e4..acb431430e09 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 @@ -528,8 +528,8 @@ namespace {{packageName}}.{{apiPackage}} {{/formParams}} {{#formParams}} {{#-first}} - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); {{/-first}} {{/formParams}} 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 848ed4f84743..0bb16ac5aa3b 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 @@ -772,8 +772,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 ac8ab93f6ea7..c9eebc7ebbd1 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 @@ -4328,8 +4328,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,8 +4636,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5541,8 +5541,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 8cb6e7891a92..f1918f456450 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 @@ -2399,8 +2399,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2649,8 +2649,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2939,8 +2939,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3218,8 +3218,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 2ba0f738c611..e78d664486ef 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 @@ -774,8 +774,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d5131e55a597..8bb11d65aa79 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 @@ -4330,8 +4330,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4650,8 +4650,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5555,8 +5555,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d14ba87732d2..3a9808335a97 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 @@ -2401,8 +2401,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2651,8 +2651,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2941,8 +2941,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3220,8 +3220,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 848ed4f84743..0bb16ac5aa3b 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 @@ -772,8 +772,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 b9abc142de44..200144d6c408 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 @@ -4328,8 +4328,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4648,8 +4648,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5553,8 +5553,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 e5aea115505a..2f79d30e582c 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 @@ -2399,8 +2399,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2649,8 +2649,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2939,8 +2939,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3218,8 +3218,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 2ba0f738c611..e78d664486ef 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 @@ -774,8 +774,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d5131e55a597..8bb11d65aa79 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 @@ -4330,8 +4330,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4650,8 +4650,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5555,8 +5555,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d14ba87732d2..3a9808335a97 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 @@ -2401,8 +2401,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2651,8 +2651,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2941,8 +2941,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3220,8 +3220,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 28b65646170b..71b5972077ea 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 @@ -771,8 +771,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 ba52b27d5413..1577fdfa035d 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 @@ -4319,8 +4319,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,8 +4627,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5531,8 +5531,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 a0c82d84ee92..4414a0a93ea4 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 @@ -2395,8 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2934,8 +2934,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,8 +3212,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 28b65646170b..71b5972077ea 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 @@ -771,8 +771,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f09345c8c4d2..28dfd334ab9e 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 @@ -4319,8 +4319,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,8 +4639,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5543,8 +5543,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 363cb0273a53..396016529eb6 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 @@ -2395,8 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2934,8 +2934,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,8 +3212,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 28b65646170b..71b5972077ea 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 @@ -771,8 +771,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 ba52b27d5413..1577fdfa035d 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 @@ -4319,8 +4319,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,8 +4627,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5531,8 +5531,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 a0c82d84ee92..4414a0a93ea4 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 @@ -2395,8 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2934,8 +2934,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,8 +3212,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 28b65646170b..71b5972077ea 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 @@ -771,8 +771,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f09345c8c4d2..28dfd334ab9e 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 @@ -4319,8 +4319,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,8 +4639,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5543,8 +5543,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 363cb0273a53..396016529eb6 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 @@ -2395,8 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2645,8 +2645,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2934,8 +2934,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,8 +3212,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 848ed4f84743..0bb16ac5aa3b 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 @@ -772,8 +772,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 ac8ab93f6ea7..c9eebc7ebbd1 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 @@ -4328,8 +4328,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,8 +4636,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5541,8 +5541,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 8cb6e7891a92..f1918f456450 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 @@ -2399,8 +2399,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2649,8 +2649,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2939,8 +2939,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3218,8 +3218,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 2ba0f738c611..e78d664486ef 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 @@ -774,8 +774,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d5131e55a597..8bb11d65aa79 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 @@ -4330,8 +4330,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4650,8 +4650,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5555,8 +5555,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d14ba87732d2..3a9808335a97 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 @@ -2401,8 +2401,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2651,8 +2651,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2941,8 +2941,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3220,8 +3220,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 848ed4f84743..0bb16ac5aa3b 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 @@ -772,8 +772,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 b9abc142de44..200144d6c408 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 @@ -4328,8 +4328,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4648,8 +4648,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5553,8 +5553,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 e5aea115505a..2f79d30e582c 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 @@ -2399,8 +2399,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2649,8 +2649,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2939,8 +2939,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3218,8 +3218,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 2ba0f738c611..e78d664486ef 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 @@ -774,8 +774,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d5131e55a597..8bb11d65aa79 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 @@ -4330,8 +4330,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4650,8 +4650,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5555,8 +5555,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d14ba87732d2..3a9808335a97 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 @@ -2401,8 +2401,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2651,8 +2651,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2941,8 +2941,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3220,8 +3220,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 848ed4f84743..0bb16ac5aa3b 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 @@ -772,8 +772,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 ac8ab93f6ea7..c9eebc7ebbd1 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 @@ -4328,8 +4328,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,8 +4636,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5541,8 +5541,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 8cb6e7891a92..f1918f456450 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 @@ -2399,8 +2399,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2649,8 +2649,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2939,8 +2939,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3218,8 +3218,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 2ba0f738c611..e78d664486ef 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 @@ -774,8 +774,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d5131e55a597..8bb11d65aa79 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 @@ -4330,8 +4330,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4650,8 +4650,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5555,8 +5555,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d14ba87732d2..3a9808335a97 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 @@ -2401,8 +2401,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2651,8 +2651,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2941,8 +2941,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3220,8 +3220,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 848ed4f84743..0bb16ac5aa3b 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 @@ -772,8 +772,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 b9abc142de44..200144d6c408 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 @@ -4328,8 +4328,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4648,8 +4648,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5553,8 +5553,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 e5aea115505a..2f79d30e582c 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 @@ -2399,8 +2399,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2649,8 +2649,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2939,8 +2939,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3218,8 +3218,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 2ba0f738c611..e78d664486ef 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 @@ -774,8 +774,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d5131e55a597..8bb11d65aa79 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 @@ -4330,8 +4330,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4650,8 +4650,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5555,8 +5555,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 d14ba87732d2..3a9808335a97 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 @@ -2401,8 +2401,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2651,8 +2651,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2941,8 +2941,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3220,8 +3220,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); 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 d87886f09966..7662ba25a466 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 @@ -770,8 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f01f7c930f97..416cfec7574e 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 @@ -4318,8 +4318,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,8 +4638,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5542,8 +5542,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 450db3c8ab6a..669f023f8fa7 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 @@ -2394,8 +2394,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2644,8 +2644,8 @@ public async Task UploadFileAsync(long petId, Option 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2933,8 +2933,8 @@ public async Task UploadFileWithRequired if (additionalMetadata.IsSet) formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); - if (formParameterLocalVars.Count > 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3211,8 +3211,8 @@ public async Task UploadFilesAsync(List 0) - multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + foreach (var formParamLocalVar in formParameterLocalVars) + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; From c5ad249e7a9f694cbd75d2512652b9e172e7f782 Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 21:42:47 -0400 Subject: [PATCH 09/15] address issue four, regenerate tests --- .../csharp/libraries/generichost/api.mustache | 29 ++++++-- .../libraries/generichost/api_test.mustache | 2 +- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 11 +--- .../src/Org.OpenAPITools/Api/FakeApi.cs | 66 +++++++------------ .../src/Org.OpenAPITools/Api/PetApi.cs | 29 ++++---- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 11 +--- .../src/Org.OpenAPITools/Api/FakeApi.cs | 66 +++++++------------ .../src/Org.OpenAPITools/Api/PetApi.cs | 29 ++++---- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 11 +--- .../src/Org.OpenAPITools/Api/FakeApi.cs | 66 +++++++------------ .../src/Org.OpenAPITools/Api/PetApi.cs | 29 ++++---- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 11 +--- .../src/Org.OpenAPITools/Api/FakeApi.cs | 66 +++++++------------ .../src/Org.OpenAPITools/Api/PetApi.cs | 29 ++++---- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 11 +--- .../src/Org.OpenAPITools/Api/FakeApi.cs | 66 +++++++------------ .../src/Org.OpenAPITools/Api/PetApi.cs | 29 ++++---- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 11 +--- .../src/Org.OpenAPITools/Api/FakeApi.cs | 66 +++++++------------ .../src/Org.OpenAPITools/Api/PetApi.cs | 29 ++++---- .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 7 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 26 ++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 13 ++-- 87 files changed, 427 insertions(+), 882 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 acb431430e09..96adcaa665f2 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 @@ -471,25 +471,40 @@ namespace {{packageName}}.{{apiPackage}} {{/headerParams}} {{#formParams}} {{#-first}} + {{#isMultipart}} MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); + {{/isMultipart}} + List> formParameterLocalVars = new List>(); {{/-first}} {{^isFile}} {{#required}} - formParameterLocalVars.Add(new KeyValuePair("{{baseName}}", ClientUtils.ParameterToString({{paramName}}))); + formParameterLocalVars.Add(new KeyValuePair("{{baseName}}", ClientUtils.ParameterToString({{paramName}}))); {{/required}} {{^required}} if ({{paramName}}.IsSet) - formParameterLocalVars.Add(new KeyValuePair("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value))); + formParameterLocalVars.Add(new KeyValuePair("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value))); {{/required}} {{/isFile}} {{#isFile}} + {{^isMultipart}} + {{! application/x-www-form-urlencoded encodes everything as text key=value pairs and has no mechanism to carry binary data. File params require multipart/form-data.}} + {{#required}} + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); + + {{/required}} + {{^required}} + if ({{paramName}}.IsSet) + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); + + {{/required}} + {{/isMultipart}} + {{#isMultipart}} {{#required}} {{#isContainer}} foreach ({{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar in {{paramName}}) @@ -524,12 +539,18 @@ namespace {{packageName}}.{{apiPackage}} } {{/required}} + {{/isMultipart}} {{/isFile}} {{/formParams}} {{#formParams}} {{#-first}} + {{#isMultipart}} foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); + {{/isMultipart}} + {{^isMultipart}} + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + {{/isMultipart}} {{/-first}} {{/formParams}} diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api_test.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api_test.mustache index 32eb2b769f31..7e0b704c1a01 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api_test.mustache @@ -35,7 +35,7 @@ namespace {{packageName}}.Test.{{apiPackage}} public async Task {{operationId}}AsyncTest() { {{#allParams}} - {{^required}}Client.Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} = default{{nrt!}}; + {{^required}}Client.Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}} = default{{nrt!}}; {{/allParams}} {{#responses}} {{#-first}} diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 495d785314c5..1924842cdbef 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 5ce22922ba57..a4aa8f3e245d 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 0bb16ac5aa3b..faf05d0da73d 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 @@ -764,16 +764,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c9eebc7ebbd1..53841d3b6baf 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 @@ -4281,10 +4281,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4296,10 +4292,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4328,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4624,10 +4616,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4636,8 +4624,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5531,18 +5518,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f1918f456450..e136aba0393c 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 @@ -2387,10 +2387,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2399,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2650,7 +2645,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2940,7 +2935,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3219,7 +3214,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 406dbc964a6d..d207bb93dc69 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default!; byte[] varByte = default!; double varDouble = default!; - Client.Option binary = default!; + Client.Option binary = default!; Client.Option callback = default!; Client.Option date = default!; Client.Option dateTime = default!; diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index a275bfac9b85..6bb1f953987c 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default!; Client.Option additionalMetadata = default!; - Client.Option file = default!; + Client.Option file = default!; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default!; - System.IO.Stream requiredFile = default!; + Org.OpenAPITools.Client.FileParameter requiredFile = default!; Client.Option additionalMetadata = default!; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default!; + List files = default!; long petId = default!; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 e78d664486ef..d2d3601f3c97 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 @@ -766,16 +766,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - List> formParameterLocalVars = new List>(); - - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 8bb11d65aa79..4d7815e53760 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 @@ -4283,55 +4283,47 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); - List> formParameterLocalVars = new List>(); + formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); + formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - - formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - - formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); + formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) - formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); + formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); if (date.IsSet) - formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); + formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); if (dateTime.IsSet) - formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); + formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); if (int32.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); + formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); if (int64.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); + formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); if (integer.IsSet) - formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); + formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); if (password.IsSet) - formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); + formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); if (varFloat.IsSet) - formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); + formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); if (varString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,20 +4630,15 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5545,18 +5532,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); + formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); - formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 3a9808335a97..41ee473881f1 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 @@ -2389,20 +2389,15 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (name.IsSet) - formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); + formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) - formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2640,10 +2635,10 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) { @@ -2652,7 +2647,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2931,7 +2926,7 @@ public async Task UploadFileWithRequired httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); { var streamContentLocalVar = new StreamContent(requiredFile.Content); @@ -2939,10 +2934,10 @@ public async Task UploadFileWithRequired } if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,7 +3207,7 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { @@ -3221,7 +3216,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 66769b3aee6a..fed093fb206f 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index c9b30a54e4d7..e9b05337bb59 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 0bb16ac5aa3b..faf05d0da73d 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 @@ -764,16 +764,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 200144d6c408..f393d2f5deba 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 @@ -4281,10 +4281,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4296,10 +4292,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4328,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,10 +4628,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4648,8 +4636,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5543,18 +5530,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 2f79d30e582c..cffda33facba 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 @@ -2387,10 +2387,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2399,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2650,7 +2645,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2940,7 +2935,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3219,7 +3214,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 406dbc964a6d..d207bb93dc69 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default!; byte[] varByte = default!; double varDouble = default!; - Client.Option binary = default!; + Client.Option binary = default!; Client.Option callback = default!; Client.Option date = default!; Client.Option dateTime = default!; diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index a275bfac9b85..6bb1f953987c 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default!; Client.Option additionalMetadata = default!; - Client.Option file = default!; + Client.Option file = default!; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default!; - System.IO.Stream requiredFile = default!; + Org.OpenAPITools.Client.FileParameter requiredFile = default!; Client.Option additionalMetadata = default!; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default!; + List files = default!; long petId = default!; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 e78d664486ef..d2d3601f3c97 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 @@ -766,16 +766,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - List> formParameterLocalVars = new List>(); - - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 8bb11d65aa79..4d7815e53760 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 @@ -4283,55 +4283,47 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); - List> formParameterLocalVars = new List>(); + formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); + formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - - formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - - formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); + formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) - formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); + formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); if (date.IsSet) - formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); + formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); if (dateTime.IsSet) - formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); + formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); if (int32.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); + formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); if (int64.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); + formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); if (integer.IsSet) - formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); + formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); if (password.IsSet) - formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); + formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); if (varFloat.IsSet) - formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); + formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); if (varString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,20 +4630,15 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5545,18 +5532,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); + formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); - formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 3a9808335a97..41ee473881f1 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 @@ -2389,20 +2389,15 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (name.IsSet) - formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); + formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) - formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2640,10 +2635,10 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) { @@ -2652,7 +2647,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2931,7 +2926,7 @@ public async Task UploadFileWithRequired httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); { var streamContentLocalVar = new StreamContent(requiredFile.Content); @@ -2939,10 +2934,10 @@ public async Task UploadFileWithRequired } if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,7 +3207,7 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { @@ -3221,7 +3216,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index dbca7881df47..62c158ea45da 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 5ce22922ba57..a4aa8f3e245d 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 71b5972077ea..af54a091bf06 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 @@ -763,16 +763,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 1577fdfa035d..c60a2480ddbf 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 @@ -4272,10 +4272,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4287,10 +4283,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4319,8 +4312,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4615,10 +4607,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4627,8 +4615,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5521,18 +5508,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 4414a0a93ea4..ced10368047e 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 @@ -2383,10 +2383,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2395,8 +2391,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2646,7 +2641,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2935,7 +2930,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3213,7 +3208,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index ce85f85778ef..6420b47bc8b4 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index c9b30a54e4d7..e9b05337bb59 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 71b5972077ea..af54a091bf06 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 @@ -763,16 +763,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 28dfd334ab9e..12ace87bd42d 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 @@ -4272,10 +4272,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4287,10 +4283,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4319,8 +4312,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,10 +4619,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4639,8 +4627,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5533,18 +5520,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 396016529eb6..7b4fad8f5076 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 @@ -2383,10 +2383,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2395,8 +2391,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2646,7 +2641,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2935,7 +2930,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3213,7 +3208,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index dbca7881df47..62c158ea45da 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 5ce22922ba57..a4aa8f3e245d 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 71b5972077ea..af54a091bf06 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 @@ -763,16 +763,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 1577fdfa035d..c60a2480ddbf 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 @@ -4272,10 +4272,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4287,10 +4283,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4319,8 +4312,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4615,10 +4607,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4627,8 +4615,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5521,18 +5508,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 4414a0a93ea4..ced10368047e 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 @@ -2383,10 +2383,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2395,8 +2391,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2646,7 +2641,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2935,7 +2930,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3213,7 +3208,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index ce85f85778ef..6420b47bc8b4 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index c9b30a54e4d7..e9b05337bb59 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 71b5972077ea..af54a091bf06 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 @@ -763,16 +763,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 28dfd334ab9e..12ace87bd42d 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 @@ -4272,10 +4272,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4287,10 +4283,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4319,8 +4312,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,10 +4619,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4639,8 +4627,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5533,18 +5520,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 396016529eb6..7b4fad8f5076 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 @@ -2383,10 +2383,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2395,8 +2391,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2646,7 +2641,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2935,7 +2930,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3213,7 +3208,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 495d785314c5..1924842cdbef 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 5ce22922ba57..a4aa8f3e245d 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 0bb16ac5aa3b..faf05d0da73d 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 @@ -764,16 +764,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c9eebc7ebbd1..53841d3b6baf 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 @@ -4281,10 +4281,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4296,10 +4292,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4328,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4624,10 +4616,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4636,8 +4624,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5531,18 +5518,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f1918f456450..e136aba0393c 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 @@ -2387,10 +2387,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2399,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2650,7 +2645,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2940,7 +2935,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3219,7 +3214,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 406dbc964a6d..d207bb93dc69 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default!; byte[] varByte = default!; double varDouble = default!; - Client.Option binary = default!; + Client.Option binary = default!; Client.Option callback = default!; Client.Option date = default!; Client.Option dateTime = default!; diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index a275bfac9b85..6bb1f953987c 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default!; Client.Option additionalMetadata = default!; - Client.Option file = default!; + Client.Option file = default!; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default!; - System.IO.Stream requiredFile = default!; + Org.OpenAPITools.Client.FileParameter requiredFile = default!; Client.Option additionalMetadata = default!; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default!; + List files = default!; long petId = default!; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 e78d664486ef..d2d3601f3c97 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 @@ -766,16 +766,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - List> formParameterLocalVars = new List>(); - - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 8bb11d65aa79..4d7815e53760 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 @@ -4283,55 +4283,47 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); - List> formParameterLocalVars = new List>(); + formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); + formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - - formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - - formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); + formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) - formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); + formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); if (date.IsSet) - formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); + formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); if (dateTime.IsSet) - formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); + formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); if (int32.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); + formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); if (int64.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); + formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); if (integer.IsSet) - formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); + formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); if (password.IsSet) - formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); + formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); if (varFloat.IsSet) - formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); + formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); if (varString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,20 +4630,15 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5545,18 +5532,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); + formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); - formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 3a9808335a97..41ee473881f1 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 @@ -2389,20 +2389,15 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (name.IsSet) - formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); + formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) - formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2640,10 +2635,10 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) { @@ -2652,7 +2647,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2931,7 +2926,7 @@ public async Task UploadFileWithRequired httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); { var streamContentLocalVar = new StreamContent(requiredFile.Content); @@ -2939,10 +2934,10 @@ public async Task UploadFileWithRequired } if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,7 +3207,7 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { @@ -3221,7 +3216,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 66769b3aee6a..fed093fb206f 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index c9b30a54e4d7..e9b05337bb59 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 0bb16ac5aa3b..faf05d0da73d 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 @@ -764,16 +764,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 200144d6c408..f393d2f5deba 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 @@ -4281,10 +4281,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4296,10 +4292,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4328,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,10 +4628,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4648,8 +4636,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5543,18 +5530,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 2f79d30e582c..cffda33facba 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 @@ -2387,10 +2387,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2399,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2650,7 +2645,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2940,7 +2935,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3219,7 +3214,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 406dbc964a6d..d207bb93dc69 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default!; byte[] varByte = default!; double varDouble = default!; - Client.Option binary = default!; + Client.Option binary = default!; Client.Option callback = default!; Client.Option date = default!; Client.Option dateTime = default!; diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index a275bfac9b85..6bb1f953987c 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default!; Client.Option additionalMetadata = default!; - Client.Option file = default!; + Client.Option file = default!; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default!; - System.IO.Stream requiredFile = default!; + Org.OpenAPITools.Client.FileParameter requiredFile = default!; Client.Option additionalMetadata = default!; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default!; + List files = default!; long petId = default!; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 e78d664486ef..d2d3601f3c97 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 @@ -766,16 +766,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - List> formParameterLocalVars = new List>(); - - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 8bb11d65aa79..4d7815e53760 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 @@ -4283,55 +4283,47 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); - List> formParameterLocalVars = new List>(); + formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); + formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - - formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - - formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); + formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) - formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); + formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); if (date.IsSet) - formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); + formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); if (dateTime.IsSet) - formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); + formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); if (int32.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); + formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); if (int64.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); + formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); if (integer.IsSet) - formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); + formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); if (password.IsSet) - formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); + formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); if (varFloat.IsSet) - formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); + formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); if (varString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,20 +4630,15 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5545,18 +5532,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); + formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); - formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 3a9808335a97..41ee473881f1 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 @@ -2389,20 +2389,15 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (name.IsSet) - formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); + formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) - formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2640,10 +2635,10 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) { @@ -2652,7 +2647,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2931,7 +2926,7 @@ public async Task UploadFileWithRequired httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); { var streamContentLocalVar = new StreamContent(requiredFile.Content); @@ -2939,10 +2934,10 @@ public async Task UploadFileWithRequired } if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,7 +3207,7 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { @@ -3221,7 +3216,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 495d785314c5..1924842cdbef 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 5ce22922ba57..a4aa8f3e245d 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 0bb16ac5aa3b..faf05d0da73d 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 @@ -764,16 +764,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c9eebc7ebbd1..53841d3b6baf 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 @@ -4281,10 +4281,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4296,10 +4292,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4328,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4624,10 +4616,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4636,8 +4624,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5531,18 +5518,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f1918f456450..e136aba0393c 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 @@ -2387,10 +2387,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2399,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2650,7 +2645,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2940,7 +2935,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3219,7 +3214,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 406dbc964a6d..d207bb93dc69 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default!; byte[] varByte = default!; double varDouble = default!; - Client.Option binary = default!; + Client.Option binary = default!; Client.Option callback = default!; Client.Option date = default!; Client.Option dateTime = default!; diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index a275bfac9b85..6bb1f953987c 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default!; Client.Option additionalMetadata = default!; - Client.Option file = default!; + Client.Option file = default!; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default!; - System.IO.Stream requiredFile = default!; + Org.OpenAPITools.Client.FileParameter requiredFile = default!; Client.Option additionalMetadata = default!; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default!; + List files = default!; long petId = default!; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 e78d664486ef..d2d3601f3c97 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 @@ -766,16 +766,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - List> formParameterLocalVars = new List>(); - - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 8bb11d65aa79..4d7815e53760 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 @@ -4283,55 +4283,47 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); - List> formParameterLocalVars = new List>(); + formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); + formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - - formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - - formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); + formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) - formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); + formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); if (date.IsSet) - formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); + formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); if (dateTime.IsSet) - formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); + formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); if (int32.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); + formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); if (int64.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); + formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); if (integer.IsSet) - formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); + formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); if (password.IsSet) - formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); + formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); if (varFloat.IsSet) - formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); + formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); if (varString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,20 +4630,15 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5545,18 +5532,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); + formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); - formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 3a9808335a97..41ee473881f1 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 @@ -2389,20 +2389,15 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (name.IsSet) - formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); + formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) - formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2640,10 +2635,10 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) { @@ -2652,7 +2647,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2931,7 +2926,7 @@ public async Task UploadFileWithRequired httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); { var streamContentLocalVar = new StreamContent(requiredFile.Content); @@ -2939,10 +2934,10 @@ public async Task UploadFileWithRequired } if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,7 +3207,7 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { @@ -3221,7 +3216,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 66769b3aee6a..fed093fb206f 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index c9b30a54e4d7..e9b05337bb59 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 0bb16ac5aa3b..faf05d0da73d 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 @@ -764,16 +764,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 200144d6c408..f393d2f5deba 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 @@ -4281,10 +4281,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4296,10 +4292,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4328,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,10 +4628,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4648,8 +4636,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5543,18 +5530,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 2f79d30e582c..cffda33facba 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 @@ -2387,10 +2387,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2399,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2650,7 +2645,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2940,7 +2935,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3219,7 +3214,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 406dbc964a6d..d207bb93dc69 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default!; byte[] varByte = default!; double varDouble = default!; - Client.Option binary = default!; + Client.Option binary = default!; Client.Option callback = default!; Client.Option date = default!; Client.Option dateTime = default!; diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index a275bfac9b85..6bb1f953987c 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default!; Client.Option additionalMetadata = default!; - Client.Option file = default!; + Client.Option file = default!; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default!; - System.IO.Stream requiredFile = default!; + Org.OpenAPITools.Client.FileParameter requiredFile = default!; Client.Option additionalMetadata = default!; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default!; + List files = default!; long petId = default!; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 e78d664486ef..d2d3601f3c97 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 @@ -766,16 +766,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - List> formParameterLocalVars = new List>(); - - formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 8bb11d65aa79..4d7815e53760 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 @@ -4283,55 +4283,47 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); + List> formParameterLocalVars = new List>(); - httpRequestMessageLocalVar.Content = multipartContentLocalVar; + formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); - List> formParameterLocalVars = new List>(); + formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); + formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); - - formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); - - formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); + formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) - formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); + formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); if (date.IsSet) - formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); + formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); if (dateTime.IsSet) - formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); + formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); if (int32.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); + formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); if (int64.IsSet) - formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); + formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); if (integer.IsSet) - formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); + formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); if (password.IsSet) - formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); + formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); if (varFloat.IsSet) - formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); + formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); if (varString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,20 +4630,15 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); if (enumFormStringArray.IsSet) - formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5545,18 +5532,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); - formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); + formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); - formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 3a9808335a97..41ee473881f1 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 @@ -2389,20 +2389,15 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (name.IsSet) - formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); + formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); if (status.IsSet) - formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2640,10 +2635,10 @@ public async Task UploadFileAsync(long petId, Option> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); if (file.IsSet) { @@ -2652,7 +2647,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2931,7 +2926,7 @@ public async Task UploadFileWithRequired httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); { var streamContentLocalVar = new StreamContent(requiredFile.Content); @@ -2939,10 +2934,10 @@ public async Task UploadFileWithRequired } if (additionalMetadata.IsSet) - formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,7 +3207,7 @@ public async Task UploadFilesAsync(List> formParameterLocalVars = new List>(); + List> formParameterLocalVars = new List>(); foreach (Org.OpenAPITools.Client.FileParameter fileParameterLocalVar in files) { @@ -3221,7 +3216,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index ce85f85778ef..694dab0ad774 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index c9b30a54e4d7..2c032a19eb90 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - System.IO.Stream requiredFile = default; + Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); 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 7662ba25a466..46093e9e6191 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 @@ -762,16 +762,11 @@ public async Task GetCountryAsync(string country, System ? "/country" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 416cfec7574e..fc1517a13bbc 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 @@ -4271,10 +4271,6 @@ public async Task TestEndpointParametersAsyn ? "/fake" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); @@ -4286,10 +4282,7 @@ public async Task TestEndpointParametersAsyn formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); if (binary.IsSet) - { - var streamContentLocalVar = new StreamContent(binary.Value.Content); - multipartContentLocalVar.Add(streamContentLocalVar, "binary", binary.Value.FileName ?? "binary"); - } + throw new NotSupportedException("File parameters cannot be sent with application/x-www-form-urlencoded. Change the operation's content type to multipart/form-data."); if (callback.IsSet) formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); @@ -4318,8 +4311,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4626,10 +4618,6 @@ public async Task TestEnumParametersAsync(Option if (enumHeaderStringArray.IsSet) httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (enumFormString.IsSet) @@ -4638,8 +4626,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5532,18 +5519,13 @@ public async Task TestJsonFormDataAsync(string par ? "/fake/jsonFormData" : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/fake/jsonFormData"); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 669f023f8fa7..cb5840e453a2 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 @@ -2382,10 +2382,6 @@ public async Task UpdatePetWithFormAsync(long pet : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/pet/{petId}"); uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); - MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent(); - - httpRequestMessageLocalVar.Content = multipartContentLocalVar; - List> formParameterLocalVars = new List>(); if (name.IsSet) @@ -2394,8 +2390,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2645,7 +2640,7 @@ public async Task UploadFileAsync(long petId, Option tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -2934,7 +2929,7 @@ public async Task UploadFileWithRequired formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); foreach (var formParamLocalVar in formParameterLocalVars) - multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value), formParamLocalVar.Key); + multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -3212,7 +3207,7 @@ public async Task UploadFilesAsync(List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; From e93812057acae4fd6299be2c6ea6df4173fdfcd5 Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 22:02:44 -0400 Subject: [PATCH 10/15] rebuild .net standard tests --- .../Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs | 2 +- .../Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 694dab0ad774..6420b47bc8b4 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -196,7 +196,7 @@ public async Task TestEndpointParametersAsyncTest() string patternWithoutDelimiter = default; byte[] varByte = default; double varDouble = default; - Client.Option binary = default; + Client.Option binary = default; Client.Option callback = default; Client.Option date = default; Client.Option dateTime = default; diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index 2c032a19eb90..e9b05337bb59 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -137,7 +137,7 @@ public async Task UploadFileAsyncTest() { long petId = default; Client.Option additionalMetadata = default; - Client.Option file = default; + Client.Option file = default; var response = await _instance.UploadFileAsync(petId, additionalMetadata, file); var model = response.Ok(); Assert.IsType(model); @@ -150,7 +150,7 @@ public async Task UploadFileAsyncTest() public async Task UploadFileWithRequiredFileAsyncTest() { long petId = default; - Client.FileParameter requiredFile = default; + Org.OpenAPITools.Client.FileParameter requiredFile = default; Client.Option additionalMetadata = default; var response = await _instance.UploadFileWithRequiredFileAsync(petId, requiredFile, additionalMetadata); var model = response.Ok(); @@ -163,7 +163,7 @@ public async Task UploadFileWithRequiredFileAsyncTest() [Fact (Skip = "not implemented")] public async Task UploadFilesAsyncTest() { - List files = default; + List files = default; long petId = default; var response = await _instance.UploadFilesAsync(files, petId); var model = response.Ok(); From f0be3643577d97c58fde86c207a2d67a20c3fdbe Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 22:17:29 -0400 Subject: [PATCH 11/15] addressed additional bot comments --- .../libraries/generichost/OperationDataType.mustache | 2 +- .../resources/csharp/libraries/generichost/api.mustache | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net4.8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net4.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../net8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++--- .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- 53 files changed, 173 insertions(+), 87 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationDataType.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationDataType.mustache index 7fc41573fde5..1cd619e131f6 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationDataType.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OperationDataType.mustache @@ -1 +1 @@ -{{#isFile}}{{#isContainer}}List<{{packageName}}.{{clientPackage}}.FileParameter>{{/isContainer}}{{^isContainer}}{{packageName}}.{{clientPackage}}.FileParameter{{>NullConditionalParameter}}{{/isContainer}}{{/isFile}}{{^isFile}}{{{dataType}}}{{>NullConditionalParameter}}{{/isFile}} \ No newline at end of file +{{#isFile}}{{#isContainer}}List<{{packageName}}.{{clientPackage}}.FileParameter>{{>NullConditionalParameter}}{{/isContainer}}{{^isContainer}}{{packageName}}.{{clientPackage}}.FileParameter{{>NullConditionalParameter}}{{/isContainer}}{{/isFile}}{{^isFile}}{{{dataType}}}{{>NullConditionalParameter}}{{/isFile}} \ No newline at end of file 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 96adcaa665f2..b7cb22444daa 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 @@ -549,7 +549,8 @@ namespace {{packageName}}.{{apiPackage}} multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); {{/isMultipart}} {{^isMultipart}} - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); {{/isMultipart}} {{/-first}} 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 53841d3b6baf..0070617289e6 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4624,7 +4625,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5524,7 +5526,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 e136aba0393c..fd403446d9a6 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 4d7815e53760..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,7 +4639,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5538,7 +5540,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f393d2f5deba..482421f8c4ea 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,7 +4637,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5536,7 +5538,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 cffda33facba..da4dfd225bc4 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 4d7815e53760..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,7 +4639,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5538,7 +5540,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 af54a091bf06..24a69b84527e 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 @@ -767,7 +767,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c60a2480ddbf..9f2605d1777f 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 @@ -4312,7 +4312,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4615,7 +4616,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5514,7 +5516,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 ced10368047e..11f4b994064c 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 @@ -2391,7 +2391,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 af54a091bf06..24a69b84527e 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 @@ -767,7 +767,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 12ace87bd42d..a3a842305a6f 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 @@ -4312,7 +4312,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,7 +4628,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5526,7 +5528,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 7b4fad8f5076..9d04b53a95c5 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 @@ -2391,7 +2391,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 af54a091bf06..24a69b84527e 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 @@ -767,7 +767,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c60a2480ddbf..9f2605d1777f 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 @@ -4312,7 +4312,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4615,7 +4616,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5514,7 +5516,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 ced10368047e..11f4b994064c 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 @@ -2391,7 +2391,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 af54a091bf06..24a69b84527e 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 @@ -767,7 +767,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 12ace87bd42d..a3a842305a6f 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 @@ -4312,7 +4312,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,7 +4628,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5526,7 +5528,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 7b4fad8f5076..9d04b53a95c5 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 @@ -2391,7 +2391,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 53841d3b6baf..0070617289e6 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4624,7 +4625,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5524,7 +5526,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 e136aba0393c..fd403446d9a6 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 4d7815e53760..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,7 +4639,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5538,7 +5540,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f393d2f5deba..482421f8c4ea 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,7 +4637,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5536,7 +5538,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 cffda33facba..da4dfd225bc4 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 4d7815e53760..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,7 +4639,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5538,7 +5540,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 53841d3b6baf..0070617289e6 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4624,7 +4625,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5524,7 +5526,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 e136aba0393c..fd403446d9a6 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 4d7815e53760..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,7 +4639,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5538,7 +5540,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 f393d2f5deba..482421f8c4ea 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,7 +4637,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5536,7 +5538,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 cffda33facba..da4dfd225bc4 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 4d7815e53760..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,7 +4639,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5538,7 +5540,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 46093e9e6191..a37b13115c90 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 @@ -766,7 +766,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 fc1517a13bbc..33cecd82aa0a 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 @@ -4311,7 +4311,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4626,7 +4627,8 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5525,7 +5527,8 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 cb5840e453a2..bbe2532cf740 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 @@ -2390,7 +2390,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; From 547771d7150adcf124b87dd4642b8454811b2f3a Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 22:42:03 -0400 Subject: [PATCH 12/15] address more bot comments --- .../resources/csharp/libraries/generichost/api.mustache | 3 +-- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net4.8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net4.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../net8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 +-- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 +++------ .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +-- 52 files changed, 86 insertions(+), 172 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 b7cb22444daa..96adcaa665f2 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 @@ -549,8 +549,7 @@ namespace {{packageName}}.{{apiPackage}} multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); {{/isMultipart}} {{^isMultipart}} - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); {{/isMultipart}} {{/-first}} 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 44d52e7e1090..faf05d0da73d 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 @@ -768,8 +768,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 0070617289e6..53841d3b6baf 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 @@ -4321,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,8 +4624,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5526,8 +5524,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 fd403446d9a6..e136aba0393c 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 @@ -2395,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 46b798fe32ca..d2d3601f3c97 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 @@ -770,8 +770,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 54a1c8c85360..4d7815e53760 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 @@ -4323,8 +4323,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,8 +4638,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5540,8 +5538,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c5de9cd55ad1..41ee473881f1 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 @@ -2397,8 +2397,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 44d52e7e1090..faf05d0da73d 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 @@ -768,8 +768,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 482421f8c4ea..f393d2f5deba 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 @@ -4321,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4637,8 +4636,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5538,8 +5536,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 da4dfd225bc4..cffda33facba 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 @@ -2395,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 46b798fe32ca..d2d3601f3c97 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 @@ -770,8 +770,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 54a1c8c85360..4d7815e53760 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 @@ -4323,8 +4323,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,8 +4638,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5540,8 +5538,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c5de9cd55ad1..41ee473881f1 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 @@ -2397,8 +2397,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 24a69b84527e..af54a091bf06 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 @@ -767,8 +767,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 9f2605d1777f..c60a2480ddbf 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 @@ -4312,8 +4312,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4616,8 +4615,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5516,8 +5514,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 11f4b994064c..ced10368047e 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 @@ -2391,8 +2391,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 24a69b84527e..af54a091bf06 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 @@ -767,8 +767,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 a3a842305a6f..12ace87bd42d 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 @@ -4312,8 +4312,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4628,8 +4627,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5528,8 +5526,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 9d04b53a95c5..7b4fad8f5076 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 @@ -2391,8 +2391,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 24a69b84527e..af54a091bf06 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 @@ -767,8 +767,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 9f2605d1777f..c60a2480ddbf 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 @@ -4312,8 +4312,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4616,8 +4615,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5516,8 +5514,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 11f4b994064c..ced10368047e 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 @@ -2391,8 +2391,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 24a69b84527e..af54a091bf06 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 @@ -767,8 +767,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 a3a842305a6f..12ace87bd42d 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 @@ -4312,8 +4312,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4628,8 +4627,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5528,8 +5526,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 9d04b53a95c5..7b4fad8f5076 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 @@ -2391,8 +2391,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 44d52e7e1090..faf05d0da73d 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 @@ -768,8 +768,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 0070617289e6..53841d3b6baf 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 @@ -4321,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,8 +4624,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5526,8 +5524,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 fd403446d9a6..e136aba0393c 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 @@ -2395,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 46b798fe32ca..d2d3601f3c97 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 @@ -770,8 +770,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 54a1c8c85360..4d7815e53760 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 @@ -4323,8 +4323,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,8 +4638,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5540,8 +5538,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c5de9cd55ad1..41ee473881f1 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 @@ -2397,8 +2397,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 44d52e7e1090..faf05d0da73d 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 @@ -768,8 +768,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 482421f8c4ea..f393d2f5deba 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 @@ -4321,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4637,8 +4636,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5538,8 +5536,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 da4dfd225bc4..cffda33facba 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 @@ -2395,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 46b798fe32ca..d2d3601f3c97 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 @@ -770,8 +770,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 54a1c8c85360..4d7815e53760 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 @@ -4323,8 +4323,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,8 +4638,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5540,8 +5538,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c5de9cd55ad1..41ee473881f1 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 @@ -2397,8 +2397,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 44d52e7e1090..faf05d0da73d 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 @@ -768,8 +768,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 0070617289e6..53841d3b6baf 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 @@ -4321,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4625,8 +4624,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5526,8 +5524,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 fd403446d9a6..e136aba0393c 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 @@ -2395,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 46b798fe32ca..d2d3601f3c97 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 @@ -770,8 +770,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 54a1c8c85360..4d7815e53760 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 @@ -4323,8 +4323,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,8 +4638,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5540,8 +5538,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c5de9cd55ad1..41ee473881f1 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 @@ -2397,8 +2397,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 44d52e7e1090..faf05d0da73d 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 @@ -768,8 +768,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 482421f8c4ea..f393d2f5deba 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 @@ -4321,8 +4321,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4637,8 +4636,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5538,8 +5536,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 da4dfd225bc4..cffda33facba 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 @@ -2395,8 +2395,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 46b798fe32ca..d2d3601f3c97 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 @@ -770,8 +770,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 54a1c8c85360..4d7815e53760 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 @@ -4323,8 +4323,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4639,8 +4638,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5540,8 +5538,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 c5de9cd55ad1..41ee473881f1 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 @@ -2397,8 +2397,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 a37b13115c90..46093e9e6191 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 @@ -766,8 +766,7 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 33cecd82aa0a..fc1517a13bbc 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 @@ -4311,8 +4311,7 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,8 +4626,7 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -5527,8 +5525,7 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 bbe2532cf740..cb5840e453a2 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 @@ -2390,8 +2390,7 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - if (formParameterLocalVars.Count > 0) - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; From 0d6d381e813d71cfb6aa1df05d2dd7922299f504 Mon Sep 17 00:00:00 2001 From: devhl Date: Sun, 8 Mar 2026 23:17:51 -0400 Subject: [PATCH 13/15] address more bot comments --- .../main/resources/csharp/libraries/generichost/api.mustache | 2 ++ .../net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net4.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../net9/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- .../standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 4 ---- 18 files changed, 2 insertions(+), 68 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 96adcaa665f2..783ed84d531c 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 @@ -549,7 +549,9 @@ namespace {{packageName}}.{{apiPackage}} multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); {{/isMultipart}} {{^isMultipart}} + {{#isBodyAllowed}} httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + {{/isBodyAllowed}} {{/isMultipart}} {{/-first}} 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 53841d3b6baf..af8a21c15074 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 @@ -4624,8 +4624,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5524,8 +5522,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 4d7815e53760..195da840d843 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 @@ -4638,8 +4638,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5538,8 +5536,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 f393d2f5deba..1eba8ca0c816 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 @@ -4636,8 +4636,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,8 +5534,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 4d7815e53760..195da840d843 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 @@ -4638,8 +4638,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5538,8 +5536,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 c60a2480ddbf..18ba08f2bd38 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 @@ -4615,8 +4615,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5514,8 +5512,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 12ace87bd42d..b11bf999a282 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 @@ -4627,8 +4627,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5526,8 +5524,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 c60a2480ddbf..18ba08f2bd38 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 @@ -4615,8 +4615,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5514,8 +5512,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 12ace87bd42d..b11bf999a282 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 @@ -4627,8 +4627,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5526,8 +5524,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 53841d3b6baf..af8a21c15074 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 @@ -4624,8 +4624,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5524,8 +5522,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 4d7815e53760..195da840d843 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 @@ -4638,8 +4638,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5538,8 +5536,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 f393d2f5deba..1eba8ca0c816 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 @@ -4636,8 +4636,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,8 +5534,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 4d7815e53760..195da840d843 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 @@ -4638,8 +4638,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5538,8 +5536,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 53841d3b6baf..af8a21c15074 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 @@ -4624,8 +4624,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5524,8 +5522,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 4d7815e53760..195da840d843 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 @@ -4638,8 +4638,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5538,8 +5536,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 f393d2f5deba..1eba8ca0c816 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 @@ -4636,8 +4636,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,8 +5534,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 4d7815e53760..195da840d843 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 @@ -4638,8 +4638,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5538,8 +5536,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 fc1517a13bbc..637ec40eb571 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 @@ -4626,8 +4626,6 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5525,8 +5523,6 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { From 3aac9c17dd6ee4b7480b6ab0d5583e23443a0bb0 Mon Sep 17 00:00:00 2001 From: devhl Date: Mon, 9 Mar 2026 00:19:17 -0400 Subject: [PATCH 14/15] address more bot comments --- .../resources/csharp/libraries/generichost/api.mustache | 5 ++--- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net10/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net10/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net10/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net4.8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net4.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../net8/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net9/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../net9/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../net9/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../SourceGeneration/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs | 3 ++- .../Petstore/src/Org.OpenAPITools/Api/FakeApi.cs | 9 ++++++++- .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 ++- 52 files changed, 206 insertions(+), 54 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 783ed84d531c..b7cb22444daa 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 @@ -549,9 +549,8 @@ namespace {{packageName}}.{{apiPackage}} multipartContentLocalVar.Add(new StringContent(formParamLocalVar.Value ?? string.Empty), formParamLocalVar.Key); {{/isMultipart}} {{^isMultipart}} - {{#isBodyAllowed}} - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); - {{/isBodyAllowed}} + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); {{/isMultipart}} {{/-first}} 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 af8a21c15074..0070617289e6 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4624,6 +4625,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5522,6 +5526,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 e136aba0393c..fd403446d9a6 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 195da840d843..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,6 +4639,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,6 +5540,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 1eba8ca0c816..482421f8c4ea 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,6 +4637,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5534,6 +5538,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 cffda33facba..da4dfd225bc4 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 195da840d843..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,6 +4639,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,6 +5540,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 af54a091bf06..24a69b84527e 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 @@ -767,7 +767,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 18ba08f2bd38..9f2605d1777f 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 @@ -4312,7 +4312,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4615,6 +4616,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5512,6 +5516,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 ced10368047e..11f4b994064c 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 @@ -2391,7 +2391,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 af54a091bf06..24a69b84527e 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 @@ -767,7 +767,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 b11bf999a282..a3a842305a6f 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 @@ -4312,7 +4312,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,6 +4628,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5524,6 +5528,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 7b4fad8f5076..9d04b53a95c5 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 @@ -2391,7 +2391,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 af54a091bf06..24a69b84527e 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 @@ -767,7 +767,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 18ba08f2bd38..9f2605d1777f 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 @@ -4312,7 +4312,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4615,6 +4616,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5512,6 +5516,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 ced10368047e..11f4b994064c 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 @@ -2391,7 +2391,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 af54a091bf06..24a69b84527e 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 @@ -767,7 +767,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 b11bf999a282..a3a842305a6f 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 @@ -4312,7 +4312,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4627,6 +4628,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5524,6 +5528,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 7b4fad8f5076..9d04b53a95c5 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 @@ -2391,7 +2391,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 af8a21c15074..0070617289e6 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4624,6 +4625,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5522,6 +5526,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 e136aba0393c..fd403446d9a6 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 195da840d843..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,6 +4639,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,6 +5540,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 1eba8ca0c816..482421f8c4ea 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,6 +4637,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5534,6 +5538,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 cffda33facba..da4dfd225bc4 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 195da840d843..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,6 +4639,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,6 +5540,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 af8a21c15074..0070617289e6 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4624,6 +4625,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5522,6 +5526,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 e136aba0393c..fd403446d9a6 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 195da840d843..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,6 +4639,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,6 +5540,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 faf05d0da73d..44d52e7e1090 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 @@ -768,7 +768,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 1eba8ca0c816..482421f8c4ea 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 @@ -4321,7 +4321,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4636,6 +4637,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5534,6 +5538,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 cffda33facba..da4dfd225bc4 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 @@ -2395,7 +2395,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 d2d3601f3c97..46b798fe32ca 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 @@ -770,7 +770,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 195da840d843..54a1c8c85360 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 @@ -4323,7 +4323,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4638,6 +4639,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5536,6 +5540,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 41ee473881f1..c5de9cd55ad1 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 @@ -2397,7 +2397,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); 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 46093e9e6191..a37b13115c90 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 @@ -766,7 +766,8 @@ public async Task GetCountryAsync(string country, System formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; 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 637ec40eb571..33cecd82aa0a 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 @@ -4311,7 +4311,8 @@ public async Task TestEndpointParametersAsyn if (varString.IsSet) formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; @@ -4626,6 +4627,9 @@ public async Task TestEnumParametersAsync(Option if (enumFormStringArray.IsSet) formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { @@ -5523,6 +5527,9 @@ public async Task TestJsonFormDataAsync(string par formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; string[] contentTypes = new string[] { 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 cb5840e453a2..bbe2532cf740 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 @@ -2390,7 +2390,8 @@ public async Task UpdatePetWithFormAsync(long pet if (status.IsSet) formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); - httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); + if (formParameterLocalVars.Count > 0) + httpRequestMessageLocalVar.Content = new FormUrlEncodedContent(formParameterLocalVars); List tokenBaseLocalVars = new List(); httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; From 289f358d1831e205be0b064cc818f6bffebc1295 Mon Sep 17 00:00:00 2001 From: devhl Date: Tue, 10 Mar 2026 21:01:06 -0400 Subject: [PATCH 15/15] added content-type --- .../libraries/generichost/FileParameter.mustache | 10 +++++++++- .../csharp/libraries/generichost/api.mustache | 4 ++++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../Tags/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AllOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../OneOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../net10/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AllOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../OneOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AllOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../OneOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../net4.8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AllOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../net8/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../OneOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../net8/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AllOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../net9/FormModels/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../OneOf/src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../net9/Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- .../Petstore/src/Org.OpenAPITools/Api/PetApi.cs | 3 +++ .../src/Org.OpenAPITools/Client/FileParameter.cs | 10 +++++++++- 66 files changed, 487 insertions(+), 48 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/FileParameter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/FileParameter.mustache index 6ebbfa231fec..156cf809dc92 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/FileParameter.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/FileParameter.mustache @@ -23,15 +23,23 @@ namespace {{packageName}}.{{clientPackage}} /// public string{{nrt?}} FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string{{nrt?}} fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string{{nrt?}} fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 b7cb22444daa..0a373206f991 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 @@ -510,6 +510,7 @@ namespace {{packageName}}.{{apiPackage}} foreach ({{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar in {{paramName}}) { var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(fileParameterLocalVar.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", fileParameterLocalVar.FileName ?? "{{baseName}}"); } @@ -517,6 +518,7 @@ namespace {{packageName}}.{{apiPackage}} {{^isContainer}} { var streamContentLocalVar = new StreamContent({{paramName}}.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue({{paramName}}.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.FileName ?? "{{baseName}}"); } @@ -529,11 +531,13 @@ namespace {{packageName}}.{{apiPackage}} foreach ({{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar in {{paramName}}.Value) { var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(fileParameterLocalVar.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", fileParameterLocalVar.FileName ?? "{{baseName}}"); } {{/isContainer}} {{^isContainer}} var streamContentLocalVar = new StreamContent({{paramName}}.Value.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue({{paramName}}.Value.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.Value.FileName ?? "{{baseName}}"); {{/isContainer}} } diff --git a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/FileParameter.cs index 42e3a7879497..0cf0b4339b78 100644 --- a/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/FileParameter.cs index edb0bd0479a5..7d76dba35616 100644 --- a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/FileParameter.cs index 77779fe7d75a..1ee76c26edb3 100644 --- a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/FileParameter.cs index f5b898e16331..dac36f04dc08 100644 --- a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/FileParameter.cs index 1e3e3f9f418f..d1da23a376e5 100644 --- a/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/FileParameter.cs @@ -29,15 +29,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs index 1913a3a0f2d9..9f2614c6f4ce 100644 --- a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs index e629f4afdaec..173a5f299951 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs index e629f4afdaec..173a5f299951 100644 --- a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 fd403446d9a6..aa542fd9c05b 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 @@ -2642,6 +2642,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3211,6 +3213,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 c5de9cd55ad1..01f96fd91373 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 @@ -2644,6 +2644,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3213,6 +3215,7 @@ public async Task UploadFilesAsync(List public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs index e629f4afdaec..173a5f299951 100644 --- a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 da4dfd225bc4..20f9ce2ce945 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 @@ -2642,6 +2642,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3211,6 +3213,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 c5de9cd55ad1..01f96fd91373 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 @@ -2644,6 +2644,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3213,6 +3215,7 @@ public async Task UploadFilesAsync(List public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs index 11da1d925144..19febd4fee67 100644 --- a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs index 936f8415fda6..d1b3775a465b 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs index 5c8e0767f76a..bbdd1b1b62e9 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs index 5c8e0767f76a..bbdd1b1b62e9 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 11f4b994064c..0daa375c9f6f 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 @@ -2638,6 +2638,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3205,6 +3207,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs index 5c8e0767f76a..bbdd1b1b62e9 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 9d04b53a95c5..432c4e94b1f6 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 @@ -2638,6 +2638,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3205,6 +3207,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs index 253a70bc8053..69509b6dee19 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs index 936f8415fda6..d1b3775a465b 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs index 5c8e0767f76a..bbdd1b1b62e9 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs index 5c8e0767f76a..bbdd1b1b62e9 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 11f4b994064c..0daa375c9f6f 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 @@ -2638,6 +2638,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3205,6 +3207,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs index 5c8e0767f76a..bbdd1b1b62e9 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 9d04b53a95c5..432c4e94b1f6 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 @@ -2638,6 +2638,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3205,6 +3207,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs index 253a70bc8053..69509b6dee19 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -26,15 +26,23 @@ public sealed class FileParameter /// public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs index 1913a3a0f2d9..9f2614c6f4ce 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs index e629f4afdaec..173a5f299951 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs index e629f4afdaec..173a5f299951 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 fd403446d9a6..aa542fd9c05b 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 @@ -2642,6 +2642,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3211,6 +3213,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 c5de9cd55ad1..01f96fd91373 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 @@ -2644,6 +2644,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3213,6 +3215,7 @@ public async Task UploadFilesAsync(List public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs index e629f4afdaec..173a5f299951 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 da4dfd225bc4..20f9ce2ce945 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 @@ -2642,6 +2642,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3211,6 +3213,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 c5de9cd55ad1..01f96fd91373 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 @@ -2644,6 +2644,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3213,6 +3215,7 @@ public async Task UploadFilesAsync(List public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs index 11da1d925144..19febd4fee67 100644 --- a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs index 1913a3a0f2d9..9f2614c6f4ce 100644 --- a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs index e629f4afdaec..173a5f299951 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs index e629f4afdaec..173a5f299951 100644 --- a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 fd403446d9a6..aa542fd9c05b 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 @@ -2642,6 +2642,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3211,6 +3213,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 c5de9cd55ad1..01f96fd91373 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 @@ -2644,6 +2644,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3213,6 +3215,7 @@ public async Task UploadFilesAsync(List public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs index e629f4afdaec..173a5f299951 100644 --- a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 da4dfd225bc4..20f9ce2ce945 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 @@ -2642,6 +2642,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3211,6 +3213,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 c5de9cd55ad1..01f96fd91373 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 @@ -2644,6 +2644,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3213,6 +3215,7 @@ public async Task UploadFilesAsync(List public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } diff --git a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs index 11da1d925144..19febd4fee67 100644 --- a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs +++ b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Client/FileParameter.cs @@ -28,15 +28,23 @@ public sealed class FileParameter /// public string? FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string? fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } } 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 bbe2532cf740..71b38eb5b6cf 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 @@ -2637,6 +2637,7 @@ public async Task UploadFileAsync(long petId, Option UploadFileWithRequired { var streamContentLocalVar = new StreamContent(requiredFile.Content); + streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(requiredFile.ContentType); multipartContentLocalVar.Add(streamContentLocalVar, "requiredFile", requiredFile.FileName ?? "requiredFile"); } @@ -3204,6 +3206,7 @@ public async Task UploadFilesAsync(List public string FileName { get; } + /// + /// The MIME type sent in the Content-Type header of the part. + /// Defaults to application/octet-stream. + /// + public string ContentType { get; } + /// /// Creates a new . /// /// The file content stream. /// Optional filename for the Content-Disposition header. - public FileParameter(global::System.IO.Stream content, string fileName = null) + /// Optional MIME type for the Content-Type header of the part. Defaults to application/octet-stream. + public FileParameter(global::System.IO.Stream content, string fileName = null, string contentType = "application/octet-stream") { Content = content; FileName = fileName; + ContentType = contentType; } } }