Skip to content

[csharp][generichost] Multi file uploads #21449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,11 @@ namespace {{packageName}}.{{apiPackage}}

List<KeyValuePair<string{{nrt?}}, string{{nrt?}}>> formParameterLocalVars = new List<KeyValuePair<string{{nrt?}}, string{{nrt?}}>>();

multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars));{{/-first}}{{^isFile}}{{#required}}
multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars));

{{/-first}}
{{^isFile}}
{{#required}}
formParameterLocalVars.Add(new KeyValuePair<string{{nrt?}}, string{{nrt?}}>("{{baseName}}", ClientUtils.ParameterToString({{paramName}})));

{{/required}}
Expand All @@ -486,13 +489,41 @@ namespace {{packageName}}.{{apiPackage}}
{{/isFile}}
{{#isFile}}
{{#required}}
{{#isContainer}}
foreach (global::System.IO.Stream streamLocalVar in {{paramName}})
{
global::System.Net.Http.StreamContent streamContentLocalVar = new global::System.Net.Http.StreamContent(streamLocalVar);
streamContentLocalVar.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "\"files\"",
FileName = "\"file\""
};
multipartContentLocalVar.Add(streamContentLocalVar);
}

{{/isContainer}}
{{^isContainer}}
multipartContentLocalVar.Add(new StreamContent({{paramName}}));

{{/isContainer}}
{{/required}}
{{^required}}
if ({{paramName}}.IsSet)
{{#isContainer}}
foreach (global::System.IO.Stream streamLocalVar in {{paramName}}.Value)
{
var streamContentLocalVar = new global::System.Net.Http.StreamContent(file);
streamContentLocalVar.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "\"files\"",
FileName = "\"file\""
};
multipartContentLocalVar.Add(streamContentLocalVar);
}
{{/isContainer}}
{{^isContainer}}
multipartContentLocalVar.Add(new StreamContent({{paramName}}.Value));

{{/isContainer}}
{{/required}}
{{/isFile}}
{{/formParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,36 @@ tags:
- name: user
description: Operations about user
paths:
/upload:
post:
summary: Upload multiple files
operationId: uploadFiles
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
files:
type: array
items:
type: string
format: binary
required:
- files
responses:
'200':
description: Files uploaded successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
fileCount:
type: integer
/roles/report:
get:
responses:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [OpenAPI Generator](https://openap

- API version: 0.1.0
- SDK version: 1.0.0
- Generator version: 7.14.0-SNAPSHOT
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen

<a id="frameworks-supported"></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
2 changes: 1 addition & 1 deletion samples/client/others/csharp-complex-files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [OpenAPI Generator](https://openap

- API version: 1.0.0
- SDK version: 1.0.0
- Generator version: 7.14.0-SNAPSHOT
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen

<a id="frameworks-supported"></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ namespace YourProject
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.

- SDK version: 1.0.0
- Generator version: 7.14.0-SNAPSHOT
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ namespace YourProject
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.

- SDK version: 1.0.0
- Generator version: 7.14.0-SNAPSHOT
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ namespace YourProject
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.

- SDK version: 1.0.0
- Generator version: 7.14.0-SNAPSHOT
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ namespace YourProject
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.

- SDK version: 1.0.0
- Generator version: 7.14.0-SNAPSHOT
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ namespace YourProject
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.

- SDK version: 1.0.0
- Generator version: 7.14.0-SNAPSHOT
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ namespace YourProject
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.

- SDK version: 1.0.0
- Generator version: 7.14.0-SNAPSHOT
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ docs/models/TestResult.md
docs/models/TestResultCode.md
docs/models/Triangle.md
docs/models/TriangleInterface.md
docs/models/UploadFiles200Response.md
docs/models/User.md
docs/models/Whale.md
docs/models/Zebra.md
Expand All @@ -140,6 +141,7 @@ docs/models/ZeroBasedEnumClassZeroBasedEnum.md
docs/scripts/git_push.ps1
docs/scripts/git_push.sh
src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs
src/Org.OpenAPITools.Test/Model/UploadFiles200ResponseTests.cs
src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
src/Org.OpenAPITools.Test/README.md
src/Org.OpenAPITools/Api/AnotherFakeApi.cs
Expand Down Expand Up @@ -295,6 +297,7 @@ src/Org.OpenAPITools/Model/TestResult.cs
src/Org.OpenAPITools/Model/TestResultCode.cs
src/Org.OpenAPITools/Model/Triangle.cs
src/Org.OpenAPITools/Model/TriangleInterface.cs
src/Org.OpenAPITools/Model/UploadFiles200Response.cs
src/Org.OpenAPITools/Model/User.cs
src/Org.OpenAPITools/Model/Whale.cs
src/Org.OpenAPITools/Model/Zebra.cs
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.14.0-SNAPSHOT
7.14.0
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ tags:
- description: Operations about user
name: user
paths:
/upload:
post:
operationId: uploadFiles
requestBody:
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/uploadFiles_request"
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/uploadFiles_200_response"
description: Files uploaded successfully
summary: Upload multiple files
/roles/report:
get:
responses:
Expand Down Expand Up @@ -2684,6 +2701,26 @@ components:
- APPROVED
- MANUAL_APPROVAL_REQUIRED
type: string
uploadFiles_request:
properties:
files:
items:
format: binary
type: string
type: array
required:
- files
type: object
uploadFiles_200_response:
example:
message: message
fileCount: 0
properties:
message:
type: string
fileCount:
type: integer
type: object
_foo_get_default_response:
example:
string:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
| [**Hello**](DefaultApi.md#hello) | **GET** /hello | Hello |
| [**RolesReportGet**](DefaultApi.md#rolesreportget) | **GET** /roles/report | |
| [**Test**](DefaultApi.md#test) | **GET** /test | Retrieve an existing Notificationtest&#39;s Elements |
| [**UploadFiles**](DefaultApi.md#uploadfiles) | **POST** /upload | Upload multiple files |

<a id="fooget"></a>
# **FooGet**
Expand Down Expand Up @@ -166,3 +167,37 @@ No authorization 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)

<a id="uploadfiles"></a>
# **UploadFiles**
> UploadFiles200Response UploadFiles (List<System.IO.Stream> files)

Upload multiple files


### Parameters

| Name | Type | Description | Notes |
|------|------|-------------|-------|
| **files** | **List&lt;System.IO.Stream&gt;** | | |

### Return type

[**UploadFiles200Response**](UploadFiles200Response.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: multipart/form-data
- **Accept**: application/json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Files uploaded successfully | - |

[[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)

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Org.OpenAPITools.Model.UploadFiles200Response

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**FileCount** | **int** | | [optional]
**Message** | **string** | | [optional]

[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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
*/


using Xunit;

using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using Org.OpenAPITools.Model;
using Org.OpenAPITools.Client;
using System.Reflection;

namespace Org.OpenAPITools.Test.Model
{
/// <summary>
/// Class for testing UploadFiles200Response
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
public class UploadFiles200ResponseTests : IDisposable
{
// TODO uncomment below to declare an instance variable for UploadFiles200Response
//private UploadFiles200Response instance;

public UploadFiles200ResponseTests()
{
// TODO uncomment below to create an instance of UploadFiles200Response
//instance = new UploadFiles200Response();
}

public void Dispose()
{
// Cleanup when everything is done.
}

/// <summary>
/// Test an instance of UploadFiles200Response
/// </summary>
[Fact]
public void UploadFiles200ResponseInstanceTest()
{
// TODO uncomment below to test "IsType" UploadFiles200Response
//Assert.IsType<UploadFiles200Response>(instance);
}

/// <summary>
/// Test the property 'FileCount'
/// </summary>
[Fact]
public void FileCountTest()
{
// TODO unit test for the property 'FileCount'
}

/// <summary>
/// Test the property 'Message'
/// </summary>
[Fact]
public void MessageTest()
{
// TODO unit test for the property 'Message'
}
}
}
Loading
Loading