Skip to content

Commit e6207d5

Browse files
committed
address issue one
1 parent 05776d6 commit e6207d5

134 files changed

Lines changed: 2883 additions & 863 deletions

File tree

Some content is hidden

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

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ public void addGenericHostSupportingFiles(final String clientPackageDir, final S
11261126
supportingFiles.add(new SupportingFile("JsonSerializerOptionsProvider.mustache", clientPackageDir, "JsonSerializerOptionsProvider.cs"));
11271127
supportingFiles.add(new SupportingFile("CookieContainer.mustache", clientPackageDir, "CookieContainer.cs"));
11281128
supportingFiles.add(new SupportingFile("Option.mustache", clientPackageDir, "Option.cs"));
1129+
supportingFiles.add(new SupportingFile("FileParameter.mustache", clientPackageDir, "FileParameter.cs"));
11291130

11301131
supportingFiles.add(new SupportingFile("IApi.mustache", sourceFolder + File.separator + packageName + File.separator + apiPackage(), getInterfacePrefix() + "Api.cs"));
11311132

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// <auto-generated>
2+
{{>partial_header}}
3+
4+
{{#nrt}}
5+
#nullable enable
6+
7+
{{/nrt}}
8+
namespace {{packageName}}.{{clientPackage}}
9+
{
10+
/// <summary>
11+
/// Represents a file to be uploaded as part of a multipart/form-data request.
12+
/// </summary>
13+
{{>visibility}} sealed class FileParameter
14+
{
15+
/// <summary>
16+
/// The file content stream.
17+
/// </summary>
18+
public global::System.IO.Stream Content { get; }
19+
20+
/// <summary>
21+
/// The filename sent in the Content-Disposition header.
22+
/// When null the parameter name from the spec is used as a fallback.
23+
/// </summary>
24+
public string{{nrt?}} FileName { get; }
25+
26+
/// <summary>
27+
/// Creates a new <see cref="FileParameter"/>.
28+
/// </summary>
29+
/// <param name="content">The file content stream.</param>
30+
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
31+
public FileParameter(global::System.IO.Stream content, string{{nrt?}} fileName = null)
32+
{
33+
Content = content;
34+
FileName = fileName;
35+
}
36+
}
37+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{#isFile}}{{#isContainer}}List<{{packageName}}.{{clientPackage}}.FileParameter>{{/isContainer}}{{^isContainer}}{{packageName}}.{{clientPackage}}.FileParameter{{>NullConditionalParameter}}{{/isContainer}}{{/isFile}}{{^isFile}}{{{dataType}}}{{>NullConditionalParameter}}{{/isFile}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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}}
1+
{{#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}}

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ namespace {{packageName}}.{{apiPackage}}
246246

247247
{{#allParams}}
248248
{{#-first}}
249-
partial void Format{{operationId}}({{#allParams}}{{#isPrimitiveType}}ref {{/isPrimitiveType}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
249+
partial void Format{{operationId}}({{#allParams}}{{#isPrimitiveType}}ref {{/isPrimitiveType}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
250250

251251
{{/-first}}
252252
{{/allParams}}
@@ -258,7 +258,7 @@ namespace {{packageName}}.{{apiPackage}}
258258
/// <param name="{{paramName}}"></param>
259259
{{/vendorExtensions.x-not-nullable-reference-types}}
260260
/// <returns></returns>
261-
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}})
261+
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}})
262262
{
263263
{{#lambda.trimTrailingWithNewLine}}
264264
{{#vendorExtensions.x-not-nullable-reference-types}}
@@ -288,7 +288,7 @@ namespace {{packageName}}.{{apiPackage}}
288288
{{#allParams}}
289289
/// <param name="{{paramName}}"></param>
290290
{{/allParams}}
291-
private void After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}{{interfacePrefix}}{{operationId}}ApiResponse apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}})
291+
private void After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}{{interfacePrefix}}{{operationId}}ApiResponse apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}})
292292
{
293293
bool suppressDefaultLog = false;
294294
After{{operationId}}({{#lambda.joinWithComma}}ref suppressDefaultLog apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}});
@@ -303,7 +303,7 @@ namespace {{packageName}}.{{apiPackage}}
303303
{{#allParams}}
304304
/// <param name="{{paramName}}"></param>
305305
{{/allParams}}
306-
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}});
306+
partial void After{{operationId}}({{#lambda.joinWithComma}}ref bool suppressDefaultLog {{interfacePrefix}}{{operationId}}ApiResponse apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}});
307307

308308
/// <summary>
309309
/// Logs exceptions that occur while retrieving the server response
@@ -314,7 +314,7 @@ namespace {{packageName}}.{{apiPackage}}
314314
{{#allParams}}
315315
/// <param name="{{paramName}}"></param>
316316
{{/allParams}}
317-
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}})
317+
private void OnError{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}Exception exceptionLocalVar string pathFormatLocalVar string pathLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{>OperationDataType}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}})
318318
{
319319
bool suppressDefaultLogLocalVar = false;
320320
OnError{{operationId}}({{#lambda.joinWithComma}}ref suppressDefaultLogLocalVar exceptionLocalVar pathFormatLocalVar pathLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}});
@@ -332,7 +332,7 @@ namespace {{packageName}}.{{apiPackage}}
332332
{{#allParams}}
333333
/// <param name="{{paramName}}"></param>
334334
{{/allParams}}
335-
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}});
335+
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}});
336336

337337
/// <summary>
338338
/// {{summary}} {{notes}}
@@ -492,32 +492,32 @@ namespace {{packageName}}.{{apiPackage}}
492492
{{#isFile}}
493493
{{#required}}
494494
{{#isContainer}}
495-
foreach (global::System.IO.Stream streamLocalVar in {{paramName}})
495+
foreach ({{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar in {{paramName}})
496496
{
497-
var streamContentLocalVar = new StreamContent(streamLocalVar);
498-
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}");
497+
var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content);
498+
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", fileParameterLocalVar.FileName ?? "{{baseName}}");
499499
}
500500

501501
{{/isContainer}}
502502
{{^isContainer}}
503-
var streamContentLocalVar = new StreamContent({{paramName}});
504-
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}");
503+
var streamContentLocalVar = new StreamContent({{paramName}}.Content);
504+
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.FileName ?? "{{baseName}}");
505505

506506
{{/isContainer}}
507507
{{/required}}
508508
{{^required}}
509509
if ({{paramName}}.IsSet)
510510
{
511511
{{#isContainer}}
512-
foreach (global::System.IO.Stream streamLocalVar in {{paramName}}.Value)
512+
foreach ({{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar in {{paramName}}.Value)
513513
{
514-
var streamContentLocalVar = new StreamContent(streamLocalVar);
515-
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}");
514+
var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content);
515+
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", fileParameterLocalVar.FileName ?? "{{baseName}}");
516516
}
517517
{{/isContainer}}
518518
{{^isContainer}}
519-
var streamContentLocalVar = new StreamContent({{paramName}}.Value);
520-
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}");
519+
var streamContentLocalVar = new StreamContent({{paramName}}.Value.Content);
520+
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.Value.FileName ?? "{{baseName}}");
521521
{{/isContainer}}
522522
}
523523

samples/client/petstore/csharp/generichost/latest/ComposedEnum/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs
2323
src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs
2424
src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs
2525
src/Org.OpenAPITools/Client/ExceptionEventArgs.cs
26+
src/Org.OpenAPITools/Client/FileParameter.cs
2627
src/Org.OpenAPITools/Client/HostConfiguration.cs
2728
src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs
2829
src/Org.OpenAPITools/Client/Option.cs
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// <auto-generated>
2+
/*
3+
* OpenAPI
4+
*
5+
* OpenAPI
6+
*
7+
* The version of the OpenAPI document: 0.0.1
8+
* Generated by: https://github.com/openapitools/openapi-generator.git
9+
*/
10+
11+
#nullable enable
12+
13+
namespace Org.OpenAPITools.Client
14+
{
15+
/// <summary>
16+
/// Represents a file to be uploaded as part of a multipart/form-data request.
17+
/// </summary>
18+
public sealed class FileParameter
19+
{
20+
/// <summary>
21+
/// The file content stream.
22+
/// </summary>
23+
public global::System.IO.Stream Content { get; }
24+
25+
/// <summary>
26+
/// The filename sent in the Content-Disposition header.
27+
/// When null the parameter name from the spec is used as a fallback.
28+
/// </summary>
29+
public string? FileName { get; }
30+
31+
/// <summary>
32+
/// Creates a new <see cref="FileParameter"/>.
33+
/// </summary>
34+
/// <param name="content">The file content stream.</param>
35+
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
36+
public FileParameter(global::System.IO.Stream content, string? fileName = null)
37+
{
38+
Content = content;
39+
FileName = fileName;
40+
}
41+
}
42+
}

samples/client/petstore/csharp/generichost/latest/HelloWorld/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs
2323
src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs
2424
src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs
2525
src/Org.OpenAPITools/Client/ExceptionEventArgs.cs
26+
src/Org.OpenAPITools/Client/FileParameter.cs
2627
src/Org.OpenAPITools/Client/HostConfiguration.cs
2728
src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs
2829
src/Org.OpenAPITools/Client/Option.cs
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// <auto-generated>
2+
/*
3+
* Minimal reproduction for csharp webhook bug
4+
*
5+
* This is an example API to reproduce a bug with webhooks in csharp codegen
6+
*
7+
* The version of the OpenAPI document: 1.0.0
8+
* Generated by: https://github.com/openapitools/openapi-generator.git
9+
*/
10+
11+
#nullable enable
12+
13+
namespace Org.OpenAPITools.Client
14+
{
15+
/// <summary>
16+
/// Represents a file to be uploaded as part of a multipart/form-data request.
17+
/// </summary>
18+
public sealed class FileParameter
19+
{
20+
/// <summary>
21+
/// The file content stream.
22+
/// </summary>
23+
public global::System.IO.Stream Content { get; }
24+
25+
/// <summary>
26+
/// The filename sent in the Content-Disposition header.
27+
/// When null the parameter name from the spec is used as a fallback.
28+
/// </summary>
29+
public string? FileName { get; }
30+
31+
/// <summary>
32+
/// Creates a new <see cref="FileParameter"/>.
33+
/// </summary>
34+
/// <param name="content">The file content stream.</param>
35+
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
36+
public FileParameter(global::System.IO.Stream content, string? fileName = null)
37+
{
38+
Content = content;
39+
FileName = fileName;
40+
}
41+
}
42+
}

samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ src/Org.OpenAPITools/Client/DateOnlyNullableJsonConverter.cs
2626
src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs
2727
src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs
2828
src/Org.OpenAPITools/Client/ExceptionEventArgs.cs
29+
src/Org.OpenAPITools/Client/FileParameter.cs
2930
src/Org.OpenAPITools/Client/HostConfiguration.cs
3031
src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs
3132
src/Org.OpenAPITools/Client/Option.cs

0 commit comments

Comments
 (0)