diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 0408e69b81d..2be16cfd637 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -132,8 +132,10 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo supportingFiles.add(new SupportingFile("index.mustache", "index.ts")); // models + // TODO: properly set model and api packages this.setModelPackage(""); - this.modelTemplateFiles.put("models.mustache", ".ts"); + supportingFiles.add(new SupportingFile("ObjectSerializer.mustache", "models", "ObjectSerializer.ts")); + modelTemplateFiles.put("model.mustache", ".ts"); // api this.setApiPackage(""); diff --git a/modules/openapi-generator/src/main/resources/typescript/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/ObjectSerializer.mustache new file mode 100644 index 00000000000..842c4a89691 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/ObjectSerializer.mustache @@ -0,0 +1,156 @@ +{{#models}} +{{#model}} +export * from './{{{ classFilename }}}'; +{{/model}} +{{/models}} + +{{#models}} +{{#model}} +import { {{classname}} } from './{{{ classFilename }}}'; +{{/model}} +{{/models}} + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: {[index: string]: any} = { + {{#models}} + {{#model}} + {{#hasEnums}} + {{#vars}} + {{#isEnum}} + {{#isContainer}}"{{classname}}.{{enumName}}": {{classname}}.{{enumName}}{{/isContainer}}{{#isNotContainer}}"{{datatypeWithEnum}}": {{datatypeWithEnum}}{{/isNotContainer}}, + {{/isEnum}} + {{/vars}} + {{/hasEnums}} + {{/model}} + {{/models}} +} + +let typeMap: {[index: string]: any} = { + {{#models}} + {{#model}} + "{{classname}}": {{classname}}, + {{/model}} + {{/models}} +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap[expectedType]) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return data.toISOString(); + } else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + } + + public static deserialize(data: any, type: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap[type]) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + } +} diff --git a/modules/openapi-generator/src/main/resources/typescript/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api.mustache index 3dd5268a4b1..fe7e4ea7ea4 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api.mustache @@ -1,39 +1,61 @@ // TODO: better import syntax? -import { BaseApiRequestFactory } from './baseapi'; -import { RequestContext } from '../http/http'; +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import { RequestContext, HttpMethod } from '../http/http'; +import {ObjectSerializer} from '../models/ObjectSerializer'; {{#imports}} import { {{classname}} } from '..{{filename}}'; {{/imports}} - - - {{#operations}} -/** - * {{classname}} - interface{{#description}} - * {{&description}}{{/description}} - * @export - * @interface {{classname}} - */ -export class {{classname}}RequestFactory { +export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof {{classname}}Interface - */ public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): RequestContext { + {{#allParams}} + {{#required}} + // verify required parameter '{{paramName}}' is not null or undefined + if ({{paramName}} === null || {{paramName}} === undefined) { + throw new RequiredError('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); + } + + {{/required}} + {{/allParams}} + + // Path Params + const localVarPath = '{{{path}}}'{{#pathParams}} + .replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}}; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.{{httpMethod}}); + + // Query Params + {{#queryParams}} + if ({{paramName}} !== undefined) { + requestContext.setQueryParam("{{basename}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); + } + {{/queryParams}} + + // Header Params + {{#headerParams}} + requestContext.setHeaderParam("{{basename}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}")); + {{/headerParams}} + + let localVarUseFormData = false; + + // Form Params + + WE ARE HERE TODO! + let authMethod = null; + + // Apply auth methods + {{#authMethods}} + authMethod = this.configuration.authMethods["{{name}}"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } + {{/authMethods}} - - return null; + return requestContext; } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index 90a7171b6f5..815c5b09642 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -33,16 +33,11 @@ export class NoAuthentication extends SecurityAuthentication { } export class APIKeyAuthentication extends SecurityAuthentication { - private apiKey: string; - public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie") { + public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { super(authName); } - - public setApiKey(apiKey: string) { - this.apiKey = apiKey; - } - + public applySecurityAuthentication(context: RequestContext) { if (this.keyLocation === "header") { context.setHeaderParam(this.paramName, this.apiKey); @@ -53,19 +48,13 @@ export class APIKeyAuthentication extends SecurityAuthentication { } } } +// TODO: guarantee that auth was configured properly export class HttpBasicAuthentication extends SecurityAuthentication { - private username: string; - private password: string; - public constructor(authName: string) { + public constructor(authName: string, private username: string, private password: string) { super(authName); } - - public setUserNameAndPassword(username: string, password: string) { - this.username = username; - this.password = password; - } public applySecurityAuthentication(context: RequestContext) { let comb = this.username + ":" + this.password; @@ -73,10 +62,49 @@ export class HttpBasicAuthentication extends SecurityAuthentication { } } -// TODO: add oauth2 -// TODO: check ^last -export const authMethods = { +export class OAuth2Authentication extends SecurityAuthentication { + public constructor(authName: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } +} + +export type AuthMethods = { {{#authMethods}} - "{{name}}": {{#isApiKey}}new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}){{/isApiKey}}{{#isBasic}}new HttpBasicAuthentication("{{keyParamName}}"){{/isBasic}}{{#isOAuth}}null{{/isOAuth}}{{^last}},{{/last}} + "{{name}}"?: {{#isApiKey}}APIKeyAuthentication{{/isApiKey}}{{#isHttp}}HttpBasicAuthentication{{/isHttp}}{{#isOAuth}}OAuth2Authentication{{/isOAuth}}, {{/authMethods}} } + +export type ApiKeyConfiguration = string; +export type HttpBasicConfiguration = { "username": string, "password": string }; +export type OAuth2Configuration = string; + +export type AuthMethodsConfiguration = { {{#authMethods}}"{{name}}"?:{{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isHttp}}HttpBasicConfiguration{{/isHttp}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}, {{/authMethods}} } + +export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = { + } + + if (!conf) { + return authMethods; + } + + {{#authMethods}} + if (conf["{{name}}"]) { + {{#isApiKey}} + authMethods["{{name}}"] = new APIKeyAuthentication("{{name}}", "{{keyParamName}}", {{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, conf["{{name}}"]); + {{/isApiKey}} + {{#isBasic}} + authMethods["{{name}}"] = new HttpBasicAuthentication("{{name}}", config["{{name}}"]["username"], config["{{name}}"]["password"]); + {{/isBasic}} + {{#isOAuth}} + authMethods["{{name}}"] = new OAuth2Authentication("{{name}}"); + {{/isOAuth}} + } + + {{/authMethods}} + return authMethods; +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index a9a25e5952d..c672e9a4d00 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -2,16 +2,14 @@ import {HttpLibrary} from './http/http'; import {Middleware} from './middleware'; import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; import {ServerConfiguration, servers} from './servers'; +import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; + export interface ConfigurationParameters { baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests - - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security + authMethods?: AuthMethodsConfiguration } export class Configuration { @@ -19,23 +17,12 @@ export class Configuration { baseServer: ServerConfiguration; httpApi: HttpLibrary; middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - + authMethods: AuthMethods; + constructor(conf: ConfigurationParameters = {}) { this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers[0]; this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; - if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; - } - if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; - } + this.authMethods = configureAuthMethods(conf.authMethods); } } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model.mustache new file mode 100644 index 00000000000..0b3ca758916 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/model.mustache @@ -0,0 +1,69 @@ +{{>licenseInfo}} +{{#models}} +{{#model}} +{{#tsImports}} +import { {{classname}} } from './{{filename}}'; +{{/tsImports}} + +{{#description}} +/** +* {{{description}}} +*/ +{{/description}} +export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ +{{#vars}} +{{#description}} + /** + * {{{description}}} + */ +{{/description}} + '{{name}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}; +{{/vars}} + + {{#discriminator}} + static discriminator: string | undefined = "{{discriminatorName}}"; + {{/discriminator}} + {{^discriminator}} + static discriminator: string | undefined = undefined; + {{/discriminator}} + + {{^isArrayModel}} + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + {{#vars}} + { + "name": "{{name}}", + "baseName": "{{baseName}}", + "type": "{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}" + }{{#hasMore}}, + {{/hasMore}} + {{/vars}} + ]; + + static getAttributeTypeMap() { + {{#parent}} + return super.getAttributeTypeMap().concat({{classname}}.attributeTypeMap); + {{/parent}} + {{^parent}} + return {{classname}}.attributeTypeMap; + {{/parent}} + } + {{/isArrayModel}} +} + +{{#hasEnums}} +export namespace {{classname}} { +{{#vars}} +{{#isEnum}} + export enum {{enumName}} { + {{#allowableValues}} + {{#enumVars}} + {{name}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} + } +{{/isEnum}} +{{/vars}} +} +{{/hasEnums}} +{{/model}} +{{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache deleted file mode 100644 index 5fa32c28b88..00000000000 --- a/modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache +++ /dev/null @@ -1,12 +0,0 @@ -/** - * {{{description}}} - * @export - * @enum {string} - */ -export enum {{classname}} { -{{#allowableValues}} -{{#enumVars}} - {{{name}}} = {{{value}}}{{^-last}},{{/-last}} -{{/enumVars}} -{{/allowableValues}} -} diff --git a/modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache deleted file mode 100644 index d4ba9f7b862..00000000000 --- a/modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache +++ /dev/null @@ -1,41 +0,0 @@ -/** - * {{{description}}} - * @export - * @interface {{classname}} - */ -export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ -{{#additionalPropertiesType}} - [key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}}; - -{{/additionalPropertiesType}} -{{#vars}} - /** - * {{{description}}} - * @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%> - * @memberof {{classname}} - */ - {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}; -{{/vars}} -}{{#hasEnums}} - -/** - * @export - * @namespace {{classname}} - */ -export namespace {{classname}} { -{{#vars}} - {{#isEnum}} - /** - * @export - * @enum {string} - */ - export enum {{enumName}} { - {{#allowableValues}} - {{#enumVars}} - {{{name}}} = {{{value}}}{{^-last}},{{/-last}} - {{/enumVars}} - {{/allowableValues}} - } - {{/isEnum}} -{{/vars}} -}{{/hasEnums}} diff --git a/modules/openapi-generator/src/main/resources/typescript/models.mustache b/modules/openapi-generator/src/main/resources/typescript/models.mustache deleted file mode 100644 index b39583e15a4..00000000000 --- a/modules/openapi-generator/src/main/resources/typescript/models.mustache +++ /dev/null @@ -1,15 +0,0 @@ -// tslint:disable -{{>licenseInfo}} -{{#models}} -{{#model}} -{{#imports}} -import { {{.}} } from './{{.}}'; -{{/imports}} -{{#isEnum}} -{{>modelEnum}} -{{/isEnum}} -{{^isEnum}} -{{>modelGeneric}} -{{/isEnum}} -{{/model}} -{{/models}} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 2ce0fb93bd3..83dd80c8f2b 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -1,134 +1,255 @@ // TODO: better import syntax? -import { BaseApiRequestFactory } from './baseapi'; -import { RequestContext } from '../http/http'; +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import { RequestContext, HttpMethod } from '../http/http'; +import {ObjectSerializer} from '../models/ObjectSerializer'; import { ApiResponse } from '../models/ApiResponse'; import { Pet } from '../models/Pet'; +export class PetApiRequestFactory extends BaseAPIRequestFactory { - - -/** - * PetApi - interface - * @export - * @interface PetApi - */ -export class PetApiRequestFactory { - - /** - * - * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public addPet(pet: Pet, options?: any): RequestContext { + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling addPet.'); + } + + + // Path Params + const localVarPath = '/pet'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public deletePet(petId: number, apiKey?: string, options?: any): RequestContext { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling deletePet.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + + requestContext.setHeaderParam("", ObjectSerializer.serialize(apiKey, "string")); + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } - /** - * Multiple status values can be provided with comma separated strings - * @summary Finds Pets by status - * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): RequestContext { + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new RequiredError('Required parameter status was null or undefined when calling findPetsByStatus.'); + } + + + // Path Params + const localVarPath = '/pet/findByStatus'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + if (status !== undefined) { + requestContext.setQueryParam("", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>")); + } + + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @summary Finds Pets by tags - * @param {Array} tags Tags to filter by - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public findPetsByTags(tags: Array, options?: any): RequestContext { + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new RequiredError('Required parameter tags was null or undefined when calling findPetsByTags.'); + } + + + // Path Params + const localVarPath = '/pet/findByTags'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + if (tags !== undefined) { + requestContext.setQueryParam("", ObjectSerializer.serialize(tags, "Array")); + } + + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } - /** - * Returns a single pet - * @summary Find pet by ID - * @param {number} petId ID of pet to return - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public getPetById(petId: number, options?: any): RequestContext { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling getPetById.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } - /** - * - * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public updatePet(pet: Pet, options?: any): RequestContext { + // verify required parameter 'pet' is not null or undefined + if (pet === null || pet === undefined) { + throw new RequiredError('Required parameter pet was null or undefined when calling updatePet.'); + } + + + // Path Params + const localVarPath = '/pet'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } - /** - * - * @summary Updates a pet in the store with form data - * @param {number} petId ID of pet that needs to be updated - * @param {string} [name] Updated name of the pet - * @param {string} [status] Updated status of the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public updatePetWithForm(petId: number, name?: string, status?: string, options?: any): RequestContext { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } - /** - * - * @summary uploads an image - * @param {number} petId ID of pet to update - * @param {string} [additionalMetadata] Additional data to pass to server - * @param {any} [file] file to upload - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): RequestContext { + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new RequiredError('Required parameter petId was null or undefined when calling uploadFile.'); + } + + + // Path Params + const localVarPath = '/pet/{petId}/uploadImage' + .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["petstore_auth"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } } diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 7f5eada6f40..436d73d1f77 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -1,71 +1,110 @@ // TODO: better import syntax? -import { BaseApiRequestFactory } from './baseapi'; -import { RequestContext } from '../http/http'; +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import { RequestContext, HttpMethod } from '../http/http'; +import {ObjectSerializer} from '../models/ObjectSerializer'; import { Order } from '../models/Order'; +export class StoreApiRequestFactory extends BaseAPIRequestFactory { - - -/** - * StoreApi - interface - * @export - * @interface StoreApi - */ -export class StoreApiRequestFactory { - - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @summary Delete purchase order by ID - * @param {string} orderId ID of the order that needs to be deleted - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ public deleteOrder(orderId: string, options?: any): RequestContext { + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling deleteOrder.'); + } + + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ public getInventory(options?: any): RequestContext { + + // Path Params + const localVarPath = '/store/inventory'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods + authMethod = this.configuration.authMethods["api_key"] + if (authMethod) { + authMethod.applySecurityAuthentication(requestContext); + } - return null; + return requestContext; } - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @summary Find purchase order by ID - * @param {number} orderId ID of pet that needs to be fetched - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ public getOrderById(orderId: number, options?: any): RequestContext { + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new RequiredError('Required parameter orderId was null or undefined when calling getOrderById.'); + } + + + // Path Params + const localVarPath = '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ public placeOrder(order: Order, options?: any): RequestContext { + // verify required parameter 'order' is not null or undefined + if (order === null || order === undefined) { + throw new RequiredError('Required parameter order was null or undefined when calling placeOrder.'); + } + + + // Path Params + const localVarPath = '/store/order'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } } diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index ec03ee79f79..3ce46788d92 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -1,129 +1,225 @@ // TODO: better import syntax? -import { BaseApiRequestFactory } from './baseapi'; -import { RequestContext } from '../http/http'; +import { BaseAPIRequestFactory, RequiredError } from './baseapi'; +import { RequestContext, HttpMethod } from '../http/http'; +import {ObjectSerializer} from '../models/ObjectSerializer'; import { User } from '../models/User'; +export class UserApiRequestFactory extends BaseAPIRequestFactory { - - -/** - * UserApi - interface - * @export - * @interface UserApi - */ -export class UserApiRequestFactory { - - /** - * This can only be done by the logged in user. - * @summary Create user - * @param {User} user Created user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public createUser(user: User, options?: any): RequestContext { + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUser.'); + } + + + // Path Params + const localVarPath = '/user'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public createUsersWithArrayInput(user: Array, options?: any): RequestContext { + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithArrayInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithArray'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public createUsersWithListInput(user: Array, options?: any): RequestContext { + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling createUsersWithListInput.'); + } + + + // Path Params + const localVarPath = '/user/createWithList'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * This can only be done by the logged in user. - * @summary Delete user - * @param {string} username The name that needs to be deleted - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public deleteUser(username: string, options?: any): RequestContext { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling deleteUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * - * @summary Get user by user name - * @param {string} username The name that needs to be fetched. Use user1 for testing. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public getUserByName(username: string, options?: any): RequestContext { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling getUserByName.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * - * @summary Logs user into the system - * @param {string} username The user name for login - * @param {string} password The password for login in clear text - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public loginUser(username: string, password: string, options?: any): RequestContext { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling loginUser.'); + } + + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new RequiredError('Required parameter password was null or undefined when calling loginUser.'); + } + + + // Path Params + const localVarPath = '/user/login'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + if (username !== undefined) { + requestContext.setQueryParam("", ObjectSerializer.serialize(username, "string")); + } + + if (password !== undefined) { + requestContext.setQueryParam("", ObjectSerializer.serialize(password, "string")); + } + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public logoutUser(options?: any): RequestContext { + + // Path Params + const localVarPath = '/user/logout'; + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } - /** - * This can only be done by the logged in user. - * @summary Updated user - * @param {string} username name that need to be deleted - * @param {User} user Updated user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ public updateUser(username: string, user: User, options?: any): RequestContext { + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new RequiredError('Required parameter username was null or undefined when calling updateUser.'); + } + + // verify required parameter 'user' is not null or undefined + if (user === null || user === undefined) { + throw new RequiredError('Required parameter user was null or undefined when calling updateUser.'); + } + + + // Path Params + const localVarPath = '/user/{username}' + .replace('{' + 'username' + '}', encodeURIComponent(String(username))); + + // Make Request Context + const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + + + // Form Params + + + let authMethod = null; + + // Apply auth methods - return null; + return requestContext; } } diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts deleted file mode 100644 index b9e34a1f536..00000000000 --- a/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts +++ /dev/null @@ -1,96 +0,0 @@ -// TODO: better import syntax? - -import { ApiResponse } from '../'; -import { Pet } from '../'; -/** - * PetApi - interface - * @export - * @interface PetApi - */ -export interface PetApiInterface { - /** - * - * @summary Add a new pet to the store - * @param {Pet} pet Pet object that needs to be added to the store - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - addPet(pet: Pet, options?: any): Promise<{}>; - - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - deletePet(petId: number, apiKey?: string, options?: any): Promise<{}>; - - /** - * Multiple status values can be provided with comma separated strings - * @summary Finds Pets by status - * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): Promise>; - - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @summary Finds Pets by tags - * @param {Array} tags Tags to filter by - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - findPetsByTags(tags: Array, options?: any): Promise>; - - /** - * Returns a single pet - * @summary Find pet by ID - * @param {number} petId ID of pet to return - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - getPetById(petId: number, options?: any): Promise; - - /** - * - * @summary Update an existing pet - * @param {Pet} pet Pet object that needs to be added to the store - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - updatePet(pet: Pet, options?: any): Promise<{}>; - - /** - * - * @summary Updates a pet in the store with form data - * @param {number} petId ID of pet that needs to be updated - * @param {string} [name] Updated name of the pet - * @param {string} [status] Updated status of the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise<{}>; - - /** - * - * @summary uploads an image - * @param {number} petId ID of pet to update - * @param {string} [additionalMetadata] Additional data to pass to server - * @param {any} [file] file to upload - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApiInterface - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): Promise; - -} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts deleted file mode 100644 index d289d721768..00000000000 --- a/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts +++ /dev/null @@ -1,49 +0,0 @@ -// TODO: better import syntax? - -import { Order } from '../'; -/** - * StoreApi - interface - * @export - * @interface StoreApi - */ -export interface StoreApiInterface { - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @summary Delete purchase order by ID - * @param {string} orderId ID of the order that needs to be deleted - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ - deleteOrder(orderId: string, options?: any): Promise<{}>; - - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ - getInventory(options?: any): Promise<{ [key: string]: number; }>; - - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @summary Find purchase order by ID - * @param {number} orderId ID of pet that needs to be fetched - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ - getOrderById(orderId: number, options?: any): Promise; - - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApiInterface - */ - placeOrder(order: Order, options?: any): Promise; - -} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts deleted file mode 100644 index 6d763d78505..00000000000 --- a/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts +++ /dev/null @@ -1,91 +0,0 @@ -// TODO: better import syntax? - -import { User } from '../'; -/** - * UserApi - interface - * @export - * @interface UserApi - */ -export interface UserApiInterface { - /** - * This can only be done by the logged in user. - * @summary Create user - * @param {User} user Created user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - createUser(user: User, options?: any): Promise<{}>; - - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - createUsersWithArrayInput(user: Array, options?: any): Promise<{}>; - - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - createUsersWithListInput(user: Array, options?: any): Promise<{}>; - - /** - * This can only be done by the logged in user. - * @summary Delete user - * @param {string} username The name that needs to be deleted - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - deleteUser(username: string, options?: any): Promise<{}>; - - /** - * - * @summary Get user by user name - * @param {string} username The name that needs to be fetched. Use user1 for testing. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - getUserByName(username: string, options?: any): Promise; - - /** - * - * @summary Logs user into the system - * @param {string} username The user name for login - * @param {string} password The password for login in clear text - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - loginUser(username: string, password: string, options?: any): Promise; - - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - logoutUser(options?: any): Promise<{}>; - - /** - * This can only be done by the logged in user. - * @summary Updated user - * @param {string} username name that need to be deleted - * @param {User} user Updated user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface - */ - updateUser(username: string, user: User, options?: any): Promise<{}>; - -} diff --git a/samples/client/petstore/typescript/builds/default/auth/auth.ts b/samples/client/petstore/typescript/builds/default/auth/auth.ts index 17c80b1d75a..a04aeb110da 100644 --- a/samples/client/petstore/typescript/builds/default/auth/auth.ts +++ b/samples/client/petstore/typescript/builds/default/auth/auth.ts @@ -33,16 +33,11 @@ export class NoAuthentication extends SecurityAuthentication { } export class APIKeyAuthentication extends SecurityAuthentication { - private apiKey: string; - public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie") { + public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) { super(authName); } - - public setApiKey(apiKey: string) { - this.apiKey = apiKey; - } - + public applySecurityAuthentication(context: RequestContext) { if (this.keyLocation === "header") { context.setHeaderParam(this.paramName, this.apiKey); @@ -53,19 +48,13 @@ export class APIKeyAuthentication extends SecurityAuthentication { } } } +// TODO: guarantee that auth was configured properly export class HttpBasicAuthentication extends SecurityAuthentication { - private username: string; - private password: string; - public constructor(authName: string) { + public constructor(authName: string, private username: string, private password: string) { super(authName); } - - public setUserNameAndPassword(username: string, password: string) { - this.username = username; - this.password = password; - } public applySecurityAuthentication(context: RequestContext) { let comb = this.username + ":" + this.password; @@ -73,8 +62,42 @@ export class HttpBasicAuthentication extends SecurityAuthentication { } } -// TODO: add oauth2 -export const authMethods = { - "api_key": new APIKeyAuthentication("api_key", "api_key", "header"), - "petstore_auth": null, +export class OAuth2Authentication extends SecurityAuthentication { + public constructor(authName: string) { + super(authName); + } + + public applySecurityAuthentication(context: RequestContext) { + // TODO + } } + +export type AuthMethods = { + "api_key"?: APIKeyAuthentication, + "petstore_auth"?: OAuth2Authentication, +} + +export type ApiKeyConfiguration = string; +export type HttpBasicConfiguration = { "username": string, "password": string }; +export type OAuth2Configuration = string; + +export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, } + +export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = { + } + + if (!conf) { + return authMethods; + } + + if (conf["api_key"]) { + authMethods["api_key"] = new APIKeyAuthentication("api_key", "api_key", "header", conf["api_key"]); + } + + if (conf["petstore_auth"]) { + authMethods["petstore_auth"] = new OAuth2Authentication("petstore_auth"); + } + + return authMethods; +} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/configuration.ts b/samples/client/petstore/typescript/builds/default/configuration.ts index a9a25e5952d..c672e9a4d00 100644 --- a/samples/client/petstore/typescript/builds/default/configuration.ts +++ b/samples/client/petstore/typescript/builds/default/configuration.ts @@ -2,16 +2,14 @@ import {HttpLibrary} from './http/http'; import {Middleware} from './middleware'; import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch"; import {ServerConfiguration, servers} from './servers'; +import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth'; + export interface ConfigurationParameters { baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests - - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security + authMethods?: AuthMethodsConfiguration } export class Configuration { @@ -19,23 +17,12 @@ export class Configuration { baseServer: ServerConfiguration; httpApi: HttpLibrary; middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - + authMethods: AuthMethods; + constructor(conf: ConfigurationParameters = {}) { this.baseServer = conf.baseServer !== undefined ? conf.baseServer : servers[0]; this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch? this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; - if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; - } - if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; - } + this.authMethods = configureAuthMethods(conf.authMethods); } } \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts index 45f839a03ab..2624f2e5065 100644 --- a/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -1,30 +1,36 @@ -// tslint:disable /* TODO: LICENSE INFO */ + /** - * Describes the result of uploading an image resource - * @export - * @interface ApiResponse - */ -export interface ApiResponse { - /** - * - * @type {number} - * @memberof ApiResponse - */ - code?: number; - /** - * - * @type {string} - * @memberof ApiResponse - */ - type?: string; - /** - * - * @type {string} - * @memberof ApiResponse - */ - message?: string; +* Describes the result of uploading an image resource +*/ +export class ApiResponse { + 'code'?: number; + 'type'?: string; + 'message'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "code", + "baseName": "code", + "type": "number" + }, + { + "name": "type", + "baseName": "type", + "type": "string" + }, + { + "name": "message", + "baseName": "message", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return ApiResponse.attributeTypeMap; + } } diff --git a/samples/client/petstore/typescript/builds/default/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/Category.ts index c950f45dfcc..f16c4fb2ea7 100644 --- a/samples/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript/builds/default/models/Category.ts @@ -1,24 +1,30 @@ -// tslint:disable /* TODO: LICENSE INFO */ + /** - * A category for a pet - * @export - * @interface Category - */ -export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; +* A category for a pet +*/ +export class Category { + 'id'?: number; + 'name'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return Category.attributeTypeMap; + } } diff --git a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts new file mode 100644 index 00000000000..f1ef2d30044 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -0,0 +1,150 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; + +import { ApiResponse } from './ApiResponse'; +import { Category } from './Category'; +import { Order } from './Order'; +import { Pet } from './Pet'; +import { Tag } from './Tag'; +import { User } from './User'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: {[index: string]: any} = { + "Order.StatusEnum": Order.StatusEnum, + "Pet.StatusEnum": Pet.StatusEnum, +} + +let typeMap: {[index: string]: any} = { + "ApiResponse": ApiResponse, + "Category": Category, + "Order": Order, + "Pet": Pet, + "Tag": Tag, + "User": User, +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap[expectedType]) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return data.toISOString(); + } else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + } + + public static deserialize(data: any, type: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap[type]) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + } +} diff --git a/samples/client/petstore/typescript/builds/default/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/Order.ts index d2699e865ee..8527b6f208f 100644 --- a/samples/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript/builds/default/models/Order.ts @@ -1,64 +1,64 @@ -// tslint:disable /* TODO: LICENSE INFO */ -/** - * An order for a pets from the pet store - * @export - * @interface Order - */ -export interface Order { - /** - * - * @type {number} - * @memberof Order - */ - id?: number; - /** - * - * @type {number} - * @memberof Order - */ - petId?: number; - /** - * - * @type {number} - * @memberof Order - */ - quantity?: number; - /** - * - * @type {Date} - * @memberof Order - */ - shipDate?: Date; - /** - * Order Status - * @type {string} - * @memberof Order - */ - status?: Order.StatusEnum; - /** - * - * @type {boolean} - * @memberof Order - */ - complete?: boolean; -} /** - * @export - * @namespace Order - */ -export namespace Order { +* An order for a pets from the pet store +*/ +export class Order { + 'id'?: number; + 'petId'?: number; + 'quantity'?: number; + 'shipDate'?: Date; /** - * @export - * @enum {string} - */ + * Order Status + */ + 'status'?: Order.StatusEnum; + 'complete'?: boolean; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "petId", + "baseName": "petId", + "type": "number" + }, + { + "name": "quantity", + "baseName": "quantity", + "type": "number" + }, + { + "name": "shipDate", + "baseName": "shipDate", + "type": "Date" + }, + { + "name": "status", + "baseName": "status", + "type": "Order.StatusEnum" + }, + { + "name": "complete", + "baseName": "complete", + "type": "boolean" + } ]; + + static getAttributeTypeMap() { + return Order.attributeTypeMap; + } +} + +export namespace Order { export enum StatusEnum { Placed = 'placed', Approved = 'approved', Delivered = 'delivered' } } - diff --git a/samples/client/petstore/typescript/builds/default/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/Pet.ts index 529d264a31e..793b68f75e8 100644 --- a/samples/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript/builds/default/models/Pet.ts @@ -1,66 +1,64 @@ -// tslint:disable /* TODO: LICENSE INFO */ -import { Category } from './Category'; -import { Tag } from './Tag'; -/** - * A pet for sale in the pet store - * @export - * @interface Pet - */ -export interface Pet { - /** - * - * @type {number} - * @memberof Pet - */ - id?: number; - /** - * - * @type {Category} - * @memberof Pet - */ - category?: Category; - /** - * - * @type {string} - * @memberof Pet - */ - name: string; - /** - * - * @type {Array} - * @memberof Pet - */ - photoUrls: Array; - /** - * - * @type {Array} - * @memberof Pet - */ - tags?: Array; - /** - * pet status in the store - * @type {string} - * @memberof Pet - */ - status?: Pet.StatusEnum; -} /** - * @export - * @namespace Pet - */ -export namespace Pet { +* A pet for sale in the pet store +*/ +export class Pet { + 'id'?: number; + 'category'?: Category; + 'name': string; + 'photoUrls': Array; + 'tags'?: Array; /** - * @export - * @enum {string} - */ + * pet status in the store + */ + 'status'?: Pet.StatusEnum; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "category", + "baseName": "category", + "type": "Category" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "photoUrls", + "baseName": "photoUrls", + "type": "Array" + }, + { + "name": "tags", + "baseName": "tags", + "type": "Array" + }, + { + "name": "status", + "baseName": "status", + "type": "Pet.StatusEnum" + } ]; + + static getAttributeTypeMap() { + return Pet.attributeTypeMap; + } +} + +export namespace Pet { export enum StatusEnum { Available = 'available', Pending = 'pending', Sold = 'sold' } } - diff --git a/samples/client/petstore/typescript/builds/default/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/Tag.ts index eb777b1c616..e1434bd3d13 100644 --- a/samples/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript/builds/default/models/Tag.ts @@ -1,24 +1,30 @@ -// tslint:disable /* TODO: LICENSE INFO */ + /** - * A tag for a pet - * @export - * @interface Tag - */ -export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; +* A tag for a pet +*/ +export class Tag { + 'id'?: number; + 'name'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return Tag.attributeTypeMap; + } } diff --git a/samples/client/petstore/typescript/builds/default/models/User.ts b/samples/client/petstore/typescript/builds/default/models/User.ts index 247a8665e8b..15df044dbf8 100644 --- a/samples/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/client/petstore/typescript/builds/default/models/User.ts @@ -1,60 +1,69 @@ -// tslint:disable /* TODO: LICENSE INFO */ + /** - * A User who is purchasing from the pet store - * @export - * @interface User - */ -export interface User { +* A User who is purchasing from the pet store +*/ +export class User { + 'id'?: number; + 'username'?: string; + 'firstName'?: string; + 'lastName'?: string; + 'email'?: string; + 'password'?: string; + 'phone'?: string; /** - * - * @type {number} - * @memberof User - */ - id?: number; - /** - * - * @type {string} - * @memberof User - */ - username?: string; - /** - * - * @type {string} - * @memberof User - */ - firstName?: string; - /** - * - * @type {string} - * @memberof User - */ - lastName?: string; - /** - * - * @type {string} - * @memberof User - */ - email?: string; - /** - * - * @type {string} - * @memberof User - */ - password?: string; - /** - * - * @type {string} - * @memberof User - */ - phone?: string; - /** - * User Status - * @type {number} - * @memberof User - */ - userStatus?: number; + * User Status + */ + 'userStatus'?: number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "username", + "baseName": "username", + "type": "string" + }, + { + "name": "firstName", + "baseName": "firstName", + "type": "string" + }, + { + "name": "lastName", + "baseName": "lastName", + "type": "string" + }, + { + "name": "email", + "baseName": "email", + "type": "string" + }, + { + "name": "password", + "baseName": "password", + "type": "string" + }, + { + "name": "phone", + "baseName": "phone", + "type": "string" + }, + { + "name": "userStatus", + "baseName": "userStatus", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return User.attributeTypeMap; + } } diff --git a/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts deleted file mode 100644 index 45f839a03ab..00000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts +++ /dev/null @@ -1,30 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * Describes the result of uploading an image resource - * @export - * @interface ApiResponse - */ -export interface ApiResponse { - /** - * - * @type {number} - * @memberof ApiResponse - */ - code?: number; - /** - * - * @type {string} - * @memberof ApiResponse - */ - type?: string; - /** - * - * @type {string} - * @memberof ApiResponse - */ - message?: string; -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/models/Category.ts deleted file mode 100644 index c950f45dfcc..00000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/Category.ts +++ /dev/null @@ -1,24 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * A category for a pet - * @export - * @interface Category - */ -export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/models/Order.ts deleted file mode 100644 index d2699e865ee..00000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/Order.ts +++ /dev/null @@ -1,64 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * An order for a pets from the pet store - * @export - * @interface Order - */ -export interface Order { - /** - * - * @type {number} - * @memberof Order - */ - id?: number; - /** - * - * @type {number} - * @memberof Order - */ - petId?: number; - /** - * - * @type {number} - * @memberof Order - */ - quantity?: number; - /** - * - * @type {Date} - * @memberof Order - */ - shipDate?: Date; - /** - * Order Status - * @type {string} - * @memberof Order - */ - status?: Order.StatusEnum; - /** - * - * @type {boolean} - * @memberof Order - */ - complete?: boolean; -} - -/** - * @export - * @namespace Order - */ -export namespace Order { - /** - * @export - * @enum {string} - */ - export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' - } -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/models/Pet.ts deleted file mode 100644 index 529d264a31e..00000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/Pet.ts +++ /dev/null @@ -1,66 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -import { Category } from './Category'; -import { Tag } from './Tag'; -/** - * A pet for sale in the pet store - * @export - * @interface Pet - */ -export interface Pet { - /** - * - * @type {number} - * @memberof Pet - */ - id?: number; - /** - * - * @type {Category} - * @memberof Pet - */ - category?: Category; - /** - * - * @type {string} - * @memberof Pet - */ - name: string; - /** - * - * @type {Array} - * @memberof Pet - */ - photoUrls: Array; - /** - * - * @type {Array} - * @memberof Pet - */ - tags?: Array; - /** - * pet status in the store - * @type {string} - * @memberof Pet - */ - status?: Pet.StatusEnum; -} - -/** - * @export - * @namespace Pet - */ -export namespace Pet { - /** - * @export - * @enum {string} - */ - export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' - } -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/models/Tag.ts deleted file mode 100644 index eb777b1c616..00000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/Tag.ts +++ /dev/null @@ -1,24 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * A tag for a pet - * @export - * @interface Tag - */ -export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; -} - diff --git a/samples/client/petstore/typescript/builds/default/models/models/User.ts b/samples/client/petstore/typescript/builds/default/models/models/User.ts deleted file mode 100644 index 247a8665e8b..00000000000 --- a/samples/client/petstore/typescript/builds/default/models/models/User.ts +++ /dev/null @@ -1,60 +0,0 @@ -// tslint:disable -/* - TODO: LICENSE INFO -*/ -/** - * A User who is purchasing from the pet store - * @export - * @interface User - */ -export interface User { - /** - * - * @type {number} - * @memberof User - */ - id?: number; - /** - * - * @type {string} - * @memberof User - */ - username?: string; - /** - * - * @type {string} - * @memberof User - */ - firstName?: string; - /** - * - * @type {string} - * @memberof User - */ - lastName?: string; - /** - * - * @type {string} - * @memberof User - */ - email?: string; - /** - * - * @type {string} - * @memberof User - */ - password?: string; - /** - * - * @type {string} - * @memberof User - */ - phone?: string; - /** - * User Status - * @type {number} - * @memberof User - */ - userStatus?: number; -} - diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json deleted file mode 100644 index c1d83a3dec0..00000000000 --- a/samples/client/petstore/typescript/builds/default/package-lock.json +++ /dev/null @@ -1,468 +0,0 @@ -{ - "name": "ts-petstore-client", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@types/chai": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.4.tgz", - "integrity": "sha512-h6+VEw2Vr3ORiFCyyJmcho2zALnUq9cvdB/IO8Xs9itrJVCenC7o26A6+m7D0ihTTr65eS259H5/Ghl/VjYs6g==", - "dev": true - }, - "@types/form-data": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", - "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", - "requires": { - "@types/node": "*" - } - }, - "@types/isomorphic-fetch": { - "version": "0.0.34", - "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", - "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" - }, - "@types/mocha": { - "version": "5.2.5", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.5.tgz", - "integrity": "sha512-lAVp+Kj54ui/vLUFxsJTMtWvZraZxum3w3Nwkble2dNuV5VnPA+Mi2oGX9XYJAaIvZi3tn3cbjS/qcJXRb6Bww==", - "dev": true - }, - "@types/node": { - "version": "10.5.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.8.tgz", - "integrity": "sha512-sWSjw+bYW/2W+1V3m8tVsm9PKJcxk3NHN7oRqNUfEdofKg0Imbdu1dQbFvLKjZQXEDXRN6IfSMACjJ7Wv4NGCQ==" - }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "btoa": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", - "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" - }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true - }, - "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", - "dev": true, - "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^3.0.0", - "get-func-name": "^2.0.0", - "pathval": "^1.0.0", - "type-detect": "^4.0.0" - } - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, - "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "requires": { - "type-detect": "^4.0.0" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "~0.4.13" - } - }, - "es6-promise": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==" - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "1.0.6", - "mime-types": "^2.1.12" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", - "requires": { - "node-fetch": "^1.0.1", - "whatwg-fetch": ">=0.10.0" - } - }, - "make-error": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", - "integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==", - "dev": true - }, - "mime-db": { - "version": "1.35.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", - "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" - }, - "mime-types": { - "version": "2.1.19", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", - "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", - "requires": { - "mime-db": "~1.35.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "dev": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", - "dev": true - }, - "querystringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.0.0.tgz", - "integrity": "sha512-eTPo5t/4bgaMNZxyjWx6N2a6AuE0mq51KWvpc7nU/MAqixcI6v6KrGUKES0HaomdnolQBBXU/++X6/QQ9KL4tw==" - }, - "requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - }, - "source-map-support": { - "version": "0.5.8", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.8.tgz", - "integrity": "sha512-WqAEWPdb78u25RfKzOF0swBpY0dKrNdjc4GvLwm7ScX/o9bj8Eh/YL8mcMhBHYDGl87UkkSXDOFnW4G7GhWhGg==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "ts-node": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", - "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", - "dev": true, - "requires": { - "arrify": "^1.0.0", - "buffer-from": "^1.1.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.5.6", - "yn": "^2.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, - "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", - "dev": true - }, - "url-parse": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz", - "integrity": "sha512-rh+KuAW36YKo0vClhQzLLveoj8FwPJNu65xLb7Mrt+eZht0IPT0IXgSv8gcMegZ6NvjJUALf6Mf25POlMwD1Fw==", - "requires": { - "querystringify": "^2.0.0", - "requires-port": "^1.0.0" - } - }, - "whatwg-fetch": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", - "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "yn": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", - "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=", - "dev": true - } - } -} diff --git a/samples/client/petstore/typescript/builds/default/servers.ts b/samples/client/petstore/typescript/builds/default/servers.ts index e91a7c80ff7..7cc55b40db0 100644 --- a/samples/client/petstore/typescript/builds/default/servers.ts +++ b/samples/client/petstore/typescript/builds/default/servers.ts @@ -11,5 +11,5 @@ export class ServerConfiguration { } export const servers = [ - new ServerConfiguration("/"), + new ServerConfiguration("http://petstore.swagger.io/v2"), ]