From 4c37865365d96efdfac451fe4ac7445de81b3169 Mon Sep 17 00:00:00 2001 From: Prashant Pant Date: Thu, 29 Feb 2024 09:06:13 +0000 Subject: [PATCH] Update generichost/api.mustache & httpclient/api.mustache to autoset singleton enums values. --- .../csharp/libraries/generichost/api.mustache | 18 ++++++++++++++++++ .../csharp/libraries/httpclient/api.mustache | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache index 337f0f32598cc..21790f1eb77ed 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache @@ -390,6 +390,12 @@ namespace {{packageName}}.{{apiPackage}} uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; {{/-first}} {{/servers}} + {{#constantParams}} + {{#isPathParam}} + // Set client side default value of Path Param "{{baseName}}". + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7B{{baseName}}%7D", Uri.EscapeDataString({{#_enum}}"{{{.}}}"{{/_enum}}.ToString())); // Constant path parameter + {{/isPathParam}} + {{/constantParams}} {{#pathParams}} uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7B{{baseName}}%7D", Uri.EscapeDataString({{paramName}}.ToString())); {{#-last}} @@ -423,6 +429,12 @@ namespace {{packageName}}.{{apiPackage}} {{/required}} {{/queryParams}} + {{#constantParams}} + {{#isQueryParam}} + // Set client side default value of Query Param "{{baseName}}". + parseQueryStringLocalVar["{{baseName}}"] = ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}}); // Constant query parameter + {{/isQueryParam}} + {{/constantParams}} {{#queryParams}} {{^required}} if ({{paramName}}.IsSet) @@ -434,6 +446,12 @@ 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}})); diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/api.mustache index c0d49570a620e..22c8fd0c3f8e7 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/api.mustache @@ -605,6 +605,12 @@ namespace {{packageName}}.{{apiPackage}} var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts); if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + {{#constantParams}} + {{#isPathParam}} + // Set client side default value of Path Param "{{baseName}}". + localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant path parameter + {{/isPathParam}} + {{/constantParams}} {{#pathParams}} {{#required}} localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter @@ -616,6 +622,12 @@ namespace {{packageName}}.{{apiPackage}} } {{/required}} {{/pathParams}} + {{#constantParams}} + {{#isQueryParam}} + // Set client side default value of Query Param "{{baseName}}". + localVarRequestOptions.QueryParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant query parameter + {{/isQueryParam}} + {{/constantParams}} {{#queryParams}} {{#required}} localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{collectionFormat}}", "{{baseName}}", {{paramName}})); @@ -627,6 +639,12 @@ namespace {{packageName}}.{{apiPackage}} } {{/required}} {{/queryParams}} + {{#constantParams}} + {{#isHeaderParam}} + // Set client side default value of Header Param "{{baseName}}". + localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{#_enum}}"{{{.}}}"{{/_enum}})); // Constant header parameter + {{/isHeaderParam}} + {{/constantParams}} {{#headerParams}} {{#required}} localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter