Skip to content

Commit

Permalink
Update generichost/api.mustache & httpclient/api.mustache to autoset …
Browse files Browse the repository at this point in the history
…singleton enums values.
  • Loading branch information
prashant-pant committed Mar 1, 2024
1 parent f44ffee commit 9468c6e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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)
Expand All @@ -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}}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}));
Expand All @@ -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
Expand Down

0 comments on commit 9468c6e

Please sign in to comment.