forked from loafle/openapi-generator-original
[Typescript] Support http bearer authentication with token provider (#6425)
* Add http bearer security * Update typescript to 3.9 * Fix: Use Authorization header for basic and bearer * Allow asynchronous tokenProvider in bearer auth
This commit is contained in:
parent
33c8d19564
commit
ae8c1be09d
@ -33,7 +33,7 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
|
|||||||
* @param {{paramName}} {{description}}
|
* @param {{paramName}} {{description}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
*/
|
*/
|
||||||
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): RequestContext {
|
public async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
|
|
||||||
@ -120,22 +120,22 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
|
|||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
{{/bodyParam}}
|
{{/bodyParam}}
|
||||||
|
|
||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
authMethod = config.authMethods["{{name}}"]
|
authMethod = config.authMethods["{{name}}"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ export abstract class SecurityAuthentication {
|
|||||||
*
|
*
|
||||||
* @params context the request context which should use this authentication scheme
|
* @params context the request context which should use this authentication scheme
|
||||||
*/
|
*/
|
||||||
public abstract applySecurityAuthentication(context: RequestContext): void;
|
public abstract applySecurityAuthentication(context: RequestContext): void | Promise<void>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,10 +95,35 @@ export class HttpBasicAuthentication extends SecurityAuthentication {
|
|||||||
|
|
||||||
public applySecurityAuthentication(context: RequestContext) {
|
public applySecurityAuthentication(context: RequestContext) {
|
||||||
let comb = this.username + ":" + this.password;
|
let comb = this.username + ":" + this.password;
|
||||||
context.setHeaderParam("Authentication", "Basic " + btoa(comb));
|
context.setHeaderParam("Authorization", "Basic " + btoa(comb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TokenProvider {
|
||||||
|
getToken(): Promise<string> | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies http bearer authentication to a request.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class HttpBearerAuthentication extends SecurityAuthentication {
|
||||||
|
/**
|
||||||
|
* Configures the http authentication with the required details.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param authName name of the authentication scheme as defined in openapi specification
|
||||||
|
* @param tokenProvider service that can provide the up-to-date token when needed
|
||||||
|
*/
|
||||||
|
public constructor(authName: string, private tokenProvider: TokenProvider) {
|
||||||
|
super(authName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async applySecurityAuthentication(context: RequestContext) {
|
||||||
|
context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: How to handle oauth2 authentication!
|
// TODO: How to handle oauth2 authentication!
|
||||||
export class OAuth2Authentication extends SecurityAuthentication {
|
export class OAuth2Authentication extends SecurityAuthentication {
|
||||||
public constructor(authName: string) {
|
public constructor(authName: string) {
|
||||||
@ -112,36 +137,39 @@ export class OAuth2Authentication extends SecurityAuthentication {
|
|||||||
|
|
||||||
export type AuthMethods = {
|
export type AuthMethods = {
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
"{{name}}"?: {{#isApiKey}}APIKeyAuthentication{{/isApiKey}}{{#isHttp}}HttpBasicAuthentication{{/isHttp}}{{#isOAuth}}OAuth2Authentication{{/isOAuth}},
|
"{{name}}"?: {{#isApiKey}}APIKeyAuthentication{{/isApiKey}}{{#isBasicBasic}}HttpBasicAuthentication{{/isBasicBasic}}{{#isBasicBearer}}HttpBearerAuthentication{{/isBasicBearer}}{{#isOAuth}}OAuth2Authentication{{/isOAuth}},
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ApiKeyConfiguration = string;
|
export type ApiKeyConfiguration = string;
|
||||||
export type HttpBasicConfiguration = { "username": string, "password": string };
|
export type HttpBasicConfiguration = { "username": string, "password": string };
|
||||||
|
export type HttpBearerConfiguration = { tokenProvider: TokenProvider };
|
||||||
export type OAuth2Configuration = string;
|
export type OAuth2Configuration = string;
|
||||||
|
|
||||||
export type AuthMethodsConfiguration = { {{#authMethods}}"{{name}}"?:{{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isHttp}}HttpBasicConfiguration{{/isHttp}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}, {{/authMethods}} }
|
export type AuthMethodsConfiguration = { {{#authMethods}}"{{name}}"?:{{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isBasicBasic}}HttpBasicConfiguration{{/isBasicBasic}}{{#isBasicBearer}}HttpBearerConfiguration{{/isBasicBearer}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}, {{/authMethods}} }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the authentication methods from a swagger description.
|
* Creates the authentication methods from a swagger description.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods {
|
export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods {
|
||||||
let authMethods: AuthMethods = {
|
let authMethods: AuthMethods = {}
|
||||||
}
|
|
||||||
|
|
||||||
if (!conf) {
|
if (!config) {
|
||||||
return authMethods;
|
return authMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
if (conf["{{name}}"]) {
|
if (config["{{name}}"]) {
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
authMethods["{{name}}"] = new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, <string> conf["{{name}}"]);
|
authMethods["{{name}}"] = new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, <string> config["{{name}}"]);
|
||||||
{{/isApiKey}}
|
{{/isApiKey}}
|
||||||
{{#isBasic}}
|
{{#isBasicBasic}}
|
||||||
authMethods["{{name}}"] = new HttpBasicAuthentication("{{name}}", config["{{name}}"]["username"], config["{{name}}"]["password"]);
|
authMethods["{{name}}"] = new HttpBasicAuthentication("{{name}}", config["{{name}}"]["username"], config["{{name}}"]["password"]);
|
||||||
{{/isBasic}}
|
{{/isBasicBasic}}
|
||||||
|
{{#isBasicBearer}}
|
||||||
|
authMethods["{{name}}"] = new HttpBearerAuthentication("{{name}}", config["{{name}}"]["tokenProvider"]);
|
||||||
|
{{/isBasicBearer}}
|
||||||
{{#isOAuth}}
|
{{#isOAuth}}
|
||||||
authMethods["{{name}}"] = new OAuth2Authentication("{{name}}");
|
authMethods["{{name}}"] = new OAuth2Authentication("{{name}}");
|
||||||
{{/isOAuth}}
|
{{/isOAuth}}
|
||||||
|
@ -172,7 +172,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
|
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.addEventListener("load", () => resolve(reader.result));
|
reader.addEventListener("load", () => resolve(reader.result as string));
|
||||||
reader.addEventListener("error", () => reject(reader.error));
|
reader.addEventListener("error", () => reject(reader.error));
|
||||||
reader.readAsText(data);
|
reader.readAsText(data);
|
||||||
});
|
});
|
||||||
|
@ -6,25 +6,17 @@ import {RequestContext, HttpMethod} from './http/http';
|
|||||||
* url template and variable configuration based on the url.
|
* url template and variable configuration based on the url.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export class ServerConfiguration<T> {
|
export class ServerConfiguration<T extends { [key: string]: string }> {
|
||||||
|
public constructor(private url: string, private variableConfiguration: T) {}
|
||||||
public constructor(private url: string, private variableConfiguration: T) {
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the variables of this server.
|
||||||
|
*
|
||||||
|
* @param variableConfiguration a partial variable configuration for the variables contained in the url
|
||||||
|
*/
|
||||||
|
public setVariables(variableConfiguration: Partial<T>) {
|
||||||
|
Object.assign(this.variableConfiguration, variableConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the variables of this server.
|
|
||||||
*
|
|
||||||
* @param variableConfiguration a partial variable configuration for the variables contained in the url
|
|
||||||
*/
|
|
||||||
public setVariables(variableConfiguration: Partial<T>) {
|
|
||||||
for (const key in variableConfiguration) {
|
|
||||||
const val = variableConfiguration[key]
|
|
||||||
// We know that val isn't undefined here - hopefully
|
|
||||||
if (val !== undefined) {
|
|
||||||
this.variableConfiguration[key] = val as T[Extract<keyof T, string>];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getConfiguration(): T {
|
public getConfiguration(): T {
|
||||||
return this.variableConfiguration
|
return this.variableConfiguration
|
||||||
@ -34,7 +26,7 @@ export class ServerConfiguration<T> {
|
|||||||
let replacedUrl = this.url;
|
let replacedUrl = this.url;
|
||||||
for (const key in this.variableConfiguration) {
|
for (const key in this.variableConfiguration) {
|
||||||
var re = new RegExp("{" + key + "}","g");
|
var re = new RegExp("{" + key + "}","g");
|
||||||
replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key].toString());
|
replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]);
|
||||||
}
|
}
|
||||||
return replacedUrl
|
return replacedUrl
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^2.9.2"
|
"typescript": "^3.9.3"
|
||||||
}{{#npmRepository}},{{/npmRepository}}
|
}{{#npmRepository}},{{/npmRepository}}
|
||||||
{{#npmRepository}}
|
{{#npmRepository}}
|
||||||
"publishConfig":{
|
"publishConfig":{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { ResponseContext, RequestContext, HttpFile } from '../http/http';
|
import { ResponseContext, RequestContext, HttpFile } from '../http/http';
|
||||||
import * as models from '../models/all';
|
import * as models from '../models/all';
|
||||||
import { Configuration} from '../configuration'
|
import { Configuration} from '../configuration'
|
||||||
import { Observable, of } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}};
|
import { Observable, of, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}};
|
||||||
import {mergeMap, map} from {{#useRxJS}}'rxjs/operators'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}};
|
import {mergeMap, map} from {{#useRxJS}}'rxjs/operators'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}};
|
||||||
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
@ -38,10 +38,10 @@ export class Observable{{classname}} {
|
|||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
*/
|
*/
|
||||||
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: Configuration): Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
||||||
const requestContext = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options);
|
const requestContextPromise = this.requestFactory.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
public addPet(pet: Pet, options?: Configuration): RequestContext {
|
public async addPet(pet: Pet, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'pet' is not null or undefined
|
// verify required parameter 'pet' is not null or undefined
|
||||||
@ -54,23 +54,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
* @param petId Pet id to delete
|
* @param petId Pet id to delete
|
||||||
* @param apiKey
|
* @param apiKey
|
||||||
*/
|
*/
|
||||||
public deletePet(petId: number, apiKey?: string, options?: Configuration): RequestContext {
|
public async deletePet(petId: number, apiKey?: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'petId' is not null or undefined
|
// verify required parameter 'petId' is not null or undefined
|
||||||
@ -97,23 +97,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiple status values can be provided with comma separated strings
|
* Multiple status values can be provided with comma separated strings
|
||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
* @param status Status values that need to be considered for filter
|
* @param status Status values that need to be considered for filter
|
||||||
*/
|
*/
|
||||||
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): RequestContext {
|
public async findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'status' is not null or undefined
|
// verify required parameter 'status' is not null or undefined
|
||||||
@ -140,23 +140,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
* @param tags Tags to filter by
|
* @param tags Tags to filter by
|
||||||
*/
|
*/
|
||||||
public findPetsByTags(tags: Array<string>, options?: Configuration): RequestContext {
|
public async findPetsByTags(tags: Array<string>, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'tags' is not null or undefined
|
// verify required parameter 'tags' is not null or undefined
|
||||||
@ -183,23 +183,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a single pet
|
* Returns a single pet
|
||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
* @param petId ID of pet to return
|
* @param petId ID of pet to return
|
||||||
*/
|
*/
|
||||||
public getPetById(petId: number, options?: Configuration): RequestContext {
|
public async getPetById(petId: number, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'petId' is not null or undefined
|
// verify required parameter 'petId' is not null or undefined
|
||||||
@ -224,22 +224,22 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
public updatePet(pet: Pet, options?: Configuration): RequestContext {
|
public async updatePet(pet: Pet, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'pet' is not null or undefined
|
// verify required parameter 'pet' is not null or undefined
|
||||||
@ -274,24 +274,24 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
* @param petId ID of pet that needs to be updated
|
* @param petId ID of pet that needs to be updated
|
||||||
* @param name Updated name of the pet
|
* @param name Updated name of the pet
|
||||||
* @param status Updated status of the pet
|
* @param status Updated status of the pet
|
||||||
*/
|
*/
|
||||||
public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): RequestContext {
|
public async updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'petId' is not null or undefined
|
// verify required parameter 'petId' is not null or undefined
|
||||||
@ -328,24 +328,24 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
requestContext.setBody(localVarFormParams);
|
requestContext.setBody(localVarFormParams);
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uploads an image
|
* uploads an image
|
||||||
* @param petId ID of pet to update
|
* @param petId ID of pet to update
|
||||||
* @param additionalMetadata Additional data to pass to server
|
* @param additionalMetadata Additional data to pass to server
|
||||||
* @param file file to upload
|
* @param file file to upload
|
||||||
*/
|
*/
|
||||||
public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): RequestContext {
|
public async uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'petId' is not null or undefined
|
// verify required parameter 'petId' is not null or undefined
|
||||||
@ -382,17 +382,17 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
requestContext.setBody(localVarFormParams);
|
requestContext.setBody(localVarFormParams);
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
* Delete purchase order by ID
|
* Delete purchase order by ID
|
||||||
* @param orderId ID of the order that needs to be deleted
|
* @param orderId ID of the order that needs to be deleted
|
||||||
*/
|
*/
|
||||||
public deleteOrder(orderId: string, options?: Configuration): RequestContext {
|
public async deleteOrder(orderId: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'orderId' is not null or undefined
|
// verify required parameter 'orderId' is not null or undefined
|
||||||
@ -44,17 +44,17 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map of status codes to quantities
|
* Returns a map of status codes to quantities
|
||||||
* Returns pet inventories by status
|
* Returns pet inventories by status
|
||||||
*/
|
*/
|
||||||
public getInventory(options?: Configuration): RequestContext {
|
public async getInventory(options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// Path Params
|
// Path Params
|
||||||
@ -72,23 +72,23 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
* Find purchase order by ID
|
* Find purchase order by ID
|
||||||
* @param orderId ID of pet that needs to be fetched
|
* @param orderId ID of pet that needs to be fetched
|
||||||
*/
|
*/
|
||||||
public getOrderById(orderId: number, options?: Configuration): RequestContext {
|
public async getOrderById(orderId: number, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'orderId' is not null or undefined
|
// verify required parameter 'orderId' is not null or undefined
|
||||||
@ -113,17 +113,17 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
* @param order order placed for purchasing the pet
|
* @param order order placed for purchasing the pet
|
||||||
*/
|
*/
|
||||||
public placeOrder(order: Order, options?: Configuration): RequestContext {
|
public async placeOrder(order: Order, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'order' is not null or undefined
|
// verify required parameter 'order' is not null or undefined
|
||||||
@ -156,12 +156,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
* Create user
|
* Create user
|
||||||
* @param user Created user object
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
public createUser(user: User, options?: Configuration): RequestContext {
|
public async createUser(user: User, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'user' is not null or undefined
|
// verify required parameter 'user' is not null or undefined
|
||||||
@ -52,22 +52,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
public createUsersWithArrayInput(user: Array<User>, options?: Configuration): RequestContext {
|
public async createUsersWithArrayInput(user: Array<User>, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'user' is not null or undefined
|
// verify required parameter 'user' is not null or undefined
|
||||||
@ -100,22 +100,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
public createUsersWithListInput(user: Array<User>, options?: Configuration): RequestContext {
|
public async createUsersWithListInput(user: Array<User>, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'user' is not null or undefined
|
// verify required parameter 'user' is not null or undefined
|
||||||
@ -148,23 +148,23 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
* Delete user
|
* Delete user
|
||||||
* @param username The name that needs to be deleted
|
* @param username The name that needs to be deleted
|
||||||
*/
|
*/
|
||||||
public deleteUser(username: string, options?: Configuration): RequestContext {
|
public async deleteUser(username: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'username' is not null or undefined
|
// verify required parameter 'username' is not null or undefined
|
||||||
@ -189,22 +189,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user by user name
|
* Get user by user name
|
||||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
*/
|
*/
|
||||||
public getUserByName(username: string, options?: Configuration): RequestContext {
|
public async getUserByName(username: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'username' is not null or undefined
|
// verify required parameter 'username' is not null or undefined
|
||||||
@ -229,18 +229,18 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs user into the system
|
* Logs user into the system
|
||||||
* @param username The user name for login
|
* @param username The user name for login
|
||||||
* @param password The password for login in clear text
|
* @param password The password for login in clear text
|
||||||
*/
|
*/
|
||||||
public loginUser(username: string, password: string, options?: Configuration): RequestContext {
|
public async loginUser(username: string, password: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'username' is not null or undefined
|
// verify required parameter 'username' is not null or undefined
|
||||||
@ -276,16 +276,16 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out current logged in user session
|
* Logs out current logged in user session
|
||||||
*/
|
*/
|
||||||
public logoutUser(options?: Configuration): RequestContext {
|
public async logoutUser(options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// Path Params
|
// Path Params
|
||||||
@ -303,24 +303,24 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
* Updated user
|
* Updated user
|
||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param user Updated user object
|
* @param user Updated user object
|
||||||
*/
|
*/
|
||||||
public updateUser(username: string, user: User, options?: Configuration): RequestContext {
|
public async updateUser(username: string, user: User, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'username' is not null or undefined
|
// verify required parameter 'username' is not null or undefined
|
||||||
@ -360,17 +360,17 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ export abstract class SecurityAuthentication {
|
|||||||
*
|
*
|
||||||
* @params context the request context which should use this authentication scheme
|
* @params context the request context which should use this authentication scheme
|
||||||
*/
|
*/
|
||||||
public abstract applySecurityAuthentication(context: RequestContext): void;
|
public abstract applySecurityAuthentication(context: RequestContext): void | Promise<void>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,10 +95,35 @@ export class HttpBasicAuthentication extends SecurityAuthentication {
|
|||||||
|
|
||||||
public applySecurityAuthentication(context: RequestContext) {
|
public applySecurityAuthentication(context: RequestContext) {
|
||||||
let comb = this.username + ":" + this.password;
|
let comb = this.username + ":" + this.password;
|
||||||
context.setHeaderParam("Authentication", "Basic " + btoa(comb));
|
context.setHeaderParam("Authorization", "Basic " + btoa(comb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TokenProvider {
|
||||||
|
getToken(): Promise<string> | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies http bearer authentication to a request.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class HttpBearerAuthentication extends SecurityAuthentication {
|
||||||
|
/**
|
||||||
|
* Configures the http authentication with the required details.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param authName name of the authentication scheme as defined in openapi specification
|
||||||
|
* @param tokenProvider service that can provide the up-to-date token when needed
|
||||||
|
*/
|
||||||
|
public constructor(authName: string, private tokenProvider: TokenProvider) {
|
||||||
|
super(authName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async applySecurityAuthentication(context: RequestContext) {
|
||||||
|
context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: How to handle oauth2 authentication!
|
// TODO: How to handle oauth2 authentication!
|
||||||
export class OAuth2Authentication extends SecurityAuthentication {
|
export class OAuth2Authentication extends SecurityAuthentication {
|
||||||
public constructor(authName: string) {
|
public constructor(authName: string) {
|
||||||
@ -117,6 +142,7 @@ export type AuthMethods = {
|
|||||||
|
|
||||||
export type ApiKeyConfiguration = string;
|
export type ApiKeyConfiguration = string;
|
||||||
export type HttpBasicConfiguration = { "username": string, "password": string };
|
export type HttpBasicConfiguration = { "username": string, "password": string };
|
||||||
|
export type HttpBearerConfiguration = { tokenProvider: TokenProvider };
|
||||||
export type OAuth2Configuration = string;
|
export type OAuth2Configuration = string;
|
||||||
|
|
||||||
export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, }
|
export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, }
|
||||||
@ -125,19 +151,18 @@ export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petst
|
|||||||
* Creates the authentication methods from a swagger description.
|
* Creates the authentication methods from a swagger description.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods {
|
export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods {
|
||||||
let authMethods: AuthMethods = {
|
let authMethods: AuthMethods = {}
|
||||||
|
|
||||||
|
if (!config) {
|
||||||
|
return authMethods;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config["api_key"]) {
|
||||||
|
authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", <string> config["api_key"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!conf) {
|
if (config["petstore_auth"]) {
|
||||||
return authMethods;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conf["api_key"]) {
|
|
||||||
authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", <string> conf["api_key"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conf["petstore_auth"]) {
|
|
||||||
authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth");
|
authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +97,9 @@
|
|||||||
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
|
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
|
||||||
},
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "2.9.2",
|
"version": "3.9.3",
|
||||||
"resolved": false,
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz",
|
||||||
"integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==",
|
"integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"url-parse": {
|
"url-parse": {
|
||||||
|
@ -26,6 +26,6 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^2.9.2"
|
"typescript": "^3.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,25 +6,17 @@ import {RequestContext, HttpMethod} from './http/http';
|
|||||||
* url template and variable configuration based on the url.
|
* url template and variable configuration based on the url.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export class ServerConfiguration<T> {
|
export class ServerConfiguration<T extends { [key: string]: string }> {
|
||||||
|
public constructor(private url: string, private variableConfiguration: T) {}
|
||||||
public constructor(private url: string, private variableConfiguration: T) {
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the variables of this server.
|
||||||
|
*
|
||||||
|
* @param variableConfiguration a partial variable configuration for the variables contained in the url
|
||||||
|
*/
|
||||||
|
public setVariables(variableConfiguration: Partial<T>) {
|
||||||
|
Object.assign(this.variableConfiguration, variableConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the variables of this server.
|
|
||||||
*
|
|
||||||
* @param variableConfiguration a partial variable configuration for the variables contained in the url
|
|
||||||
*/
|
|
||||||
public setVariables(variableConfiguration: Partial<T>) {
|
|
||||||
for (const key in variableConfiguration) {
|
|
||||||
const val = variableConfiguration[key]
|
|
||||||
// We know that val isn't undefined here - hopefully
|
|
||||||
if (val !== undefined) {
|
|
||||||
this.variableConfiguration[key] = val as T[Extract<keyof T, string>];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getConfiguration(): T {
|
public getConfiguration(): T {
|
||||||
return this.variableConfiguration
|
return this.variableConfiguration
|
||||||
@ -34,7 +26,7 @@ export class ServerConfiguration<T> {
|
|||||||
let replacedUrl = this.url;
|
let replacedUrl = this.url;
|
||||||
for (const key in this.variableConfiguration) {
|
for (const key in this.variableConfiguration) {
|
||||||
var re = new RegExp("{" + key + "}","g");
|
var re = new RegExp("{" + key + "}","g");
|
||||||
replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key].toString());
|
replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]);
|
||||||
}
|
}
|
||||||
return replacedUrl
|
return replacedUrl
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { ResponseContext, RequestContext, HttpFile } from '../http/http';
|
import { ResponseContext, RequestContext, HttpFile } from '../http/http';
|
||||||
import * as models from '../models/all';
|
import * as models from '../models/all';
|
||||||
import { Configuration} from '../configuration'
|
import { Configuration} from '../configuration'
|
||||||
import { Observable, of } from '../rxjsStub';
|
import { Observable, of, from } from '../rxjsStub';
|
||||||
import {mergeMap, map} from '../rxjsStub';
|
import {mergeMap, map} from '../rxjsStub';
|
||||||
|
|
||||||
import { ApiResponse } from '../models/ApiResponse';
|
import { ApiResponse } from '../models/ApiResponse';
|
||||||
@ -30,10 +30,10 @@ export class ObservablePetApi {
|
|||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
public addPet(pet: Pet, options?: Configuration): Observable<Pet> {
|
public addPet(pet: Pet, options?: Configuration): Observable<Pet> {
|
||||||
const requestContext = this.requestFactory.addPet(pet, options);
|
const requestContextPromise = this.requestFactory.addPet(pet, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -54,10 +54,10 @@ export class ObservablePetApi {
|
|||||||
* @param apiKey
|
* @param apiKey
|
||||||
*/
|
*/
|
||||||
public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable<void> {
|
public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.deletePet(petId, apiKey, options);
|
const requestContextPromise = this.requestFactory.deletePet(petId, apiKey, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -78,10 +78,10 @@ export class ObservablePetApi {
|
|||||||
* @param status Status values that need to be considered for filter
|
* @param status Status values that need to be considered for filter
|
||||||
*/
|
*/
|
||||||
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable<Array<Pet>> {
|
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable<Array<Pet>> {
|
||||||
const requestContext = this.requestFactory.findPetsByStatus(status, options);
|
const requestContextPromise = this.requestFactory.findPetsByStatus(status, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -102,10 +102,10 @@ export class ObservablePetApi {
|
|||||||
* @param tags Tags to filter by
|
* @param tags Tags to filter by
|
||||||
*/
|
*/
|
||||||
public findPetsByTags(tags: Array<string>, options?: Configuration): Observable<Array<Pet>> {
|
public findPetsByTags(tags: Array<string>, options?: Configuration): Observable<Array<Pet>> {
|
||||||
const requestContext = this.requestFactory.findPetsByTags(tags, options);
|
const requestContextPromise = this.requestFactory.findPetsByTags(tags, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -126,10 +126,10 @@ export class ObservablePetApi {
|
|||||||
* @param petId ID of pet to return
|
* @param petId ID of pet to return
|
||||||
*/
|
*/
|
||||||
public getPetById(petId: number, options?: Configuration): Observable<Pet> {
|
public getPetById(petId: number, options?: Configuration): Observable<Pet> {
|
||||||
const requestContext = this.requestFactory.getPetById(petId, options);
|
const requestContextPromise = this.requestFactory.getPetById(petId, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -149,10 +149,10 @@ export class ObservablePetApi {
|
|||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
public updatePet(pet: Pet, options?: Configuration): Observable<Pet> {
|
public updatePet(pet: Pet, options?: Configuration): Observable<Pet> {
|
||||||
const requestContext = this.requestFactory.updatePet(pet, options);
|
const requestContextPromise = this.requestFactory.updatePet(pet, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -174,10 +174,10 @@ export class ObservablePetApi {
|
|||||||
* @param status Updated status of the pet
|
* @param status Updated status of the pet
|
||||||
*/
|
*/
|
||||||
public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable<void> {
|
public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options);
|
const requestContextPromise = this.requestFactory.updatePetWithForm(petId, name, status, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -199,10 +199,10 @@ export class ObservablePetApi {
|
|||||||
* @param file file to upload
|
* @param file file to upload
|
||||||
*/
|
*/
|
||||||
public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable<ApiResponse> {
|
public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable<ApiResponse> {
|
||||||
const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options);
|
const requestContextPromise = this.requestFactory.uploadFile(petId, additionalMetadata, file, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -241,10 +241,10 @@ export class ObservableStoreApi {
|
|||||||
* @param orderId ID of the order that needs to be deleted
|
* @param orderId ID of the order that needs to be deleted
|
||||||
*/
|
*/
|
||||||
public deleteOrder(orderId: string, options?: Configuration): Observable<void> {
|
public deleteOrder(orderId: string, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.deleteOrder(orderId, options);
|
const requestContextPromise = this.requestFactory.deleteOrder(orderId, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -264,10 +264,10 @@ export class ObservableStoreApi {
|
|||||||
* Returns pet inventories by status
|
* Returns pet inventories by status
|
||||||
*/
|
*/
|
||||||
public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> {
|
public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> {
|
||||||
const requestContext = this.requestFactory.getInventory(options);
|
const requestContextPromise = this.requestFactory.getInventory(options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -288,10 +288,10 @@ export class ObservableStoreApi {
|
|||||||
* @param orderId ID of pet that needs to be fetched
|
* @param orderId ID of pet that needs to be fetched
|
||||||
*/
|
*/
|
||||||
public getOrderById(orderId: number, options?: Configuration): Observable<Order> {
|
public getOrderById(orderId: number, options?: Configuration): Observable<Order> {
|
||||||
const requestContext = this.requestFactory.getOrderById(orderId, options);
|
const requestContextPromise = this.requestFactory.getOrderById(orderId, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -311,10 +311,10 @@ export class ObservableStoreApi {
|
|||||||
* @param order order placed for purchasing the pet
|
* @param order order placed for purchasing the pet
|
||||||
*/
|
*/
|
||||||
public placeOrder(order: Order, options?: Configuration): Observable<Order> {
|
public placeOrder(order: Order, options?: Configuration): Observable<Order> {
|
||||||
const requestContext = this.requestFactory.placeOrder(order, options);
|
const requestContextPromise = this.requestFactory.placeOrder(order, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -353,10 +353,10 @@ export class ObservableUserApi {
|
|||||||
* @param user Created user object
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
public createUser(user: User, options?: Configuration): Observable<void> {
|
public createUser(user: User, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.createUser(user, options);
|
const requestContextPromise = this.requestFactory.createUser(user, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -376,10 +376,10 @@ export class ObservableUserApi {
|
|||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
public createUsersWithArrayInput(user: Array<User>, options?: Configuration): Observable<void> {
|
public createUsersWithArrayInput(user: Array<User>, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.createUsersWithArrayInput(user, options);
|
const requestContextPromise = this.requestFactory.createUsersWithArrayInput(user, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -399,10 +399,10 @@ export class ObservableUserApi {
|
|||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
public createUsersWithListInput(user: Array<User>, options?: Configuration): Observable<void> {
|
public createUsersWithListInput(user: Array<User>, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.createUsersWithListInput(user, options);
|
const requestContextPromise = this.requestFactory.createUsersWithListInput(user, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -423,10 +423,10 @@ export class ObservableUserApi {
|
|||||||
* @param username The name that needs to be deleted
|
* @param username The name that needs to be deleted
|
||||||
*/
|
*/
|
||||||
public deleteUser(username: string, options?: Configuration): Observable<void> {
|
public deleteUser(username: string, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.deleteUser(username, options);
|
const requestContextPromise = this.requestFactory.deleteUser(username, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -446,10 +446,10 @@ export class ObservableUserApi {
|
|||||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
*/
|
*/
|
||||||
public getUserByName(username: string, options?: Configuration): Observable<User> {
|
public getUserByName(username: string, options?: Configuration): Observable<User> {
|
||||||
const requestContext = this.requestFactory.getUserByName(username, options);
|
const requestContextPromise = this.requestFactory.getUserByName(username, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -470,10 +470,10 @@ export class ObservableUserApi {
|
|||||||
* @param password The password for login in clear text
|
* @param password The password for login in clear text
|
||||||
*/
|
*/
|
||||||
public loginUser(username: string, password: string, options?: Configuration): Observable<string> {
|
public loginUser(username: string, password: string, options?: Configuration): Observable<string> {
|
||||||
const requestContext = this.requestFactory.loginUser(username, password, options);
|
const requestContextPromise = this.requestFactory.loginUser(username, password, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -492,10 +492,10 @@ export class ObservableUserApi {
|
|||||||
* Logs out current logged in user session
|
* Logs out current logged in user session
|
||||||
*/
|
*/
|
||||||
public logoutUser(options?: Configuration): Observable<void> {
|
public logoutUser(options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.logoutUser(options);
|
const requestContextPromise = this.requestFactory.logoutUser(options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -517,10 +517,10 @@ export class ObservableUserApi {
|
|||||||
* @param user Updated user object
|
* @param user Updated user object
|
||||||
*/
|
*/
|
||||||
public updateUser(username: string, user: User, options?: Configuration): Observable<void> {
|
public updateUser(username: string, user: User, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.updateUser(username, user, options);
|
const requestContextPromise = this.requestFactory.updateUser(username, user, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
public addPet(pet: Pet, options?: Configuration): RequestContext {
|
public async addPet(pet: Pet, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'pet' is not null or undefined
|
// verify required parameter 'pet' is not null or undefined
|
||||||
@ -53,23 +53,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
* @param petId Pet id to delete
|
* @param petId Pet id to delete
|
||||||
* @param apiKey
|
* @param apiKey
|
||||||
*/
|
*/
|
||||||
public deletePet(petId: number, apiKey?: string, options?: Configuration): RequestContext {
|
public async deletePet(petId: number, apiKey?: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'petId' is not null or undefined
|
// verify required parameter 'petId' is not null or undefined
|
||||||
@ -96,23 +96,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiple status values can be provided with comma separated strings
|
* Multiple status values can be provided with comma separated strings
|
||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
* @param status Status values that need to be considered for filter
|
* @param status Status values that need to be considered for filter
|
||||||
*/
|
*/
|
||||||
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): RequestContext {
|
public async findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'status' is not null or undefined
|
// verify required parameter 'status' is not null or undefined
|
||||||
@ -139,23 +139,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
* @param tags Tags to filter by
|
* @param tags Tags to filter by
|
||||||
*/
|
*/
|
||||||
public findPetsByTags(tags: Array<string>, options?: Configuration): RequestContext {
|
public async findPetsByTags(tags: Array<string>, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'tags' is not null or undefined
|
// verify required parameter 'tags' is not null or undefined
|
||||||
@ -182,23 +182,23 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a single pet
|
* Returns a single pet
|
||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
* @param petId ID of pet to return
|
* @param petId ID of pet to return
|
||||||
*/
|
*/
|
||||||
public getPetById(petId: number, options?: Configuration): RequestContext {
|
public async getPetById(petId: number, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'petId' is not null or undefined
|
// verify required parameter 'petId' is not null or undefined
|
||||||
@ -223,22 +223,22 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
public updatePet(pet: Pet, options?: Configuration): RequestContext {
|
public async updatePet(pet: Pet, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'pet' is not null or undefined
|
// verify required parameter 'pet' is not null or undefined
|
||||||
@ -273,24 +273,24 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
* @param petId ID of pet that needs to be updated
|
* @param petId ID of pet that needs to be updated
|
||||||
* @param name Updated name of the pet
|
* @param name Updated name of the pet
|
||||||
* @param status Updated status of the pet
|
* @param status Updated status of the pet
|
||||||
*/
|
*/
|
||||||
public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): RequestContext {
|
public async updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'petId' is not null or undefined
|
// verify required parameter 'petId' is not null or undefined
|
||||||
@ -327,24 +327,24 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
requestContext.setBody(localVarFormParams);
|
requestContext.setBody(localVarFormParams);
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uploads an image
|
* uploads an image
|
||||||
* @param petId ID of pet to update
|
* @param petId ID of pet to update
|
||||||
* @param additionalMetadata Additional data to pass to server
|
* @param additionalMetadata Additional data to pass to server
|
||||||
* @param file file to upload
|
* @param file file to upload
|
||||||
*/
|
*/
|
||||||
public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): RequestContext {
|
public async uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'petId' is not null or undefined
|
// verify required parameter 'petId' is not null or undefined
|
||||||
@ -381,17 +381,17 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
requestContext.setBody(localVarFormParams);
|
requestContext.setBody(localVarFormParams);
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["petstore_auth"]
|
authMethod = config.authMethods["petstore_auth"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
* Delete purchase order by ID
|
* Delete purchase order by ID
|
||||||
* @param orderId ID of the order that needs to be deleted
|
* @param orderId ID of the order that needs to be deleted
|
||||||
*/
|
*/
|
||||||
public deleteOrder(orderId: string, options?: Configuration): RequestContext {
|
public async deleteOrder(orderId: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'orderId' is not null or undefined
|
// verify required parameter 'orderId' is not null or undefined
|
||||||
@ -43,17 +43,17 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map of status codes to quantities
|
* Returns a map of status codes to quantities
|
||||||
* Returns pet inventories by status
|
* Returns pet inventories by status
|
||||||
*/
|
*/
|
||||||
public getInventory(options?: Configuration): RequestContext {
|
public async getInventory(options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// Path Params
|
// Path Params
|
||||||
@ -71,23 +71,23 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
* Find purchase order by ID
|
* Find purchase order by ID
|
||||||
* @param orderId ID of pet that needs to be fetched
|
* @param orderId ID of pet that needs to be fetched
|
||||||
*/
|
*/
|
||||||
public getOrderById(orderId: number, options?: Configuration): RequestContext {
|
public async getOrderById(orderId: number, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'orderId' is not null or undefined
|
// verify required parameter 'orderId' is not null or undefined
|
||||||
@ -112,17 +112,17 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
* @param order order placed for purchasing the pet
|
* @param order order placed for purchasing the pet
|
||||||
*/
|
*/
|
||||||
public placeOrder(order: Order, options?: Configuration): RequestContext {
|
public async placeOrder(order: Order, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'order' is not null or undefined
|
// verify required parameter 'order' is not null or undefined
|
||||||
@ -155,12 +155,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
* Create user
|
* Create user
|
||||||
* @param user Created user object
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
public createUser(user: User, options?: Configuration): RequestContext {
|
public async createUser(user: User, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'user' is not null or undefined
|
// verify required parameter 'user' is not null or undefined
|
||||||
@ -51,22 +51,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
public createUsersWithArrayInput(user: Array<User>, options?: Configuration): RequestContext {
|
public async createUsersWithArrayInput(user: Array<User>, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'user' is not null or undefined
|
// verify required parameter 'user' is not null or undefined
|
||||||
@ -99,22 +99,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
public createUsersWithListInput(user: Array<User>, options?: Configuration): RequestContext {
|
public async createUsersWithListInput(user: Array<User>, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'user' is not null or undefined
|
// verify required parameter 'user' is not null or undefined
|
||||||
@ -147,23 +147,23 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
* Delete user
|
* Delete user
|
||||||
* @param username The name that needs to be deleted
|
* @param username The name that needs to be deleted
|
||||||
*/
|
*/
|
||||||
public deleteUser(username: string, options?: Configuration): RequestContext {
|
public async deleteUser(username: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'username' is not null or undefined
|
// verify required parameter 'username' is not null or undefined
|
||||||
@ -188,22 +188,22 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user by user name
|
* Get user by user name
|
||||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
*/
|
*/
|
||||||
public getUserByName(username: string, options?: Configuration): RequestContext {
|
public async getUserByName(username: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'username' is not null or undefined
|
// verify required parameter 'username' is not null or undefined
|
||||||
@ -228,18 +228,18 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs user into the system
|
* Logs user into the system
|
||||||
* @param username The user name for login
|
* @param username The user name for login
|
||||||
* @param password The password for login in clear text
|
* @param password The password for login in clear text
|
||||||
*/
|
*/
|
||||||
public loginUser(username: string, password: string, options?: Configuration): RequestContext {
|
public async loginUser(username: string, password: string, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'username' is not null or undefined
|
// verify required parameter 'username' is not null or undefined
|
||||||
@ -275,16 +275,16 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out current logged in user session
|
* Logs out current logged in user session
|
||||||
*/
|
*/
|
||||||
public logoutUser(options?: Configuration): RequestContext {
|
public async logoutUser(options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// Path Params
|
// Path Params
|
||||||
@ -302,24 +302,24 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
|
|
||||||
// Body Params
|
// Body Params
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
* Updated user
|
* Updated user
|
||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param user Updated user object
|
* @param user Updated user object
|
||||||
*/
|
*/
|
||||||
public updateUser(username: string, user: User, options?: Configuration): RequestContext {
|
public async updateUser(username: string, user: User, options?: Configuration): Promise<RequestContext> {
|
||||||
let config = options || this.configuration;
|
let config = options || this.configuration;
|
||||||
|
|
||||||
// verify required parameter 'username' is not null or undefined
|
// verify required parameter 'username' is not null or undefined
|
||||||
@ -359,17 +359,17 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
contentType
|
contentType
|
||||||
);
|
);
|
||||||
requestContext.setBody(serializedBody);
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
let authMethod = null;
|
let authMethod = null;
|
||||||
// Apply auth methods
|
// Apply auth methods
|
||||||
authMethod = config.authMethods["api_key"]
|
authMethod = config.authMethods["api_key"]
|
||||||
if (authMethod) {
|
if (authMethod) {
|
||||||
authMethod.applySecurityAuthentication(requestContext);
|
await authMethod.applySecurityAuthentication(requestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestContext;
|
return requestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ export abstract class SecurityAuthentication {
|
|||||||
*
|
*
|
||||||
* @params context the request context which should use this authentication scheme
|
* @params context the request context which should use this authentication scheme
|
||||||
*/
|
*/
|
||||||
public abstract applySecurityAuthentication(context: RequestContext): void;
|
public abstract applySecurityAuthentication(context: RequestContext): void | Promise<void>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,10 +95,35 @@ export class HttpBasicAuthentication extends SecurityAuthentication {
|
|||||||
|
|
||||||
public applySecurityAuthentication(context: RequestContext) {
|
public applySecurityAuthentication(context: RequestContext) {
|
||||||
let comb = this.username + ":" + this.password;
|
let comb = this.username + ":" + this.password;
|
||||||
context.setHeaderParam("Authentication", "Basic " + btoa(comb));
|
context.setHeaderParam("Authorization", "Basic " + btoa(comb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TokenProvider {
|
||||||
|
getToken(): Promise<string> | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies http bearer authentication to a request.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class HttpBearerAuthentication extends SecurityAuthentication {
|
||||||
|
/**
|
||||||
|
* Configures the http authentication with the required details.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param authName name of the authentication scheme as defined in openapi specification
|
||||||
|
* @param tokenProvider service that can provide the up-to-date token when needed
|
||||||
|
*/
|
||||||
|
public constructor(authName: string, private tokenProvider: TokenProvider) {
|
||||||
|
super(authName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async applySecurityAuthentication(context: RequestContext) {
|
||||||
|
context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: How to handle oauth2 authentication!
|
// TODO: How to handle oauth2 authentication!
|
||||||
export class OAuth2Authentication extends SecurityAuthentication {
|
export class OAuth2Authentication extends SecurityAuthentication {
|
||||||
public constructor(authName: string) {
|
public constructor(authName: string) {
|
||||||
@ -117,6 +142,7 @@ export type AuthMethods = {
|
|||||||
|
|
||||||
export type ApiKeyConfiguration = string;
|
export type ApiKeyConfiguration = string;
|
||||||
export type HttpBasicConfiguration = { "username": string, "password": string };
|
export type HttpBasicConfiguration = { "username": string, "password": string };
|
||||||
|
export type HttpBearerConfiguration = { tokenProvider: TokenProvider };
|
||||||
export type OAuth2Configuration = string;
|
export type OAuth2Configuration = string;
|
||||||
|
|
||||||
export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, }
|
export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, }
|
||||||
@ -125,19 +151,18 @@ export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petst
|
|||||||
* Creates the authentication methods from a swagger description.
|
* Creates the authentication methods from a swagger description.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods {
|
export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods {
|
||||||
let authMethods: AuthMethods = {
|
let authMethods: AuthMethods = {}
|
||||||
|
|
||||||
|
if (!config) {
|
||||||
|
return authMethods;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config["api_key"]) {
|
||||||
|
authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", <string> config["api_key"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!conf) {
|
if (config["petstore_auth"]) {
|
||||||
return authMethods;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conf["api_key"]) {
|
|
||||||
authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", <string> conf["api_key"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conf["petstore_auth"]) {
|
|
||||||
authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth");
|
authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
|
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.addEventListener("load", () => resolve(reader.result));
|
reader.addEventListener("load", () => resolve(reader.result as string));
|
||||||
reader.addEventListener("error", () => reject(reader.error));
|
reader.addEventListener("error", () => reject(reader.error));
|
||||||
reader.readAsText(data);
|
reader.readAsText(data);
|
||||||
});
|
});
|
||||||
|
@ -43,9 +43,9 @@
|
|||||||
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
|
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
|
||||||
},
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "2.9.2",
|
"version": "3.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz",
|
||||||
"integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==",
|
"integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"url-parse": {
|
"url-parse": {
|
||||||
|
@ -24,6 +24,6 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^2.9.2"
|
"typescript": "^3.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,25 +6,17 @@ import {RequestContext, HttpMethod} from './http/http';
|
|||||||
* url template and variable configuration based on the url.
|
* url template and variable configuration based on the url.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export class ServerConfiguration<T> {
|
export class ServerConfiguration<T extends { [key: string]: string }> {
|
||||||
|
public constructor(private url: string, private variableConfiguration: T) {}
|
||||||
public constructor(private url: string, private variableConfiguration: T) {
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the variables of this server.
|
||||||
|
*
|
||||||
|
* @param variableConfiguration a partial variable configuration for the variables contained in the url
|
||||||
|
*/
|
||||||
|
public setVariables(variableConfiguration: Partial<T>) {
|
||||||
|
Object.assign(this.variableConfiguration, variableConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the variables of this server.
|
|
||||||
*
|
|
||||||
* @param variableConfiguration a partial variable configuration for the variables contained in the url
|
|
||||||
*/
|
|
||||||
public setVariables(variableConfiguration: Partial<T>) {
|
|
||||||
for (const key in variableConfiguration) {
|
|
||||||
const val = variableConfiguration[key]
|
|
||||||
// We know that val isn't undefined here - hopefully
|
|
||||||
if (val !== undefined) {
|
|
||||||
this.variableConfiguration[key] = val as T[Extract<keyof T, string>];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getConfiguration(): T {
|
public getConfiguration(): T {
|
||||||
return this.variableConfiguration
|
return this.variableConfiguration
|
||||||
@ -34,7 +26,7 @@ export class ServerConfiguration<T> {
|
|||||||
let replacedUrl = this.url;
|
let replacedUrl = this.url;
|
||||||
for (const key in this.variableConfiguration) {
|
for (const key in this.variableConfiguration) {
|
||||||
var re = new RegExp("{" + key + "}","g");
|
var re = new RegExp("{" + key + "}","g");
|
||||||
replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key].toString());
|
replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]);
|
||||||
}
|
}
|
||||||
return replacedUrl
|
return replacedUrl
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { ResponseContext, RequestContext, HttpFile } from '../http/http';
|
import { ResponseContext, RequestContext, HttpFile } from '../http/http';
|
||||||
import * as models from '../models/all';
|
import * as models from '../models/all';
|
||||||
import { Configuration} from '../configuration'
|
import { Configuration} from '../configuration'
|
||||||
import { Observable, of } from '../rxjsStub';
|
import { Observable, of, from } from '../rxjsStub';
|
||||||
import {mergeMap, map} from '../rxjsStub';
|
import {mergeMap, map} from '../rxjsStub';
|
||||||
|
|
||||||
import { ApiResponse } from '../models/ApiResponse';
|
import { ApiResponse } from '../models/ApiResponse';
|
||||||
@ -30,10 +30,10 @@ export class ObservablePetApi {
|
|||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
public addPet(pet: Pet, options?: Configuration): Observable<Pet> {
|
public addPet(pet: Pet, options?: Configuration): Observable<Pet> {
|
||||||
const requestContext = this.requestFactory.addPet(pet, options);
|
const requestContextPromise = this.requestFactory.addPet(pet, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -54,10 +54,10 @@ export class ObservablePetApi {
|
|||||||
* @param apiKey
|
* @param apiKey
|
||||||
*/
|
*/
|
||||||
public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable<void> {
|
public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.deletePet(petId, apiKey, options);
|
const requestContextPromise = this.requestFactory.deletePet(petId, apiKey, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -78,10 +78,10 @@ export class ObservablePetApi {
|
|||||||
* @param status Status values that need to be considered for filter
|
* @param status Status values that need to be considered for filter
|
||||||
*/
|
*/
|
||||||
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable<Array<Pet>> {
|
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable<Array<Pet>> {
|
||||||
const requestContext = this.requestFactory.findPetsByStatus(status, options);
|
const requestContextPromise = this.requestFactory.findPetsByStatus(status, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -102,10 +102,10 @@ export class ObservablePetApi {
|
|||||||
* @param tags Tags to filter by
|
* @param tags Tags to filter by
|
||||||
*/
|
*/
|
||||||
public findPetsByTags(tags: Array<string>, options?: Configuration): Observable<Array<Pet>> {
|
public findPetsByTags(tags: Array<string>, options?: Configuration): Observable<Array<Pet>> {
|
||||||
const requestContext = this.requestFactory.findPetsByTags(tags, options);
|
const requestContextPromise = this.requestFactory.findPetsByTags(tags, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -126,10 +126,10 @@ export class ObservablePetApi {
|
|||||||
* @param petId ID of pet to return
|
* @param petId ID of pet to return
|
||||||
*/
|
*/
|
||||||
public getPetById(petId: number, options?: Configuration): Observable<Pet> {
|
public getPetById(petId: number, options?: Configuration): Observable<Pet> {
|
||||||
const requestContext = this.requestFactory.getPetById(petId, options);
|
const requestContextPromise = this.requestFactory.getPetById(petId, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -149,10 +149,10 @@ export class ObservablePetApi {
|
|||||||
* @param pet Pet object that needs to be added to the store
|
* @param pet Pet object that needs to be added to the store
|
||||||
*/
|
*/
|
||||||
public updatePet(pet: Pet, options?: Configuration): Observable<Pet> {
|
public updatePet(pet: Pet, options?: Configuration): Observable<Pet> {
|
||||||
const requestContext = this.requestFactory.updatePet(pet, options);
|
const requestContextPromise = this.requestFactory.updatePet(pet, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -174,10 +174,10 @@ export class ObservablePetApi {
|
|||||||
* @param status Updated status of the pet
|
* @param status Updated status of the pet
|
||||||
*/
|
*/
|
||||||
public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable<void> {
|
public updatePetWithForm(petId: number, name?: string, status?: string, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options);
|
const requestContextPromise = this.requestFactory.updatePetWithForm(petId, name, status, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -199,10 +199,10 @@ export class ObservablePetApi {
|
|||||||
* @param file file to upload
|
* @param file file to upload
|
||||||
*/
|
*/
|
||||||
public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable<ApiResponse> {
|
public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, options?: Configuration): Observable<ApiResponse> {
|
||||||
const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options);
|
const requestContextPromise = this.requestFactory.uploadFile(petId, additionalMetadata, file, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -241,10 +241,10 @@ export class ObservableStoreApi {
|
|||||||
* @param orderId ID of the order that needs to be deleted
|
* @param orderId ID of the order that needs to be deleted
|
||||||
*/
|
*/
|
||||||
public deleteOrder(orderId: string, options?: Configuration): Observable<void> {
|
public deleteOrder(orderId: string, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.deleteOrder(orderId, options);
|
const requestContextPromise = this.requestFactory.deleteOrder(orderId, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -264,10 +264,10 @@ export class ObservableStoreApi {
|
|||||||
* Returns pet inventories by status
|
* Returns pet inventories by status
|
||||||
*/
|
*/
|
||||||
public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> {
|
public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> {
|
||||||
const requestContext = this.requestFactory.getInventory(options);
|
const requestContextPromise = this.requestFactory.getInventory(options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -288,10 +288,10 @@ export class ObservableStoreApi {
|
|||||||
* @param orderId ID of pet that needs to be fetched
|
* @param orderId ID of pet that needs to be fetched
|
||||||
*/
|
*/
|
||||||
public getOrderById(orderId: number, options?: Configuration): Observable<Order> {
|
public getOrderById(orderId: number, options?: Configuration): Observable<Order> {
|
||||||
const requestContext = this.requestFactory.getOrderById(orderId, options);
|
const requestContextPromise = this.requestFactory.getOrderById(orderId, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -311,10 +311,10 @@ export class ObservableStoreApi {
|
|||||||
* @param order order placed for purchasing the pet
|
* @param order order placed for purchasing the pet
|
||||||
*/
|
*/
|
||||||
public placeOrder(order: Order, options?: Configuration): Observable<Order> {
|
public placeOrder(order: Order, options?: Configuration): Observable<Order> {
|
||||||
const requestContext = this.requestFactory.placeOrder(order, options);
|
const requestContextPromise = this.requestFactory.placeOrder(order, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -353,10 +353,10 @@ export class ObservableUserApi {
|
|||||||
* @param user Created user object
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
public createUser(user: User, options?: Configuration): Observable<void> {
|
public createUser(user: User, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.createUser(user, options);
|
const requestContextPromise = this.requestFactory.createUser(user, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -376,10 +376,10 @@ export class ObservableUserApi {
|
|||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
public createUsersWithArrayInput(user: Array<User>, options?: Configuration): Observable<void> {
|
public createUsersWithArrayInput(user: Array<User>, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.createUsersWithArrayInput(user, options);
|
const requestContextPromise = this.requestFactory.createUsersWithArrayInput(user, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -399,10 +399,10 @@ export class ObservableUserApi {
|
|||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
public createUsersWithListInput(user: Array<User>, options?: Configuration): Observable<void> {
|
public createUsersWithListInput(user: Array<User>, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.createUsersWithListInput(user, options);
|
const requestContextPromise = this.requestFactory.createUsersWithListInput(user, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -423,10 +423,10 @@ export class ObservableUserApi {
|
|||||||
* @param username The name that needs to be deleted
|
* @param username The name that needs to be deleted
|
||||||
*/
|
*/
|
||||||
public deleteUser(username: string, options?: Configuration): Observable<void> {
|
public deleteUser(username: string, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.deleteUser(username, options);
|
const requestContextPromise = this.requestFactory.deleteUser(username, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -446,10 +446,10 @@ export class ObservableUserApi {
|
|||||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
*/
|
*/
|
||||||
public getUserByName(username: string, options?: Configuration): Observable<User> {
|
public getUserByName(username: string, options?: Configuration): Observable<User> {
|
||||||
const requestContext = this.requestFactory.getUserByName(username, options);
|
const requestContextPromise = this.requestFactory.getUserByName(username, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -470,10 +470,10 @@ export class ObservableUserApi {
|
|||||||
* @param password The password for login in clear text
|
* @param password The password for login in clear text
|
||||||
*/
|
*/
|
||||||
public loginUser(username: string, password: string, options?: Configuration): Observable<string> {
|
public loginUser(username: string, password: string, options?: Configuration): Observable<string> {
|
||||||
const requestContext = this.requestFactory.loginUser(username, password, options);
|
const requestContextPromise = this.requestFactory.loginUser(username, password, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -492,10 +492,10 @@ export class ObservableUserApi {
|
|||||||
* Logs out current logged in user session
|
* Logs out current logged in user session
|
||||||
*/
|
*/
|
||||||
public logoutUser(options?: Configuration): Observable<void> {
|
public logoutUser(options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.logoutUser(options);
|
const requestContextPromise = this.requestFactory.logoutUser(options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
@ -517,10 +517,10 @@ export class ObservableUserApi {
|
|||||||
* @param user Updated user object
|
* @param user Updated user object
|
||||||
*/
|
*/
|
||||||
public updateUser(username: string, user: User, options?: Configuration): Observable<void> {
|
public updateUser(username: string, user: User, options?: Configuration): Observable<void> {
|
||||||
const requestContext = this.requestFactory.updateUser(username, user, options);
|
const requestContextPromise = this.requestFactory.updateUser(username, user, options);
|
||||||
|
|
||||||
// build promise chain
|
// build promise chain
|
||||||
let middlewarePreObservable = of(requestContext);
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
for (let middleware of this.configuration.middleware) {
|
for (let middleware of this.configuration.middleware) {
|
||||||
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
}
|
}
|
||||||
|
@ -1259,6 +1259,27 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/node-fetch": {
|
||||||
|
"version": "2.5.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz",
|
||||||
|
"integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==",
|
||||||
|
"requires": {
|
||||||
|
"@types/node": "*",
|
||||||
|
"form-data": "^3.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"form-data": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==",
|
||||||
|
"requires": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.8",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"asynckit": {
|
"asynckit": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"bundled": true
|
"bundled": true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user