forked from loafle/openapi-generator-original
[BUG][typescript-rxjs] Fix nully type coalescing in Configuration getters (#5329)
* [typescript-rxjs] fix coalescing in Configuration
- eliminate nully "" (empty string) value via conditional check
- use concrete "string" type in typeof check
("function" may be returned for Object types
* [typescript-rxjs] update petstore sample
* run petstore-all
- run the script for updating all petstores
./bin/typescript-rxjs-petstore-all.sh
This commit is contained in:
@@ -36,12 +36,18 @@ export class Configuration {
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
return apiKey && (typeof apiKey === 'function' ? apiKey : () => apiKey);
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof apiKey === 'string' ? () => apiKey : apiKey;
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
return accessToken && (typeof accessToken === 'function' ? accessToken : () => accessToken);
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof accessToken === 'string' ? () => accessToken : accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,12 +47,18 @@ export class Configuration {
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
return apiKey && (typeof apiKey === 'function' ? apiKey : () => apiKey);
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof apiKey === 'string' ? () => apiKey : apiKey;
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
return accessToken && (typeof accessToken === 'function' ? accessToken : () => accessToken);
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof accessToken === 'string' ? () => accessToken : accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,12 +47,18 @@ export class Configuration {
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
return apiKey && (typeof apiKey === 'function' ? apiKey : () => apiKey);
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof apiKey === 'string' ? () => apiKey : apiKey;
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
return accessToken && (typeof accessToken === 'function' ? accessToken : () => accessToken);
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof accessToken === 'string' ? () => accessToken : accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,12 +47,18 @@ export class Configuration {
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
return apiKey && (typeof apiKey === 'function' ? apiKey : () => apiKey);
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof apiKey === 'string' ? () => apiKey : apiKey;
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
return accessToken && (typeof accessToken === 'function' ? accessToken : () => accessToken);
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof accessToken === 'string' ? () => accessToken : accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,12 +47,18 @@ export class Configuration {
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
return apiKey && (typeof apiKey === 'function' ? apiKey : () => apiKey);
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof apiKey === 'string' ? () => apiKey : apiKey;
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
return accessToken && (typeof accessToken === 'function' ? accessToken : () => accessToken);
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof accessToken === 'string' ? () => accessToken : accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user