Skip to content

Commit 2cd543a

Browse files
committed
multi file uploads
1 parent 5eb083e commit 2cd543a

File tree

298 files changed

+12209
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

298 files changed

+12209
-204
lines changed

modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,11 @@ namespace {{packageName}}.{{apiPackage}}
473473

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

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

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

480483
{{/required}}
@@ -486,13 +489,41 @@ namespace {{packageName}}.{{apiPackage}}
486489
{{/isFile}}
487490
{{#isFile}}
488491
{{#required}}
492+
{{#isContainer}}
493+
foreach (global::System.IO.Stream streamLocalVar in {{paramName}})
494+
{
495+
global::System.Net.Http.StreamContent streamContentLocalVar = new global::System.Net.Http.StreamContent(streamLocalVar);
496+
streamContentLocalVar.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
497+
{
498+
Name = "\"files\"",
499+
FileName = "\"file\""
500+
};
501+
multipartContentLocalVar.Add(streamContentLocalVar);
502+
}
503+
504+
{{/isContainer}}
505+
{{^isContainer}}
489506
multipartContentLocalVar.Add(new StreamContent({{paramName}}));
490507

508+
{{/isContainer}}
491509
{{/required}}
492510
{{^required}}
493511
if ({{paramName}}.IsSet)
512+
{{#isContainer}}
513+
foreach (global::System.IO.Stream streamLocalVar in {{paramName}}.Value)
514+
{
515+
var streamContentLocalVar = new global::System.Net.Http.StreamContent(file);
516+
streamContentLocalVar.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
517+
{
518+
Name = "\"files\"",
519+
FileName = "\"file\""
520+
};
521+
multipartContentLocalVar.Add(streamContentLocalVar);
522+
}
523+
{{/isContainer}}
524+
{{^isContainer}}
494525
multipartContentLocalVar.Add(new StreamContent({{paramName}}.Value));
495-
526+
{{/isContainer}}
496527
{{/required}}
497528
{{/isFile}}
498529
{{/formParams}}

modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,36 @@ tags:
1717
- name: user
1818
description: Operations about user
1919
paths:
20+
/upload:
21+
post:
22+
summary: Upload multiple files
23+
operationId: uploadFiles
24+
requestBody:
25+
required: true
26+
content:
27+
multipart/form-data:
28+
schema:
29+
type: object
30+
properties:
31+
files:
32+
type: array
33+
items:
34+
type: string
35+
format: binary
36+
required:
37+
- files
38+
responses:
39+
'200':
40+
description: Files uploaded successfully
41+
content:
42+
application/json:
43+
schema:
44+
type: object
45+
properties:
46+
message:
47+
type: string
48+
fileCount:
49+
type: integer
2050
/roles/report:
2151
get:
2252
responses:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.14.0-SNAPSHOT
1+
7.14.0

samples/client/echo_api/csharp/restsharp/net8/EchoApi/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [OpenAPI Generator](https://openap
66

77
- API version: 0.1.0
88
- SDK version: 1.0.0
9-
- Generator version: 7.14.0-SNAPSHOT
9+
- Generator version: 7.14.0
1010
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
1111

1212
<a id="frameworks-supported"></a>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.14.0-SNAPSHOT
1+
7.14.0

samples/client/others/csharp-complex-files/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [OpenAPI Generator](https://openap
66

77
- API version: 1.0.0
88
- SDK version: 1.0.0
9-
- Generator version: 7.14.0-SNAPSHOT
9+
- Generator version: 7.14.0
1010
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
1111

1212
<a id="frameworks-supported"></a>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.14.0-SNAPSHOT
1+
7.14.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.14.0-SNAPSHOT
1+
7.14.0

samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ namespace YourProject
104104
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
105105

106106
- SDK version: 1.0.0
107-
- Generator version: 7.14.0-SNAPSHOT
107+
- Generator version: 7.14.0
108108
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.14.0-SNAPSHOT
1+
7.14.0

0 commit comments

Comments
 (0)