Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,35 @@ using System.Net.Http.Headers;
throw new JsonException("The specified discriminator was not found.");
}

/// <summary>
/// Determines if the provided header is a content header
/// </summary>
/// <param name="header">The header to check</param>
/// <returns>True if a content header; False otherwise</returns>
public static bool IsContentHeader(string header)
{
return ContentHeaders.Contains(header.ToLowerInvariant());
}

/// <summary>
/// The collection of content headers as per
/// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers
/// </summary>
private static readonly string[] ContentHeaders = new String[]
{
"allow",
"content-encoding",
"content-disposition",
"content-language",
"content-length",
"content-location",
"content-md5",
"content-range",
"content-type",
"expires",
"last-modified"
};

/// <summary>
/// The base path of the API
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,23 +452,6 @@ namespace {{packageName}}.{{apiPackage}}

{{/-last}}
{{/queryParams}}
{{#constantParams}}
{{#isHeaderParam}}
// Set client side default value of Header Param "{{baseName}}".
httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant header parameter
{{/isHeaderParam}}
{{/constantParams}}
{{#headerParams}}
{{#required}}
httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}));

{{/required}}
{{^required}}
if ({{paramName}}.IsSet)
httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value));

{{/required}}
{{/headerParams}}
{{#formParams}}
{{#-first}}
{{#isMultipart}}
Expand Down Expand Up @@ -561,18 +544,65 @@ namespace {{packageName}}.{{apiPackage}}
{{/formParams}}
{{#bodyParam}}
{{#required}}
httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream
? httpRequestMessageLocalVar.Content = new StreamContent(stream)
httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is {{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar
? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content)
: httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions));
{{/required}}
{{^required}}
if ({{paramName}}.IsSet)
httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream
? httpRequestMessageLocalVar.Content = new StreamContent(stream)
: httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions));
{
httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is {{packageName}}.{{clientPackage}}.FileParameter fileParameterLocalVar
? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content)
: httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize({{paramName}}{{^required}}.Value{{/required}}, _jsonSerializerOptions));
}
{{/required}}

{{/bodyParam}}

{{#constantParams}}
{{#isHeaderParam}}
// Set client side default value of Header Param "{{baseName}}".
if (ClientUtils.IsContentHeader("{{baseName}}"))
{
httpRequestMessageLocalVar.Content.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant header parameter
}
else
{
httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant header parameter
}

{{/isHeaderParam}}
{{/constantParams}}
{{#headerParams}}
{{#required}}
// Set client side default value of Header Param "{{baseName}}".
if (ClientUtils.IsContentHeader("{{baseName}}"))
{
httpRequestMessageLocalVar.Content?.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}));
}
else
{
httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}));
}

{{/required}}
{{^required}}
if ({{paramName}}.IsSet)
{
// Set client side default value of Header Param "{{baseName}}".
if (ClientUtils.IsContentHeader("{{baseName}}"))
{
httpRequestMessageLocalVar.Content?.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value));
}
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
else
{
httpRequestMessageLocalVar.Headers.Add("{{baseName}}", ClientUtils.ParameterToString({{paramName}}.Value));
}
}

{{/required}}
{{/headerParams}}

{{#authMethods}}
{{#-first}}
List<TokenBase> tokenBaseLocalVars = new List<TokenBase>();
Expand Down Expand Up @@ -907,4 +937,4 @@ namespace {{packageName}}.{{apiPackage}}
}
{{/operations}}
}
{{/lambda.trimLineBreaks}}
{{/lambda.trimLineBreaks}}
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,35 @@ public static bool IsJsonMime(string mime)
throw new JsonException("The specified discriminator was not found.");
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
}

/// <summary>
/// Determines if the provided header is a content header
/// </summary>
/// <param name="header">The header to check</param>
/// <returns>True if a content header; False otherwise</returns>
public static bool IsContentHeader(string header)
{
return ContentHeaders.Contains(header.ToLowerInvariant());
}

/// <summary>
/// The collection of content headers as per
/// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers
/// </summary>
private static readonly string[] ContentHeaders = new String[]
{
"allow",
"content-encoding",
"content-disposition",
"content-language",
"content-length",
"content-location",
"content-md5",
"content-range",
"content-type",
"expires",
"last-modified"
};

/// <summary>
/// The base path of the API
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,11 @@ public async Task<IHelloWorldPostApiResponse> HelloWorldPostAsync(Option<HelloWo
: string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/helloWorld");

if (helloWorldPostRequest.IsSet)
httpRequestMessageLocalVar.Content = (helloWorldPostRequest.Value as object) is System.IO.Stream stream
? httpRequestMessageLocalVar.Content = new StreamContent(stream)
: httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(helloWorldPostRequest.Value, _jsonSerializerOptions));
{
httpRequestMessageLocalVar.Content = (helloWorldPostRequest.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar
? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content)
: httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(helloWorldPostRequest.Value, _jsonSerializerOptions));
}

httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,35 @@ public static bool IsJsonMime(string mime)
throw new JsonException("The specified discriminator was not found.");
}

/// <summary>
/// Determines if the provided header is a content header
/// </summary>
/// <param name="header">The header to check</param>
/// <returns>True if a content header; False otherwise</returns>
public static bool IsContentHeader(string header)
{
return ContentHeaders.Contains(header.ToLowerInvariant());
}

/// <summary>
/// The collection of content headers as per
/// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers
/// </summary>
private static readonly string[] ContentHeaders = new String[]
{
"allow",
"content-encoding",
"content-disposition",
"content-language",
"content-length",
"content-location",
"content-md5",
"content-range",
"content-type",
"expires",
"last-modified"
};

/// <summary>
/// The base path of the API
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,35 @@ public static bool IsJsonMime(string mime)
throw new JsonException("The specified discriminator was not found.");
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
}

/// <summary>
/// Determines if the provided header is a content header
/// </summary>
/// <param name="header">The header to check</param>
/// <returns>True if a content header; False otherwise</returns>
public static bool IsContentHeader(string header)
{
return ContentHeaders.Contains(header.ToLowerInvariant());
}

/// <summary>
/// The collection of content headers as per
/// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers
/// </summary>
private static readonly string[] ContentHeaders = new String[]
{
"allow",
"content-encoding",
"content-disposition",
"content-language",
"content-length",
"content-location",
"content-md5",
"content-range",
"content-type",
"expires",
"last-modified"
};

/// <summary>
/// The base path of the API
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@ public async Task<IOneOfArrayApiResponse> OneOfArrayAsync(Option<OneOfArrayReque
: string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/one-of-array");

if (oneOfArrayRequest.IsSet)
httpRequestMessageLocalVar.Content = (oneOfArrayRequest.Value as object) is System.IO.Stream stream
? httpRequestMessageLocalVar.Content = new StreamContent(stream)
: httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(oneOfArrayRequest.Value, _jsonSerializerOptions));
{
httpRequestMessageLocalVar.Content = (oneOfArrayRequest.Value as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar
? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content)
: httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(oneOfArrayRequest.Value, _jsonSerializerOptions));
}

httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,35 @@ public static bool IsJsonMime(string mime)
throw new JsonException("The specified discriminator was not found.");
}

/// <summary>
/// Determines if the provided header is a content header
/// </summary>
/// <param name="header">The header to check</param>
/// <returns>True if a content header; False otherwise</returns>
public static bool IsContentHeader(string header)
{
return ContentHeaders.Contains(header.ToLowerInvariant());
}

/// <summary>
/// The collection of content headers as per
/// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers
/// </summary>
private static readonly string[] ContentHeaders = new String[]
{
"allow",
"content-encoding",
"content-disposition",
"content-language",
"content-length",
"content-location",
"content-md5",
"content-range",
"content-type",
"expires",
"last-modified"
};

/// <summary>
/// The base path of the API
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,35 @@ public static bool IsJsonMime(string mime)
throw new JsonException("The specified discriminator was not found.");
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
}

/// <summary>
/// Determines if the provided header is a content header
/// </summary>
/// <param name="header">The header to check</param>
/// <returns>True if a content header; False otherwise</returns>
public static bool IsContentHeader(string header)
{
return ContentHeaders.Contains(header.ToLowerInvariant());
}

/// <summary>
/// The collection of content headers as per
/// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcontent.headers
/// </summary>
private static readonly string[] ContentHeaders = new String[]
{
"allow",
"content-encoding",
"content-disposition",
"content-language",
"content-length",
"content-location",
"content-md5",
"content-range",
"content-type",
"expires",
"last-modified"
};

/// <summary>
/// The base path of the API
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ public async Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsyn
? "/another-fake/dummy"
: string.Concat(HttpClient.BaseAddress.AbsolutePath.TrimEnd('/'), "/another-fake/dummy");

httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream
? httpRequestMessageLocalVar.Content = new StreamContent(stream)
httpRequestMessageLocalVar.Content = (modelClient as object) is Org.OpenAPITools.Client.FileParameter fileParameterLocalVar
? httpRequestMessageLocalVar.Content = new StreamContent(fileParameterLocalVar.Content)
: httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions));

httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;
Expand Down
Loading