[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:
Ermolay Romanov 2020-02-18 15:28:26 -05:00 committed by GitHub
parent 4f7d45f603
commit 1ec2c26053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 10 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}