forked from loafle/openapi-generator-original
Add hasQueryParamsOrAuth to reflect apiKey in query (#10582)
Compilation fails in generated typescript-angular client when an `apiKey` is passed in query due to an uninitialised variable. This change adds `getHasQueryParamsOrAuth()` to reflect if there's at least one query parameter or passing API keys in query in the `hasQueryParamsOrAuth` template variable.
This commit is contained in:
@@ -87,6 +87,15 @@ public class CodegenOperation {
|
||||
return nonempty(queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one query parameter or passing API keys in query
|
||||
*
|
||||
* @return true if query parameter exists or passing API keys in query, false otherwise
|
||||
*/
|
||||
public boolean getHasQueryParamsOrAuth() {
|
||||
return getHasQueryParams() || (authMethods != null && authMethods.stream().anyMatch(authMethod -> authMethod.isKeyInQuery));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one header parameter
|
||||
*
|
||||
|
||||
@@ -178,7 +178,7 @@ export class {{classname}} {
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
|
||||
{{#hasQueryParams}}
|
||||
{{#hasQueryParamsOrAuth}}
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
{{#queryParams}}
|
||||
{{#isArray}}
|
||||
@@ -209,7 +209,7 @@ export class {{classname}} {
|
||||
{{/isArray}}
|
||||
{{/queryParams}}
|
||||
|
||||
{{/hasQueryParams}}
|
||||
{{/hasQueryParamsOrAuth}}
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
{{#headerParams}}
|
||||
{{#isArray}}
|
||||
@@ -359,9 +359,9 @@ export class {{classname}} {
|
||||
{{#httpContextInOptions}}
|
||||
context: localVarHttpContext,
|
||||
{{/httpContextInOptions}}
|
||||
{{#hasQueryParams}}
|
||||
{{#hasQueryParamsOrAuth}}
|
||||
params: localVarQueryParameters,
|
||||
{{/hasQueryParams}}
|
||||
{{/hasQueryParamsOrAuth}}
|
||||
{{#isResponseFile}}
|
||||
responseType: "blob",
|
||||
{{/isResponseFile}}
|
||||
|
||||
Reference in New Issue
Block a user