Skip to content

Commit 289f358

Browse files
committed
added content-type
1 parent 3aac9c1 commit 289f358

66 files changed

Lines changed: 487 additions & 48 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/resources/csharp/libraries/generichost/FileParameter.mustache

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,23 @@ namespace {{packageName}}.{{clientPackage}}
2323
/// </summary>
2424
public string{{nrt?}} FileName { get; }
2525

26+
/// <summary>
27+
/// The MIME type sent in the Content-Type header of the part.
28+
/// Defaults to <c>application/octet-stream</c>.
29+
/// </summary>
30+
public string ContentType { get; }
31+
2632
/// <summary>
2733
/// Creates a new <see cref="FileParameter"/>.
2834
/// </summary>
2935
/// <param name="content">The file content stream.</param>
3036
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
31-
public FileParameter(global::System.IO.Stream content, string{{nrt?}} fileName = null)
37+
/// <param name="contentType">Optional MIME type for the Content-Type header of the part. Defaults to <c>application/octet-stream</c>.</param>
38+
public FileParameter(global::System.IO.Stream content, string{{nrt?}} fileName = null, string contentType = "application/octet-stream")
3239
{
3340
Content = content;
3441
FileName = fileName;
42+
ContentType = contentType;
3543
}
3644
}
3745
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,15 @@ namespace {{packageName}}.{{apiPackage}}
510510
foreach ({{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar in {{paramName}})
511511
{
512512
var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content);
513+
streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(fileParameterLocalVar.ContentType);
513514
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", fileParameterLocalVar.FileName ?? "{{baseName}}");
514515
}
515516

516517
{{/isContainer}}
517518
{{^isContainer}}
518519
{
519520
var streamContentLocalVar = new StreamContent({{paramName}}.Content);
521+
streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue({{paramName}}.ContentType);
520522
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.FileName ?? "{{baseName}}");
521523
}
522524

@@ -529,11 +531,13 @@ namespace {{packageName}}.{{apiPackage}}
529531
foreach ({{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar in {{paramName}}.Value)
530532
{
531533
var streamContentLocalVar = new StreamContent(fileParameterLocalVar.Content);
534+
streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue(fileParameterLocalVar.ContentType);
532535
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", fileParameterLocalVar.FileName ?? "{{baseName}}");
533536
}
534537
{{/isContainer}}
535538
{{^isContainer}}
536539
var streamContentLocalVar = new StreamContent({{paramName}}.Value.Content);
540+
streamContentLocalVar.Headers.ContentType = new MediaTypeHeaderValue({{paramName}}.Value.ContentType);
537541
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}", {{paramName}}.Value.FileName ?? "{{baseName}}");
538542
{{/isContainer}}
539543
}

samples/client/petstore/csharp/generichost/latest/ComposedEnum/src/Org.OpenAPITools/Client/FileParameter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ public sealed class FileParameter
2828
/// </summary>
2929
public string? FileName { get; }
3030

31+
/// <summary>
32+
/// The MIME type sent in the Content-Type header of the part.
33+
/// Defaults to <c>application/octet-stream</c>.
34+
/// </summary>
35+
public string ContentType { get; }
36+
3137
/// <summary>
3238
/// Creates a new <see cref="FileParameter"/>.
3339
/// </summary>
3440
/// <param name="content">The file content stream.</param>
3541
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
36-
public FileParameter(global::System.IO.Stream content, string? fileName = null)
42+
/// <param name="contentType">Optional MIME type for the Content-Type header of the part. Defaults to <c>application/octet-stream</c>.</param>
43+
public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream")
3744
{
3845
Content = content;
3946
FileName = fileName;
47+
ContentType = contentType;
4048
}
4149
}
4250
}

samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Client/FileParameter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ public sealed class FileParameter
2828
/// </summary>
2929
public string? FileName { get; }
3030

31+
/// <summary>
32+
/// The MIME type sent in the Content-Type header of the part.
33+
/// Defaults to <c>application/octet-stream</c>.
34+
/// </summary>
35+
public string ContentType { get; }
36+
3137
/// <summary>
3238
/// Creates a new <see cref="FileParameter"/>.
3339
/// </summary>
3440
/// <param name="content">The file content stream.</param>
3541
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
36-
public FileParameter(global::System.IO.Stream content, string? fileName = null)
42+
/// <param name="contentType">Optional MIME type for the Content-Type header of the part. Defaults to <c>application/octet-stream</c>.</param>
43+
public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream")
3744
{
3845
Content = content;
3946
FileName = fileName;
47+
ContentType = contentType;
4048
}
4149
}
4250
}

samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Client/FileParameter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ public sealed class FileParameter
2828
/// </summary>
2929
public string? FileName { get; }
3030

31+
/// <summary>
32+
/// The MIME type sent in the Content-Type header of the part.
33+
/// Defaults to <c>application/octet-stream</c>.
34+
/// </summary>
35+
public string ContentType { get; }
36+
3137
/// <summary>
3238
/// Creates a new <see cref="FileParameter"/>.
3339
/// </summary>
3440
/// <param name="content">The file content stream.</param>
3541
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
36-
public FileParameter(global::System.IO.Stream content, string? fileName = null)
42+
/// <param name="contentType">Optional MIME type for the Content-Type header of the part. Defaults to <c>application/octet-stream</c>.</param>
43+
public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream")
3744
{
3845
Content = content;
3946
FileName = fileName;
47+
ContentType = contentType;
4048
}
4149
}
4250
}

samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Client/FileParameter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ public sealed class FileParameter
2828
/// </summary>
2929
public string? FileName { get; }
3030

31+
/// <summary>
32+
/// The MIME type sent in the Content-Type header of the part.
33+
/// Defaults to <c>application/octet-stream</c>.
34+
/// </summary>
35+
public string ContentType { get; }
36+
3137
/// <summary>
3238
/// Creates a new <see cref="FileParameter"/>.
3339
/// </summary>
3440
/// <param name="content">The file content stream.</param>
3541
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
36-
public FileParameter(global::System.IO.Stream content, string? fileName = null)
42+
/// <param name="contentType">Optional MIME type for the Content-Type header of the part. Defaults to <c>application/octet-stream</c>.</param>
43+
public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream")
3744
{
3845
Content = content;
3946
FileName = fileName;
47+
ContentType = contentType;
4048
}
4149
}
4250
}

samples/client/petstore/csharp/generichost/latest/Tags/src/Org.OpenAPITools/Client/FileParameter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,23 @@ public sealed class FileParameter
2929
/// </summary>
3030
public string? FileName { get; }
3131

32+
/// <summary>
33+
/// The MIME type sent in the Content-Type header of the part.
34+
/// Defaults to <c>application/octet-stream</c>.
35+
/// </summary>
36+
public string ContentType { get; }
37+
3238
/// <summary>
3339
/// Creates a new <see cref="FileParameter"/>.
3440
/// </summary>
3541
/// <param name="content">The file content stream.</param>
3642
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
37-
public FileParameter(global::System.IO.Stream content, string? fileName = null)
43+
/// <param name="contentType">Optional MIME type for the Content-Type header of the part. Defaults to <c>application/octet-stream</c>.</param>
44+
public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream")
3845
{
3946
Content = content;
4047
FileName = fileName;
48+
ContentType = contentType;
4149
}
4250
}
4351
}

samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Client/FileParameter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ public sealed class FileParameter
2828
/// </summary>
2929
public string? FileName { get; }
3030

31+
/// <summary>
32+
/// The MIME type sent in the Content-Type header of the part.
33+
/// Defaults to <c>application/octet-stream</c>.
34+
/// </summary>
35+
public string ContentType { get; }
36+
3137
/// <summary>
3238
/// Creates a new <see cref="FileParameter"/>.
3339
/// </summary>
3440
/// <param name="content">The file content stream.</param>
3541
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
36-
public FileParameter(global::System.IO.Stream content, string? fileName = null)
42+
/// <param name="contentType">Optional MIME type for the Content-Type header of the part. Defaults to <c>application/octet-stream</c>.</param>
43+
public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream")
3744
{
3845
Content = content;
3946
FileName = fileName;
47+
ContentType = contentType;
4048
}
4149
}
4250
}

samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Client/FileParameter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ public sealed class FileParameter
2828
/// </summary>
2929
public string? FileName { get; }
3030

31+
/// <summary>
32+
/// The MIME type sent in the Content-Type header of the part.
33+
/// Defaults to <c>application/octet-stream</c>.
34+
/// </summary>
35+
public string ContentType { get; }
36+
3137
/// <summary>
3238
/// Creates a new <see cref="FileParameter"/>.
3339
/// </summary>
3440
/// <param name="content">The file content stream.</param>
3541
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
36-
public FileParameter(global::System.IO.Stream content, string? fileName = null)
42+
/// <param name="contentType">Optional MIME type for the Content-Type header of the part. Defaults to <c>application/octet-stream</c>.</param>
43+
public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream")
3744
{
3845
Content = content;
3946
FileName = fileName;
47+
ContentType = contentType;
4048
}
4149
}
4250
}

samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Client/FileParameter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ public sealed class FileParameter
2828
/// </summary>
2929
public string? FileName { get; }
3030

31+
/// <summary>
32+
/// The MIME type sent in the Content-Type header of the part.
33+
/// Defaults to <c>application/octet-stream</c>.
34+
/// </summary>
35+
public string ContentType { get; }
36+
3137
/// <summary>
3238
/// Creates a new <see cref="FileParameter"/>.
3339
/// </summary>
3440
/// <param name="content">The file content stream.</param>
3541
/// <param name="fileName">Optional filename for the Content-Disposition header.</param>
36-
public FileParameter(global::System.IO.Stream content, string? fileName = null)
42+
/// <param name="contentType">Optional MIME type for the Content-Type header of the part. Defaults to <c>application/octet-stream</c>.</param>
43+
public FileParameter(global::System.IO.Stream content, string? fileName = null, string contentType = "application/octet-stream")
3744
{
3845
Content = content;
3946
FileName = fileName;
47+
ContentType = contentType;
4048
}
4149
}
4250
}

0 commit comments

Comments
 (0)