Skip to content

Commit 695f707

Browse files
authored
[BUG][typescript-angular] apiKeys cause service compilation errors (#22775)
* [BUG][typescript-angular] apiKeys cause service compilation errors Updated TypeScript Angular `configuration.mustache` to properly handle apiKeys in query parameters by using `OpenApiHttpParams` instead of `HttpHeaders` to avoid compilation errors. Fixes #22774 * add generated samples
1 parent 51d5310 commit 695f707

16 files changed

Lines changed: 48 additions & 32 deletions

File tree

modules/openapi-generator/src/main/resources/typescript-angular/configuration.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface {{configurationParametersInterfaceName}} {
56
/**
@@ -198,7 +199,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
198199
: headers;
199200
}
200201

201-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
202+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
202203
const value = this.lookupCredential(credentialKey);
203204
return value
204205
? query.set(paramName, value)

samples/client/others/typescript-angular-v20/builds/query-param-deep-object/configuration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface ConfigurationParameters {
56
/**
@@ -159,7 +160,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
159160
: headers;
160161
}
161162

162-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
163+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
163164
const value = this.lookupCredential(credentialKey);
164165
return value
165166
? query.set(paramName, value)

samples/client/others/typescript-angular-v20/builds/query-param-form/configuration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface ConfigurationParameters {
56
/**
@@ -159,7 +160,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
159160
: headers;
160161
}
161162

162-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
163+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
163164
const value = this.lookupCredential(credentialKey);
164165
return value
165166
? query.set(paramName, value)

samples/client/others/typescript-angular-v20/builds/query-param-json/configuration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface ConfigurationParameters {
56
/**
@@ -159,7 +160,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
159160
: headers;
160161
}
161162

162-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
163+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
163164
const value = this.lookupCredential(credentialKey);
164165
return value
165166
? query.set(paramName, value)

samples/client/others/typescript-angular/builds/composed-schemas-tagged-unions/configuration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface ConfigurationParameters {
56
/**
@@ -159,7 +160,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
159160
: headers;
160161
}
161162

162-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
163+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
163164
const value = this.lookupCredential(credentialKey);
164165
return value
165166
? query.set(paramName, value)

samples/client/others/typescript-angular/builds/composed-schemas/configuration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface ConfigurationParameters {
56
/**
@@ -159,7 +160,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
159160
: headers;
160161
}
161162

162-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
163+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
163164
const value = this.lookupCredential(credentialKey);
164165
return value
165166
? query.set(paramName, value)

samples/client/petstore/typescript-angular-v16-provided-in-root/builds/default/configuration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface ConfigurationParameters {
56
/**
@@ -179,7 +180,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
179180
: headers;
180181
}
181182

182-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
183+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
183184
const value = this.lookupCredential(credentialKey);
184185
return value
185186
? query.set(paramName, value)

samples/client/petstore/typescript-angular-v17-provided-in-root/builds/default/configuration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface ConfigurationParameters {
56
/**
@@ -179,7 +180,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
179180
: headers;
180181
}
181182

182-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
183+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
183184
const value = this.lookupCredential(credentialKey);
184185
return value
185186
? query.set(paramName, value)

samples/client/petstore/typescript-angular-v18-provided-in-root/builds/default/configuration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface ConfigurationParameters {
56
/**
@@ -179,7 +180,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
179180
: headers;
180181
}
181182

182-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
183+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
183184
const value = this.lookupCredential(credentialKey);
184185
return value
185186
? query.set(paramName, value)

samples/client/petstore/typescript-angular-v19-provided-in-root/builds/default/configuration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HttpHeaders, HttpParams, HttpParameterCodec } from '@angular/common/http';
1+
import { HttpHeaders, HttpParameterCodec } from '@angular/common/http';
22
import { Param } from './param';
3+
import { OpenApiHttpParams } from './query.params';
34

45
export interface ConfigurationParameters {
56
/**
@@ -179,7 +180,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder,
179180
: headers;
180181
}
181182

182-
public addCredentialToQuery(credentialKey: string, paramName: string, query: HttpParams): HttpParams {
183+
public addCredentialToQuery(credentialKey: string, paramName: string, query: OpenApiHttpParams): OpenApiHttpParams {
183184
const value = this.lookupCredential(credentialKey);
184185
return value
185186
? query.set(paramName, value)

0 commit comments

Comments
 (0)