From bd6300b51612023e1ff2982082a2f08d884a4c31 Mon Sep 17 00:00:00 2001 From: James Batt Date: Thu, 12 Jul 2018 18:08:31 +1000 Subject: [PATCH 01/39] added my fork from https://github.com/Place1/swagger-codegen-typescript-browser --- ...ITools.Test.csproj.CoreCompileInputs.cache | 1 + ....Test.csprojResolveAssemblyReference.cache | Bin 0 -> 5893 bytes .../TypeScriptFetchClientCodegen.java | 7 +- .../typescript-fetch/README.mustache | 45 -- .../resources/typescript-fetch/api.mustache | 706 ++++++++++-------- .../typescript-fetch/configuration.mustache | 55 -- .../typescript-fetch/custom.d.mustache | 2 - .../typescript-fetch/git_push.sh.mustache | 51 -- .../main/resources/typescript-fetch/gitignore | 3 - .../resources/typescript-fetch/index.mustache | 5 - .../typescript-fetch/licenseInfo.mustache | 4 +- .../typescript-fetch/modelEnum.mustache | 8 +- .../typescript-fetch/modelGeneric.mustache | 24 +- .../typescript-fetch/package.mustache | 32 - .../typescript-fetch/tsconfig.mustache | 19 - 15 files changed, 402 insertions(+), 560 deletions(-) create mode 100644 CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csproj.CoreCompileInputs.cache create mode 100644 CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csprojResolveAssemblyReference.cache delete mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/README.mustache delete mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/configuration.mustache delete mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/custom.d.mustache delete mode 100755 modules/openapi-generator/src/main/resources/typescript-fetch/git_push.sh.mustache delete mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/gitignore delete mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/index.mustache delete mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache delete mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/tsconfig.mustache diff --git a/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csproj.CoreCompileInputs.cache b/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csproj.CoreCompileInputs.cache new file mode 100644 index 000000000000..4096123585d5 --- /dev/null +++ b/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +c2fcc2ae9693a8e8d02b25e286844aad88188fcb diff --git a/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csprojResolveAssemblyReference.cache b/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000000000000000000000000000000000000..76cdea6cfa7346d02b1e3bf1f9538be1f65cacde GIT binary patch literal 5893 zcmb_ge{38_6}~y!=iBw!=cWl58XKFYp{<=eU+r_8rY1NhPORFA>njPRaW3n-IeX*1 zU3YgcsUtxulB%>+Buz>}B1D6#{-kv!Xpjh0YKTGYpOhBS3Mv7uYDxrDqCylRc;9%} zx94us)Z9k01#w&vl&n5JfK<dLeqH0rX^UhEs8Z^D`OhR zs-+4Nl@OO5T1^AwK|{&*D;e7`s~vm7eMWvtF}Ya}&^{x}hfQOzn&oB~e@LnOc_mq7 zg|;hNfm?whswV8mHQ-{c@>%o1hwv}l*1aKuRmoS8lqw;rNYtYx(;Etr$i@fN zF;g+8LEl(FGK5U zh~*F~AU*-{Nr(oBPm!p?jMn0b_9owXlSC?P?RS$R@ewek;bB)^rrxnu(~_RgxIJ)m zNl&xe1Mipgw75Okl9Ha!x;@yZlAddwp2#X{Y;{gvX{qc)oxGw-xpu9R%p|)K>pD7l zd-u93xbb6c1WrVqVtF?ytXL`ARQ2(QYNgctl*X~kt0okSDqMzJmSOgqnF-aVs!C;i zK<_W09$=89=JN$nU?V2aD^pWE+ix2A3Y6x`Cdbwho^uLv$=P6xJX@pj_H-!SuPNhJQ~(v{ zv+7_VSW!_yZ!j3HbA0J6BDvsNJ*SQr%=s^Sr|!`A#zHM9S?khf-EyT|&e}?hyVjX} zi83WD53QqpX>bQj@*lF^v7pqsZ*1q`^`! zva{5{5~0WprAQENrbhkZawKiRpm~x3YO){GMAv)lj7O2#^Q0}1{D_ny35t*)*-DM5 zv-xfzlC~8&hQaZi2bRrv6q!Bi<#?uq1La3>e2E%0o&zRrFXHb2{*xX^_Jl`~+2daP z$4c-~cm)1V4?c>IG+M;p1^n-OAlYe;BC|(GTkz5MNGbXVB}d?A09W*plr6$@z@PFU zvXdS~X5aC`pD2Mxu@Ufls1bGxjx<>W*8qOZgU60~6q!Bb1wT>(j-)KW@1jO%e(jQ3 zgth?vpa+e8)1%1j0Wb9ZCD14^0{U(=9JgG)$Vk&g=KWy4*F(k*c@&u)^fG_l%N#`( z!u10msN%u@5#gysQd*Rw(HBY&DSHf)epDSl;!Y{0NBCY9U-_6CrpJYWjwgyh_9bG7 zYmosl&htbOmZ#|r23FB}?g<1QCMATGl0K5^O$3OA(ZA|neXwJ8=Jmfn8awoKbmn61 zpXV;_xp4Tte^>0)4i26?+VsQq@0@!5wcnll{i#>Fu5Jk)sWET)*FE1pF#Csn^@o31 zy>HtMb2rr;eYfhuTXQWhKK8e{_p&<&BgfAD;N zQ~0H(Ad3815LCV_hz|cL2o~QdIM%1>{m4x}^PeN{1P_eg*R=2E!*AZ-{Ziwr!L$4) z&5gV7`26wNqrB-G-#xcs`HH`s+3?I&iJ6*Tcl_e7yIaQBoM?DA@#M@4wWq7&*ZuaZ zXN{Mm7w`Dit8XOV8eI3_roQUAKdnEsdU?;x%kLjQXq // tslint:disable {{>licenseInfo}} -import * as url from "url"; -import * as portableFetch from "portable-fetch"; -import { Configuration } from "./configuration"; +export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); -const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; +{{#models}} +{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}{{/model}} +{{/models}} -/** - * - * @export - * @interface FetchAPI - */ -export interface FetchAPI { - (url: string, init?: any): Promise; +{{#apiInfo}} +{{#apis}} +{{#operations}} +{{#operation}} +{{#allParams.0}} +export interface {{operationIdCamelCase}}Request { + {{#allParams}} + {{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; + {{/allParams}} } -/** - * - * @export - * @interface FetchArgs - */ -export interface FetchArgs { - url: string; - options: any; -} +{{/allParams.0}} +{{/operation}} +{{/operations}} +{{/apis}} +{{/apiInfo}} /** - * - * @export - * @class BaseAPI + * This is the base class for all generated API classes. */ export class BaseAPI { - protected configuration: Configuration; - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; + private middleware: Middleware[]; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + switch(context.responseType) { + case 'JSON': + const result = await response.json() as T; + return transformPropertyNames(result, context.modelPropertyNaming); + case 'text': + return await response.text() as any as T; + default: + return response as any as T; + } + } + throw response; + } + + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre(this.fetchApi, fetchParams.url, fetchParams.init) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post(this.fetchApi, url, init, response.clone()) || response; + } + } + return response; + } + + /** + * https://swagger.io/docs/specification/2-0/describing-responses/ + * + * If the response type for a given API is a 'string' we need to avoid + * parsing the response as json because JSON.parse("some string") will + * fail when the string isn't actually JSON. + */ + protected getResponseType(returnType: string): ResponseType { + switch (returnType) { + case 'string': + return 'text' + default: + return 'JSON' } } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } }; -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ export class RequiredError extends Error { - name: "RequiredError" + name = 'RequiredError'; constructor(public field: string, msg?: string) { super(msg); } } -{{#models}} -{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}{{/model}} -{{/models}} {{#apiInfo}}{{#apis}}{{#operations}} /** - * {{classname}} - fetch parameter creator{{#description}} - * {{&description}}{{/description}} - * @export + * {{#description}}{{{description}}}{{/description}}{{^description}}no description{{/description}} */ -export const {{classname}}FetchParamCreator = function (configuration?: Configuration) { - return { +export class {{classname}} extends BaseAPI { + {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: any = {}): FetchArgs { - {{#allParams}} - {{#required}} - // verify required parameter '{{paramName}}' is not null or undefined - if ({{paramName}} === null || {{paramName}} === undefined) { - throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); - } - {{/required}} - {{/allParams}} - const localVarPath = `{{{path}}}`{{#pathParams}} - .replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}}; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: '{{httpMethod}}' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - {{#hasFormParams}} - const localVarFormParams = new url.URLSearchParams(); - {{/hasFormParams}} - - {{#authMethods}} - // authentication {{name}} required - {{#isApiKey}} - {{#isKeyInHeader}} - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("{{keyParamName}}") - : configuration.apiKey; - localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue; - } - {{/isKeyInHeader}} - {{#isKeyInQuery}} - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("{{keyParamName}}") - : configuration.apiKey; - localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue; - } - {{/isKeyInQuery}} - {{/isApiKey}} - {{#isBasic}} - // http basic authentication required - if (configuration && (configuration.username || configuration.password)) { - localVarHeaderParameter["Authorization"] = "Basic " + btoa(configuration.username + ":" + configuration.password); - } - {{/isBasic}} - {{#isOAuth}} - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } - {{/isOAuth}} + /** + {{#notes}} + * {{¬es}} + {{/notes}} + {{#summary}} + * {{&summary}} + {{/summary}} + */ + async {{nickname}}({{#allParams.0}}requestParameters: {{operationIdCamelCase}}Request{{/allParams.0}}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { + {{#allParams}} + {{#required}} + if (requestParameters.{{paramName}} === null || requestParameters.{{paramName}} === undefined) { + throw new RequiredError('{{paramName}}','Required parameter requestParameters.{{paramName}} was null or undefined when calling {{nickname}}.'); + } + + {{/required}} + {{/allParams}} + {{#hasQueryParams}} + const queryParameters: HTTPQuery = {}; - {{/authMethods}} - {{#queryParams}} - {{#isListContainer}} - if ({{paramName}}) { + {{/hasQueryParams}} + {{#queryParams}} + {{#isListContainer}} + if (requestParameters.{{paramName}}) { {{#isCollectionFormatMulti}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}; + queryParameters['{{baseName}}'] = requestParameters.{{paramName}}; {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]); + queryParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]); {{/isCollectionFormatMulti}} - } - {{/isListContainer}} - {{^isListContainer}} - if ({{paramName}} !== undefined) { - {{#isDateTime}} - localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString(); - {{/isDateTime}} - {{^isDateTime}} - {{#isDate}} - localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString(); - {{/isDate}} - {{^isDate}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}; - {{/isDate}} - {{/isDateTime}} - } - {{/isListContainer}} + } - {{/queryParams}} - {{#headerParams}} - {{#isListContainer}} - if ({{paramName}}) { - localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); - } - {{/isListContainer}} - {{^isListContainer}} - if ({{paramName}} !== undefined && {{paramName}} !== null) { - localVarHeaderParameter['{{baseName}}'] = String({{paramName}}); + {{/isListContainer}} + {{^isListContainer}} + if (requestParameters.{{paramName}} !== undefined) { + {{#isDateTime}} + queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString(); + {{/isDateTime}} + {{^isDateTime}} + {{#isDate}} + queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString(); + {{/isDate}} + {{^isDate}} + queryParameters['{{baseName}}'] = requestParameters.{{paramName}}; + {{/isDate}} + {{/isDateTime}} + } + + {{/isListContainer}} + {{/queryParams}} + const headerParameters: HTTPHeaders = {}; + + {{#bodyParam}} + {{^consumes}} + headerParameters['Content-Type'] = 'application/json'; + + {{/consumes}} + {{#consumes.0}} + headerParameters['Content-Type'] = '{{{mediaType}}}'; + + {{/consumes.0}} + {{/bodyParam}} + {{#headerParams}} + {{#isListContainer}} + if (requestParameters.{{paramName}}) { + headerParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); + } + + {{/isListContainer}} + {{^isListContainer}} + if (requestParameters.{{paramName}} !== undefined && requestParameters.{{paramName}} !== null) { + headerParameters['{{baseName}}'] = String(requestParameters.{{paramName}}); + } + + {{/isListContainer}} + {{/headerParams}} + {{#authMethods}} + {{#isBasic}} + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + + {{/isBasic}} + {{#isApiKey}} + {{#isKeyInHeader}} + if (this.configuration && this.configuration.apiKey) { + headerParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication + } + + {{/isKeyInHeader}} + {{#isKeyInQuery}} + if (this.configuration && this.configuration.apiKey) { + queryParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication + } + + {{/isKeyInQuery}} + {{/isApiKey}} + {{#isOAuth}} + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; } - {{/isListContainer}} + } - {{/headerParams}} - {{#formParams}} - {{#isListContainer}} - if ({{paramName}}) { + {{/isOAuth}} + {{/authMethods}} + {{#hasFormParams}} + const formData = new FormData(); + {{/hasFormParams}} + {{#formParams}} + {{#isListContainer}} + if (requestParameters.{{paramName}}) { {{#isCollectionFormatMulti}} - {{paramName}}.forEach((element) => { - localVarFormParams.append('{{baseName}}', element as any); - }) + requestParameters.{{paramName}}.forEach((element) => { + formData.append('{{baseName}}', element as any); + }) {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); + formData.set('{{baseName}}', requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); {{/isCollectionFormatMulti}} - } - {{/isListContainer}} - {{^isListContainer}} - if ({{paramName}} !== undefined) { - localVarFormParams.set('{{baseName}}', {{paramName}} as any); - } - {{/isListContainer}} - - {{/formParams}} - {{#hasFormParams}} - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - - {{/hasFormParams}} - {{#bodyParam}} - {{^consumes}} - localVarHeaderParameter['Content-Type'] = 'application/json'; - {{/consumes}} - {{#consumes.0}} - localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}'; - {{/consumes.0}} - - {{/bodyParam}} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - {{#hasFormParams}} - localVarRequestOptions.body = localVarFormParams.toString(); - {{/hasFormParams}} - {{#bodyParam}} - const needsSerialization = ("{{dataType}}" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}} || ""); - {{/bodyParam}} - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - {{/operation}} - } -}; + } -/** - * {{classname}} - functional programming interface{{#description}} - * {{{description}}}{{/description}} - * @export - */ -export const {{classname}}Fp = function(configuration?: Configuration) { - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { - const localVarFetchArgs = {{classname}}FetchParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response{{#returnType}}.json(){{/returnType}}; - } else { - throw response; - } - }); - }; - }, - {{/operation}} + {{/isListContainer}} + {{^isListContainer}} + if (requestParameters.{{paramName}} !== undefined) { + formData.set('{{baseName}}', requestParameters.{{paramName}} as any); + } + + {{/isListContainer}} + {{/formParams}} + return this.request<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>({ + path: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}}, + method: '{{httpMethod}}', + headers: headerParameters, + {{#hasQueryParams}} + query: queryParameters, + {{/hasQueryParams}} + {{#hasBodyParam}} + {{#bodyParam}} + body: requestParameters.{{paramName}}, + {{/bodyParam}} + {{/hasBodyParam}} + {{#hasFormParams}} + body: formData, + {{/hasFormParams}} + {{#returnType}} + responseType: this.getResponseType('{{{returnType}}}'), + {{/returnType}} + modelPropertyNaming: '{{modelPropertyNaming}}', + }); } -}; -/** - * {{classname}} - factory interface{{#description}} - * {{&description}}{{/description}} - * @export - */ -export const {{classname}}Factory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - {{#operation}} - /** - * {{¬es}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams}} - * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} - {{/allParams}} - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) { - return {{classname}}Fp(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(fetch, basePath); - }, {{/operation}} - }; +} +{{/operations}}{{/apis}}{{/apiInfo}} + + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", }; -{{#withInterfaces}} -/** - * {{classname}} - interface{{#description}} - * {{&description}}{{/description}} - * @export - * @interface {{classname}} - */ -export interface {{classname}}Interface { -{{#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 - */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}>; +export type FetchAPI = GlobalFetch['fetch']; -{{/operation}} +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // 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 } -{{/withInterfaces}} -/** - * {{classname}} - object-oriented interface{{#description}} - * {{{description}}}{{/description}} - * @export - * @class {{classname}} - * @extends {BaseAPI} - */ -{{#withInterfaces}} -export class {{classname}} extends BaseAPI implements {{classname}}Interface { -{{/withInterfaces}} -{{^withInterfaces}} -export class {{classname}} extends BaseAPI { -{{/withInterfaces}} - {{#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}} - */ - public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) { - return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(this.fetch, this.basePath); +export class Configuration { + + basePath: string; + fetchApi: FetchAPI; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + 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; + } } +} - {{/operation}} +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +type ResponseType = 'JSON' | 'text'; + +interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; + responseType?: ResponseType; + modelPropertyNaming: ModelPropertyNaming; +} + +function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} + +export interface Middleware { + pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; + post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; +} + +function capitalize(word: string) { + return word.charAt(0).toUpperCase() + word.slice(1); +} + +function toPascalCase(name: string) { + return name + .split('_') + .map(capitalize) + .join(''); +} + +function toCamelCase(name: string) { + const pascalCase = toPascalCase(name); + return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1); +} + +function applyPropertyNameConverter(json: any, converter: (name: string) => string) { + if (json instanceof Array) { + json.forEach((value) => { + if (typeof value === 'object') { + return applyPropertyNameConverter(value, converter); + } + }); + } else { + Object.keys(json).forEach((origKey) => { + if (json.hasOwnProperty(origKey)) { + let value = json[origKey]; + if (value instanceof Array || (value !== null && value.constructor === Object)) { + value = applyPropertyNameConverter(value, converter); + } + const newKey = converter(origKey); + json[newKey] = json[origKey]; + delete json[origKey]; + json[newKey] = value; + } + }); + } + return json; +} + +function transformPropertyNames(json: any, modelPropertyNaming: ModelPropertyNaming) { + switch (modelPropertyNaming) { + case 'camelCase': + return applyPropertyNameConverter(json, toCamelCase); + + case 'original': + default: + return json; + } } -{{/operations}}{{/apis}}{{/apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/configuration.mustache deleted file mode 100644 index 5614b8396455..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/configuration.mustache +++ /dev/null @@ -1,55 +0,0 @@ -// tslint:disable -{{>licenseInfo}} - -export interface ConfigurationParameters { - apiKey?: string | ((name: string) => string); - username?: string; - password?: string; - accessToken?: string | ((name: string, scopes?: string[]) => string); - basePath?: string; -} - -export class Configuration { - /** - * parameter for apiKey security - * @param name security name - * @memberof Configuration - */ - apiKey?: string | ((name: string) => string); - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - username?: string; - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - password?: string; - /** - * parameter for oauth2 security - * @param name security name - * @param scopes oauth2 scope - * @memberof Configuration - */ - accessToken?: string | ((name: string, scopes?: string[]) => string); - /** - * override base path - * - * @type {string} - * @memberof Configuration - */ - basePath?: string; - - constructor(param: ConfigurationParameters = {}) { - this.apiKey = param.apiKey; - this.username = param.username; - this.password = param.password; - this.accessToken = param.accessToken; - this.basePath = param.basePath; - } -} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/custom.d.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/custom.d.mustache deleted file mode 100644 index 9a5ceb3588a8..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/custom.d.mustache +++ /dev/null @@ -1,2 +0,0 @@ -declare module 'portable-fetch'; -declare module 'url'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/git_push.sh.mustache deleted file mode 100755 index 4db97099b751..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/git_push.sh.mustache +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 - -if [ "$git_user_id" = "" ]; then - git_user_id="{{{gitUserId}}}" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="{{{gitRepoId}}}" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="{{{releaseNote}}}" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=`git remote` -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git - else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https' diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/gitignore b/modules/openapi-generator/src/main/resources/typescript-fetch/gitignore deleted file mode 100644 index 35e2fb2b02ed..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/gitignore +++ /dev/null @@ -1,3 +0,0 @@ -wwwroot/*.js -node_modules -typings diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/index.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/index.mustache deleted file mode 100644 index 9c8794b3f282..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/index.mustache +++ /dev/null @@ -1,5 +0,0 @@ -// tslint:disable -{{>licenseInfo}} - -export * from "./api"; -export * from "./configuration"; diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/licenseInfo.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/licenseInfo.mustache index 469fb03940fe..bbd8742e52a5 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/licenseInfo.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/licenseInfo.mustache @@ -5,7 +5,7 @@ * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache index 5fa32c28b882..94979d8d63ce 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache @@ -1,12 +1,8 @@ -/** - * {{{description}}} - * @export - * @enum {string} - */ +{{#description}}// {{description}}{{/description}} export enum {{classname}} { {{#allowableValues}} {{#enumVars}} - {{{name}}} = {{{value}}}{{^-last}},{{/-last}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} {{#description}}// {{description}}{{/description}} {{/enumVars}} {{/allowableValues}} } diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index d4ba9f7b862c..e47bae82c741 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -1,38 +1,20 @@ -/** - * {{{description}}} - * @export - * @interface {{classname}} - */ +{{#description}}// {{description}}{{/description}} 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}}; + {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; {{#description}}// {{description}}{{/description}} {{/vars}} }{{#hasEnums}} -/** - * @export - * @namespace {{classname}} - */ export namespace {{classname}} { {{#vars}} {{#isEnum}} - /** - * @export - * @enum {string} - */ export enum {{enumName}} { {{#allowableValues}} {{#enumVars}} - {{{name}}} = {{{value}}}{{^-last}},{{/-last}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} {{#description}}// {{description}}{{/description}} {{/enumVars}} {{/allowableValues}} } diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache deleted file mode 100644 index 88c86ffde58e..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "{{npmName}}", - "version": "{{npmVersion}}", - "description": "OpenAPI client for {{npmName}}", - "author": "OpenAPI-Generator Contributors", - "keywords": [ - "fetch", - "typescript", - "openapi-client", - "openapi-generator", - "{{npmName}}" - ], - "license": "Unlicense", - "main": "./dist/index.js", - "typings": "./dist/index.d.ts", - "scripts" : { - "build": "tsc --outDir dist/", - "prepublishOnly": "npm run build" - }, - "dependencies": { - "portable-fetch": "^3.0.0" - }, - "devDependencies": { - "@types/node": "^8.0.9", - "typescript": "^2.0" - }{{#npmRepository}},{{/npmRepository}} -{{#npmRepository}} - "publishConfig":{ - "registry":"{{npmRepository}}" - } -{{/npmRepository}} -} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/tsconfig.mustache deleted file mode 100644 index 6e59886490bc..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/tsconfig.mustache +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "declaration": true, - "target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}", - "module": "commonjs", - "noImplicitAny": true, - "outDir": "dist", - "rootDir": "."{{^supportsES6}}, - "lib": [ - "es6", - "dom" - ] - {{/supportsES6}} - }, - "exclude": [ - "dist", - "node_modules" - ] -} From 6a785f9d1cb34bc89d4dd144819d5a106d4e8cdc Mon Sep 17 00:00:00 2001 From: James Batt Date: Fri, 13 Jul 2018 10:10:38 +1000 Subject: [PATCH 02/39] ran bin/typescript-fetch-petstore-all.sh --- .../typescript-fetch/builds/default/api.ts | 2587 +++++---------- .../typescript-fetch/builds/es6-target/api.ts | 2587 +++++---------- .../builds/with-interfaces/api.ts | 2780 +++++------------ .../builds/with-npm-version/api.ts | 2587 +++++---------- 4 files changed, 3086 insertions(+), 7455 deletions(-) diff --git a/samples/client/petstore/typescript-fetch/builds/default/api.ts b/samples/client/petstore/typescript-fetch/builds/default/api.ts index b1af2421c621..590cace43914 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -1,4 +1,3 @@ -/// // tslint:disable /** * OpenAPI Petstore @@ -7,1985 +6,951 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ -import * as url from "url"; -import * as portableFetch from "portable-fetch"; -import { Configuration } from "./configuration"; +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface FetchAPI - */ -export interface FetchAPI { - (url: string, init?: any): Promise; -} - -/** - * - * @export - * @interface FetchArgs - */ -export interface FetchArgs { - url: string; - options: any; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - name: "RequiredError" - constructor(public field: string, msg?: string) { - super(msg); - } -} - -/** - * Describes the result of uploading an image resource - * @export - * @interface ApiResponse - */ +// Describes the result of uploading an image resource export interface ApiResponse { - /** - * - * @type {number} - * @memberof ApiResponse - */ - code?: number; - /** - * - * @type {string} - * @memberof ApiResponse - */ - type?: string; - /** - * - * @type {string} - * @memberof ApiResponse - */ - message?: string; + code?: number; + type?: string; + message?: string; } -/** - * A category for a pet - * @export - * @interface Category - */ +// A category for a pet export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; + id?: number; + name?: string; } -/** - * An order for a pets from the pet store - * @export - * @interface Order - */ +// An order for a pets from the pet store 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; + id?: number; + petId?: number; + quantity?: number; + shipDate?: Date; + status?: Order.StatusEnum; // Order Status + complete?: boolean; } -/** - * @export - * @namespace Order - */ export namespace Order { - /** - * @export - * @enum {string} - */ export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' + Placed = 'placed', // Order Status + Approved = 'approved', // Order Status + Delivered = 'delivered' // Order Status } } -/** - * A pet for sale in the pet store - * @export - * @interface Pet - */ +// A pet for sale in the pet store 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; + id?: number; + category?: Category; + name: string; + photoUrls: Array; + tags?: Array; + status?: Pet.StatusEnum; // pet status in the store } -/** - * @export - * @namespace Pet - */ export namespace Pet { - /** - * @export - * @enum {string} - */ export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' + Available = 'available', // pet status in the store + Pending = 'pending', // pet status in the store + Sold = 'sold' // pet status in the store } } -/** - * A tag for a pet - * @export - * @interface Tag - */ +// A tag for a pet export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; + id?: number; + name?: string; } -/** - * A User who is purchasing from the pet store - * @export - * @interface User - */ +// A User who is purchasing from the pet store 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; + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + userStatus?: number; // User Status } -/** - * PetApi - fetch parameter creator - * @export - */ -export const PetApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface AddPetRequest { + pet: Pet; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface FindPetsByStatusRequest { + status: Array<'available' | 'pending' | 'sold'>; +} - if (apiKey !== undefined && apiKey !== null) { - localVarHeaderParameter['api_key'] = String(apiKey); - } +export interface FindPetsByTagsRequest { + tags: Array; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options: any = {}): FetchArgs { - // verify required parameter 'status' is not null or undefined - if (status === null || status === undefined) { - throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); - } - const localVarPath = `/pet/findByStatus`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface GetPetByIdRequest { + petId: number; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface UpdatePetRequest { + pet: Pet; +} - if (status) { - localVarQueryParameter['status'] = status.join(COLLECTION_FORMATS["csv"]); - } +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options: any = {}): FetchArgs { - // verify required parameter 'tags' is not null or undefined - if (tags === null || tags === undefined) { - throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); - } - const localVarPath = `/pet/findByTags`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: any; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface DeleteOrderRequest { + orderId: string; +} - if (tags) { - localVarQueryParameter['tags'] = tags.join(COLLECTION_FORMATS["csv"]); - } +export interface GetOrderByIdRequest { + orderId: number; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getPetById(petId: number, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; - } +export interface PlaceOrderRequest { + order: Order; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface CreateUserRequest { + user: User; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface CreateUsersWithArrayInputRequest { + user: Array; +} - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface CreateUsersWithListInputRequest { + user: Array; +} - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } +export interface DeleteUserRequest { + username: string; +} - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } +export interface GetUserByNameRequest { + username: string; +} - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling uploadFile.'); - } - const localVarPath = `/pet/{petId}/uploadImage` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface LoginUserRequest { + username: string; + password: string; +} - if (additionalMetadata !== undefined) { - localVarFormParams.set('additionalMetadata', additionalMetadata as any); - } +export interface UpdateUserRequest { + username: string; + user: User; +} + + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } - if (file !== undefined) { - localVarFormParams.set('file', file as any); + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + switch(context.responseType) { + case 'JSON': + const result = await response.json() as T; + return transformPropertyNames(result, context.modelPropertyNaming); + case 'text': + return await response.text() as any as T; + default: + return response as any as T; } + } + throw response; + } - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre(this.fetchApi, fetchParams.url, fetchParams.init) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post(this.fetchApi, url, init, response.clone()) || response; + } + } + return response; + } - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, + /** + * https://swagger.io/docs/specification/2-0/describing-responses/ + * + * If the response type for a given API is a 'string' we need to avoid + * parsing the response as json because JSON.parse("some string") will + * fail when the string isn't actually JSON. + */ + protected getResponseType(returnType: string): ResponseType { + switch (returnType) { + case 'string': + return 'text' + default: + return 'JSON' + } } -}; -/** - * PetApi - functional programming interface - * @export - */ -export const PetApiFp = function(configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(pet, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByStatus(status, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByTags(tags, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - getPetById(petId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).getPetById(petId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(pet, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; } }; -/** - * PetApi - factory interface - * @export - */ -export const PetApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options?: any) { - return PetApiFp(configuration).addPet(pet, options)(fetch, basePath); - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options?: any) { - return PetApiFp(configuration).deletePet(petId, apiKey, options)(fetch, basePath); - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { - return PetApiFp(configuration).findPetsByStatus(status, options)(fetch, basePath); - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options?: any) { - return PetApiFp(configuration).findPetsByTags(tags, options)(fetch, basePath); - }, - /** - * 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} - */ - getPetById(petId: number, options?: any) { - return PetApiFp(configuration).getPetById(petId, options)(fetch, basePath); - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options?: any) { - return PetApiFp(configuration).updatePet(pet, options)(fetch, basePath); - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { - return PetApiFp(configuration).updatePetWithForm(petId, name, status, options)(fetch, basePath); - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { - return PetApiFp(configuration).uploadFile(petId, additionalMetadata, file, options)(fetch, basePath); - }, - }; -}; +export class RequiredError extends Error { + name = 'RequiredError'; + constructor(public field: string, msg?: string) { + super(msg); + } +} + /** - * PetApi - object-oriented interface - * @export - * @class PetApi - * @extends {BaseAPI} + * no description */ export class PetApi extends BaseAPI { + /** - * - * @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 PetApi + * Add a new pet to the store */ - public addPet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).addPet(pet, options)(this.fetch, this.basePath); + async addPet(requestParameters: AddPetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet`, + method: 'POST', + headers: headerParameters, + body: requestParameters.pet, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApi + * Deletes a pet */ - public deletePet(petId: number, apiKey?: string, options?: any) { - return PetApiFp(this.configuration).deletePet(petId, apiKey, options)(this.fetch, this.basePath); + async deletePet(requestParameters: DeletePetRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Finds Pets by status */ - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { - return PetApiFp(this.configuration).findPetsByStatus(status, options)(this.fetch, this.basePath); + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(COLLECTION_FORMATS["csv"]); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request>({ + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('Array'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Finds Pets by tags */ - public findPetsByTags(tags: Array, options?: any) { - return PetApiFp(this.configuration).findPetsByTags(tags, options)(this.fetch, this.basePath); + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(COLLECTION_FORMATS["csv"]); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request>({ + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('Array'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Find pet by ID */ - public getPetById(petId: number, options?: any) { - return PetApiFp(this.configuration).getPetById(petId, options)(this.fetch, this.basePath); + async getPetById(requestParameters: GetPetByIdRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('Pet'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * Update an existing pet */ - public updatePet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).updatePet(pet, options)(this.fetch, this.basePath); + async updatePet(requestParameters: UpdatePetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet`, + method: 'PUT', + headers: headerParameters, + body: requestParameters.pet, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * Updates a pet in the store with form data */ - public updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { - return PetApiFp(this.configuration).updatePetWithForm(petId, name, status, options)(this.fetch, this.basePath); + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.name !== undefined) { + formData.set('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + formData.set('status', requestParameters.status as any); + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * uploads an image */ - public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { - return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options)(this.fetch, this.basePath); - } + async uploadFile(requestParameters: UploadFileRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } -} + const headerParameters: HTTPHeaders = {}; -/** - * StoreApi - fetch parameter creator - * @export - */ -export const StoreApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling deleteOrder.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options: any = {}): FetchArgs { - const localVarPath = `/store/inventory`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; } + } - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling getOrderById.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options: any = {}): FetchArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); - } - const localVarPath = `/store/order`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(order || {}) : (order || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; + const formData = new FormData(); + if (requestParameters.additionalMetadata !== undefined) { + formData.set('additionalMetadata', requestParameters.additionalMetadata as any); + } -/** - * StoreApi - functional programming interface - * @export - */ -export const StoreApiFp = function(configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getInventory(options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getOrderById(orderId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).placeOrder(order, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, + if (requestParameters.file !== undefined) { + formData.set('file', requestParameters.file as any); + } + + return this.request({ + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + responseType: this.getResponseType('ApiResponse'), + modelPropertyNaming: 'camelCase', + }); } -}; -/** - * StoreApi - factory interface - * @export - */ -export const StoreApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options?: any) { - return StoreApiFp(configuration).deleteOrder(orderId, options)(fetch, basePath); - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options?: any) { - return StoreApiFp(configuration).getInventory(options)(fetch, basePath); - }, - /** - * 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} - */ - getOrderById(orderId: number, options?: any) { - return StoreApiFp(configuration).getOrderById(orderId, options)(fetch, basePath); - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options?: any) { - return StoreApiFp(configuration).placeOrder(order, options)(fetch, basePath); - }, - }; -}; +} /** - * StoreApi - object-oriented interface - * @export - * @class StoreApi - * @extends {BaseAPI} + * no description */ export class StoreApi extends BaseAPI { + /** * 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 StoreApi + * Delete purchase order by ID */ - public deleteOrder(orderId: string, options?: any) { - return StoreApiFp(this.configuration).deleteOrder(orderId, options)(this.fetch, this.basePath); + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApi + * Returns pet inventories by status */ - public getInventory(options?: any) { - return StoreApiFp(this.configuration).getInventory(options)(this.fetch, this.basePath); + async getInventory(): Promise<{ [key: string]: number; }> { + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + return this.request<{ [key: string]: number; }>({ + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('{ [key: string]: number; }'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 StoreApi + * Find purchase order by ID */ - public getOrderById(orderId: number, options?: any) { - return StoreApiFp(this.configuration).getOrderById(orderId, options)(this.fetch, this.basePath); + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('Order'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 StoreApi + * Place an order for a pet */ - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.fetch, this.basePath); - } - -} - -/** - * UserApi - fetch parameter creator - * @export - */ -export const UserApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); - } - const localVarPath = `/user`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); - } - const localVarPath = `/user/createWithArray`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); - } - const localVarPath = `/user/createWithList`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - deleteUser(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('password','Required parameter password was null or undefined when calling loginUser.'); - } - const localVarPath = `/user/login`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - if (username !== undefined) { - localVarQueryParameter['username'] = username; - } + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + if (requestParameters.order === null || requestParameters.order === undefined) { + throw new RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + } - if (password !== undefined) { - localVarQueryParameter['password'] = password; - } + const headerParameters: HTTPHeaders = {}; - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options: any = {}): FetchArgs { - const localVarPath = `/user/logout`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('user','Required parameter user was null or undefined when calling updateUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; + headerParameters['Content-Type'] = 'application/json'; -/** - * UserApi - functional programming interface - * @export - */ -export const UserApiFp = function(configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).getUserByName(username, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).loginUser(username, password, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, + return this.request({ + path: `/store/order`, + method: 'POST', + headers: headerParameters, + body: requestParameters.order, + responseType: this.getResponseType('Order'), + modelPropertyNaming: 'camelCase', + }); } -}; -/** - * UserApi - factory interface - * @export - */ -export const UserApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * 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} - */ - createUser(user: User, options?: any) { - return UserApiFp(configuration).createUser(user, options)(fetch, basePath); - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithArrayInput(user, options)(fetch, basePath); - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithListInput(user, options)(fetch, basePath); - }, - /** - * 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} - */ - deleteUser(username: string, options?: any) { - return UserApiFp(configuration).deleteUser(username, options)(fetch, basePath); - }, - /** - * - * @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} - */ - getUserByName(username: string, options?: any) { - return UserApiFp(configuration).getUserByName(username, options)(fetch, basePath); - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options?: any) { - return UserApiFp(configuration).loginUser(username, password, options)(fetch, basePath); - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options?: any) { - return UserApiFp(configuration).logoutUser(options)(fetch, basePath); - }, - /** - * 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} - */ - updateUser(username: string, user: User, options?: any) { - return UserApiFp(configuration).updateUser(username, user, options)(fetch, basePath); - }, - }; -}; +} /** - * UserApi - object-oriented interface - * @export - * @class UserApi - * @extends {BaseAPI} + * no description */ export class UserApi extends BaseAPI { + /** * 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 UserApi + * Create user */ - public createUser(user: User, options?: any) { - return UserApiFp(this.configuration).createUser(user, options)(this.fetch, this.basePath); + async createUser(requestParameters: CreateUserRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Creates list of users with given input array */ - public createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithArrayInput(user, options)(this.fetch, this.basePath); + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Creates list of users with given input array */ - public createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithListInput(user, options)(this.fetch, this.basePath); + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** * 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 UserApi + * Delete user */ - public deleteUser(username: string, options?: any) { - return UserApiFp(this.configuration).deleteUser(username, options)(this.fetch, this.basePath); + async deleteUser(requestParameters: DeleteUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Get user by user name */ - public getUserByName(username: string, options?: any) { - return UserApiFp(this.configuration).getUserByName(username, options)(this.fetch, this.basePath); + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('User'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Logs user into the system */ - public loginUser(username: string, password: string, options?: any) { - return UserApiFp(this.configuration).loginUser(username, password, options)(this.fetch, this.basePath); + async loginUser(requestParameters: LoginUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('string'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApi + * Logs out current logged in user session */ - public logoutUser(options?: any) { - return UserApiFp(this.configuration).logoutUser(options)(this.fetch, this.basePath); + async logoutUser(): Promise { + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * 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 UserApi + * Updated user */ - public updateUser(username: string, user: User, options?: any) { - return UserApiFp(this.configuration).updateUser(username, user, options)(this.fetch, this.basePath); + async updateUser(requestParameters: UpdateUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); + } + +} + + + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = GlobalFetch['fetch']; + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // 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 +} + +export class Configuration { + + basePath: string; + fetchApi: FetchAPI; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + 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; + } } +} + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +type ResponseType = 'JSON' | 'text'; + +interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; + responseType?: ResponseType; + modelPropertyNaming: ModelPropertyNaming; +} + +function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} +export interface Middleware { + pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; + post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; } +function capitalize(word: string) { + return word.charAt(0).toUpperCase() + word.slice(1); +} + +function toPascalCase(name: string) { + return name + .split('_') + .map(capitalize) + .join(''); +} + +function toCamelCase(name: string) { + const pascalCase = toPascalCase(name); + return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1); +} + +function applyPropertyNameConverter(json: any, converter: (name: string) => string) { + if (json instanceof Array) { + json.forEach((value) => { + if (typeof value === 'object') { + return applyPropertyNameConverter(value, converter); + } + }); + } else { + Object.keys(json).forEach((origKey) => { + if (json.hasOwnProperty(origKey)) { + let value = json[origKey]; + if (value instanceof Array || (value !== null && value.constructor === Object)) { + value = applyPropertyNameConverter(value, converter); + } + const newKey = converter(origKey); + json[newKey] = json[origKey]; + delete json[origKey]; + json[newKey] = value; + } + }); + } + return json; +} + +function transformPropertyNames(json: any, modelPropertyNaming: ModelPropertyNaming) { + switch (modelPropertyNaming) { + case 'camelCase': + return applyPropertyNameConverter(json, toCamelCase); + + case 'original': + default: + return json; + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts index b1af2421c621..590cace43914 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts @@ -1,4 +1,3 @@ -/// // tslint:disable /** * OpenAPI Petstore @@ -7,1985 +6,951 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ -import * as url from "url"; -import * as portableFetch from "portable-fetch"; -import { Configuration } from "./configuration"; +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface FetchAPI - */ -export interface FetchAPI { - (url: string, init?: any): Promise; -} - -/** - * - * @export - * @interface FetchArgs - */ -export interface FetchArgs { - url: string; - options: any; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - name: "RequiredError" - constructor(public field: string, msg?: string) { - super(msg); - } -} - -/** - * Describes the result of uploading an image resource - * @export - * @interface ApiResponse - */ +// Describes the result of uploading an image resource export interface ApiResponse { - /** - * - * @type {number} - * @memberof ApiResponse - */ - code?: number; - /** - * - * @type {string} - * @memberof ApiResponse - */ - type?: string; - /** - * - * @type {string} - * @memberof ApiResponse - */ - message?: string; + code?: number; + type?: string; + message?: string; } -/** - * A category for a pet - * @export - * @interface Category - */ +// A category for a pet export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; + id?: number; + name?: string; } -/** - * An order for a pets from the pet store - * @export - * @interface Order - */ +// An order for a pets from the pet store 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; + id?: number; + petId?: number; + quantity?: number; + shipDate?: Date; + status?: Order.StatusEnum; // Order Status + complete?: boolean; } -/** - * @export - * @namespace Order - */ export namespace Order { - /** - * @export - * @enum {string} - */ export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' + Placed = 'placed', // Order Status + Approved = 'approved', // Order Status + Delivered = 'delivered' // Order Status } } -/** - * A pet for sale in the pet store - * @export - * @interface Pet - */ +// A pet for sale in the pet store 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; + id?: number; + category?: Category; + name: string; + photoUrls: Array; + tags?: Array; + status?: Pet.StatusEnum; // pet status in the store } -/** - * @export - * @namespace Pet - */ export namespace Pet { - /** - * @export - * @enum {string} - */ export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' + Available = 'available', // pet status in the store + Pending = 'pending', // pet status in the store + Sold = 'sold' // pet status in the store } } -/** - * A tag for a pet - * @export - * @interface Tag - */ +// A tag for a pet export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; + id?: number; + name?: string; } -/** - * A User who is purchasing from the pet store - * @export - * @interface User - */ +// A User who is purchasing from the pet store 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; + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + userStatus?: number; // User Status } -/** - * PetApi - fetch parameter creator - * @export - */ -export const PetApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface AddPetRequest { + pet: Pet; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface FindPetsByStatusRequest { + status: Array<'available' | 'pending' | 'sold'>; +} - if (apiKey !== undefined && apiKey !== null) { - localVarHeaderParameter['api_key'] = String(apiKey); - } +export interface FindPetsByTagsRequest { + tags: Array; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options: any = {}): FetchArgs { - // verify required parameter 'status' is not null or undefined - if (status === null || status === undefined) { - throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); - } - const localVarPath = `/pet/findByStatus`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface GetPetByIdRequest { + petId: number; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface UpdatePetRequest { + pet: Pet; +} - if (status) { - localVarQueryParameter['status'] = status.join(COLLECTION_FORMATS["csv"]); - } +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options: any = {}): FetchArgs { - // verify required parameter 'tags' is not null or undefined - if (tags === null || tags === undefined) { - throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); - } - const localVarPath = `/pet/findByTags`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: any; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface DeleteOrderRequest { + orderId: string; +} - if (tags) { - localVarQueryParameter['tags'] = tags.join(COLLECTION_FORMATS["csv"]); - } +export interface GetOrderByIdRequest { + orderId: number; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getPetById(petId: number, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; - } +export interface PlaceOrderRequest { + order: Order; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface CreateUserRequest { + user: User; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface CreateUsersWithArrayInputRequest { + user: Array; +} - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface CreateUsersWithListInputRequest { + user: Array; +} - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } +export interface DeleteUserRequest { + username: string; +} - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } +export interface GetUserByNameRequest { + username: string; +} - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling uploadFile.'); - } - const localVarPath = `/pet/{petId}/uploadImage` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface LoginUserRequest { + username: string; + password: string; +} - if (additionalMetadata !== undefined) { - localVarFormParams.set('additionalMetadata', additionalMetadata as any); - } +export interface UpdateUserRequest { + username: string; + user: User; +} + + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } - if (file !== undefined) { - localVarFormParams.set('file', file as any); + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + switch(context.responseType) { + case 'JSON': + const result = await response.json() as T; + return transformPropertyNames(result, context.modelPropertyNaming); + case 'text': + return await response.text() as any as T; + default: + return response as any as T; } + } + throw response; + } - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre(this.fetchApi, fetchParams.url, fetchParams.init) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post(this.fetchApi, url, init, response.clone()) || response; + } + } + return response; + } - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, + /** + * https://swagger.io/docs/specification/2-0/describing-responses/ + * + * If the response type for a given API is a 'string' we need to avoid + * parsing the response as json because JSON.parse("some string") will + * fail when the string isn't actually JSON. + */ + protected getResponseType(returnType: string): ResponseType { + switch (returnType) { + case 'string': + return 'text' + default: + return 'JSON' + } } -}; -/** - * PetApi - functional programming interface - * @export - */ -export const PetApiFp = function(configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(pet, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByStatus(status, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByTags(tags, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - getPetById(petId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).getPetById(petId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(pet, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; } }; -/** - * PetApi - factory interface - * @export - */ -export const PetApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options?: any) { - return PetApiFp(configuration).addPet(pet, options)(fetch, basePath); - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options?: any) { - return PetApiFp(configuration).deletePet(petId, apiKey, options)(fetch, basePath); - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { - return PetApiFp(configuration).findPetsByStatus(status, options)(fetch, basePath); - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options?: any) { - return PetApiFp(configuration).findPetsByTags(tags, options)(fetch, basePath); - }, - /** - * 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} - */ - getPetById(petId: number, options?: any) { - return PetApiFp(configuration).getPetById(petId, options)(fetch, basePath); - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options?: any) { - return PetApiFp(configuration).updatePet(pet, options)(fetch, basePath); - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { - return PetApiFp(configuration).updatePetWithForm(petId, name, status, options)(fetch, basePath); - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { - return PetApiFp(configuration).uploadFile(petId, additionalMetadata, file, options)(fetch, basePath); - }, - }; -}; +export class RequiredError extends Error { + name = 'RequiredError'; + constructor(public field: string, msg?: string) { + super(msg); + } +} + /** - * PetApi - object-oriented interface - * @export - * @class PetApi - * @extends {BaseAPI} + * no description */ export class PetApi extends BaseAPI { + /** - * - * @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 PetApi + * Add a new pet to the store */ - public addPet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).addPet(pet, options)(this.fetch, this.basePath); + async addPet(requestParameters: AddPetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet`, + method: 'POST', + headers: headerParameters, + body: requestParameters.pet, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApi + * Deletes a pet */ - public deletePet(petId: number, apiKey?: string, options?: any) { - return PetApiFp(this.configuration).deletePet(petId, apiKey, options)(this.fetch, this.basePath); + async deletePet(requestParameters: DeletePetRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Finds Pets by status */ - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { - return PetApiFp(this.configuration).findPetsByStatus(status, options)(this.fetch, this.basePath); + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(COLLECTION_FORMATS["csv"]); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request>({ + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('Array'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Finds Pets by tags */ - public findPetsByTags(tags: Array, options?: any) { - return PetApiFp(this.configuration).findPetsByTags(tags, options)(this.fetch, this.basePath); + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(COLLECTION_FORMATS["csv"]); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request>({ + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('Array'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Find pet by ID */ - public getPetById(petId: number, options?: any) { - return PetApiFp(this.configuration).getPetById(petId, options)(this.fetch, this.basePath); + async getPetById(requestParameters: GetPetByIdRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('Pet'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * Update an existing pet */ - public updatePet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).updatePet(pet, options)(this.fetch, this.basePath); + async updatePet(requestParameters: UpdatePetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet`, + method: 'PUT', + headers: headerParameters, + body: requestParameters.pet, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * Updates a pet in the store with form data */ - public updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { - return PetApiFp(this.configuration).updatePetWithForm(petId, name, status, options)(this.fetch, this.basePath); + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.name !== undefined) { + formData.set('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + formData.set('status', requestParameters.status as any); + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * uploads an image */ - public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { - return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options)(this.fetch, this.basePath); - } + async uploadFile(requestParameters: UploadFileRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } -} + const headerParameters: HTTPHeaders = {}; -/** - * StoreApi - fetch parameter creator - * @export - */ -export const StoreApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling deleteOrder.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options: any = {}): FetchArgs { - const localVarPath = `/store/inventory`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; } + } - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling getOrderById.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options: any = {}): FetchArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); - } - const localVarPath = `/store/order`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(order || {}) : (order || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; + const formData = new FormData(); + if (requestParameters.additionalMetadata !== undefined) { + formData.set('additionalMetadata', requestParameters.additionalMetadata as any); + } -/** - * StoreApi - functional programming interface - * @export - */ -export const StoreApiFp = function(configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getInventory(options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getOrderById(orderId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).placeOrder(order, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, + if (requestParameters.file !== undefined) { + formData.set('file', requestParameters.file as any); + } + + return this.request({ + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + responseType: this.getResponseType('ApiResponse'), + modelPropertyNaming: 'camelCase', + }); } -}; -/** - * StoreApi - factory interface - * @export - */ -export const StoreApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options?: any) { - return StoreApiFp(configuration).deleteOrder(orderId, options)(fetch, basePath); - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options?: any) { - return StoreApiFp(configuration).getInventory(options)(fetch, basePath); - }, - /** - * 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} - */ - getOrderById(orderId: number, options?: any) { - return StoreApiFp(configuration).getOrderById(orderId, options)(fetch, basePath); - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options?: any) { - return StoreApiFp(configuration).placeOrder(order, options)(fetch, basePath); - }, - }; -}; +} /** - * StoreApi - object-oriented interface - * @export - * @class StoreApi - * @extends {BaseAPI} + * no description */ export class StoreApi extends BaseAPI { + /** * 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 StoreApi + * Delete purchase order by ID */ - public deleteOrder(orderId: string, options?: any) { - return StoreApiFp(this.configuration).deleteOrder(orderId, options)(this.fetch, this.basePath); + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApi + * Returns pet inventories by status */ - public getInventory(options?: any) { - return StoreApiFp(this.configuration).getInventory(options)(this.fetch, this.basePath); + async getInventory(): Promise<{ [key: string]: number; }> { + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + return this.request<{ [key: string]: number; }>({ + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('{ [key: string]: number; }'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 StoreApi + * Find purchase order by ID */ - public getOrderById(orderId: number, options?: any) { - return StoreApiFp(this.configuration).getOrderById(orderId, options)(this.fetch, this.basePath); + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('Order'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 StoreApi + * Place an order for a pet */ - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.fetch, this.basePath); - } - -} - -/** - * UserApi - fetch parameter creator - * @export - */ -export const UserApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); - } - const localVarPath = `/user`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); - } - const localVarPath = `/user/createWithArray`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); - } - const localVarPath = `/user/createWithList`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - deleteUser(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('password','Required parameter password was null or undefined when calling loginUser.'); - } - const localVarPath = `/user/login`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - if (username !== undefined) { - localVarQueryParameter['username'] = username; - } + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + if (requestParameters.order === null || requestParameters.order === undefined) { + throw new RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + } - if (password !== undefined) { - localVarQueryParameter['password'] = password; - } + const headerParameters: HTTPHeaders = {}; - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options: any = {}): FetchArgs { - const localVarPath = `/user/logout`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('user','Required parameter user was null or undefined when calling updateUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; + headerParameters['Content-Type'] = 'application/json'; -/** - * UserApi - functional programming interface - * @export - */ -export const UserApiFp = function(configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).getUserByName(username, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).loginUser(username, password, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, + return this.request({ + path: `/store/order`, + method: 'POST', + headers: headerParameters, + body: requestParameters.order, + responseType: this.getResponseType('Order'), + modelPropertyNaming: 'camelCase', + }); } -}; -/** - * UserApi - factory interface - * @export - */ -export const UserApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * 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} - */ - createUser(user: User, options?: any) { - return UserApiFp(configuration).createUser(user, options)(fetch, basePath); - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithArrayInput(user, options)(fetch, basePath); - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithListInput(user, options)(fetch, basePath); - }, - /** - * 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} - */ - deleteUser(username: string, options?: any) { - return UserApiFp(configuration).deleteUser(username, options)(fetch, basePath); - }, - /** - * - * @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} - */ - getUserByName(username: string, options?: any) { - return UserApiFp(configuration).getUserByName(username, options)(fetch, basePath); - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options?: any) { - return UserApiFp(configuration).loginUser(username, password, options)(fetch, basePath); - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options?: any) { - return UserApiFp(configuration).logoutUser(options)(fetch, basePath); - }, - /** - * 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} - */ - updateUser(username: string, user: User, options?: any) { - return UserApiFp(configuration).updateUser(username, user, options)(fetch, basePath); - }, - }; -}; +} /** - * UserApi - object-oriented interface - * @export - * @class UserApi - * @extends {BaseAPI} + * no description */ export class UserApi extends BaseAPI { + /** * 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 UserApi + * Create user */ - public createUser(user: User, options?: any) { - return UserApiFp(this.configuration).createUser(user, options)(this.fetch, this.basePath); + async createUser(requestParameters: CreateUserRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Creates list of users with given input array */ - public createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithArrayInput(user, options)(this.fetch, this.basePath); + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Creates list of users with given input array */ - public createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithListInput(user, options)(this.fetch, this.basePath); + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** * 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 UserApi + * Delete user */ - public deleteUser(username: string, options?: any) { - return UserApiFp(this.configuration).deleteUser(username, options)(this.fetch, this.basePath); + async deleteUser(requestParameters: DeleteUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Get user by user name */ - public getUserByName(username: string, options?: any) { - return UserApiFp(this.configuration).getUserByName(username, options)(this.fetch, this.basePath); + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('User'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Logs user into the system */ - public loginUser(username: string, password: string, options?: any) { - return UserApiFp(this.configuration).loginUser(username, password, options)(this.fetch, this.basePath); + async loginUser(requestParameters: LoginUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('string'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApi + * Logs out current logged in user session */ - public logoutUser(options?: any) { - return UserApiFp(this.configuration).logoutUser(options)(this.fetch, this.basePath); + async logoutUser(): Promise { + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * 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 UserApi + * Updated user */ - public updateUser(username: string, user: User, options?: any) { - return UserApiFp(this.configuration).updateUser(username, user, options)(this.fetch, this.basePath); + async updateUser(requestParameters: UpdateUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); + } + +} + + + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = GlobalFetch['fetch']; + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // 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 +} + +export class Configuration { + + basePath: string; + fetchApi: FetchAPI; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + 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; + } } +} + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +type ResponseType = 'JSON' | 'text'; + +interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; + responseType?: ResponseType; + modelPropertyNaming: ModelPropertyNaming; +} + +function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} +export interface Middleware { + pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; + post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; } +function capitalize(word: string) { + return word.charAt(0).toUpperCase() + word.slice(1); +} + +function toPascalCase(name: string) { + return name + .split('_') + .map(capitalize) + .join(''); +} + +function toCamelCase(name: string) { + const pascalCase = toPascalCase(name); + return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1); +} + +function applyPropertyNameConverter(json: any, converter: (name: string) => string) { + if (json instanceof Array) { + json.forEach((value) => { + if (typeof value === 'object') { + return applyPropertyNameConverter(value, converter); + } + }); + } else { + Object.keys(json).forEach((origKey) => { + if (json.hasOwnProperty(origKey)) { + let value = json[origKey]; + if (value instanceof Array || (value !== null && value.constructor === Object)) { + value = applyPropertyNameConverter(value, converter); + } + const newKey = converter(origKey); + json[newKey] = json[origKey]; + delete json[origKey]; + json[newKey] = value; + } + }); + } + return json; +} + +function transformPropertyNames(json: any, modelPropertyNaming: ModelPropertyNaming) { + switch (modelPropertyNaming) { + case 'camelCase': + return applyPropertyNameConverter(json, toCamelCase); + + case 'original': + default: + return json; + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts index b806c22b2afa..590cace43914 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts @@ -1,4 +1,3 @@ -/// // tslint:disable /** * OpenAPI Petstore @@ -7,2214 +6,951 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ -import * as url from "url"; -import * as portableFetch from "portable-fetch"; -import { Configuration } from "./configuration"; +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface FetchAPI - */ -export interface FetchAPI { - (url: string, init?: any): Promise; -} - -/** - * - * @export - * @interface FetchArgs - */ -export interface FetchArgs { - url: string; - options: any; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - name: "RequiredError" - constructor(public field: string, msg?: string) { - super(msg); - } -} - -/** - * Describes the result of uploading an image resource - * @export - * @interface ApiResponse - */ +// Describes the result of uploading an image resource export interface ApiResponse { - /** - * - * @type {number} - * @memberof ApiResponse - */ - code?: number; - /** - * - * @type {string} - * @memberof ApiResponse - */ - type?: string; - /** - * - * @type {string} - * @memberof ApiResponse - */ - message?: string; + code?: number; + type?: string; + message?: string; } -/** - * A category for a pet - * @export - * @interface Category - */ +// A category for a pet export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; + id?: number; + name?: string; } -/** - * An order for a pets from the pet store - * @export - * @interface Order - */ +// An order for a pets from the pet store 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; + id?: number; + petId?: number; + quantity?: number; + shipDate?: Date; + status?: Order.StatusEnum; // Order Status + complete?: boolean; } -/** - * @export - * @namespace Order - */ export namespace Order { - /** - * @export - * @enum {string} - */ export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' + Placed = 'placed', // Order Status + Approved = 'approved', // Order Status + Delivered = 'delivered' // Order Status } } -/** - * A pet for sale in the pet store - * @export - * @interface Pet - */ +// A pet for sale in the pet store 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; + id?: number; + category?: Category; + name: string; + photoUrls: Array; + tags?: Array; + status?: Pet.StatusEnum; // pet status in the store } -/** - * @export - * @namespace Pet - */ export namespace Pet { - /** - * @export - * @enum {string} - */ export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' + Available = 'available', // pet status in the store + Pending = 'pending', // pet status in the store + Sold = 'sold' // pet status in the store } } -/** - * A tag for a pet - * @export - * @interface Tag - */ +// A tag for a pet export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; + id?: number; + name?: string; } -/** - * A User who is purchasing from the pet store - * @export - * @interface User - */ +// A User who is purchasing from the pet store 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; + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + userStatus?: number; // User Status } -/** - * PetApi - fetch parameter creator - * @export - */ -export const PetApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface AddPetRequest { + pet: Pet; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface FindPetsByStatusRequest { + status: Array<'available' | 'pending' | 'sold'>; +} - if (apiKey !== undefined && apiKey !== null) { - localVarHeaderParameter['api_key'] = String(apiKey); - } +export interface FindPetsByTagsRequest { + tags: Array; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options: any = {}): FetchArgs { - // verify required parameter 'status' is not null or undefined - if (status === null || status === undefined) { - throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); - } - const localVarPath = `/pet/findByStatus`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface GetPetByIdRequest { + petId: number; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface UpdatePetRequest { + pet: Pet; +} - if (status) { - localVarQueryParameter['status'] = status.join(COLLECTION_FORMATS["csv"]); - } +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options: any = {}): FetchArgs { - // verify required parameter 'tags' is not null or undefined - if (tags === null || tags === undefined) { - throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); - } - const localVarPath = `/pet/findByTags`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: any; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface DeleteOrderRequest { + orderId: string; +} - if (tags) { - localVarQueryParameter['tags'] = tags.join(COLLECTION_FORMATS["csv"]); - } +export interface GetOrderByIdRequest { + orderId: number; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getPetById(petId: number, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; - } +export interface PlaceOrderRequest { + order: Order; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface CreateUserRequest { + user: User; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface CreateUsersWithArrayInputRequest { + user: Array; +} - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface CreateUsersWithListInputRequest { + user: Array; +} - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } +export interface DeleteUserRequest { + username: string; +} - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } +export interface GetUserByNameRequest { + username: string; +} - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling uploadFile.'); - } - const localVarPath = `/pet/{petId}/uploadImage` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface LoginUserRequest { + username: string; + password: string; +} - if (additionalMetadata !== undefined) { - localVarFormParams.set('additionalMetadata', additionalMetadata as any); - } +export interface UpdateUserRequest { + username: string; + user: User; +} - if (file !== undefined) { - localVarFormParams.set('file', file as any); - } - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); + private middleware: Middleware[]; - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; } -}; -/** - * PetApi - functional programming interface - * @export - */ -export const PetApiFp = function(configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(pet, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByStatus(status, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByTags(tags, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - getPetById(petId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).getPetById(petId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(pet, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; } -}; - -/** - * PetApi - factory interface - * @export - */ -export const PetApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options?: any) { - return PetApiFp(configuration).addPet(pet, options)(fetch, basePath); - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options?: any) { - return PetApiFp(configuration).deletePet(petId, apiKey, options)(fetch, basePath); - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { - return PetApiFp(configuration).findPetsByStatus(status, options)(fetch, basePath); - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options?: any) { - return PetApiFp(configuration).findPetsByTags(tags, options)(fetch, basePath); - }, - /** - * 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} - */ - getPetById(petId: number, options?: any) { - return PetApiFp(configuration).getPetById(petId, options)(fetch, basePath); - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options?: any) { - return PetApiFp(configuration).updatePet(pet, options)(fetch, basePath); - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { - return PetApiFp(configuration).updatePetWithForm(petId, name, status, options)(fetch, basePath); - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { - return PetApiFp(configuration).uploadFile(petId, additionalMetadata, file, options)(fetch, basePath); - }, - }; -}; - -/** - * 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<{}>; + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } - /** - * 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>; + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } - /** - * 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>; + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + switch(context.responseType) { + case 'JSON': + const result = await response.json() as T; + return transformPropertyNames(result, context.modelPropertyNaming); + case 'text': + return await response.text() as any as T; + default: + return response as any as T; + } + } + throw response; + } - /** - * 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; + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } - /** - * - * @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<{}>; + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre(this.fetchApi, fetchParams.url, fetchParams.init) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post(this.fetchApi, url, init, response.clone()) || response; + } + } + return response; + } /** - * - * @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 + * https://swagger.io/docs/specification/2-0/describing-responses/ + * + * If the response type for a given API is a 'string' we need to avoid + * parsing the response as json because JSON.parse("some string") will + * fail when the string isn't actually JSON. */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise<{}>; + protected getResponseType(returnType: string): ResponseType { + switch (returnType) { + case 'string': + return 'text' + default: + return 'JSON' + } + } /** - * - * @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 + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): Promise; + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; +export class RequiredError extends Error { + name = 'RequiredError'; + constructor(public field: string, msg?: string) { + super(msg); + } } + /** - * PetApi - object-oriented interface - * @export - * @class PetApi - * @extends {BaseAPI} + * no description */ -export class PetApi extends BaseAPI implements PetApiInterface { +export class PetApi extends BaseAPI { + /** - * - * @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 PetApi + * Add a new pet to the store */ - public addPet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).addPet(pet, options)(this.fetch, this.basePath); + async addPet(requestParameters: AddPetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet`, + method: 'POST', + headers: headerParameters, + body: requestParameters.pet, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApi + * Deletes a pet */ - public deletePet(petId: number, apiKey?: string, options?: any) { - return PetApiFp(this.configuration).deletePet(petId, apiKey, options)(this.fetch, this.basePath); + async deletePet(requestParameters: DeletePetRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Finds Pets by status */ - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { - return PetApiFp(this.configuration).findPetsByStatus(status, options)(this.fetch, this.basePath); + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(COLLECTION_FORMATS["csv"]); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request>({ + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('Array'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Finds Pets by tags */ - public findPetsByTags(tags: Array, options?: any) { - return PetApiFp(this.configuration).findPetsByTags(tags, options)(this.fetch, this.basePath); + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(COLLECTION_FORMATS["csv"]); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request>({ + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('Array'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Find pet by ID */ - public getPetById(petId: number, options?: any) { - return PetApiFp(this.configuration).getPetById(petId, options)(this.fetch, this.basePath); - } + async getPetById(requestParameters: GetPetByIdRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } - /** - * - * @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 PetApi - */ - public updatePet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).updatePet(pet, options)(this.fetch, this.basePath); + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('Pet'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * Update an existing pet */ - public updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { - return PetApiFp(this.configuration).updatePetWithForm(petId, name, status, options)(this.fetch, this.basePath); + async updatePet(requestParameters: UpdatePetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet`, + method: 'PUT', + headers: headerParameters, + body: requestParameters.pet, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * Updates a pet in the store with form data */ - public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { - return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options)(this.fetch, this.basePath); - } + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } -} + const headerParameters: HTTPHeaders = {}; -/** - * StoreApi - fetch parameter creator - * @export - */ -export const StoreApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling deleteOrder.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options: any = {}): FetchArgs { - const localVarPath = `/store/inventory`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; } + } - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling getOrderById.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options: any = {}): FetchArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); - } - const localVarPath = `/store/order`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(order || {}) : (order || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; + const formData = new FormData(); + if (requestParameters.name !== undefined) { + formData.set('name', requestParameters.name as any); + } -/** - * StoreApi - functional programming interface - * @export - */ -export const StoreApiFp = function(configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getInventory(options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getOrderById(orderId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).placeOrder(order, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - } -}; + if (requestParameters.status !== undefined) { + formData.set('status', requestParameters.status as any); + } -/** - * StoreApi - factory interface - * @export - */ -export const StoreApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options?: any) { - return StoreApiFp(configuration).deleteOrder(orderId, options)(fetch, basePath); - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options?: any) { - return StoreApiFp(configuration).getInventory(options)(fetch, basePath); - }, - /** - * 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} - */ - getOrderById(orderId: number, options?: any) { - return StoreApiFp(configuration).getOrderById(orderId, options)(fetch, basePath); - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options?: any) { - return StoreApiFp(configuration).placeOrder(order, options)(fetch, basePath); - }, - }; -}; + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + modelPropertyNaming: 'camelCase', + }); + } -/** - * 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 + * uploads an image */ - deleteOrder(orderId: string, options?: any): Promise<{}>; + async uploadFile(requestParameters: UploadFileRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } - /** - * 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; }>; + const headerParameters: HTTPHeaders = {}; - /** - * 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; + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } - /** - * - * @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; + const formData = new FormData(); + if (requestParameters.additionalMetadata !== undefined) { + formData.set('additionalMetadata', requestParameters.additionalMetadata as any); + } + + if (requestParameters.file !== undefined) { + formData.set('file', requestParameters.file as any); + } + + return this.request({ + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + responseType: this.getResponseType('ApiResponse'), + modelPropertyNaming: 'camelCase', + }); + } } /** - * StoreApi - object-oriented interface - * @export - * @class StoreApi - * @extends {BaseAPI} + * no description */ -export class StoreApi extends BaseAPI implements StoreApiInterface { +export class StoreApi extends BaseAPI { + /** * 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 StoreApi + * Delete purchase order by ID */ - public deleteOrder(orderId: string, options?: any) { - return StoreApiFp(this.configuration).deleteOrder(orderId, options)(this.fetch, this.basePath); + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApi + * Returns pet inventories by status */ - public getInventory(options?: any) { - return StoreApiFp(this.configuration).getInventory(options)(this.fetch, this.basePath); + async getInventory(): Promise<{ [key: string]: number; }> { + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + return this.request<{ [key: string]: number; }>({ + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('{ [key: string]: number; }'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 StoreApi + * Find purchase order by ID */ - public getOrderById(orderId: number, options?: any) { - return StoreApiFp(this.configuration).getOrderById(orderId, options)(this.fetch, this.basePath); + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('Order'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 StoreApi + * Place an order for a pet */ - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.fetch, this.basePath); - } + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + if (requestParameters.order === null || requestParameters.order === undefined) { + throw new RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + } -} + const headerParameters: HTTPHeaders = {}; -/** - * UserApi - fetch parameter creator - * @export - */ -export const UserApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); - } - const localVarPath = `/user`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); - } - const localVarPath = `/user/createWithArray`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); - } - const localVarPath = `/user/createWithList`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - deleteUser(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('password','Required parameter password was null or undefined when calling loginUser.'); - } - const localVarPath = `/user/login`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - if (username !== undefined) { - localVarQueryParameter['username'] = username; - } - - if (password !== undefined) { - localVarQueryParameter['password'] = password; - } + headerParameters['Content-Type'] = 'application/json'; - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options: any = {}): FetchArgs { - const localVarPath = `/user/logout`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('user','Required parameter user was null or undefined when calling updateUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, + return this.request({ + path: `/store/order`, + method: 'POST', + headers: headerParameters, + body: requestParameters.order, + responseType: this.getResponseType('Order'), + modelPropertyNaming: 'camelCase', + }); } -}; -/** - * UserApi - functional programming interface - * @export - */ -export const UserApiFp = function(configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).getUserByName(username, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).loginUser(username, password, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - } -}; +} /** - * UserApi - factory interface - * @export + * no description */ -export const UserApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * 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} - */ - createUser(user: User, options?: any) { - return UserApiFp(configuration).createUser(user, options)(fetch, basePath); - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithArrayInput(user, options)(fetch, basePath); - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithListInput(user, options)(fetch, basePath); - }, - /** - * 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} - */ - deleteUser(username: string, options?: any) { - return UserApiFp(configuration).deleteUser(username, options)(fetch, basePath); - }, - /** - * - * @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} - */ - getUserByName(username: string, options?: any) { - return UserApiFp(configuration).getUserByName(username, options)(fetch, basePath); - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options?: any) { - return UserApiFp(configuration).loginUser(username, password, options)(fetch, basePath); - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options?: any) { - return UserApiFp(configuration).logoutUser(options)(fetch, basePath); - }, - /** - * 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} - */ - updateUser(username: string, user: User, options?: any) { - return UserApiFp(configuration).updateUser(username, user, options)(fetch, basePath); - }, - }; -}; +export class UserApi extends BaseAPI { -/** - * 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 + * Create user */ - 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<{}>; + async createUser(requestParameters: CreateUserRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + } - /** - * 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<{}>; + const headerParameters: HTTPHeaders = {}; - /** - * - * @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; + headerParameters['Content-Type'] = 'application/json'; - /** - * - * @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; + return this.request({ + path: `/user`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); + } /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApiInterface + * Creates list of users with given input array */ - logoutUser(options?: any): Promise<{}>; + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + } - /** - * 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<{}>; + const headerParameters: HTTPHeaders = {}; -} + headerParameters['Content-Type'] = 'application/json'; -/** - * UserApi - object-oriented interface - * @export - * @class UserApi - * @extends {BaseAPI} - */ -export class UserApi extends BaseAPI implements 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 UserApi - */ - public createUser(user: User, options?: any) { - return UserApiFp(this.configuration).createUser(user, options)(this.fetch, this.basePath); + return this.request({ + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Creates list of users with given input array */ - public createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithArrayInput(user, options)(this.fetch, this.basePath); - } + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + } - /** - * - * @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 UserApi - */ - public createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithListInput(user, options)(this.fetch, this.basePath); + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** * 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 UserApi + * Delete user */ - public deleteUser(username: string, options?: any) { - return UserApiFp(this.configuration).deleteUser(username, options)(this.fetch, this.basePath); + async deleteUser(requestParameters: DeleteUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Get user by user name */ - public getUserByName(username: string, options?: any) { - return UserApiFp(this.configuration).getUserByName(username, options)(this.fetch, this.basePath); + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('User'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Logs user into the system */ - public loginUser(username: string, password: string, options?: any) { - return UserApiFp(this.configuration).loginUser(username, password, options)(this.fetch, this.basePath); + async loginUser(requestParameters: LoginUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('string'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApi + * Logs out current logged in user session */ - public logoutUser(options?: any) { - return UserApiFp(this.configuration).logoutUser(options)(this.fetch, this.basePath); + async logoutUser(): Promise { + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * 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 UserApi + * Updated user */ - public updateUser(username: string, user: User, options?: any) { - return UserApiFp(this.configuration).updateUser(username, user, options)(this.fetch, this.basePath); + async updateUser(requestParameters: UpdateUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } } + + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = GlobalFetch['fetch']; + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // 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 +} + +export class Configuration { + + basePath: string; + fetchApi: FetchAPI; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + 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; + } + } +} + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +type ResponseType = 'JSON' | 'text'; + +interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; + responseType?: ResponseType; + modelPropertyNaming: ModelPropertyNaming; +} + +function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} + +export interface Middleware { + pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; + post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; +} + +function capitalize(word: string) { + return word.charAt(0).toUpperCase() + word.slice(1); +} + +function toPascalCase(name: string) { + return name + .split('_') + .map(capitalize) + .join(''); +} + +function toCamelCase(name: string) { + const pascalCase = toPascalCase(name); + return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1); +} + +function applyPropertyNameConverter(json: any, converter: (name: string) => string) { + if (json instanceof Array) { + json.forEach((value) => { + if (typeof value === 'object') { + return applyPropertyNameConverter(value, converter); + } + }); + } else { + Object.keys(json).forEach((origKey) => { + if (json.hasOwnProperty(origKey)) { + let value = json[origKey]; + if (value instanceof Array || (value !== null && value.constructor === Object)) { + value = applyPropertyNameConverter(value, converter); + } + const newKey = converter(origKey); + json[newKey] = json[origKey]; + delete json[origKey]; + json[newKey] = value; + } + }); + } + return json; +} + +function transformPropertyNames(json: any, modelPropertyNaming: ModelPropertyNaming) { + switch (modelPropertyNaming) { + case 'camelCase': + return applyPropertyNameConverter(json, toCamelCase); + + case 'original': + default: + return json; + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts index b1af2421c621..590cace43914 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts @@ -1,4 +1,3 @@ -/// // tslint:disable /** * OpenAPI Petstore @@ -7,1985 +6,951 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ -import * as url from "url"; -import * as portableFetch from "portable-fetch"; -import { Configuration } from "./configuration"; +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface FetchAPI - */ -export interface FetchAPI { - (url: string, init?: any): Promise; -} - -/** - * - * @export - * @interface FetchArgs - */ -export interface FetchArgs { - url: string; - options: any; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - name: "RequiredError" - constructor(public field: string, msg?: string) { - super(msg); - } -} - -/** - * Describes the result of uploading an image resource - * @export - * @interface ApiResponse - */ +// Describes the result of uploading an image resource export interface ApiResponse { - /** - * - * @type {number} - * @memberof ApiResponse - */ - code?: number; - /** - * - * @type {string} - * @memberof ApiResponse - */ - type?: string; - /** - * - * @type {string} - * @memberof ApiResponse - */ - message?: string; + code?: number; + type?: string; + message?: string; } -/** - * A category for a pet - * @export - * @interface Category - */ +// A category for a pet export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; + id?: number; + name?: string; } -/** - * An order for a pets from the pet store - * @export - * @interface Order - */ +// An order for a pets from the pet store 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; + id?: number; + petId?: number; + quantity?: number; + shipDate?: Date; + status?: Order.StatusEnum; // Order Status + complete?: boolean; } -/** - * @export - * @namespace Order - */ export namespace Order { - /** - * @export - * @enum {string} - */ export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' + Placed = 'placed', // Order Status + Approved = 'approved', // Order Status + Delivered = 'delivered' // Order Status } } -/** - * A pet for sale in the pet store - * @export - * @interface Pet - */ +// A pet for sale in the pet store 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; + id?: number; + category?: Category; + name: string; + photoUrls: Array; + tags?: Array; + status?: Pet.StatusEnum; // pet status in the store } -/** - * @export - * @namespace Pet - */ export namespace Pet { - /** - * @export - * @enum {string} - */ export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' + Available = 'available', // pet status in the store + Pending = 'pending', // pet status in the store + Sold = 'sold' // pet status in the store } } -/** - * A tag for a pet - * @export - * @interface Tag - */ +// A tag for a pet export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; + id?: number; + name?: string; } -/** - * A User who is purchasing from the pet store - * @export - * @interface User - */ +// A User who is purchasing from the pet store 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; + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + userStatus?: number; // User Status } -/** - * PetApi - fetch parameter creator - * @export - */ -export const PetApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface AddPetRequest { + pet: Pet; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface FindPetsByStatusRequest { + status: Array<'available' | 'pending' | 'sold'>; +} - if (apiKey !== undefined && apiKey !== null) { - localVarHeaderParameter['api_key'] = String(apiKey); - } +export interface FindPetsByTagsRequest { + tags: Array; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options: any = {}): FetchArgs { - // verify required parameter 'status' is not null or undefined - if (status === null || status === undefined) { - throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); - } - const localVarPath = `/pet/findByStatus`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface GetPetByIdRequest { + petId: number; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface UpdatePetRequest { + pet: Pet; +} - if (status) { - localVarQueryParameter['status'] = status.join(COLLECTION_FORMATS["csv"]); - } +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options: any = {}): FetchArgs { - // verify required parameter 'tags' is not null or undefined - if (tags === null || tags === undefined) { - throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); - } - const localVarPath = `/pet/findByTags`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: any; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface DeleteOrderRequest { + orderId: string; +} - if (tags) { - localVarQueryParameter['tags'] = tags.join(COLLECTION_FORMATS["csv"]); - } +export interface GetOrderByIdRequest { + orderId: number; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getPetById(petId: number, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; - } +export interface PlaceOrderRequest { + order: Order; +} - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; +export interface CreateUserRequest { + user: User; +} - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface CreateUsersWithArrayInputRequest { + user: Array; +} - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface CreateUsersWithListInputRequest { + user: Array; +} - if (name !== undefined) { - localVarFormParams.set('name', name as any); - } +export interface DeleteUserRequest { + username: string; +} - if (status !== undefined) { - localVarFormParams.set('status', status as any); - } +export interface GetUserByNameRequest { + username: string; +} - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling uploadFile.'); - } - const localVarPath = `/pet/{petId}/uploadImage` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } +export interface LoginUserRequest { + username: string; + password: string; +} - if (additionalMetadata !== undefined) { - localVarFormParams.set('additionalMetadata', additionalMetadata as any); - } +export interface UpdateUserRequest { + username: string; + user: User; +} + + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } - if (file !== undefined) { - localVarFormParams.set('file', file as any); + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + switch(context.responseType) { + case 'JSON': + const result = await response.json() as T; + return transformPropertyNames(result, context.modelPropertyNaming); + case 'text': + return await response.text() as any as T; + default: + return response as any as T; } + } + throw response; + } - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre(this.fetchApi, fetchParams.url, fetchParams.init) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post(this.fetchApi, url, init, response.clone()) || response; + } + } + return response; + } - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, + /** + * https://swagger.io/docs/specification/2-0/describing-responses/ + * + * If the response type for a given API is a 'string' we need to avoid + * parsing the response as json because JSON.parse("some string") will + * fail when the string isn't actually JSON. + */ + protected getResponseType(returnType: string): ResponseType { + switch (returnType) { + case 'string': + return 'text' + default: + return 'JSON' + } } -}; -/** - * PetApi - functional programming interface - * @export - */ -export const PetApiFp = function(configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(pet, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByStatus(status, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByTags(tags, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - getPetById(petId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).getPetById(petId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(pet, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = PetApiFetchParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; } }; -/** - * PetApi - factory interface - * @export - */ -export const PetApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options?: any) { - return PetApiFp(configuration).addPet(pet, options)(fetch, basePath); - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options?: any) { - return PetApiFp(configuration).deletePet(petId, apiKey, options)(fetch, basePath); - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { - return PetApiFp(configuration).findPetsByStatus(status, options)(fetch, basePath); - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options?: any) { - return PetApiFp(configuration).findPetsByTags(tags, options)(fetch, basePath); - }, - /** - * 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} - */ - getPetById(petId: number, options?: any) { - return PetApiFp(configuration).getPetById(petId, options)(fetch, basePath); - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options?: any) { - return PetApiFp(configuration).updatePet(pet, options)(fetch, basePath); - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { - return PetApiFp(configuration).updatePetWithForm(petId, name, status, options)(fetch, basePath); - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { - return PetApiFp(configuration).uploadFile(petId, additionalMetadata, file, options)(fetch, basePath); - }, - }; -}; +export class RequiredError extends Error { + name = 'RequiredError'; + constructor(public field: string, msg?: string) { + super(msg); + } +} + /** - * PetApi - object-oriented interface - * @export - * @class PetApi - * @extends {BaseAPI} + * no description */ export class PetApi extends BaseAPI { + /** - * - * @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 PetApi + * Add a new pet to the store */ - public addPet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).addPet(pet, options)(this.fetch, this.basePath); + async addPet(requestParameters: AddPetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet`, + method: 'POST', + headers: headerParameters, + body: requestParameters.pet, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof PetApi + * Deletes a pet */ - public deletePet(petId: number, apiKey?: string, options?: any) { - return PetApiFp(this.configuration).deletePet(petId, apiKey, options)(this.fetch, this.basePath); + async deletePet(requestParameters: DeletePetRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Finds Pets by status */ - public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { - return PetApiFp(this.configuration).findPetsByStatus(status, options)(this.fetch, this.basePath); + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(COLLECTION_FORMATS["csv"]); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request>({ + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('Array'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Finds Pets by tags */ - public findPetsByTags(tags: Array, options?: any) { - return PetApiFp(this.configuration).findPetsByTags(tags, options)(this.fetch, this.basePath); + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(COLLECTION_FORMATS["csv"]); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request>({ + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('Array'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 PetApi + * Find pet by ID */ - public getPetById(petId: number, options?: any) { - return PetApiFp(this.configuration).getPetById(petId, options)(this.fetch, this.basePath); + async getPetById(requestParameters: GetPetByIdRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('Pet'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * Update an existing pet */ - public updatePet(pet: Pet, options?: any) { - return PetApiFp(this.configuration).updatePet(pet, options)(this.fetch, this.basePath); + async updatePet(requestParameters: UpdatePetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + return this.request({ + path: `/pet`, + method: 'PUT', + headers: headerParameters, + body: requestParameters.pet, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * Updates a pet in the store with form data */ - public updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { - return PetApiFp(this.configuration).updatePetWithForm(petId, name, status, options)(this.fetch, this.basePath); + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } + + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.name !== undefined) { + formData.set('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + formData.set('status', requestParameters.status as any); + } + + return this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 PetApi + * uploads an image */ - public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { - return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options)(this.fetch, this.basePath); - } + async uploadFile(requestParameters: UploadFileRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } -} + const headerParameters: HTTPHeaders = {}; -/** - * StoreApi - fetch parameter creator - * @export - */ -export const StoreApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling deleteOrder.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options: any = {}): FetchArgs { - const localVarPath = `/store/inventory`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; } + } - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling getOrderById.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options: any = {}): FetchArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); - } - const localVarPath = `/store/order`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(order || {}) : (order || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; + const formData = new FormData(); + if (requestParameters.additionalMetadata !== undefined) { + formData.set('additionalMetadata', requestParameters.additionalMetadata as any); + } -/** - * StoreApi - functional programming interface - * @export - */ -export const StoreApiFp = function(configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getInventory(options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getOrderById(orderId, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = StoreApiFetchParamCreator(configuration).placeOrder(order, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, + if (requestParameters.file !== undefined) { + formData.set('file', requestParameters.file as any); + } + + return this.request({ + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + responseType: this.getResponseType('ApiResponse'), + modelPropertyNaming: 'camelCase', + }); } -}; -/** - * StoreApi - factory interface - * @export - */ -export const StoreApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options?: any) { - return StoreApiFp(configuration).deleteOrder(orderId, options)(fetch, basePath); - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options?: any) { - return StoreApiFp(configuration).getInventory(options)(fetch, basePath); - }, - /** - * 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} - */ - getOrderById(orderId: number, options?: any) { - return StoreApiFp(configuration).getOrderById(orderId, options)(fetch, basePath); - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options?: any) { - return StoreApiFp(configuration).placeOrder(order, options)(fetch, basePath); - }, - }; -}; +} /** - * StoreApi - object-oriented interface - * @export - * @class StoreApi - * @extends {BaseAPI} + * no description */ export class StoreApi extends BaseAPI { + /** * 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 StoreApi + * Delete purchase order by ID */ - public deleteOrder(orderId: string, options?: any) { - return StoreApiFp(this.configuration).deleteOrder(orderId, options)(this.fetch, this.basePath); + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof StoreApi + * Returns pet inventories by status */ - public getInventory(options?: any) { - return StoreApiFp(this.configuration).getInventory(options)(this.fetch, this.basePath); + async getInventory(): Promise<{ [key: string]: number; }> { + const headerParameters: HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + return this.request<{ [key: string]: number; }>({ + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('{ [key: string]: number; }'), + modelPropertyNaming: 'camelCase', + }); } /** * 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 StoreApi + * Find purchase order by ID */ - public getOrderById(orderId: number, options?: any) { - return StoreApiFp(this.configuration).getOrderById(orderId, options)(this.fetch, this.basePath); + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('Order'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 StoreApi + * Place an order for a pet */ - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.fetch, this.basePath); - } - -} - -/** - * UserApi - fetch parameter creator - * @export - */ -export const UserApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); - } - const localVarPath = `/user`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); - } - const localVarPath = `/user/createWithArray`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); - } - const localVarPath = `/user/createWithList`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'POST' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - deleteUser(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('password','Required parameter password was null or undefined when calling loginUser.'); - } - const localVarPath = `/user/login`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - if (username !== undefined) { - localVarQueryParameter['username'] = username; - } + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + if (requestParameters.order === null || requestParameters.order === undefined) { + throw new RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + } - if (password !== undefined) { - localVarQueryParameter['password'] = password; - } + const headerParameters: HTTPHeaders = {}; - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options: any = {}): FetchArgs { - const localVarPath = `/user/logout`; - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'GET' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('user','Required parameter user was null or undefined when calling updateUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; + headerParameters['Content-Type'] = 'application/json'; -/** - * UserApi - functional programming interface - * @export - */ -export const UserApiFp = function(configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).getUserByName(username, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).loginUser(username, password, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response.json(); - } else { - throw response; - } - }); - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, user, options); - return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { - if (response.status >= 200 && response.status < 300) { - return response; - } else { - throw response; - } - }); - }; - }, + return this.request({ + path: `/store/order`, + method: 'POST', + headers: headerParameters, + body: requestParameters.order, + responseType: this.getResponseType('Order'), + modelPropertyNaming: 'camelCase', + }); } -}; -/** - * UserApi - factory interface - * @export - */ -export const UserApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) { - return { - /** - * 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} - */ - createUser(user: User, options?: any) { - return UserApiFp(configuration).createUser(user, options)(fetch, basePath); - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithArrayInput(user, options)(fetch, basePath); - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(configuration).createUsersWithListInput(user, options)(fetch, basePath); - }, - /** - * 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} - */ - deleteUser(username: string, options?: any) { - return UserApiFp(configuration).deleteUser(username, options)(fetch, basePath); - }, - /** - * - * @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} - */ - getUserByName(username: string, options?: any) { - return UserApiFp(configuration).getUserByName(username, options)(fetch, basePath); - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options?: any) { - return UserApiFp(configuration).loginUser(username, password, options)(fetch, basePath); - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options?: any) { - return UserApiFp(configuration).logoutUser(options)(fetch, basePath); - }, - /** - * 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} - */ - updateUser(username: string, user: User, options?: any) { - return UserApiFp(configuration).updateUser(username, user, options)(fetch, basePath); - }, - }; -}; +} /** - * UserApi - object-oriented interface - * @export - * @class UserApi - * @extends {BaseAPI} + * no description */ export class UserApi extends BaseAPI { + /** * 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 UserApi + * Create user */ - public createUser(user: User, options?: any) { - return UserApiFp(this.configuration).createUser(user, options)(this.fetch, this.basePath); + async createUser(requestParameters: CreateUserRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Creates list of users with given input array */ - public createUsersWithArrayInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithArrayInput(user, options)(this.fetch, this.basePath); + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Creates list of users with given input array */ - public createUsersWithListInput(user: Array, options?: any) { - return UserApiFp(this.configuration).createUsersWithListInput(user, options)(this.fetch, this.basePath); + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); } /** * 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 UserApi + * Delete user */ - public deleteUser(username: string, options?: any) { - return UserApiFp(this.configuration).deleteUser(username, options)(this.fetch, this.basePath); + async deleteUser(requestParameters: DeleteUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Get user by user name */ - public getUserByName(username: string, options?: any) { - return UserApiFp(this.configuration).getUserByName(username, options)(this.fetch, this.basePath); + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + responseType: this.getResponseType('User'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @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 UserApi + * Logs user into the system */ - public loginUser(username: string, password: string, options?: any) { - return UserApiFp(this.configuration).loginUser(username, password, options)(this.fetch, this.basePath); + async loginUser(requestParameters: LoginUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: HTTPQuery = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + responseType: this.getResponseType('string'), + modelPropertyNaming: 'camelCase', + }); } /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserApi + * Logs out current logged in user session */ - public logoutUser(options?: any) { - return UserApiFp(this.configuration).logoutUser(options)(this.fetch, this.basePath); + async logoutUser(): Promise { + const headerParameters: HTTPHeaders = {}; + + return this.request({ + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + modelPropertyNaming: 'camelCase', + }); } /** * 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 UserApi + * Updated user */ - public updateUser(username: string, user: User, options?: any) { - return UserApiFp(this.configuration).updateUser(username, user, options)(this.fetch, this.basePath); + async updateUser(requestParameters: UpdateUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + } + + const headerParameters: HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + return this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + body: requestParameters.user, + modelPropertyNaming: 'camelCase', + }); + } + +} + + + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = GlobalFetch['fetch']; + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // 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 +} + +export class Configuration { + + basePath: string; + fetchApi: FetchAPI; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + 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; + } } +} + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +type ResponseType = 'JSON' | 'text'; + +interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; + responseType?: ResponseType; + modelPropertyNaming: ModelPropertyNaming; +} + +function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} +export interface Middleware { + pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; + post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; } +function capitalize(word: string) { + return word.charAt(0).toUpperCase() + word.slice(1); +} + +function toPascalCase(name: string) { + return name + .split('_') + .map(capitalize) + .join(''); +} + +function toCamelCase(name: string) { + const pascalCase = toPascalCase(name); + return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1); +} + +function applyPropertyNameConverter(json: any, converter: (name: string) => string) { + if (json instanceof Array) { + json.forEach((value) => { + if (typeof value === 'object') { + return applyPropertyNameConverter(value, converter); + } + }); + } else { + Object.keys(json).forEach((origKey) => { + if (json.hasOwnProperty(origKey)) { + let value = json[origKey]; + if (value instanceof Array || (value !== null && value.constructor === Object)) { + value = applyPropertyNameConverter(value, converter); + } + const newKey = converter(origKey); + json[newKey] = json[origKey]; + delete json[origKey]; + json[newKey] = value; + } + }); + } + return json; +} + +function transformPropertyNames(json: any, modelPropertyNaming: ModelPropertyNaming) { + switch (modelPropertyNaming) { + case 'camelCase': + return applyPropertyNameConverter(json, toCamelCase); + + case 'original': + default: + return json; + } +} From 1692ce7141bac90d25aa2d0912c2217f1d3423b1 Mon Sep 17 00:00:00 2001 From: James Batt Date: Sun, 15 Jul 2018 12:19:55 +1000 Subject: [PATCH 03/39] use FormData.append rather than .set for IE11 compat --- .../src/main/resources/typescript-fetch/api.mustache | 4 ++-- .../petstore/typescript-fetch/builds/default/api.ts | 8 ++++---- .../petstore/typescript-fetch/builds/es6-target/api.ts | 8 ++++---- .../typescript-fetch/builds/with-interfaces/api.ts | 8 ++++---- .../typescript-fetch/builds/with-npm-version/api.ts | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache index af99f8bb27d7..5cb4854b0d06 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache @@ -264,14 +264,14 @@ export class {{classname}} extends BaseAPI { }) {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - formData.set('{{baseName}}', requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); + formData.append('{{baseName}}', requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); {{/isCollectionFormatMulti}} } {{/isListContainer}} {{^isListContainer}} if (requestParameters.{{paramName}} !== undefined) { - formData.set('{{baseName}}', requestParameters.{{paramName}} as any); + formData.append('{{baseName}}', requestParameters.{{paramName}} as any); } {{/isListContainer}} diff --git a/samples/client/petstore/typescript-fetch/builds/default/api.ts b/samples/client/petstore/typescript-fetch/builds/default/api.ts index 590cace43914..511049ee061f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -488,11 +488,11 @@ export class PetApi extends BaseAPI { const formData = new FormData(); if (requestParameters.name !== undefined) { - formData.set('name', requestParameters.name as any); + formData.append('name', requestParameters.name as any); } if (requestParameters.status !== undefined) { - formData.set('status', requestParameters.status as any); + formData.append('status', requestParameters.status as any); } return this.request({ @@ -525,11 +525,11 @@ export class PetApi extends BaseAPI { const formData = new FormData(); if (requestParameters.additionalMetadata !== undefined) { - formData.set('additionalMetadata', requestParameters.additionalMetadata as any); + formData.append('additionalMetadata', requestParameters.additionalMetadata as any); } if (requestParameters.file !== undefined) { - formData.set('file', requestParameters.file as any); + formData.append('file', requestParameters.file as any); } return this.request({ diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts index 590cace43914..511049ee061f 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts @@ -488,11 +488,11 @@ export class PetApi extends BaseAPI { const formData = new FormData(); if (requestParameters.name !== undefined) { - formData.set('name', requestParameters.name as any); + formData.append('name', requestParameters.name as any); } if (requestParameters.status !== undefined) { - formData.set('status', requestParameters.status as any); + formData.append('status', requestParameters.status as any); } return this.request({ @@ -525,11 +525,11 @@ export class PetApi extends BaseAPI { const formData = new FormData(); if (requestParameters.additionalMetadata !== undefined) { - formData.set('additionalMetadata', requestParameters.additionalMetadata as any); + formData.append('additionalMetadata', requestParameters.additionalMetadata as any); } if (requestParameters.file !== undefined) { - formData.set('file', requestParameters.file as any); + formData.append('file', requestParameters.file as any); } return this.request({ diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts index 590cace43914..511049ee061f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts @@ -488,11 +488,11 @@ export class PetApi extends BaseAPI { const formData = new FormData(); if (requestParameters.name !== undefined) { - formData.set('name', requestParameters.name as any); + formData.append('name', requestParameters.name as any); } if (requestParameters.status !== undefined) { - formData.set('status', requestParameters.status as any); + formData.append('status', requestParameters.status as any); } return this.request({ @@ -525,11 +525,11 @@ export class PetApi extends BaseAPI { const formData = new FormData(); if (requestParameters.additionalMetadata !== undefined) { - formData.set('additionalMetadata', requestParameters.additionalMetadata as any); + formData.append('additionalMetadata', requestParameters.additionalMetadata as any); } if (requestParameters.file !== undefined) { - formData.set('file', requestParameters.file as any); + formData.append('file', requestParameters.file as any); } return this.request({ diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts index 590cace43914..511049ee061f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts @@ -488,11 +488,11 @@ export class PetApi extends BaseAPI { const formData = new FormData(); if (requestParameters.name !== undefined) { - formData.set('name', requestParameters.name as any); + formData.append('name', requestParameters.name as any); } if (requestParameters.status !== undefined) { - formData.set('status', requestParameters.status as any); + formData.append('status', requestParameters.status as any); } return this.request({ @@ -525,11 +525,11 @@ export class PetApi extends BaseAPI { const formData = new FormData(); if (requestParameters.additionalMetadata !== undefined) { - formData.set('additionalMetadata', requestParameters.additionalMetadata as any); + formData.append('additionalMetadata', requestParameters.additionalMetadata as any); } if (requestParameters.file !== undefined) { - formData.set('file', requestParameters.file as any); + formData.append('file', requestParameters.file as any); } return this.request({ From ccfd874d292c970e783134cd92833106cfd0676a Mon Sep 17 00:00:00 2001 From: James Batt Date: Mon, 16 Jul 2018 21:27:59 +1000 Subject: [PATCH 04/39] reverted change to licenseInfo.mustache --- .../src/main/resources/typescript-fetch/licenseInfo.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/licenseInfo.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/licenseInfo.mustache index bbd8742e52a5..469fb03940fe 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/licenseInfo.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/licenseInfo.mustache @@ -5,7 +5,7 @@ * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ From 9c94a31df90857db85a68629c845088a797294e2 Mon Sep 17 00:00:00 2001 From: James Batt Date: Mon, 16 Jul 2018 21:45:21 +1000 Subject: [PATCH 05/39] reverted some comments --- .../typescript-fetch/modelEnum.mustache | 8 +++++-- .../typescript-fetch/modelGeneric.mustache | 23 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache index 94979d8d63ce..3143e1c0c6e8 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache @@ -1,8 +1,12 @@ -{{#description}}// {{description}}{{/description}} +/** + * {{{description}}} + * @export + * @enum {string} + */ export enum {{classname}} { {{#allowableValues}} {{#enumVars}} - {{{name}}} = {{{value}}}{{^-last}},{{/-last}} {{#description}}// {{description}}{{/description}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} {{#description}}// {{description}}{{/description}} {{/enumVars}} {{/allowableValues}} } diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index e47bae82c741..527cc1de0cbf 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -1,20 +1,37 @@ -{{#description}}// {{description}}{{/description}} +/** + * {{{description}}} + * @export + * @interface {{classname}} + */ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{#additionalPropertiesType}} [key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}}; {{/additionalPropertiesType}} {{#vars}} - {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; {{#description}}// {{description}}{{/description}} + /** + * {{{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}} {{#description}}// {{description}}{{/description}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} {{/enumVars}} {{/allowableValues}} } From 7a3efa994c5c6d5be844910d8ed30d6d82fdd8b4 Mon Sep 17 00:00:00 2001 From: James Batt Date: Thu, 19 Jul 2018 21:48:19 +1000 Subject: [PATCH 06/39] added package.json and tsconfig.json back to the generator --- .../typescript-fetch/package.mustache | 20 ++ .../typescript-fetch/tsconfig.mustache | 18 ++ .../typescript-fetch/builds/default/api.ts | 257 +++++++++++++++--- .../typescript-fetch/builds/es6-target/api.ts | 257 +++++++++++++++--- .../builds/es6-target/package.json | 16 +- .../builds/es6-target/tsconfig.json | 1 - .../builds/with-interfaces/api.ts | 257 +++++++++++++++--- .../builds/with-npm-version/api.ts | 257 +++++++++++++++--- .../builds/with-npm-version/package.json | 16 +- .../builds/with-npm-version/tsconfig.json | 1 - 10 files changed, 906 insertions(+), 194 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/tsconfig.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache new file mode 100644 index 000000000000..99bd327a22f0 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache @@ -0,0 +1,20 @@ +{ + "name": "{{npmName}}", + "version": "{{npmVersion}}", + "description": "OpenAPI client for {{npmName}}", + "author": "OpenAPI-Generator", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts" : { + "build": "tsc --outDir dist/", + "prepublishOnly": "npm run build" + }, + "devDependencies": { + "typescript": "^2.9" + }{{#npmRepository}},{{/npmRepository}} +{{#npmRepository}} + "publishConfig":{ + "registry":"{{npmRepository}}" + } +{{/npmRepository}} +} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/tsconfig.mustache new file mode 100644 index 000000000000..1c4f5fd4e712 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/tsconfig.mustache @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}", + "module": "commonjs", + "outDir": "dist", + "rootDir": "."{{^supportsES6}}, + "lib": [ + "es6", + "dom" + ] + {{/supportsES6}} + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-fetch/builds/default/api.ts b/samples/client/petstore/typescript-fetch/builds/default/api.ts index 511049ee061f..9ca1bee917b7 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -6,79 +6,254 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); -// Describes the result of uploading an image resource +/** + * Describes the result of uploading an image resource + * @export + * @interface ApiResponse + */ export interface ApiResponse { - code?: number; - type?: string; - message?: string; + /** + * + * @type {number} + * @memberof ApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ApiResponse + */ + message?: string; } -// A category for a pet +/** + * A category for a pet + * @export + * @interface Category + */ export interface Category { - id?: number; - name?: string; + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; } -// An order for a pets from the pet store +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ export interface Order { - id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - status?: Order.StatusEnum; // Order Status - complete?: boolean; + /** + * + * @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', // Order Status - Approved = 'approved', // Order Status - Delivered = 'delivered' // Order Status + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' } } -// A pet for sale in the pet store +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ export interface Pet { - id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - status?: Pet.StatusEnum; // pet status in the store + /** + * + * @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', // pet status in the store - Pending = 'pending', // pet status in the store - Sold = 'sold' // pet status in the store + Available = 'available', + Pending = 'pending', + Sold = 'sold' } } -// A tag for a pet +/** + * A tag for a pet + * @export + * @interface Tag + */ export interface Tag { - id?: number; - name?: string; + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; } -// A User who is purchasing from the pet store +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ export interface User { - id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - userStatus?: number; // User Status + /** + * + * @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-fetch/builds/es6-target/api.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts index 511049ee061f..9ca1bee917b7 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts @@ -6,79 +6,254 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); -// Describes the result of uploading an image resource +/** + * Describes the result of uploading an image resource + * @export + * @interface ApiResponse + */ export interface ApiResponse { - code?: number; - type?: string; - message?: string; + /** + * + * @type {number} + * @memberof ApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ApiResponse + */ + message?: string; } -// A category for a pet +/** + * A category for a pet + * @export + * @interface Category + */ export interface Category { - id?: number; - name?: string; + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; } -// An order for a pets from the pet store +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ export interface Order { - id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - status?: Order.StatusEnum; // Order Status - complete?: boolean; + /** + * + * @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', // Order Status - Approved = 'approved', // Order Status - Delivered = 'delivered' // Order Status + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' } } -// A pet for sale in the pet store +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ export interface Pet { - id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - status?: Pet.StatusEnum; // pet status in the store + /** + * + * @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', // pet status in the store - Pending = 'pending', // pet status in the store - Sold = 'sold' // pet status in the store + Available = 'available', + Pending = 'pending', + Sold = 'sold' } } -// A tag for a pet +/** + * A tag for a pet + * @export + * @interface Tag + */ export interface Tag { - id?: number; - name?: string; + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; } -// A User who is purchasing from the pet store +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ export interface User { - id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - userStatus?: number; // User Status + /** + * + * @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-fetch/builds/es6-target/package.json b/samples/client/petstore/typescript-fetch/builds/es6-target/package.json index 220573dfd7d8..cdac1209c010 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/package.json +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/package.json @@ -2,27 +2,15 @@ "name": "@swagger/typescript-fetch-petstore", "version": "1.0.0", "description": "OpenAPI client for @swagger/typescript-fetch-petstore", - "author": "OpenAPI-Generator Contributors", - "keywords": [ - "fetch", - "typescript", - "openapi-client", - "openapi-generator", - "@swagger/typescript-fetch-petstore" - ], - "license": "Unlicense", + "author": "OpenAPI-Generator", "main": "./dist/index.js", "typings": "./dist/index.d.ts", "scripts" : { "build": "tsc --outDir dist/", "prepublishOnly": "npm run build" }, - "dependencies": { - "portable-fetch": "^3.0.0" - }, "devDependencies": { - "@types/node": "^8.0.9", - "typescript": "^2.0" + "typescript": "^2.9" }, "publishConfig":{ "registry":"https://skimdb.npmjs.com/registry" diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/tsconfig.json b/samples/client/petstore/typescript-fetch/builds/es6-target/tsconfig.json index 0eb23e488b27..cbe91accff1d 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/tsconfig.json +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/tsconfig.json @@ -3,7 +3,6 @@ "declaration": true, "target": "es6", "module": "commonjs", - "noImplicitAny": true, "outDir": "dist", "rootDir": "." }, "exclude": [ diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts index 511049ee061f..9ca1bee917b7 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts @@ -6,79 +6,254 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); -// Describes the result of uploading an image resource +/** + * Describes the result of uploading an image resource + * @export + * @interface ApiResponse + */ export interface ApiResponse { - code?: number; - type?: string; - message?: string; + /** + * + * @type {number} + * @memberof ApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ApiResponse + */ + message?: string; } -// A category for a pet +/** + * A category for a pet + * @export + * @interface Category + */ export interface Category { - id?: number; - name?: string; + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; } -// An order for a pets from the pet store +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ export interface Order { - id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - status?: Order.StatusEnum; // Order Status - complete?: boolean; + /** + * + * @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', // Order Status - Approved = 'approved', // Order Status - Delivered = 'delivered' // Order Status + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' } } -// A pet for sale in the pet store +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ export interface Pet { - id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - status?: Pet.StatusEnum; // pet status in the store + /** + * + * @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', // pet status in the store - Pending = 'pending', // pet status in the store - Sold = 'sold' // pet status in the store + Available = 'available', + Pending = 'pending', + Sold = 'sold' } } -// A tag for a pet +/** + * A tag for a pet + * @export + * @interface Tag + */ export interface Tag { - id?: number; - name?: string; + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; } -// A User who is purchasing from the pet store +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ export interface User { - id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - userStatus?: number; // User Status + /** + * + * @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-fetch/builds/with-npm-version/api.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts index 511049ee061f..9ca1bee917b7 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts @@ -6,79 +6,254 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); -// Describes the result of uploading an image resource +/** + * Describes the result of uploading an image resource + * @export + * @interface ApiResponse + */ export interface ApiResponse { - code?: number; - type?: string; - message?: string; + /** + * + * @type {number} + * @memberof ApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ApiResponse + */ + message?: string; } -// A category for a pet +/** + * A category for a pet + * @export + * @interface Category + */ export interface Category { - id?: number; - name?: string; + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; } -// An order for a pets from the pet store +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ export interface Order { - id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - status?: Order.StatusEnum; // Order Status - complete?: boolean; + /** + * + * @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', // Order Status - Approved = 'approved', // Order Status - Delivered = 'delivered' // Order Status + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' } } -// A pet for sale in the pet store +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ export interface Pet { - id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - status?: Pet.StatusEnum; // pet status in the store + /** + * + * @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', // pet status in the store - Pending = 'pending', // pet status in the store - Sold = 'sold' // pet status in the store + Available = 'available', + Pending = 'pending', + Sold = 'sold' } } -// A tag for a pet +/** + * A tag for a pet + * @export + * @interface Tag + */ export interface Tag { - id?: number; - name?: string; + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; } -// A User who is purchasing from the pet store +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ export interface User { - id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - userStatus?: number; // User Status + /** + * + * @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-fetch/builds/with-npm-version/package.json b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json index 220573dfd7d8..cdac1209c010 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json @@ -2,27 +2,15 @@ "name": "@swagger/typescript-fetch-petstore", "version": "1.0.0", "description": "OpenAPI client for @swagger/typescript-fetch-petstore", - "author": "OpenAPI-Generator Contributors", - "keywords": [ - "fetch", - "typescript", - "openapi-client", - "openapi-generator", - "@swagger/typescript-fetch-petstore" - ], - "license": "Unlicense", + "author": "OpenAPI-Generator", "main": "./dist/index.js", "typings": "./dist/index.d.ts", "scripts" : { "build": "tsc --outDir dist/", "prepublishOnly": "npm run build" }, - "dependencies": { - "portable-fetch": "^3.0.0" - }, "devDependencies": { - "@types/node": "^8.0.9", - "typescript": "^2.0" + "typescript": "^2.9" }, "publishConfig":{ "registry":"https://skimdb.npmjs.com/registry" diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/tsconfig.json b/samples/client/petstore/typescript-fetch/builds/with-npm-version/tsconfig.json index 50ab7fa3f2fd..5a7e3c193526 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/tsconfig.json +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/tsconfig.json @@ -3,7 +3,6 @@ "declaration": true, "target": "es5", "module": "commonjs", - "noImplicitAny": true, "outDir": "dist", "rootDir": ".", "lib": [ From 2e6268d9d620a643d6b0e46360c57ac9207d978d Mon Sep 17 00:00:00 2001 From: James Batt Date: Wed, 25 Jul 2018 19:48:01 +1000 Subject: [PATCH 07/39] added support for blob (application/octet-stream) responses --- .../resources/typescript-fetch/api.mustache | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache index 3c13eceebbd6..e9e78ad3c3b8 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache @@ -56,11 +56,15 @@ export class BaseAPI { const response = await this.fetchApi(url, init); if (response.status >= 200 && response.status < 300) { switch(context.responseType) { - case 'JSON': + case ResponseType.response: + return response as any as T; + case ResponseType.text: + return await response.text() as any as T; + case ResponseType.file: + return await response.blob() as any as T; + case ResponseType.json: const result = await response.json() as T; return transformPropertyNames(result, context.modelPropertyNaming); - case 'text': - return await response.text() as any as T; default: return response as any as T; } @@ -110,10 +114,12 @@ export class BaseAPI { */ protected getResponseType(returnType: string): ResponseType { switch (returnType) { + case 'file': + return 'blob'; case 'string': - return 'text' + return 'text'; default: - return 'JSON' + return 'json'; } } @@ -292,7 +298,20 @@ export class {{classname}} extends BaseAPI { body: formData, {{/hasFormParams}} {{#returnType}} - responseType: this.getResponseType('{{{returnType}}}'), + {{#isResponseFile}} + responseType: ResponseType.file + {{/isResponseFile}} + {{^isResponseFile}} + {{#returnTypeIsPrimitive}} + responseType: this.getResponseType('{{returnType}}'), + {{/returnTypeIsPrimitive}} + {{^returnTypeIsPrimitive}} + responseType: ResponseType.json, + {{/returnTypeIsPrimitive}} + {{/isResponseFile}} + {{/returnType}} + {{^returnType}} + responseType: ResponseType.response, {{/returnType}} modelPropertyNaming: '{{modelPropertyNaming}}', }); @@ -360,7 +379,13 @@ export interface FetchParams { init: RequestInit; } -type ResponseType = 'JSON' | 'text'; +enum ResponseType { + file = 'file', + text = 'text', + blob = 'blob', + json = 'json', + response = 'response', +} interface RequestOpts { path: string; From 88a939f8ca1d0e294daf17d486b298e10ac24b68 Mon Sep 17 00:00:00 2001 From: James Batt Date: Thu, 26 Jul 2018 19:25:26 +1000 Subject: [PATCH 08/39] models and apis are now in folders --- .../TypeScriptFetchClientCodegen.java | 44 +++- .../typescript-fetch/apis.index.mustache | 7 + .../resources/typescript-fetch/apis.mustache | 202 +++++++++++++++++ .../resources/typescript-fetch/index.mustache | 3 + .../typescript-fetch/modelGeneric.mustache | 8 + .../typescript-fetch/models.index.mustache | 5 + .../typescript-fetch/models.mustache | 12 + .../{api.mustache => runtime.mustache} | 211 +----------------- 8 files changed, 284 insertions(+), 208 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/apis.index.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/index.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/models.index.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript-fetch/models.mustache rename modules/openapi-generator/src/main/resources/typescript-fetch/{api.mustache => runtime.mustache} (54%) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index f26c09ba5c28..8ff8522b97d5 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -25,8 +25,9 @@ import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.utils.ModelUtils; +import java.io.File; import java.text.SimpleDateFormat; -import java.util.Date; +import java.util.*; public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodegen { private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm"); @@ -51,6 +52,12 @@ public TypeScriptFetchClientCodegen() { outputFolder = "generated-code/typescript-fetch"; embeddedTemplateDir = templateDir = "typescript-fetch"; + this.apiPackage = "apis"; + this.apiTemplateFiles.put("apis.mustache", ".ts"); + this.modelPackage = "models"; + this.modelTemplateFiles.put("models.mustache", ".ts"); + + this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); @@ -97,7 +104,10 @@ public void setNpmRepository(String npmRepository) { @Override public void processOpts() { super.processOpts(); - supportingFiles.add(new SupportingFile("api.mustache", "", "api.ts")); + supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts")); + supportingFiles.add(new SupportingFile("runtime.mustache", "", "runtime.ts")); + supportingFiles.add(new SupportingFile("apis.index.mustache", apiPackage().replace('.', File.separatorChar), "index.ts")); + supportingFiles.add(new SupportingFile("models.index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts")); if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); @@ -128,6 +138,20 @@ protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Sc addImport(codegenModel, codegenModel.additionalPropertiesType); } + @Override + public Map postProcessAllModels(Map objs) { + Map result = super.postProcessAllModels(objs); + for (Map.Entry entry : result.entrySet()) { + Map inner = (Map) entry.getValue(); + List> models = (List>) inner.get("models"); + for (Map model : models) { + CodegenModel codegenModel = (CodegenModel) model.get("model"); + model.put("hasImports", codegenModel.imports.size() > 0); + } + } + return result; + } + private void addNpmPackageGeneration() { if (additionalProperties.containsKey(NPM_NAME)) { this.setNpmName(additionalProperties.get(NPM_NAME).toString()); @@ -152,4 +176,20 @@ private void addNpmPackageGeneration() { supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); } + @Override + public Map postProcessOperationsWithModels(Map operations, List allModels) { + this.addOperationModelImportInfomation(operations); + return operations; + } + + private void addOperationModelImportInfomation(Map operations) { + // This method will add extra infomation to the operations.imports array. + // The api template uses this infomation to import all the required + // models for a given operation. + List> imports = (List>) operations.get("imports"); + for (Map im : imports) { + im.put("className", im.get("import").toString().replace("models.", "")); + } + } + } diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.index.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.index.mustache new file mode 100644 index 000000000000..6286332d7bcf --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.index.mustache @@ -0,0 +1,7 @@ +{{#apiInfo}} +{{#apis}} +{{#operations}} +export * from './{{ classFilename }}'; +{{/operations}} +{{/apis}} +{{/apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache new file mode 100644 index 000000000000..b819116bf81d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -0,0 +1,202 @@ +// tslint:disable +{{>licenseInfo}} + +import * as runtime from '../runtime'; +{{#imports.0}} +import { + {{#imports}} + {{className}}, + {{/imports}} +} from '../models'; +{{/imports.0}} + +{{#operations}} +{{#operation}} +{{#allParams.0}} +export interface {{operationIdCamelCase}}Request { + {{#allParams}} + {{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; + {{/allParams}} +} + +{{/allParams.0}} +{{/operation}} +{{/operations}} +{{#operations}} +/** + * {{#description}}{{{description}}}{{/description}}{{^description}}no description{{/description}} + */ +export class {{classname}} extends runtime.BaseAPI { + + {{#operation}} + /** + {{#notes}} + * {{¬es}} + {{/notes}} + {{#summary}} + * {{&summary}} + {{/summary}} + */ + async {{nickname}}({{#allParams.0}}requestParameters: {{operationIdCamelCase}}Request{{/allParams.0}}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { + {{#allParams}} + {{#required}} + if (requestParameters.{{paramName}} === null || requestParameters.{{paramName}} === undefined) { + throw new runtime.RequiredError('{{paramName}}','Required parameter requestParameters.{{paramName}} was null or undefined when calling {{nickname}}.'); + } + + {{/required}} + {{/allParams}} + {{#hasQueryParams}} + const queryParameters: runtime.HTTPQuery = {}; + + {{/hasQueryParams}} + {{#queryParams}} + {{#isListContainer}} + if (requestParameters.{{paramName}}) { + {{#isCollectionFormatMulti}} + queryParameters['{{baseName}}'] = requestParameters.{{paramName}}; + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + queryParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]); + {{/isCollectionFormatMulti}} + } + + {{/isListContainer}} + {{^isListContainer}} + if (requestParameters.{{paramName}} !== undefined) { + {{#isDateTime}} + queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString(); + {{/isDateTime}} + {{^isDateTime}} + {{#isDate}} + queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString(); + {{/isDate}} + {{^isDate}} + queryParameters['{{baseName}}'] = requestParameters.{{paramName}}; + {{/isDate}} + {{/isDateTime}} + } + + {{/isListContainer}} + {{/queryParams}} + const headerParameters: runtime.HTTPHeaders = {}; + + {{#bodyParam}} + {{^consumes}} + headerParameters['Content-Type'] = 'application/json'; + + {{/consumes}} + {{#consumes.0}} + headerParameters['Content-Type'] = '{{{mediaType}}}'; + + {{/consumes.0}} + {{/bodyParam}} + {{#headerParams}} + {{#isListContainer}} + if (requestParameters.{{paramName}}) { + headerParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"])); + } + + {{/isListContainer}} + {{^isListContainer}} + if (requestParameters.{{paramName}} !== undefined && requestParameters.{{paramName}} !== null) { + headerParameters['{{baseName}}'] = String(requestParameters.{{paramName}}); + } + + {{/isListContainer}} + {{/headerParams}} + {{#authMethods}} + {{#isBasic}} + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + + {{/isBasic}} + {{#isApiKey}} + {{#isKeyInHeader}} + if (this.configuration && this.configuration.apiKey) { + headerParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication + } + + {{/isKeyInHeader}} + {{#isKeyInQuery}} + if (this.configuration && this.configuration.apiKey) { + queryParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication + } + + {{/isKeyInQuery}} + {{/isApiKey}} + {{#isOAuth}} + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + {{/isOAuth}} + {{/authMethods}} + {{#hasFormParams}} + const formData = new FormData(); + {{/hasFormParams}} + {{#formParams}} + {{#isListContainer}} + if (requestParameters.{{paramName}}) { + {{#isCollectionFormatMulti}} + requestParameters.{{paramName}}.forEach((element) => { + formData.append('{{baseName}}', element as any); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + formData.append('{{baseName}}', requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); + {{/isCollectionFormatMulti}} + } + + {{/isListContainer}} + {{^isListContainer}} + if (requestParameters.{{paramName}} !== undefined) { + formData.append('{{baseName}}', requestParameters.{{paramName}} as any); + } + + {{/isListContainer}} + {{/formParams}} + return this.request<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>({ + path: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}}, + method: '{{httpMethod}}', + headers: headerParameters, + {{#hasQueryParams}} + query: queryParameters, + {{/hasQueryParams}} + {{#hasBodyParam}} + {{#bodyParam}} + body: requestParameters.{{paramName}}, + {{/bodyParam}} + {{/hasBodyParam}} + {{#hasFormParams}} + body: formData, + {{/hasFormParams}} + {{#returnType}} + {{#isResponseFile}} + responseType: runtime.ResponseType.file + {{/isResponseFile}} + {{^isResponseFile}} + {{#returnTypeIsPrimitive}} + responseType: this.getResponseType('{{returnType}}'), + {{/returnTypeIsPrimitive}} + {{^returnTypeIsPrimitive}} + responseType: runtime.ResponseType.json, + {{/returnTypeIsPrimitive}} + {{/isResponseFile}} + {{/returnType}} + {{^returnType}} + responseType: runtime.ResponseType.response, + {{/returnType}} + modelPropertyNaming: '{{modelPropertyNaming}}', + }); + } + + {{/operation}} +} +{{/operations}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/index.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/index.mustache new file mode 100644 index 000000000000..848ecfa4d100 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/index.mustache @@ -0,0 +1,3 @@ +export * from './runtime'; +export * from './apis'; +export * from './models'; diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 71c5ab00aeec..ff202cb0ff06 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -1,3 +1,11 @@ +{{#hasImports}} +import { + {{#imports}} + {{{.}}}, + {{/imports}} +} from './'; + +{{/hasImports}} /** * {{{description}}} * @export diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/models.index.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/models.index.mustache new file mode 100644 index 000000000000..02a39c248c4d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/models.index.mustache @@ -0,0 +1,5 @@ +{{#models}} +{{#model}} +export * from './{{{ classFilename }}}'; +{{/model}} +{{/models}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/models.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/models.mustache new file mode 100644 index 000000000000..ff9993dc14ca --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/models.mustache @@ -0,0 +1,12 @@ +// tslint:disable +{{>licenseInfo}} +{{#models}} +{{#model}} +{{#isEnum}} +{{>modelEnum}} +{{/isEnum}} +{{^isEnum}} +{{>modelGeneric}} +{{/isEnum}} +{{/model}} +{{/models}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache similarity index 54% rename from modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache rename to modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index e9e78ad3c3b8..7e52c285a3bf 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -3,27 +3,6 @@ export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); -{{#models}} -{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}{{/model}} -{{/models}} - -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} -{{#allParams.0}} -export interface {{operationIdCamelCase}}Request { - {{#allParams}} - {{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; - {{/allParams}} -} - -{{/allParams.0}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} - /** * This is the base class for all generated API classes. */ @@ -115,11 +94,11 @@ export class BaseAPI { protected getResponseType(returnType: string): ResponseType { switch (returnType) { case 'file': - return 'blob'; + return ResponseType.blob; case 'string': - return 'text'; + return responseType.text; default: - return 'json'; + return responseType.json; } } @@ -142,186 +121,6 @@ export class RequiredError extends Error { } } -{{#apiInfo}}{{#apis}}{{#operations}} -/** - * {{#description}}{{{description}}}{{/description}}{{^description}}no description{{/description}} - */ -export class {{classname}} extends BaseAPI { - - {{#operation}} - /** - {{#notes}} - * {{¬es}} - {{/notes}} - {{#summary}} - * {{&summary}} - {{/summary}} - */ - async {{nickname}}({{#allParams.0}}requestParameters: {{operationIdCamelCase}}Request{{/allParams.0}}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { - {{#allParams}} - {{#required}} - if (requestParameters.{{paramName}} === null || requestParameters.{{paramName}} === undefined) { - throw new RequiredError('{{paramName}}','Required parameter requestParameters.{{paramName}} was null or undefined when calling {{nickname}}.'); - } - - {{/required}} - {{/allParams}} - {{#hasQueryParams}} - const queryParameters: HTTPQuery = {}; - - {{/hasQueryParams}} - {{#queryParams}} - {{#isListContainer}} - if (requestParameters.{{paramName}}) { - {{#isCollectionFormatMulti}} - queryParameters['{{baseName}}'] = requestParameters.{{paramName}}; - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}} - queryParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]); - {{/isCollectionFormatMulti}} - } - - {{/isListContainer}} - {{^isListContainer}} - if (requestParameters.{{paramName}} !== undefined) { - {{#isDateTime}} - queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString(); - {{/isDateTime}} - {{^isDateTime}} - {{#isDate}} - queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString(); - {{/isDate}} - {{^isDate}} - queryParameters['{{baseName}}'] = requestParameters.{{paramName}}; - {{/isDate}} - {{/isDateTime}} - } - - {{/isListContainer}} - {{/queryParams}} - const headerParameters: HTTPHeaders = {}; - - {{#bodyParam}} - {{^consumes}} - headerParameters['Content-Type'] = 'application/json'; - - {{/consumes}} - {{#consumes.0}} - headerParameters['Content-Type'] = '{{{mediaType}}}'; - - {{/consumes.0}} - {{/bodyParam}} - {{#headerParams}} - {{#isListContainer}} - if (requestParameters.{{paramName}}) { - headerParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); - } - - {{/isListContainer}} - {{^isListContainer}} - if (requestParameters.{{paramName}} !== undefined && requestParameters.{{paramName}} !== null) { - headerParameters['{{baseName}}'] = String(requestParameters.{{paramName}}); - } - - {{/isListContainer}} - {{/headerParams}} - {{#authMethods}} - {{#isBasic}} - if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); - } - - {{/isBasic}} - {{#isApiKey}} - {{#isKeyInHeader}} - if (this.configuration && this.configuration.apiKey) { - headerParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication - } - - {{/isKeyInHeader}} - {{#isKeyInQuery}} - if (this.configuration && this.configuration.apiKey) { - queryParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication - } - - {{/isKeyInQuery}} - {{/isApiKey}} - {{#isOAuth}} - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - {{/isOAuth}} - {{/authMethods}} - {{#hasFormParams}} - const formData = new FormData(); - {{/hasFormParams}} - {{#formParams}} - {{#isListContainer}} - if (requestParameters.{{paramName}}) { - {{#isCollectionFormatMulti}} - requestParameters.{{paramName}}.forEach((element) => { - formData.append('{{baseName}}', element as any); - }) - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}} - formData.append('{{baseName}}', requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); - {{/isCollectionFormatMulti}} - } - - {{/isListContainer}} - {{^isListContainer}} - if (requestParameters.{{paramName}} !== undefined) { - formData.append('{{baseName}}', requestParameters.{{paramName}} as any); - } - - {{/isListContainer}} - {{/formParams}} - return this.request<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>({ - path: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}}, - method: '{{httpMethod}}', - headers: headerParameters, - {{#hasQueryParams}} - query: queryParameters, - {{/hasQueryParams}} - {{#hasBodyParam}} - {{#bodyParam}} - body: requestParameters.{{paramName}}, - {{/bodyParam}} - {{/hasBodyParam}} - {{#hasFormParams}} - body: formData, - {{/hasFormParams}} - {{#returnType}} - {{#isResponseFile}} - responseType: ResponseType.file - {{/isResponseFile}} - {{^isResponseFile}} - {{#returnTypeIsPrimitive}} - responseType: this.getResponseType('{{returnType}}'), - {{/returnTypeIsPrimitive}} - {{^returnTypeIsPrimitive}} - responseType: ResponseType.json, - {{/returnTypeIsPrimitive}} - {{/isResponseFile}} - {{/returnType}} - {{^returnType}} - responseType: ResponseType.response, - {{/returnType}} - modelPropertyNaming: '{{modelPropertyNaming}}', - }); - } - - {{/operation}} -} -{{/operations}}{{/apis}}{{/apiInfo}} - - export const COLLECTION_FORMATS = { csv: ",", ssv: " ", @@ -379,7 +178,7 @@ export interface FetchParams { init: RequestInit; } -enum ResponseType { +export enum ResponseType { file = 'file', text = 'text', blob = 'blob', @@ -387,7 +186,7 @@ enum ResponseType { response = 'response', } -interface RequestOpts { +export interface RequestOpts { path: string; method: HTTPMethod; headers: HTTPHeaders; From f8af494bc496b015acbb4ff0462f99d89df4e238 Mon Sep 17 00:00:00 2001 From: James Batt Date: Thu, 26 Jul 2018 21:14:52 +1000 Subject: [PATCH 09/39] added support for modelPropertyNaming based on the spec --- .../TypeScriptFetchClientCodegen.java | 7 +- .../resources/typescript-fetch/apis.mustache | 57 +++++++---- .../typescript-fetch/modelGeneric.mustache | 26 ++++- .../typescript-fetch/runtime.mustache | 95 +------------------ 4 files changed, 70 insertions(+), 115 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index 8ff8522b97d5..74fb34614024 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -22,7 +22,9 @@ import io.swagger.v3.parser.util.SchemaTypeUtil; import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CodegenModel; +import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.SupportingFile; +import org.openapitools.codegen.CodegenConstants.MODEL_PROPERTY_NAMING_TYPE; import org.openapitools.codegen.utils.ModelUtils; import java.io.File; @@ -63,8 +65,6 @@ public TypeScriptFetchClientCodegen() { this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); - - this.additionalProperties.put("modelPropertyNaming", getModelPropertyNaming()); } @Override @@ -104,11 +104,12 @@ public void setNpmRepository(String npmRepository) { @Override public void processOpts() { super.processOpts(); + additionalProperties.put("isOriginalModelPropertyNaming", getModelPropertyNaming().equals("original")); + additionalProperties.put("modelPropertyNaming", getModelPropertyNaming()); supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts")); supportingFiles.add(new SupportingFile("runtime.mustache", "", "runtime.ts")); supportingFiles.add(new SupportingFile("apis.index.mustache", apiPackage().replace('.', File.separatorChar), "index.ts")); supportingFiles.add(new SupportingFile("models.index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts")); - if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); } diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index b819116bf81d..27cf592d5070 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -6,6 +6,9 @@ import * as runtime from '../runtime'; import { {{#imports}} {{className}}, + {{^isOriginalModelPropertyNaming}} + {{className}}FromJSON, + {{/isOriginalModelPropertyNaming}} {{/imports}} } from '../models'; {{/imports.0}} @@ -162,7 +165,7 @@ export class {{classname}} extends runtime.BaseAPI { {{/isListContainer}} {{/formParams}} - return this.request<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>({ + const response = await this.request({ path: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}}, method: '{{httpMethod}}', headers: headerParameters, @@ -177,24 +180,42 @@ export class {{classname}} extends runtime.BaseAPI { {{#hasFormParams}} body: formData, {{/hasFormParams}} - {{#returnType}} - {{#isResponseFile}} - responseType: runtime.ResponseType.file - {{/isResponseFile}} - {{^isResponseFile}} - {{#returnTypeIsPrimitive}} - responseType: this.getResponseType('{{returnType}}'), - {{/returnTypeIsPrimitive}} - {{^returnTypeIsPrimitive}} - responseType: runtime.ResponseType.json, - {{/returnTypeIsPrimitive}} - {{/isResponseFile}} - {{/returnType}} - {{^returnType}} - responseType: runtime.ResponseType.response, - {{/returnType}} - modelPropertyNaming: '{{modelPropertyNaming}}', }); + {{#returnType}} + {{#isResponseFile}} + return response.blob(); + {{/isResponseFile}} + {{^isResponseFile}} + {{#returnTypeIsPrimitive}} + {{#isMapContainer}} + return response.json(); + {{/isMapContainer}} + {{#isListContainer}} + return response.json(); + {{/isListContainer}} + {{#returnSimpleType}} + return response.text(); + {{/returnSimpleType}} + {{/returnTypeIsPrimitive}} + {{^returnTypeIsPrimitive}} + {{#isOriginalModelPropertyNaming}} + return await response.json(); + {{/isOriginalModelPropertyNaming}} + {{^isOriginalModelPropertyNaming}} + {{#isListContainer}} + const json = await response.json() as Array; + return json.map({{returnBaseType}}FromJSON); + {{/isListContainer}} + {{^isListContainer}} + return {{returnBaseType}}FromJSON(await response.json()); + {{/isListContainer}} + {{/isOriginalModelPropertyNaming}} + {{/returnTypeIsPrimitive}} + {{/isResponseFile}} + {{/returnType}} + {{^returnType}} + return response; + {{/returnType}} } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index ff202cb0ff06..a2893bd133e6 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -2,6 +2,9 @@ import { {{#imports}} {{{.}}}, + {{^isOriginalModelPropertyNaming}} + {{.}}FromJSON, + {{/isOriginalModelPropertyNaming}} {{/imports}} } from './'; @@ -23,7 +26,28 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ */ {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; {{/vars}} -}{{#hasEnums}} +} +{{^isOriginalModelPropertyNaming}} + +export function {{classname}}FromJSON(json: any): {{classname}} { + return { + {{#vars}} + {{#isPrimitiveType}} + '{{name}}': json['{{baseName}}'], + {{/isPrimitiveType}} + {{^isPrimitiveType}} + {{#isContainer}} + '{{name}}': (json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON), + {{/isContainer}} + {{^isContainer}} + '{{name}}': {{datatype}}FromJSON(json['{{baseName}}']), + {{/isContainer}} + {{/isPrimitiveType}} + {{/vars}} + }; +} +{{/isOriginalModelPropertyNaming}} +{{#hasEnums}} /** * @export diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 7e52c285a3bf..5208316884e6 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -30,23 +30,11 @@ export class BaseAPI { return this.withMiddleware(...middlewares); } - protected async request(context: RequestOpts): Promise { + protected async request(context: RequestOpts): Promise { const { url, init } = this.createFetchParams(context); const response = await this.fetchApi(url, init); if (response.status >= 200 && response.status < 300) { - switch(context.responseType) { - case ResponseType.response: - return response as any as T; - case ResponseType.text: - return await response.text() as any as T; - case ResponseType.file: - return await response.blob() as any as T; - case ResponseType.json: - const result = await response.json() as T; - return transformPropertyNames(result, context.modelPropertyNaming); - default: - return response as any as T; - } + return response; } throw response; } @@ -84,24 +72,6 @@ export class BaseAPI { return response; } - /** - * https://swagger.io/docs/specification/2-0/describing-responses/ - * - * If the response type for a given API is a 'string' we need to avoid - * parsing the response as json because JSON.parse("some string") will - * fail when the string isn't actually JSON. - */ - protected getResponseType(returnType: string): ResponseType { - switch (returnType) { - case 'file': - return ResponseType.blob; - case 'string': - return responseType.text; - default: - return responseType.json; - } - } - /** * Create a shallow clone of `this` by constructing a new instance * and then shallow cloning data members. @@ -178,22 +148,12 @@ export interface FetchParams { init: RequestInit; } -export enum ResponseType { - file = 'file', - text = 'text', - blob = 'blob', - json = 'json', - response = 'response', -} - export interface RequestOpts { path: string; method: HTTPMethod; headers: HTTPHeaders; query?: HTTPQuery; body?: HTTPBody; - responseType?: ResponseType; - modelPropertyNaming: ModelPropertyNaming; } function querystring(params: HTTPQuery) { @@ -213,54 +173,3 @@ export interface Middleware { pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; } - -function capitalize(word: string) { - return word.charAt(0).toUpperCase() + word.slice(1); -} - -function toPascalCase(name: string) { - return name - .split('_') - .map(capitalize) - .join(''); -} - -function toCamelCase(name: string) { - const pascalCase = toPascalCase(name); - return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1); -} - -function applyPropertyNameConverter(json: any, converter: (name: string) => string) { - if (json instanceof Array) { - json.forEach((value) => { - if (typeof value === 'object') { - return applyPropertyNameConverter(value, converter); - } - }); - } else { - Object.keys(json).forEach((origKey) => { - if (json.hasOwnProperty(origKey)) { - let value = json[origKey]; - if (value instanceof Array || (value !== null && value.constructor === Object)) { - value = applyPropertyNameConverter(value, converter); - } - const newKey = converter(origKey); - json[newKey] = json[origKey]; - delete json[origKey]; - json[newKey] = value; - } - }); - } - return json; -} - -function transformPropertyNames(json: any, modelPropertyNaming: ModelPropertyNaming) { - switch (modelPropertyNaming) { - case 'camelCase': - return applyPropertyNameConverter(json, toCamelCase); - - case 'original': - default: - return json; - } -} From d73a6e88103648e7e208714a250b522ee9a616c9 Mon Sep 17 00:00:00 2001 From: James Batt Date: Thu, 26 Jul 2018 21:24:40 +1000 Subject: [PATCH 10/39] bug fix --- .../typescript-fetch/runtime.mustache | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 5208316884e6..f21776f1704d 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -60,13 +60,21 @@ export class BaseAPI { let fetchParams = { url, init }; for (const middleware of this.middleware) { if (middleware.pre) { - fetchParams = await middleware.pre(this.fetchApi, fetchParams.url, fetchParams.init) || fetchParams; + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; } } let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); for (const middleware of this.middleware) { if (middleware.post) { - response = await middleware.post(this.fetchApi, url, init, response.clone()) || response; + response = await middleware.post({ + fetch: this.fetchApi, + url, + init, + response: response.clone(), + }) || response; } } return response; @@ -169,7 +177,20 @@ function querystring(params: HTTPQuery) { .join('&'); } +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + export interface Middleware { - pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; - post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; } From 4b4202a4c2432a64ee7c3ad063a3dcc2b6cc1270 Mon Sep 17 00:00:00 2001 From: James Batt Date: Thu, 26 Jul 2018 21:25:37 +1000 Subject: [PATCH 11/39] updated samples --- .../builds/default/apis/PetApi.ts | 325 ++++++++++++++++++ .../builds/default/apis/StoreApi.ts | 116 +++++++ .../builds/default/apis/UserApi.ts | 230 +++++++++++++ .../builds/default/apis/index.ts | 3 + .../typescript-fetch/builds/default/index.ts | 3 + .../builds/default/models/ApiResponse.ts | 48 +++ .../builds/default/models/Category.ts | 41 +++ .../builds/default/models/Order.ts | 84 +++++ .../builds/default/models/Pet.ts | 91 +++++ .../builds/default/models/Tag.ts | 41 +++ .../builds/default/models/User.ts | 83 +++++ .../builds/default/models/index.ts | 6 + .../builds/default/runtime.ts | 207 +++++++++++ .../builds/es6-target/apis/PetApi.ts | 325 ++++++++++++++++++ .../builds/es6-target/apis/StoreApi.ts | 116 +++++++ .../builds/es6-target/apis/UserApi.ts | 230 +++++++++++++ .../builds/es6-target/apis/index.ts | 3 + .../builds/es6-target/index.ts | 3 + .../builds/es6-target/models/ApiResponse.ts | 48 +++ .../builds/es6-target/models/Category.ts | 41 +++ .../builds/es6-target/models/Order.ts | 84 +++++ .../builds/es6-target/models/Pet.ts | 91 +++++ .../builds/es6-target/models/Tag.ts | 41 +++ .../builds/es6-target/models/User.ts | 83 +++++ .../builds/es6-target/models/index.ts | 6 + .../builds/es6-target/runtime.ts | 207 +++++++++++ .../builds/with-interfaces/apis/PetApi.ts | 325 ++++++++++++++++++ .../builds/with-interfaces/apis/StoreApi.ts | 116 +++++++ .../builds/with-interfaces/apis/UserApi.ts | 230 +++++++++++++ .../builds/with-interfaces/apis/index.ts | 3 + .../builds/with-interfaces/index.ts | 3 + .../with-interfaces/models/ApiResponse.ts | 48 +++ .../builds/with-interfaces/models/Category.ts | 41 +++ .../builds/with-interfaces/models/Order.ts | 84 +++++ .../builds/with-interfaces/models/Pet.ts | 91 +++++ .../builds/with-interfaces/models/Tag.ts | 41 +++ .../builds/with-interfaces/models/User.ts | 83 +++++ .../builds/with-interfaces/models/index.ts | 6 + .../builds/with-interfaces/runtime.ts | 207 +++++++++++ .../builds/with-npm-version/apis/PetApi.ts | 325 ++++++++++++++++++ .../builds/with-npm-version/apis/StoreApi.ts | 116 +++++++ .../builds/with-npm-version/apis/UserApi.ts | 230 +++++++++++++ .../builds/with-npm-version/apis/index.ts | 3 + .../builds/with-npm-version/index.ts | 3 + .../with-npm-version/models/ApiResponse.ts | 48 +++ .../with-npm-version/models/Category.ts | 41 +++ .../builds/with-npm-version/models/Order.ts | 84 +++++ .../builds/with-npm-version/models/Pet.ts | 91 +++++ .../builds/with-npm-version/models/Tag.ts | 41 +++ .../builds/with-npm-version/models/User.ts | 83 +++++ .../builds/with-npm-version/models/index.ts | 6 + .../builds/with-npm-version/runtime.ts | 207 +++++++++++ 52 files changed, 5112 insertions(+) create mode 100644 samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/apis/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/models/Category.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/models/Order.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/models/User.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/models/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default/runtime.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/apis/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/models/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/models/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/models/index.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts new file mode 100644 index 000000000000..31c401e3e010 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts @@ -0,0 +1,325 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + ApiResponse, + ApiResponseFromJSON, + Pet, + PetFromJSON, +} from '../models'; + +export interface AddPetRequest { + pet: Pet; +} + +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} + +export interface FindPetsByStatusRequest { + status: Array<'available' | 'pending' | 'sold'>; +} + +export interface FindPetsByTagsRequest { + tags: Array; +} + +export interface GetPetByIdRequest { + petId: number; +} + +export interface UpdatePetRequest { + pet: Pet; +} + +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} + +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: any; +} + +/** + * no description + */ +export class PetApi extends runtime.BaseAPI { + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet`, + method: 'POST', + headers: headerParameters, + body: requestParameters.pet, + }); + return response; + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + const json = await response.json() as Array; + return json.map(PetFromJSON); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + const json = await response.json() as Array; + return json.map(PetFromJSON); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + }); + return PetFromJSON(await response.json()); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet`, + method: 'PUT', + headers: headerParameters, + body: requestParameters.pet, + }); + return response; + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.name !== undefined) { + formData.append('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + formData.append('status', requestParameters.status as any); + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + }); + return response; + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.additionalMetadata !== undefined) { + formData.append('additionalMetadata', requestParameters.additionalMetadata as any); + } + + if (requestParameters.file !== undefined) { + formData.append('file', requestParameters.file as any); + } + + const response = await this.request({ + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + }); + return ApiResponseFromJSON(await response.json()); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts new file mode 100644 index 000000000000..36dcd092d1ef --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts @@ -0,0 +1,116 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + Order, + OrderFromJSON, +} from '../models'; + +export interface DeleteOrderRequest { + orderId: string; +} + +export interface GetOrderByIdRequest { + orderId: number; +} + +export interface PlaceOrderRequest { + order: Order; +} + +/** + * no description + */ +export class StoreApi extends runtime.BaseAPI { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(): Promise<{ [key: string]: number; }> { + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + const response = await this.request({ + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + }); + return response.json(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + }); + return OrderFromJSON(await response.json()); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + if (requestParameters.order === null || requestParameters.order === undefined) { + throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/store/order`, + method: 'POST', + headers: headerParameters, + body: requestParameters.order, + }); + return OrderFromJSON(await response.json()); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts new file mode 100644 index 000000000000..ff5e783e6a1c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts @@ -0,0 +1,230 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + User, + UserFromJSON, +} from '../models'; + +export interface CreateUserRequest { + user: User; +} + +export interface CreateUsersWithArrayInputRequest { + user: Array; +} + +export interface CreateUsersWithListInputRequest { + user: Array; +} + +export interface DeleteUserRequest { + username: string; +} + +export interface GetUserByNameRequest { + username: string; +} + +export interface LoginUserRequest { + username: string; + password: string; +} + +export interface UpdateUserRequest { + username: string; + user: User; +} + +/** + * no description + */ +export class UserApi extends runtime.BaseAPI { + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * Creates list of users with given input array + */ + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + }); + return UserFromJSON(await response.json()); + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + return response.text(); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(): Promise { + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + }); + return response; + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/index.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/index.ts new file mode 100644 index 000000000000..056206bfaca3 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/index.ts @@ -0,0 +1,3 @@ +export * from './PetApi'; +export * from './StoreApi'; +export * from './UserApi'; diff --git a/samples/client/petstore/typescript-fetch/builds/default/index.ts b/samples/client/petstore/typescript-fetch/builds/default/index.ts new file mode 100644 index 000000000000..848ecfa4d100 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/index.ts @@ -0,0 +1,3 @@ +export * from './runtime'; +export * from './apis'; +export * from './models'; diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts new file mode 100644 index 000000000000..14e27d99bf9c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts @@ -0,0 +1,48 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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; +} + +export function ApiResponseFromJSON(json: any): ApiResponse { + return { + 'code': json['code'], + 'type': json['type'], + 'message': json['message'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts new file mode 100644 index 000000000000..ac72fbd0d4cf --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts @@ -0,0 +1,41 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + +export function CategoryFromJSON(json: any): Category { + return { + 'id': json['id'], + 'name': json['name'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts new file mode 100644 index 000000000000..206a785143a9 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts @@ -0,0 +1,84 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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 function OrderFromJSON(json: any): Order { + return { + 'id': json['id'], + 'petId': json['petId'], + 'quantity': json['quantity'], + 'shipDate': json['shipDate'], + 'status': json['status'], + 'complete': json['complete'], + }; +} + +/** + * @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-fetch/builds/default/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts new file mode 100644 index 000000000000..41ef494fcbbd --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts @@ -0,0 +1,91 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { + Category, + CategoryFromJSON, + Tag, + TagFromJSON, +} from './'; + +/** + * 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 function PetFromJSON(json: any): Pet { + return { + 'id': json['id'], + 'category': CategoryFromJSON(json['category']), + 'name': json['name'], + 'photoUrls': json['photoUrls'], + 'tags': (json['tags'] as Array).map(TagFromJSON), + 'status': json['status'], + }; +} + +/** + * @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-fetch/builds/default/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts new file mode 100644 index 000000000000..d425d79a08ab --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts @@ -0,0 +1,41 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + +export function TagFromJSON(json: any): Tag { + return { + 'id': json['id'], + 'name': json['name'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts new file mode 100644 index 000000000000..621e3aa44ed9 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts @@ -0,0 +1,83 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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; +} + +export function UserFromJSON(json: any): User { + return { + 'id': json['id'], + 'username': json['username'], + 'firstName': json['firstName'], + 'lastName': json['lastName'], + 'email': json['email'], + 'password': json['password'], + 'phone': json['phone'], + 'userStatus': json['userStatus'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/index.ts b/samples/client/petstore/typescript-fetch/builds/default/models/index.ts new file mode 100644 index 000000000000..f53c1dd42bdd --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/models/index.ts @@ -0,0 +1,6 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts new file mode 100644 index 000000000000..556de28ec6c0 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -0,0 +1,207 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + return response; + } + throw response; + } + + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url, + init, + response: response.clone(), + }) || response; + } + } + return response; + } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; + +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = GlobalFetch['fetch']; + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // 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 +} + +export class Configuration { + + basePath: string; + fetchApi: FetchAPI; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + 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; + } + } +} + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +export interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; +} + +function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} + +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts new file mode 100644 index 000000000000..31c401e3e010 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts @@ -0,0 +1,325 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + ApiResponse, + ApiResponseFromJSON, + Pet, + PetFromJSON, +} from '../models'; + +export interface AddPetRequest { + pet: Pet; +} + +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} + +export interface FindPetsByStatusRequest { + status: Array<'available' | 'pending' | 'sold'>; +} + +export interface FindPetsByTagsRequest { + tags: Array; +} + +export interface GetPetByIdRequest { + petId: number; +} + +export interface UpdatePetRequest { + pet: Pet; +} + +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} + +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: any; +} + +/** + * no description + */ +export class PetApi extends runtime.BaseAPI { + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet`, + method: 'POST', + headers: headerParameters, + body: requestParameters.pet, + }); + return response; + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + const json = await response.json() as Array; + return json.map(PetFromJSON); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + const json = await response.json() as Array; + return json.map(PetFromJSON); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + }); + return PetFromJSON(await response.json()); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet`, + method: 'PUT', + headers: headerParameters, + body: requestParameters.pet, + }); + return response; + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.name !== undefined) { + formData.append('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + formData.append('status', requestParameters.status as any); + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + }); + return response; + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.additionalMetadata !== undefined) { + formData.append('additionalMetadata', requestParameters.additionalMetadata as any); + } + + if (requestParameters.file !== undefined) { + formData.append('file', requestParameters.file as any); + } + + const response = await this.request({ + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + }); + return ApiResponseFromJSON(await response.json()); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts new file mode 100644 index 000000000000..36dcd092d1ef --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts @@ -0,0 +1,116 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + Order, + OrderFromJSON, +} from '../models'; + +export interface DeleteOrderRequest { + orderId: string; +} + +export interface GetOrderByIdRequest { + orderId: number; +} + +export interface PlaceOrderRequest { + order: Order; +} + +/** + * no description + */ +export class StoreApi extends runtime.BaseAPI { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(): Promise<{ [key: string]: number; }> { + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + const response = await this.request({ + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + }); + return response.json(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + }); + return OrderFromJSON(await response.json()); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + if (requestParameters.order === null || requestParameters.order === undefined) { + throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/store/order`, + method: 'POST', + headers: headerParameters, + body: requestParameters.order, + }); + return OrderFromJSON(await response.json()); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts new file mode 100644 index 000000000000..ff5e783e6a1c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts @@ -0,0 +1,230 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + User, + UserFromJSON, +} from '../models'; + +export interface CreateUserRequest { + user: User; +} + +export interface CreateUsersWithArrayInputRequest { + user: Array; +} + +export interface CreateUsersWithListInputRequest { + user: Array; +} + +export interface DeleteUserRequest { + username: string; +} + +export interface GetUserByNameRequest { + username: string; +} + +export interface LoginUserRequest { + username: string; + password: string; +} + +export interface UpdateUserRequest { + username: string; + user: User; +} + +/** + * no description + */ +export class UserApi extends runtime.BaseAPI { + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * Creates list of users with given input array + */ + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + }); + return UserFromJSON(await response.json()); + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + return response.text(); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(): Promise { + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + }); + return response; + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/index.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/index.ts new file mode 100644 index 000000000000..056206bfaca3 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/index.ts @@ -0,0 +1,3 @@ +export * from './PetApi'; +export * from './StoreApi'; +export * from './UserApi'; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/index.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/index.ts new file mode 100644 index 000000000000..848ecfa4d100 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/index.ts @@ -0,0 +1,3 @@ +export * from './runtime'; +export * from './apis'; +export * from './models'; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts new file mode 100644 index 000000000000..14e27d99bf9c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts @@ -0,0 +1,48 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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; +} + +export function ApiResponseFromJSON(json: any): ApiResponse { + return { + 'code': json['code'], + 'type': json['type'], + 'message': json['message'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts new file mode 100644 index 000000000000..ac72fbd0d4cf --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts @@ -0,0 +1,41 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + +export function CategoryFromJSON(json: any): Category { + return { + 'id': json['id'], + 'name': json['name'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts new file mode 100644 index 000000000000..206a785143a9 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts @@ -0,0 +1,84 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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 function OrderFromJSON(json: any): Order { + return { + 'id': json['id'], + 'petId': json['petId'], + 'quantity': json['quantity'], + 'shipDate': json['shipDate'], + 'status': json['status'], + 'complete': json['complete'], + }; +} + +/** + * @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-fetch/builds/es6-target/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts new file mode 100644 index 000000000000..41ef494fcbbd --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts @@ -0,0 +1,91 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { + Category, + CategoryFromJSON, + Tag, + TagFromJSON, +} from './'; + +/** + * 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 function PetFromJSON(json: any): Pet { + return { + 'id': json['id'], + 'category': CategoryFromJSON(json['category']), + 'name': json['name'], + 'photoUrls': json['photoUrls'], + 'tags': (json['tags'] as Array).map(TagFromJSON), + 'status': json['status'], + }; +} + +/** + * @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-fetch/builds/es6-target/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts new file mode 100644 index 000000000000..d425d79a08ab --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts @@ -0,0 +1,41 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + +export function TagFromJSON(json: any): Tag { + return { + 'id': json['id'], + 'name': json['name'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts new file mode 100644 index 000000000000..621e3aa44ed9 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts @@ -0,0 +1,83 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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; +} + +export function UserFromJSON(json: any): User { + return { + 'id': json['id'], + 'username': json['username'], + 'firstName': json['firstName'], + 'lastName': json['lastName'], + 'email': json['email'], + 'password': json['password'], + 'phone': json['phone'], + 'userStatus': json['userStatus'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/index.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/index.ts new file mode 100644 index 000000000000..f53c1dd42bdd --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/index.ts @@ -0,0 +1,6 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts new file mode 100644 index 000000000000..556de28ec6c0 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts @@ -0,0 +1,207 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + return response; + } + throw response; + } + + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url, + init, + response: response.clone(), + }) || response; + } + } + return response; + } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; + +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = GlobalFetch['fetch']; + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // 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 +} + +export class Configuration { + + basePath: string; + fetchApi: FetchAPI; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + 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; + } + } +} + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +export interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; +} + +function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} + +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts new file mode 100644 index 000000000000..31c401e3e010 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts @@ -0,0 +1,325 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + ApiResponse, + ApiResponseFromJSON, + Pet, + PetFromJSON, +} from '../models'; + +export interface AddPetRequest { + pet: Pet; +} + +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} + +export interface FindPetsByStatusRequest { + status: Array<'available' | 'pending' | 'sold'>; +} + +export interface FindPetsByTagsRequest { + tags: Array; +} + +export interface GetPetByIdRequest { + petId: number; +} + +export interface UpdatePetRequest { + pet: Pet; +} + +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} + +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: any; +} + +/** + * no description + */ +export class PetApi extends runtime.BaseAPI { + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet`, + method: 'POST', + headers: headerParameters, + body: requestParameters.pet, + }); + return response; + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + const json = await response.json() as Array; + return json.map(PetFromJSON); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + const json = await response.json() as Array; + return json.map(PetFromJSON); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + }); + return PetFromJSON(await response.json()); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet`, + method: 'PUT', + headers: headerParameters, + body: requestParameters.pet, + }); + return response; + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.name !== undefined) { + formData.append('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + formData.append('status', requestParameters.status as any); + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + }); + return response; + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.additionalMetadata !== undefined) { + formData.append('additionalMetadata', requestParameters.additionalMetadata as any); + } + + if (requestParameters.file !== undefined) { + formData.append('file', requestParameters.file as any); + } + + const response = await this.request({ + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + }); + return ApiResponseFromJSON(await response.json()); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts new file mode 100644 index 000000000000..36dcd092d1ef --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts @@ -0,0 +1,116 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + Order, + OrderFromJSON, +} from '../models'; + +export interface DeleteOrderRequest { + orderId: string; +} + +export interface GetOrderByIdRequest { + orderId: number; +} + +export interface PlaceOrderRequest { + order: Order; +} + +/** + * no description + */ +export class StoreApi extends runtime.BaseAPI { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(): Promise<{ [key: string]: number; }> { + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + const response = await this.request({ + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + }); + return response.json(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + }); + return OrderFromJSON(await response.json()); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + if (requestParameters.order === null || requestParameters.order === undefined) { + throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/store/order`, + method: 'POST', + headers: headerParameters, + body: requestParameters.order, + }); + return OrderFromJSON(await response.json()); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts new file mode 100644 index 000000000000..ff5e783e6a1c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts @@ -0,0 +1,230 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + User, + UserFromJSON, +} from '../models'; + +export interface CreateUserRequest { + user: User; +} + +export interface CreateUsersWithArrayInputRequest { + user: Array; +} + +export interface CreateUsersWithListInputRequest { + user: Array; +} + +export interface DeleteUserRequest { + username: string; +} + +export interface GetUserByNameRequest { + username: string; +} + +export interface LoginUserRequest { + username: string; + password: string; +} + +export interface UpdateUserRequest { + username: string; + user: User; +} + +/** + * no description + */ +export class UserApi extends runtime.BaseAPI { + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * Creates list of users with given input array + */ + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + }); + return UserFromJSON(await response.json()); + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + return response.text(); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(): Promise { + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + }); + return response; + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/index.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/index.ts new file mode 100644 index 000000000000..056206bfaca3 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/index.ts @@ -0,0 +1,3 @@ +export * from './PetApi'; +export * from './StoreApi'; +export * from './UserApi'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/index.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/index.ts new file mode 100644 index 000000000000..848ecfa4d100 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/index.ts @@ -0,0 +1,3 @@ +export * from './runtime'; +export * from './apis'; +export * from './models'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts new file mode 100644 index 000000000000..14e27d99bf9c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts @@ -0,0 +1,48 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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; +} + +export function ApiResponseFromJSON(json: any): ApiResponse { + return { + 'code': json['code'], + 'type': json['type'], + 'message': json['message'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts new file mode 100644 index 000000000000..ac72fbd0d4cf --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts @@ -0,0 +1,41 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + +export function CategoryFromJSON(json: any): Category { + return { + 'id': json['id'], + 'name': json['name'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts new file mode 100644 index 000000000000..206a785143a9 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts @@ -0,0 +1,84 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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 function OrderFromJSON(json: any): Order { + return { + 'id': json['id'], + 'petId': json['petId'], + 'quantity': json['quantity'], + 'shipDate': json['shipDate'], + 'status': json['status'], + 'complete': json['complete'], + }; +} + +/** + * @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-fetch/builds/with-interfaces/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts new file mode 100644 index 000000000000..41ef494fcbbd --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts @@ -0,0 +1,91 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { + Category, + CategoryFromJSON, + Tag, + TagFromJSON, +} from './'; + +/** + * 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 function PetFromJSON(json: any): Pet { + return { + 'id': json['id'], + 'category': CategoryFromJSON(json['category']), + 'name': json['name'], + 'photoUrls': json['photoUrls'], + 'tags': (json['tags'] as Array).map(TagFromJSON), + 'status': json['status'], + }; +} + +/** + * @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-fetch/builds/with-interfaces/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts new file mode 100644 index 000000000000..d425d79a08ab --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts @@ -0,0 +1,41 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + +export function TagFromJSON(json: any): Tag { + return { + 'id': json['id'], + 'name': json['name'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts new file mode 100644 index 000000000000..621e3aa44ed9 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts @@ -0,0 +1,83 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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; +} + +export function UserFromJSON(json: any): User { + return { + 'id': json['id'], + 'username': json['username'], + 'firstName': json['firstName'], + 'lastName': json['lastName'], + 'email': json['email'], + 'password': json['password'], + 'phone': json['phone'], + 'userStatus': json['userStatus'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/index.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/index.ts new file mode 100644 index 000000000000..f53c1dd42bdd --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/index.ts @@ -0,0 +1,6 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts new file mode 100644 index 000000000000..556de28ec6c0 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -0,0 +1,207 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + return response; + } + throw response; + } + + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url, + init, + response: response.clone(), + }) || response; + } + } + return response; + } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; + +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = GlobalFetch['fetch']; + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // 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 +} + +export class Configuration { + + basePath: string; + fetchApi: FetchAPI; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + 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; + } + } +} + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +export interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; +} + +function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} + +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts new file mode 100644 index 000000000000..31c401e3e010 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts @@ -0,0 +1,325 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + ApiResponse, + ApiResponseFromJSON, + Pet, + PetFromJSON, +} from '../models'; + +export interface AddPetRequest { + pet: Pet; +} + +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} + +export interface FindPetsByStatusRequest { + status: Array<'available' | 'pending' | 'sold'>; +} + +export interface FindPetsByTagsRequest { + tags: Array; +} + +export interface GetPetByIdRequest { + petId: number; +} + +export interface UpdatePetRequest { + pet: Pet; +} + +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} + +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: any; +} + +/** + * no description + */ +export class PetApi extends runtime.BaseAPI { + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet`, + method: 'POST', + headers: headerParameters, + body: requestParameters.pet, + }); + return response; + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + const json = await response.json() as Array; + return json.map(PetFromJSON); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + const json = await response.json() as Array; + return json.map(PetFromJSON); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + }); + return PetFromJSON(await response.json()); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest): Promise { + if (requestParameters.pet === null || requestParameters.pet === undefined) { + throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const response = await this.request({ + path: `/pet`, + method: 'PUT', + headers: headerParameters, + body: requestParameters.pet, + }); + return response; + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.name !== undefined) { + formData.append('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + formData.append('status', requestParameters.status as any); + } + + const response = await this.request({ + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + }); + return response; + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest): Promise { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + if (typeof this.configuration.accessToken === 'function') { + headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } else { + headerParameters["Authorization"] = this.configuration.accessToken; + } + } + + const formData = new FormData(); + if (requestParameters.additionalMetadata !== undefined) { + formData.append('additionalMetadata', requestParameters.additionalMetadata as any); + } + + if (requestParameters.file !== undefined) { + formData.append('file', requestParameters.file as any); + } + + const response = await this.request({ + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + body: formData, + }); + return ApiResponseFromJSON(await response.json()); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts new file mode 100644 index 000000000000..36dcd092d1ef --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts @@ -0,0 +1,116 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + Order, + OrderFromJSON, +} from '../models'; + +export interface DeleteOrderRequest { + orderId: string; +} + +export interface GetOrderByIdRequest { + orderId: number; +} + +export interface PlaceOrderRequest { + order: Order; +} + +/** + * no description + */ +export class StoreApi extends runtime.BaseAPI { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(): Promise<{ [key: string]: number; }> { + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + const response = await this.request({ + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + }); + return response.json(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + }); + return OrderFromJSON(await response.json()); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + if (requestParameters.order === null || requestParameters.order === undefined) { + throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/store/order`, + method: 'POST', + headers: headerParameters, + body: requestParameters.order, + }); + return OrderFromJSON(await response.json()); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts new file mode 100644 index 000000000000..ff5e783e6a1c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts @@ -0,0 +1,230 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + User, + UserFromJSON, +} from '../models'; + +export interface CreateUserRequest { + user: User; +} + +export interface CreateUsersWithArrayInputRequest { + user: Array; +} + +export interface CreateUsersWithListInputRequest { + user: Array; +} + +export interface DeleteUserRequest { + username: string; +} + +export interface GetUserByNameRequest { + username: string; +} + +export interface LoginUserRequest { + username: string; + password: string; +} + +export interface UpdateUserRequest { + username: string; + user: User; +} + +/** + * no description + */ +export class UserApi extends runtime.BaseAPI { + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * Creates list of users with given input array + */ + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + }); + return response; + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + }); + return UserFromJSON(await response.json()); + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: runtime.HTTPQuery = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + return response.text(); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(): Promise { + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + }); + return response; + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest): Promise { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.user === null || requestParameters.user === undefined) { + throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + body: requestParameters.user, + }); + return response; + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/index.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/index.ts new file mode 100644 index 000000000000..056206bfaca3 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/index.ts @@ -0,0 +1,3 @@ +export * from './PetApi'; +export * from './StoreApi'; +export * from './UserApi'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/index.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/index.ts new file mode 100644 index 000000000000..848ecfa4d100 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/index.ts @@ -0,0 +1,3 @@ +export * from './runtime'; +export * from './apis'; +export * from './models'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts new file mode 100644 index 000000000000..14e27d99bf9c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts @@ -0,0 +1,48 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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; +} + +export function ApiResponseFromJSON(json: any): ApiResponse { + return { + 'code': json['code'], + 'type': json['type'], + 'message': json['message'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts new file mode 100644 index 000000000000..ac72fbd0d4cf --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts @@ -0,0 +1,41 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + +export function CategoryFromJSON(json: any): Category { + return { + 'id': json['id'], + 'name': json['name'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts new file mode 100644 index 000000000000..206a785143a9 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts @@ -0,0 +1,84 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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 function OrderFromJSON(json: any): Order { + return { + 'id': json['id'], + 'petId': json['petId'], + 'quantity': json['quantity'], + 'shipDate': json['shipDate'], + 'status': json['status'], + 'complete': json['complete'], + }; +} + +/** + * @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-fetch/builds/with-npm-version/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts new file mode 100644 index 000000000000..41ef494fcbbd --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts @@ -0,0 +1,91 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { + Category, + CategoryFromJSON, + Tag, + TagFromJSON, +} from './'; + +/** + * 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 function PetFromJSON(json: any): Pet { + return { + 'id': json['id'], + 'category': CategoryFromJSON(json['category']), + 'name': json['name'], + 'photoUrls': json['photoUrls'], + 'tags': (json['tags'] as Array).map(TagFromJSON), + 'status': json['status'], + }; +} + +/** + * @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-fetch/builds/with-npm-version/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts new file mode 100644 index 000000000000..d425d79a08ab --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts @@ -0,0 +1,41 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + +export function TagFromJSON(json: any): Tag { + return { + 'id': json['id'], + 'name': json['name'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts new file mode 100644 index 000000000000..621e3aa44ed9 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts @@ -0,0 +1,83 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * 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; +} + +export function UserFromJSON(json: any): User { + return { + 'id': json['id'], + 'username': json['username'], + 'firstName': json['firstName'], + 'lastName': json['lastName'], + 'email': json['email'], + 'password': json['password'], + 'phone': json['phone'], + 'userStatus': json['userStatus'], + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/index.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/index.ts new file mode 100644 index 000000000000..f53c1dd42bdd --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/index.ts @@ -0,0 +1,6 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts new file mode 100644 index 000000000000..556de28ec6c0 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts @@ -0,0 +1,207 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + return response; + } + throw response; + } + + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url, + init, + response: response.clone(), + }) || response; + } + } + return response; + } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; + +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = GlobalFetch['fetch']; + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // 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 +} + +export class Configuration { + + basePath: string; + fetchApi: FetchAPI; + middleware: Middleware[]; + username?: string; + password?: string; + apiKey?: (name: string) => string; + accessToken?: (name: string, scopes?: string[]) => string; + + constructor(conf: ConfigurationParameters = {}) { + this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; + this.fetchApi = conf.fetchApi || window.fetch.bind(window); + 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; + } + } +} + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +export interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; +} + +function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} + +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} From f30aa4682f6788a487a8026e27b1166257f9456c Mon Sep 17 00:00:00 2001 From: Jeremie Bresson Date: Tue, 31 Jul 2018 07:41:04 +0200 Subject: [PATCH 12/39] Restore pom.xml for typescript project --- .../petstore/typescript-fetch/builds/default | 26 +++++++ .../typescript-fetch/builds/es6-target | 59 +++++++++++++++ .../builds/with-npm-version/pom.xml | 73 +++++++++++++++++++ .../typescript-fetch/tests/default/pom.xml | 59 +++++++++++++++ bin/typescript-fetch-petstore-target-es6.sh | 2 + ...escript-fetch-petstore-with-npm-version.sh | 2 + bin/typescript-fetch-petstore.sh | 2 + .../typescript-fetch/builds/default/pom.xml | 26 +++++++ .../builds/es6-target/pom.xml | 59 +++++++++++++++ .../builds/with-npm-version/pom.xml | 73 +++++++++++++++++++ .../typescript-fetch/tests/default/pom.xml | 59 +++++++++++++++ 11 files changed, 440 insertions(+) create mode 100644 CI/samples.ci/client/petstore/typescript-fetch/builds/default create mode 100644 CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target create mode 100644 CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml create mode 100644 CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml create mode 100644 samples/client/petstore/typescript-fetch/builds/default/pom.xml create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/pom.xml create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml create mode 100644 samples/client/petstore/typescript-fetch/tests/default/pom.xml diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/default b/CI/samples.ci/client/petstore/typescript-fetch/builds/default new file mode 100644 index 000000000000..6b36b1d83c46 --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/default @@ -0,0 +1,26 @@ + + 4.0.0 + com.wordnik + TypeScriptAngularBuildPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Default Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + + diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target b/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target new file mode 100644 index 000000000000..8b8e6052761e --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target @@ -0,0 +1,59 @@ + + 4.0.0 + com.wordnik + TypeScriptAngularBuildES6PestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch ES6 Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + integration-test + + exec + + + npm + + install + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml new file mode 100644 index 000000000000..b7725ec2309e --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + com.wordnik + TypeScriptAngularBuildWithNPMVersionPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Petstore Client (with npm) + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + integration-test + + exec + + + npm + + install + + + + + npm-build + integration-test + + exec + + + npm + + run + build + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml new file mode 100644 index 000000000000..5e76c65dfede --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + com.wordnik + TypeScriptFetchPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Petstore Test Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/bin/typescript-fetch-petstore-target-es6.sh b/bin/typescript-fetch-petstore-target-es6.sh index 9abb1598b9f9..755fb4c7cc85 100755 --- a/bin/typescript-fetch-petstore-target-es6.sh +++ b/bin/typescript-fetch-petstore-target-es6.sh @@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/ ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-target-es6.json -o samples/client/petstore/typescript-fetch/builds/es6-target $@" java $JAVA_OPTS -jar $executable $ags +cp CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target/pom.xml samples/client/petstore/typescript-fetch/builds/es6-target/pom.xml +cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml \ No newline at end of file diff --git a/bin/typescript-fetch-petstore-with-npm-version.sh b/bin/typescript-fetch-petstore-with-npm-version.sh index ab540f271f15..4e604b9b88eb 100755 --- a/bin/typescript-fetch-petstore-with-npm-version.sh +++ b/bin/typescript-fetch-petstore-with-npm-version.sh @@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/ ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-with-npm-version.json -o samples/client/petstore/typescript-fetch/builds/with-npm-version $@" java $JAVA_OPTS -jar $executable $ags +cp CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml samples/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml +cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml \ No newline at end of file diff --git a/bin/typescript-fetch-petstore.sh b/bin/typescript-fetch-petstore.sh index 8cdf91ef5940..e2a9d85f4d62 100755 --- a/bin/typescript-fetch-petstore.sh +++ b/bin/typescript-fetch-petstore.sh @@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/ ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -o samples/client/petstore/typescript-fetch/builds/default $@" java $JAVA_OPTS -jar $executable $ags +cp CI/samples.ci/client/petstore/typescript-fetch/builds/default/pom.xml samples/client/petstore/typescript-fetch/builds/default/pom.xml +cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml \ No newline at end of file diff --git a/samples/client/petstore/typescript-fetch/builds/default/pom.xml b/samples/client/petstore/typescript-fetch/builds/default/pom.xml new file mode 100644 index 000000000000..6b36b1d83c46 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + com.wordnik + TypeScriptAngularBuildPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Default Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/pom.xml b/samples/client/petstore/typescript-fetch/builds/es6-target/pom.xml new file mode 100644 index 000000000000..8b8e6052761e --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + com.wordnik + TypeScriptAngularBuildES6PestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch ES6 Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + integration-test + + exec + + + npm + + install + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml b/samples/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml new file mode 100644 index 000000000000..b7725ec2309e --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + com.wordnik + TypeScriptAngularBuildWithNPMVersionPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Petstore Client (with npm) + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + integration-test + + exec + + + npm + + install + + + + + npm-build + integration-test + + exec + + + npm + + run + build + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/samples/client/petstore/typescript-fetch/tests/default/pom.xml b/samples/client/petstore/typescript-fetch/tests/default/pom.xml new file mode 100644 index 000000000000..5e76c65dfede --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + com.wordnik + TypeScriptFetchPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Petstore Test Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + From df07b3e1c1b05774ef3e41b2d9603ebbed03be51 Mon Sep 17 00:00:00 2001 From: Jeremie Bresson Date: Tue, 31 Jul 2018 15:24:22 +0200 Subject: [PATCH 13/39] =?UTF-8?q?Restore=20samples/client/petstore/typescr?= =?UTF-8?q?ipt-fetch/tests/default/package.json=20=E2=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/default/package.json | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 samples/client/petstore/typescript-fetch/tests/default/package.json diff --git a/samples/client/petstore/typescript-fetch/tests/default/package.json b/samples/client/petstore/typescript-fetch/tests/default/package.json new file mode 100644 index 000000000000..96ac38788f23 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/package.json @@ -0,0 +1,36 @@ +{ + "private": true, + "dependencies": { + "@swagger/typescript-fetch-petstore": "file:../../builds/with-npm-version", + "chai": "^4.1.0", + "ts-node": "^3.3.0" + }, + "scripts": { + "prepublish": "npm install ../../builds/with-npm-version && npm run build && npm run webpack && npm run browserify", + "test": "mocha test/*.ts --compilers ts:ts-node/register --timeout 10000", + "build": "tsc", + "webpack": "webpack", + "browserify": "browserify test -p [ tsify ] > ./dist/test.browserify-bundle.js" + }, + "devDependencies": { + "@types/chai": "^4.0.1", + "@types/isomorphic-fetch": "0.0.34", + "@types/mocha": "^2.2.41", + "@types/node": "^8.0.14", + "browserify": "^14.4.0", + "mocha": "^3.4.2", + "ts-loader": "^2.3.0", + "tsify": "^3.0.1", + "typescript": "^2.4.1", + "typings": "^2.1.1", + "webpack": "^1.13.0" + }, + "name": "typescript-fetch-test", + "version": "1.0.0", + "directories": { + "test": "test" + }, + "author": "", + "license": "ISC", + "description": "" +} From 9e01d50b1c9fe9d3e33e55fc210e876858949af9 Mon Sep 17 00:00:00 2001 From: James Batt Date: Sat, 11 Aug 2018 15:32:00 +1000 Subject: [PATCH 14/39] added support for response type Date conversion --- .../codegen/languages/TypeScriptFetchClientCodegen.java | 2 +- .../src/main/resources/typescript-fetch/apis.mustache | 5 ----- .../main/resources/typescript-fetch/modelGeneric.mustache | 4 +--- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index 74fb34614024..8c5020018af0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -110,6 +110,7 @@ public void processOpts() { supportingFiles.add(new SupportingFile("runtime.mustache", "", "runtime.ts")); supportingFiles.add(new SupportingFile("apis.index.mustache", apiPackage().replace('.', File.separatorChar), "index.ts")); supportingFiles.add(new SupportingFile("models.index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts")); + supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); } @@ -174,7 +175,6 @@ private void addNpmPackageGeneration() { //Files for building our lib supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); - supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); } @Override diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index 27cf592d5070..b912b34f63b4 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -198,10 +198,6 @@ export class {{classname}} extends runtime.BaseAPI { {{/returnSimpleType}} {{/returnTypeIsPrimitive}} {{^returnTypeIsPrimitive}} - {{#isOriginalModelPropertyNaming}} - return await response.json(); - {{/isOriginalModelPropertyNaming}} - {{^isOriginalModelPropertyNaming}} {{#isListContainer}} const json = await response.json() as Array; return json.map({{returnBaseType}}FromJSON); @@ -209,7 +205,6 @@ export class {{classname}} extends runtime.BaseAPI { {{^isListContainer}} return {{returnBaseType}}FromJSON(await response.json()); {{/isListContainer}} - {{/isOriginalModelPropertyNaming}} {{/returnTypeIsPrimitive}} {{/isResponseFile}} {{/returnType}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index a2893bd133e6..09255ff2045f 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -27,13 +27,12 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; {{/vars}} } -{{^isOriginalModelPropertyNaming}} export function {{classname}}FromJSON(json: any): {{classname}} { return { {{#vars}} {{#isPrimitiveType}} - '{{name}}': json['{{baseName}}'], + '{{name}}': {{#isDate}}{{^required}}json['{{baseName}}'] === undefined ? undefined : {{/required}}new Date(json['{{baseName}}']){{/isDate}}{{#isDateTime}}{{^required}}json['{{baseName}}'] === undefined ? undefined : {{/required}}new Date(json['{{baseName}}']){{/isDateTime}}{{^isDate}}{{^isDateTime}}json['{{baseName}}']{{/isDateTime}}{{/isDate}}, {{/isPrimitiveType}} {{^isPrimitiveType}} {{#isContainer}} @@ -46,7 +45,6 @@ export function {{classname}}FromJSON(json: any): {{classname}} { {{/vars}} }; } -{{/isOriginalModelPropertyNaming}} {{#hasEnums}} /** From d3ed16dd3e98aa1d4c29e9f1b999509c85344641 Mon Sep 17 00:00:00 2001 From: James Batt Date: Sat, 11 Aug 2018 15:32:57 +1000 Subject: [PATCH 15/39] updated samples --- .../builds/default/models/Order.ts | 2 +- .../builds/default/tsconfig.json | 17 +++++++++++++++++ .../builds/es6-target/models/Order.ts | 2 +- .../builds/with-interfaces/models/Order.ts | 2 +- .../builds/with-interfaces/tsconfig.json | 17 +++++++++++++++++ .../builds/with-npm-version/models/Order.ts | 2 +- 6 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 samples/client/petstore/typescript-fetch/builds/default/tsconfig.json create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/tsconfig.json diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts index 206a785143a9..8e4f0edab49e 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts @@ -60,7 +60,7 @@ export function OrderFromJSON(json: any): Order { 'id': json['id'], 'petId': json['petId'], 'quantity': json['quantity'], - 'shipDate': json['shipDate'], + 'shipDate': json['shipDate'] === undefined ? undefined : new Date(json['shipDate']), 'status': json['status'], 'complete': json['complete'], }; diff --git a/samples/client/petstore/typescript-fetch/builds/default/tsconfig.json b/samples/client/petstore/typescript-fetch/builds/default/tsconfig.json new file mode 100644 index 000000000000..5a7e3c193526 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "outDir": "dist", + "rootDir": ".", + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts index 206a785143a9..8e4f0edab49e 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts @@ -60,7 +60,7 @@ export function OrderFromJSON(json: any): Order { 'id': json['id'], 'petId': json['petId'], 'quantity': json['quantity'], - 'shipDate': json['shipDate'], + 'shipDate': json['shipDate'] === undefined ? undefined : new Date(json['shipDate']), 'status': json['status'], 'complete': json['complete'], }; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts index 206a785143a9..8e4f0edab49e 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts @@ -60,7 +60,7 @@ export function OrderFromJSON(json: any): Order { 'id': json['id'], 'petId': json['petId'], 'quantity': json['quantity'], - 'shipDate': json['shipDate'], + 'shipDate': json['shipDate'] === undefined ? undefined : new Date(json['shipDate']), 'status': json['status'], 'complete': json['complete'], }; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/tsconfig.json b/samples/client/petstore/typescript-fetch/builds/with-interfaces/tsconfig.json new file mode 100644 index 000000000000..5a7e3c193526 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "outDir": "dist", + "rootDir": ".", + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts index 206a785143a9..8e4f0edab49e 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts @@ -60,7 +60,7 @@ export function OrderFromJSON(json: any): Order { 'id': json['id'], 'petId': json['petId'], 'quantity': json['quantity'], - 'shipDate': json['shipDate'], + 'shipDate': json['shipDate'] === undefined ? undefined : new Date(json['shipDate']), 'status': json['status'], 'complete': json['complete'], }; From cc4f8e01acb75fafeedf2929144cdd809da3710a Mon Sep 17 00:00:00 2001 From: Jeremie Bresson Date: Sun, 12 Aug 2018 18:57:20 +0200 Subject: [PATCH 16/39] Rework pom in "samples.ci" --- .../typescript-fetch/builds/{default => default/pom.xml} | 2 +- .../typescript-fetch/builds/{es6-target => es6-target/pom.xml} | 2 +- .../petstore/typescript-fetch/builds/with-npm-version/pom.xml | 2 +- .../client/petstore/typescript-fetch/tests/default/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename CI/samples.ci/client/petstore/typescript-fetch/builds/{default => default/pom.xml} (95%) rename CI/samples.ci/client/petstore/typescript-fetch/builds/{es6-target => es6-target/pom.xml} (98%) diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/default b/CI/samples.ci/client/petstore/typescript-fetch/builds/default/pom.xml similarity index 95% rename from CI/samples.ci/client/petstore/typescript-fetch/builds/default rename to CI/samples.ci/client/petstore/typescript-fetch/builds/default/pom.xml index 6b36b1d83c46..b40b83a0c751 100644 --- a/CI/samples.ci/client/petstore/typescript-fetch/builds/default +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/default/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.wordnik + org.openapitools TypeScriptAngularBuildPestoreClientTests pom 1.0-SNAPSHOT diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target b/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target/pom.xml similarity index 98% rename from CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target rename to CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target/pom.xml index 8b8e6052761e..db6dfdfeb6aa 100644 --- a/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.wordnik + org.openapitools TypeScriptAngularBuildES6PestoreClientTests pom 1.0-SNAPSHOT diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml index b7725ec2309e..339fe7665186 100644 --- a/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.wordnik + org.openapitools TypeScriptAngularBuildWithNPMVersionPestoreClientTests pom 1.0-SNAPSHOT diff --git a/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml index 5e76c65dfede..92063ea7bcc5 100644 --- a/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml +++ b/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.wordnik + org.openapitools TypeScriptFetchPestoreClientTests pom 1.0-SNAPSHOT From f2bbde5fb6571e5281a1b35ae3cffe7f44cd1846 Mon Sep 17 00:00:00 2001 From: Jeremie Bresson Date: Fri, 17 Aug 2018 15:59:43 +0200 Subject: [PATCH 17/39] Restore "samples/client/petstore/typescript-fetch/tests/default" --- .../tests/default/package-lock.json | 4306 +++++++++++++++++ .../default/run_tests_via_browserify.html | 26 + .../tests/default/run_tests_via_webpack.html | 27 + .../tests/default/test/PetApi.ts | 79 + .../tests/default/test/PetApiFactory.ts | 91 + .../tests/default/test/StoreApi.ts | 31 + .../tests/default/test/StoreApiFactory.ts | 42 + .../tests/default/test/index.ts | 4 + .../tests/default/tsconfig.json | 19 + .../tests/default/webpack.config.js | 30 + 10 files changed, 4655 insertions(+) create mode 100644 samples/client/petstore/typescript-fetch/tests/default/package-lock.json create mode 100644 samples/client/petstore/typescript-fetch/tests/default/run_tests_via_browserify.html create mode 100644 samples/client/petstore/typescript-fetch/tests/default/run_tests_via_webpack.html create mode 100644 samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts create mode 100644 samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts create mode 100644 samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts create mode 100644 samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts create mode 100644 samples/client/petstore/typescript-fetch/tests/default/test/index.ts create mode 100644 samples/client/petstore/typescript-fetch/tests/default/tsconfig.json create mode 100644 samples/client/petstore/typescript-fetch/tests/default/webpack.config.js diff --git a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json new file mode 100644 index 000000000000..c16f4968148d --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json @@ -0,0 +1,4306 @@ +{ + "name": "typescript-fetch-test", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@swagger/typescript-fetch-petstore": { + "version": "file:../../builds/with-npm-version", + "requires": { + "portable-fetch": "^3.0.0" + }, + "dependencies": { + "encoding": { + "version": "0.1.12", + "bundled": true, + "requires": { + "iconv-lite": "~0.4.13" + } + }, + "iconv-lite": { + "version": "0.4.23", + "bundled": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "is-stream": { + "version": "1.1.0", + "bundled": true + }, + "node-fetch": { + "version": "1.7.3", + "bundled": true, + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + }, + "portable-fetch": { + "version": "3.0.0", + "bundled": true, + "requires": { + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" + } + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true + }, + "whatwg-fetch": { + "version": "2.0.4", + "bundled": true + } + } + }, + "@types/chai": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.0.2.tgz", + "integrity": "sha512-0pHNZTD0SpQhz1kUM4Muhgdn4acxq21kp726pZfWMmKYGbmmv8XkGTt3k/0QDklhTUYBD6hknZ/1YFokyP/G7Q==", + "dev": true + }, + "@types/isomorphic-fetch": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", + "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=", + "dev": true + }, + "@types/mocha": { + "version": "2.2.41", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.41.tgz", + "integrity": "sha1-4nzwgXFT658nE7LT9saPHhw8pgg=", + "dev": true + }, + "@types/node": { + "version": "8.0.19", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.19.tgz", + "integrity": "sha512-VRQB+Q0L3YZWs45uRdpN9oWr82meL/8TrJ6faoKT5tp0uub2l/aRMhtm5fo68h7kjYKH60f9/bay1nF7ZpTW5g==", + "dev": true + }, + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + } + }, + "abbrev": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", + "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=", + "dev": true + }, + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "dev": true + }, + "agent-base": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.1.1.tgz", + "integrity": "sha1-1t4Q1a9hMtW9aSQn1G/FOFOQlMc=", + "dev": true, + "requires": { + "extend": "~3.0.0", + "semver": "~5.0.1" + }, + "dependencies": { + "semver": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz", + "integrity": "sha1-d0Zt5YnNXTyV8TiqeLxWmjy10no=", + "dev": true + } + } + }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" + } + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true + }, + "ansi-align": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz", + "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", + "dev": true, + "requires": { + "string-width": "^2.0.0" + } + }, + "ansi-escapes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", + "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "dev": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=", + "dev": true + }, + "anymatch": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", + "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", + "dev": true, + "requires": { + "micromatch": "^2.1.5", + "normalize-path": "^2.0.0" + } + }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "dev": true + }, + "arr-diff": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", + "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", + "dev": true, + "requires": { + "arr-flatten": "^1.0.1" + } + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "array-filter": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz", + "integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=", + "dev": true + }, + "array-map": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", + "integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=", + "dev": true + }, + "array-reduce": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz", + "integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=", + "dev": true + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, + "array-unique": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", + "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" + }, + "asn1.js": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", + "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", + "dev": true, + "requires": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "assert": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", + "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", + "dev": true, + "requires": { + "util": "0.10.3" + } + }, + "assertion-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz", + "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=" + }, + "astw": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz", + "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", + "dev": true, + "requires": { + "acorn": "^4.0.3" + } + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "async-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", + "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base64-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", + "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==", + "dev": true + }, + "big.js": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz", + "integrity": "sha1-TK2iGTZS6zyp7I5VyQFWacmAaXg=", + "dev": true + }, + "binary-extensions": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.9.0.tgz", + "integrity": "sha1-ZlBsFs5vTWkopbPNajPKQelB43s=", + "dev": true + }, + "bluebird": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", + "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=", + "dev": true + }, + "bn.js": { + "version": "4.11.7", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.7.tgz", + "integrity": "sha512-LxFiV5mefv0ley0SzqkOPR1bC4EbpPx8LkOz5vMe/Yi15t5hzwgO/G+tc7wOtL4PZTYjwHu8JnEiSLumuSjSfA==", + "dev": true + }, + "boxen": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.2.1.tgz", + "integrity": "sha1-DxHn/jRO25OXl3/BPt5/ZNlWSB0=", + "dev": true, + "requires": { + "ansi-align": "^2.0.0", + "camelcase": "^4.0.0", + "chalk": "^2.0.1", + "cli-boxes": "^1.0.0", + "string-width": "^2.0.0", + "term-size": "^1.2.0", + "widest-line": "^1.0.0" + } + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", + "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", + "dev": true, + "requires": { + "expand-range": "^1.8.1", + "preserve": "^0.2.0", + "repeat-element": "^1.1.2" + } + }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "dev": true + }, + "browser-pack": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.0.2.tgz", + "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", + "dev": true, + "requires": { + "JSONStream": "^1.0.3", + "combine-source-map": "~0.7.1", + "defined": "^1.0.0", + "through2": "^2.0.0", + "umd": "^3.0.0" + } + }, + "browser-resolve": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz", + "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=", + "dev": true, + "requires": { + "resolve": "1.1.7" + }, + "dependencies": { + "resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + } + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, + "browserify": { + "version": "14.4.0", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.4.0.tgz", + "integrity": "sha1-CJo0Y69Y0OSNjNQHCz90ZU1avKk=", + "dev": true, + "requires": { + "JSONStream": "^1.0.3", + "assert": "^1.4.0", + "browser-pack": "^6.0.1", + "browser-resolve": "^1.11.0", + "browserify-zlib": "~0.1.2", + "buffer": "^5.0.2", + "cached-path-relative": "^1.0.0", + "concat-stream": "~1.5.1", + "console-browserify": "^1.1.0", + "constants-browserify": "~1.0.0", + "crypto-browserify": "^3.0.0", + "defined": "^1.0.0", + "deps-sort": "^2.0.0", + "domain-browser": "~1.1.0", + "duplexer2": "~0.1.2", + "events": "~1.1.0", + "glob": "^7.1.0", + "has": "^1.0.0", + "htmlescape": "^1.1.0", + "https-browserify": "^1.0.0", + "inherits": "~2.0.1", + "insert-module-globals": "^7.0.0", + "labeled-stream-splicer": "^2.0.0", + "module-deps": "^4.0.8", + "os-browserify": "~0.1.1", + "parents": "^1.0.1", + "path-browserify": "~0.0.0", + "process": "~0.11.0", + "punycode": "^1.3.2", + "querystring-es3": "~0.2.0", + "read-only-stream": "^2.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.1.4", + "shasum": "^1.0.0", + "shell-quote": "^1.6.1", + "stream-browserify": "^2.0.0", + "stream-http": "^2.0.0", + "string_decoder": "~1.0.0", + "subarg": "^1.0.0", + "syntax-error": "^1.1.1", + "through2": "^2.0.0", + "timers-browserify": "^1.0.1", + "tty-browserify": "~0.0.0", + "url": "~0.11.0", + "util": "~0.10.1", + "vm-browserify": "~0.0.1", + "xtend": "^4.0.0" + } + }, + "browserify-aes": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.0.6.tgz", + "integrity": "sha1-Xncl297x/Vkw1OurSFZ85FHEigo=", + "dev": true, + "requires": { + "buffer-xor": "^1.0.2", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "browserify-cipher": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", + "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "dev": true, + "requires": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "browserify-des": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", + "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "dev": true, + "requires": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "browserify-rsa": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" + } + }, + "browserify-sign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", + "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "dev": true, + "requires": { + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" + } + }, + "browserify-zlib": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", + "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "dev": true, + "requires": { + "pako": "~0.2.0" + } + }, + "buffer": { + "version": "5.0.7", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.7.tgz", + "integrity": "sha512-NeeHXWh5pCbPQCt2/6rLvXqapZfVsqw/YgRgaHpT3H9Uzgs+S0lSg5SQzouIuDvcmlQRqBe8hOO2scKCu3cxrg==", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", + "dev": true + }, + "builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", + "dev": true + }, + "cached-path-relative": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz", + "integrity": "sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc=", + "dev": true + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "dev": true + }, + "capture-stack-trace": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz", + "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=", + "dev": true + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "requires": { + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" + } + }, + "chai": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.0.tgz", + "integrity": "sha1-MxoDkbVcOvh0CunDt0WLwcOAXm0=", + "requires": { + "assertion-error": "^1.0.1", + "check-error": "^1.0.1", + "deep-eql": "^2.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.0.0", + "type-detect": "^4.0.0" + } + }, + "chalk": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.0.1.tgz", + "integrity": "sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0g==", + "requires": { + "ansi-styles": "^3.1.0", + "escape-string-regexp": "^1.0.5", + "supports-color": "^4.0.0" + }, + "dependencies": { + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" + }, + "supports-color": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.1.tgz", + "integrity": "sha512-qxzYsob3yv6U+xMzPrv170y8AwGP7i74g+pbixCfD6rgso8BscLT2qXIuz6TpOaiJZ3mFgT5O9lyT9nMU4LfaA==", + "requires": { + "has-flag": "^2.0.0" + } + } + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" + }, + "chokidar": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", + "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", + "dev": true, + "requires": { + "anymatch": "^1.3.0", + "async-each": "^1.0.0", + "fsevents": "^1.0.0", + "glob-parent": "^2.0.0", + "inherits": "^2.0.1", + "is-binary-path": "^1.0.0", + "is-glob": "^2.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.0.0" + } + }, + "cipher-base": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "cli-boxes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", + "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=", + "dev": true + }, + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "dev": true, + "requires": { + "restore-cursor": "^1.0.1" + } + }, + "cli-truncate": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-1.1.0.tgz", + "integrity": "sha512-bAtZo0u82gCfaAGfSNxUdTI9mNyza7D8w4CVCcaOsy7sgwDzvx6ekr6cuWJqY3UGzgnQ1+4wgENup5eIhgxEYA==", + "dev": true, + "requires": { + "slice-ansi": "^1.0.0", + "string-width": "^2.0.0" + } + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "requires": { + "center-align": "^0.1.1", + "right-align": "^0.1.1", + "wordwrap": "0.0.2" + }, + "dependencies": { + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + } + } + }, + "clone": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", + "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=", + "dev": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "color-convert": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", + "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "requires": { + "color-name": "^1.1.1" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "columnify": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/columnify/-/columnify-1.5.4.tgz", + "integrity": "sha1-Rzfd8ce2mop8NAVweC6UfuyOeLs=", + "dev": true, + "requires": { + "strip-ansi": "^3.0.0", + "wcwidth": "^1.0.0" + } + }, + "combine-source-map": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.7.2.tgz", + "integrity": "sha1-CHAxKFazB6h8xKxIbzqaYq7MwJ4=", + "dev": true, + "requires": { + "convert-source-map": "~1.1.0", + "inline-source-map": "~0.6.0", + "lodash.memoize": "~3.0.3", + "source-map": "~0.5.3" + } + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true, + "requires": { + "graceful-readlink": ">= 1.0.0" + } + }, + "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 + }, + "concat-stream": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", + "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", + "dev": true, + "requires": { + "inherits": "~2.0.1", + "readable-stream": "~2.0.0", + "typedarray": "~0.0.5" + }, + "dependencies": { + "readable-stream": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, + "configstore": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.1.tgz", + "integrity": "sha512-5oNkD/L++l0O6xGXxb1EWS7SivtjfGQlRyxJsYgE0Z495/L81e2h4/d3r969hoPXuFItzNOKMtsXgYG4c7dYvw==", + "dev": true, + "requires": { + "dot-prop": "^4.1.0", + "graceful-fs": "^4.1.2", + "make-dir": "^1.0.0", + "unique-string": "^1.0.0", + "write-file-atomic": "^2.0.0", + "xdg-basedir": "^3.0.0" + } + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "^0.1.4" + } + }, + "constants-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", + "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", + "dev": true + }, + "convert-source-map": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", + "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "create-ecdh": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz", + "integrity": "sha1-iIxyNZbN92EvZJgjPuvXo1MBc30=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "elliptic": "^6.0.0" + } + }, + "create-error-class": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", + "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", + "dev": true, + "requires": { + "capture-stack-trace": "^1.0.0" + } + }, + "create-hash": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", + "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", + "dev": true, + "requires": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "sha.js": "^2.4.0" + } + }, + "create-hmac": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.6.tgz", + "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", + "dev": true, + "requires": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "crypto-browserify": { + "version": "3.11.1", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.1.tgz", + "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", + "dev": true, + "requires": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "crypto-random-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", + "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=", + "dev": true + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "deep-eql": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-2.0.2.tgz", + "integrity": "sha1-sbrAblbwp2d3aG1Qyf63XC7XZ5o=", + "requires": { + "type-detect": "^3.0.0" + }, + "dependencies": { + "type-detect": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-3.0.0.tgz", + "integrity": "sha1-RtDMhVOrt7E6NSsNbeov1Y8tm1U=" + } + } + }, + "deep-extend": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", + "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", + "dev": true + }, + "defaults": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", + "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "dev": true, + "requires": { + "clone": "^1.0.2" + } + }, + "defined": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", + "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", + "dev": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "deps-sort": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz", + "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", + "dev": true, + "requires": { + "JSONStream": "^1.0.3", + "shasum": "^1.0.0", + "subarg": "^1.0.0", + "through2": "^2.0.0" + } + }, + "des.js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", + "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "detect-indent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz", + "integrity": "sha1-OHHMCmoALow+Wzz38zYmRnXwa50=", + "dev": true + }, + "detective": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/detective/-/detective-4.5.0.tgz", + "integrity": "sha1-blqMaybmx6JUsca210kNmOyR7dE=", + "dev": true, + "requires": { + "acorn": "^4.0.3", + "defined": "^1.0.0" + } + }, + "diff": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", + "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=" + }, + "diffie-hellman": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz", + "integrity": "sha1-tYNXOScM/ias9jIJn97SoH8gnl4=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "dom-walk": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", + "integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=", + "dev": true + }, + "domain-browser": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", + "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", + "dev": true + }, + "dot-prop": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", + "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", + "dev": true, + "requires": { + "is-obj": "^1.0.0" + } + }, + "duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", + "dev": true, + "requires": { + "readable-stream": "^2.0.2" + } + }, + "duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", + "dev": true + }, + "elegant-spinner": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/elegant-spinner/-/elegant-spinner-1.0.1.tgz", + "integrity": "sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4=", + "dev": true + }, + "elliptic": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", + "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "dev": true, + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, + "emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "dev": true + }, + "enhanced-resolve": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz", + "integrity": "sha1-BCHjOf1xQZs9oT0Smzl5BAIwR24=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.4.0", + "object-assign": "^4.0.1", + "tapable": "^0.2.7" + } + }, + "errno": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz", + "integrity": "sha1-uJbiOp5ei6M4cfyZar02NfyaHH0=", + "dev": true, + "requires": { + "prr": "~0.0.0" + } + }, + "error-ex": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", + "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "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=" + }, + "events": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", + "dev": true + }, + "evp_bytestokey": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.0.tgz", + "integrity": "sha1-SXtmrZ/vZc18CKYYCCS6FHa2blM=", + "dev": true, + "requires": { + "create-hash": "^1.1.1" + } + }, + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "dev": true, + "requires": { + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "exit-hook": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", + "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", + "dev": true + }, + "expand-brackets": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", + "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", + "dev": true, + "requires": { + "is-posix-bracket": "^0.1.0" + } + }, + "expand-range": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", + "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", + "dev": true, + "requires": { + "fill-range": "^2.1.0" + } + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", + "dev": true + }, + "extglob": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", + "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", + "dev": true, + "requires": { + "is-extglob": "^1.0.0" + } + }, + "filename-regex": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", + "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", + "dev": true + }, + "fill-range": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", + "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", + "dev": true, + "requires": { + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^1.1.3", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "for-own": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", + "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", + "dev": true, + "requires": { + "for-in": "^1.0.1" + } + }, + "form-data": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.2.0.tgz", + "integrity": "sha1-ml47kpX5gLJiPPZPojixTOvKcHs=", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.5", + "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 + }, + "fsevents": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz", + "integrity": "sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==", + "dev": true, + "optional": true, + "requires": { + "nan": "^2.9.2", + "node-pre-gyp": "^0.10.0" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "optional": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "fs-minipass": { + "version": "1.2.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "dev": true, + "optional": 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" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.21", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safer-buffer": "^2.1.0" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "ini": { + "version": "1.3.5", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true + }, + "minipass": { + "version": "2.2.4", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "^5.1.1", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "needle": { + "version": "2.2.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.10.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.0", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.1.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "npm-packlist": { + "version": "1.1.10", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "^0.5.1", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "glob": "^7.0.5" + } + }, + "safe-buffer": { + "version": "5.1.1", + "bundled": true, + "dev": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "bundled": true, + "dev": true, + "optional": true + }, + "semver": { + "version": "5.5.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "4.4.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "chownr": "^1.0.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.2.4", + "minizlib": "^1.1.0", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.1", + "yallist": "^3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "^1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "yallist": { + "version": "3.0.2", + "bundled": true, + "dev": true + } + } + }, + "function-bind": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.0.tgz", + "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=", + "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=" + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", + "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" + } + }, + "glob-base": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", + "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", + "dev": true, + "requires": { + "glob-parent": "^2.0.0", + "is-glob": "^2.0.0" + } + }, + "glob-parent": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", + "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", + "dev": true, + "requires": { + "is-glob": "^2.0.0" + } + }, + "global": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz", + "integrity": "sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8=", + "dev": true, + "requires": { + "min-document": "^2.19.0", + "process": "~0.5.1" + }, + "dependencies": { + "process": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz", + "integrity": "sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8=", + "dev": true + } + } + }, + "got": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", + "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", + "dev": true, + "requires": { + "create-error-class": "^3.0.0", + "duplexer3": "^0.1.4", + "get-stream": "^3.0.0", + "is-redirect": "^1.0.0", + "is-retry-allowed": "^1.0.0", + "is-stream": "^1.0.0", + "lowercase-keys": "^1.0.0", + "safe-buffer": "^5.0.1", + "timed-out": "^4.0.0", + "unzip-response": "^2.0.1", + "url-parse-lax": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true + }, + "growl": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", + "dev": true + }, + "has": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", + "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "dev": true, + "requires": { + "function-bind": "^1.0.2" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "dev": true + }, + "hash-base": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", + "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", + "dev": true, + "requires": { + "inherits": "^2.0.1" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "dev": true, + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "htmlescape": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", + "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", + "dev": true + }, + "http-proxy-agent": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-1.0.0.tgz", + "integrity": "sha1-zBzjjkU7+YSg93AtLdWcc9CBKEo=", + "dev": true, + "requires": { + "agent-base": "2", + "debug": "2", + "extend": "3" + } + }, + "https-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", + "dev": true + }, + "https-proxy-agent": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz", + "integrity": "sha1-NffabEjOTdv6JkiRrFk+5f+GceY=", + "dev": true, + "requires": { + "agent-base": "2", + "debug": "2", + "extend": "3" + } + }, + "ieee754": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", + "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", + "dev": true + }, + "import-lazy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", + "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", + "dev": true + }, + "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 + }, + "ini": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", + "dev": true + }, + "inline-source-map": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", + "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", + "dev": true, + "requires": { + "source-map": "~0.5.3" + } + }, + "insert-module-globals": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.0.1.tgz", + "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", + "dev": true, + "requires": { + "JSONStream": "^1.0.3", + "combine-source-map": "~0.7.1", + "concat-stream": "~1.5.1", + "is-buffer": "^1.1.0", + "lexical-scope": "^1.2.0", + "process": "~0.11.0", + "through2": "^2.0.0", + "xtend": "^4.0.0" + } + }, + "interpret": { + "version": "0.6.6", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-0.6.6.tgz", + "integrity": "sha1-/s16GOfOXKar+5U+H4YhOknxYls=", + "dev": true + }, + "invariant": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.2.tgz", + "integrity": "sha1-nh9WrArNtr8wMwbzOL47IErmA2A=", + "dev": true, + "requires": { + "loose-envify": "^1.0.0" + } + }, + "is-absolute": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", + "integrity": "sha1-IN5p89uULvLYe5wto28XIjWxtes=", + "dev": true, + "requires": { + "is-relative": "^0.2.1", + "is-windows": "^0.2.0" + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "dev": true + }, + "is-dotfile": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", + "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", + "dev": true + }, + "is-equal-shallow": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", + "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", + "dev": true, + "requires": { + "is-primitive": "^2.0.0" + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", + "dev": true, + "requires": { + "is-extglob": "^1.0.0" + } + }, + "is-npm": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", + "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=", + "dev": true + }, + "is-number": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", + "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + } + }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", + "dev": true + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, + "is-posix-bracket": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", + "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", + "dev": true + }, + "is-primitive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", + "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", + "dev": true + }, + "is-redirect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", + "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", + "dev": true + }, + "is-relative": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", + "integrity": "sha1-0n9MfVFtF1+2ENuEu+7yPDvJeqU=", + "dev": true, + "requires": { + "is-unc-path": "^0.1.1" + } + }, + "is-retry-allowed": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", + "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-unc-path": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz", + "integrity": "sha1-arBTpyVzwQJQ/0FqOBTDUXivObk=", + "dev": true, + "requires": { + "unc-path-regex": "^0.1.0" + } + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "is-windows": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", + "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "json-stable-stringify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", + "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, + "json3": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", + "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", + "dev": true + }, + "json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "dev": true + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "dev": true + }, + "jspm-config": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/jspm-config/-/jspm-config-0.3.4.tgz", + "integrity": "sha1-RMJpAuSujs4jZs7cn/FrEKXzkcY=", + "dev": true, + "requires": { + "any-promise": "^1.3.0", + "graceful-fs": "^4.1.4", + "make-error-cause": "^1.2.1", + "object.pick": "^1.1.2", + "parse-json": "^2.2.0", + "strip-bom": "^3.0.0", + "thenify": "^3.2.0", + "throat": "^3.0.0", + "xtend": "^4.0.1" + }, + "dependencies": { + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + } + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + }, + "labeled-stream-splicer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.0.tgz", + "integrity": "sha1-pS4dE4AkwAuGscDJH2d5GLiuClk=", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "isarray": "~0.0.1", + "stream-splicer": "^2.0.0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + } + } + }, + "latest-version": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", + "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", + "dev": true, + "requires": { + "package-json": "^4.0.0" + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true + }, + "lexical-scope": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", + "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", + "dev": true, + "requires": { + "astw": "^2.0.0" + } + }, + "listify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/listify/-/listify-1.0.0.tgz", + "integrity": "sha1-A8p7otFQ1CZ3c/dOV1WNEFPSvuM=", + "dev": true + }, + "loader-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", + "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", + "dev": true, + "requires": { + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0" + } + }, + "lockfile": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.3.tgz", + "integrity": "sha1-Jjj8OaAzHpysGgS3F5mTHJxQ33k=", + "dev": true + }, + "lodash._baseassign": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", + "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", + "dev": true, + "requires": { + "lodash._basecopy": "^3.0.0", + "lodash.keys": "^3.0.0" + } + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basecreate": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", + "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", + "dev": true + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash.create": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", + "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", + "dev": true, + "requires": { + "lodash._baseassign": "^3.0.0", + "lodash._basecreate": "^3.0.0", + "lodash._isiterateecall": "^3.0.0" + } + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" + } + }, + "lodash.memoize": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", + "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", + "dev": true + }, + "log-update": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-1.0.2.tgz", + "integrity": "sha1-GZKfZMQJPS0ucHWh2tivWcKWuNE=", + "dev": true, + "requires": { + "ansi-escapes": "^1.0.0", + "cli-cursor": "^1.0.2" + } + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "loose-envify": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", + "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "dev": true, + "requires": { + "js-tokens": "^3.0.0" + } + }, + "lowercase-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", + "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=", + "dev": true + }, + "lru-cache": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", + "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "make-dir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.0.0.tgz", + "integrity": "sha1-l6ARdR6R3YfPre9Ygy67BJNt6Xg=", + "dev": true, + "requires": { + "pify": "^2.3.0" + } + }, + "make-error": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.0.tgz", + "integrity": "sha1-Uq06M5zPEM5itAQLcI/nByRLi5Y=" + }, + "make-error-cause": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/make-error-cause/-/make-error-cause-1.2.2.tgz", + "integrity": "sha1-3wOI/NCzeBbf8KX7gQiTl3fcvJ0=", + "dev": true, + "requires": { + "make-error": "^1.2.0" + } + }, + "memory-fs": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", + "integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "micromatch": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", + "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", + "dev": true, + "requires": { + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" + } + }, + "miller-rabin": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.0.tgz", + "integrity": "sha1-SmL7HUKTPAVYOYL0xxb2+55sbT0=", + "dev": true, + "requires": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + } + }, + "mime-db": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.29.0.tgz", + "integrity": "sha1-SNJtI1WJZRcErFkWygYAGRQmaHg=", + "dev": true + }, + "mime-types": { + "version": "2.1.16", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.16.tgz", + "integrity": "sha1-K4WKUuXs1RbbiXrCvodIeDBpjiM=", + "dev": true, + "requires": { + "mime-db": "~1.29.0" + } + }, + "min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=", + "dev": true, + "requires": { + "dom-walk": "^0.1.0" + } + }, + "minimalistic-assert": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz", + "integrity": "sha1-cCvi3aazf0g2vLP121ZkG2Sh09M=", + "dev": true + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", + "dev": true + }, + "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": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + } + } + }, + "mocha": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.0.tgz", + "integrity": "sha512-pIU2PJjrPYvYRqVpjXzj76qltO9uBYI7woYAMoxbSefsa+vqAfptjoeevd6bUgwD0mPIO+hv9f7ltvsNreL2PA==", + "dev": true, + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.9.0", + "debug": "2.6.8", + "diff": "3.2.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.1", + "growl": "1.9.2", + "json3": "3.3.2", + "lodash.create": "3.1.1", + "mkdirp": "0.5.1", + "supports-color": "3.1.2" + }, + "dependencies": { + "glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, + "module-deps": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz", + "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", + "dev": true, + "requires": { + "JSONStream": "^1.0.3", + "browser-resolve": "^1.7.0", + "cached-path-relative": "^1.0.0", + "concat-stream": "~1.5.0", + "defined": "^1.0.0", + "detective": "^4.0.0", + "duplexer2": "^0.1.2", + "inherits": "^2.0.1", + "parents": "^1.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.1.3", + "stream-combiner2": "^1.1.1", + "subarg": "^1.0.0", + "through2": "^2.0.0", + "xtend": "^4.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "nan": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", + "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", + "dev": true, + "optional": true + }, + "node-libs-browser": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-0.7.0.tgz", + "integrity": "sha1-PicsCBnjCJNeJmdECNevDhSRuDs=", + "dev": true, + "requires": { + "assert": "^1.1.1", + "browserify-zlib": "^0.1.4", + "buffer": "^4.9.0", + "console-browserify": "^1.1.0", + "constants-browserify": "^1.0.0", + "crypto-browserify": "3.3.0", + "domain-browser": "^1.1.1", + "events": "^1.0.0", + "https-browserify": "0.0.1", + "os-browserify": "^0.2.0", + "path-browserify": "0.0.0", + "process": "^0.11.0", + "punycode": "^1.2.4", + "querystring-es3": "^0.2.0", + "readable-stream": "^2.0.5", + "stream-browserify": "^2.0.1", + "stream-http": "^2.3.1", + "string_decoder": "^0.10.25", + "timers-browserify": "^2.0.2", + "tty-browserify": "0.0.0", + "url": "^0.11.0", + "util": "^0.10.3", + "vm-browserify": "0.0.4" + }, + "dependencies": { + "browserify-aes": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-0.4.0.tgz", + "integrity": "sha1-BnFJtmjfMcS1hTPgLQHoBthgjiw=", + "dev": true, + "requires": { + "inherits": "^2.0.1" + } + }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, + "crypto-browserify": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.3.0.tgz", + "integrity": "sha1-ufx1u0oO1h3PHNXa6W6zDJw+UGw=", + "dev": true, + "requires": { + "browserify-aes": "0.4.0", + "pbkdf2-compat": "2.0.1", + "ripemd160": "0.2.0", + "sha.js": "2.2.6" + } + }, + "https-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-0.0.1.tgz", + "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=", + "dev": true + }, + "os-browserify": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.2.1.tgz", + "integrity": "sha1-Y/xMzuXS13Y9Jrv4YBB45sLgBE8=", + "dev": true + }, + "ripemd160": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-0.2.0.tgz", + "integrity": "sha1-K/GYveFnys+lHAqSjoS2i74XH84=", + "dev": true + }, + "sha.js": { + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.2.6.tgz", + "integrity": "sha1-F93t3F9yL7ZlAWWIlUYZd4ZzFbo=", + "dev": true + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "timers-browserify": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.3.tgz", + "integrity": "sha512-+JAqyNgg+M8+gXIrq2EeUr4kZqRz47Ysco7X5QKRGScRE9HIHckyHD1asozSFGeqx2nmPCgA8T5tIGVO0ML7/w==", + "dev": true, + "requires": { + "global": "^4.3.2", + "setimmediate": "^1.0.4" + } + } + } + }, + "nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "dev": true, + "requires": { + "abbrev": "1" + } + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object.omit": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", + "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", + "dev": true, + "requires": { + "for-own": "^0.1.4", + "is-extendable": "^0.1.1" + } + }, + "object.pick": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.2.0.tgz", + "integrity": "sha1-tTkr7peC2m2ft9avr1OXefEjTCs=", + "dev": true, + "requires": { + "isobject": "^2.1.0" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", + "dev": true + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" + }, + "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + } + } + }, + "os-browserify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.1.2.tgz", + "integrity": "sha1-ScoCk+CxlZCl9d4Qx/JlphfY/lQ=", + "dev": true + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "package-json": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", + "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", + "dev": true, + "requires": { + "got": "^6.7.1", + "registry-auth-token": "^3.0.1", + "registry-url": "^3.0.3", + "semver": "^5.1.0" + } + }, + "pako": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", + "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", + "dev": true + }, + "parents": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", + "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", + "dev": true, + "requires": { + "path-platform": "~0.11.15" + } + }, + "parse-asn1": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.0.tgz", + "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", + "dev": true, + "requires": { + "asn1.js": "^4.0.0", + "browserify-aes": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3" + } + }, + "parse-glob": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", + "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", + "dev": true, + "requires": { + "glob-base": "^0.3.0", + "is-dotfile": "^1.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.0" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, + "path-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", + "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "dev": true + }, + "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 + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", + "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "dev": true + }, + "path-platform": { + "version": "0.11.15", + "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", + "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=" + }, + "pbkdf2": { + "version": "3.0.13", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.13.tgz", + "integrity": "sha512-+dCHxDH+djNtjgWmvVC/my3SYBAKpKNqKSjLkp+GtWWYe4XPE+e/PSD2aCanlEZZnqPk2uekTKNC/ccbwd2X2Q==", + "dev": true, + "requires": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "pbkdf2-compat": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pbkdf2-compat/-/pbkdf2-compat-2.0.1.tgz", + "integrity": "sha1-tuDI+plJTZTgURV1gCpZpcFC8og=", + "dev": true + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "popsicle": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/popsicle/-/popsicle-9.1.0.tgz", + "integrity": "sha1-T5APONV6V07BcO2kBJbjZAgr/2Y=", + "dev": true, + "requires": { + "concat-stream": "^1.4.7", + "form-data": "^2.0.0", + "make-error-cause": "^1.2.1", + "tough-cookie": "^2.0.0" + } + }, + "popsicle-proxy-agent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/popsicle-proxy-agent/-/popsicle-proxy-agent-3.0.0.tgz", + "integrity": "sha1-uRM8VdlFdZq37mG3cRNkYg066tw=", + "dev": true, + "requires": { + "http-proxy-agent": "^1.0.0", + "https-proxy-agent": "^1.0.0" + } + }, + "popsicle-retry": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/popsicle-retry/-/popsicle-retry-3.2.1.tgz", + "integrity": "sha1-4G6GZTO0KnoSPrMwy+Y6fOvLoQw=", + "dev": true, + "requires": { + "any-promise": "^1.1.0", + "xtend": "^4.0.1" + } + }, + "popsicle-rewrite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/popsicle-rewrite/-/popsicle-rewrite-1.0.0.tgz", + "integrity": "sha1-HdTo6pwxgjUfuCD4eTTZkvf7kAc=", + "dev": true + }, + "popsicle-status": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/popsicle-status/-/popsicle-status-2.0.1.tgz", + "integrity": "sha1-jdcMT+fGlBCa3XhP/oDqysHnso0=", + "dev": true + }, + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", + "dev": true + }, + "preserve": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", + "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", + "dev": true + }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "promise-finally": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/promise-finally/-/promise-finally-3.0.0.tgz", + "integrity": "sha1-3dXQ+JVDKxIGzrjaEnUGTRjnqiM=", + "dev": true + }, + "prr": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz", + "integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo=", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "public-encrypt": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", + "integrity": "sha1-OfaZ86RlYN1eusvKaTyvfGXBjMY=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1" + } + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "dev": true + }, + "querystring-es3": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", + "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", + "dev": true + }, + "randomatic": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "randombytes": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", + "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "rc": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.1.tgz", + "integrity": "sha1-LgPo5C7kULjLPc5lvhv4l04d/ZU=", + "dev": true, + "requires": { + "deep-extend": "~0.4.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + } + }, + "read-only-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", + "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", + "dev": true, + "requires": { + "readable-stream": "^2.0.2" + } + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.0.3", + "util-deprecate": "~1.0.1" + } + }, + "readdirp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", + "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "minimatch": "^3.0.2", + "readable-stream": "^2.0.2", + "set-immediate-shim": "^1.0.1" + } + }, + "regex-cache": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", + "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=", + "dev": true, + "requires": { + "is-equal-shallow": "^0.1.3", + "is-primitive": "^2.0.0" + } + }, + "registry-auth-token": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.1.tgz", + "integrity": "sha1-+w0yie4Nmtosu1KvXf5mywcNMAY=", + "dev": true, + "requires": { + "rc": "^1.1.6", + "safe-buffer": "^5.0.1" + } + }, + "registry-url": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", + "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", + "dev": true, + "requires": { + "rc": "^1.0.1" + } + }, + "remove-trailing-separator": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz", + "integrity": "sha1-abBi2XhyetFNxrVrpKt3L9jXBRE=", + "dev": true + }, + "repeat-element": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "resolve": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", + "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", + "dev": true, + "requires": { + "path-parse": "^1.0.5" + } + }, + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "dev": true, + "requires": { + "exit-hook": "^1.0.0", + "onetime": "^1.0.0" + } + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "requires": { + "align-text": "^0.1.1" + } + }, + "rimraf": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", + "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", + "dev": true, + "requires": { + "glob": "^7.0.5" + } + }, + "ripemd160": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", + "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", + "dev": true, + "requires": { + "hash-base": "^2.0.0", + "inherits": "^2.0.1" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "semver": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "dev": true + }, + "semver-diff": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", + "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", + "dev": true, + "requires": { + "semver": "^5.0.3" + } + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", + "dev": true + }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", + "dev": true + }, + "sha.js": { + "version": "2.4.8", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.8.tgz", + "integrity": "sha1-NwaMLEdra69ALRSknGf1l5IfY08=", + "dev": true, + "requires": { + "inherits": "^2.0.1" + } + }, + "shasum": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", + "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", + "dev": true, + "requires": { + "json-stable-stringify": "~0.0.0", + "sha.js": "~2.4.4" + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "shell-quote": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", + "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", + "dev": true, + "requires": { + "array-filter": "~0.0.0", + "array-map": "~0.0.0", + "array-reduce": "~0.0.0", + "jsonify": "~0.0.0" + } + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0" + } + }, + "slide": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz", + "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=", + "dev": true + }, + "sort-keys": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", + "integrity": "sha1-RBttTTRnmPG05J6JIK37oOVD+a0=", + "dev": true, + "requires": { + "is-plain-obj": "^1.0.0" + } + }, + "source-list-map": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-0.1.8.tgz", + "integrity": "sha1-xVCyq1Qn9rPyH1r+rYjE9Vh7IQY=", + "dev": true + }, + "source-map": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=" + }, + "source-map-support": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.15.tgz", + "integrity": "sha1-AyAt9lwG0r2MfsI2KhkwVv7407E=", + "requires": { + "source-map": "^0.5.6" + } + }, + "stream-browserify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", + "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", + "dev": true, + "requires": { + "inherits": "~2.0.1", + "readable-stream": "^2.0.2" + } + }, + "stream-combiner2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", + "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", + "dev": true, + "requires": { + "duplexer2": "~0.1.0", + "readable-stream": "^2.0.2" + } + }, + "stream-http": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz", + "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==", + "dev": true, + "requires": { + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.2.6", + "to-arraybuffer": "^1.0.0", + "xtend": "^4.0.0" + } + }, + "stream-splicer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz", + "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "readable-stream": "^2.0.2" + } + }, + "string-template": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/string-template/-/string-template-1.0.0.tgz", + "integrity": "sha1-np8iM9wA8hhxjsN5oopWc+zKi5Y=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, + "requires": { + "is-utf8": "^0.2.0" + } + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "subarg": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", + "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", + "dev": true, + "requires": { + "minimist": "^1.1.0" + } + }, + "supports-color": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "dev": true, + "requires": { + "has-flag": "^1.0.0" + } + }, + "syntax-error": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.3.0.tgz", + "integrity": "sha1-HtkmbE1AvnXcVb+bsct3Biu5bKE=", + "dev": true, + "requires": { + "acorn": "^4.0.3" + } + }, + "tapable": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz", + "integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI=", + "dev": true + }, + "term-size": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/term-size/-/term-size-1.2.0.tgz", + "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", + "dev": true, + "requires": { + "execa": "^0.7.0" + } + }, + "thenify": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.0.tgz", + "integrity": "sha1-5p44obq+lpsBCCB5eLn2K4hgSDk=", + "dev": true, + "requires": { + "any-promise": "^1.0.0" + } + }, + "throat": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/throat/-/throat-3.2.0.tgz", + "integrity": "sha512-/EY8VpvlqJ+sFtLPeOgc8Pl7kQVOWv0woD87KTXVHPIAE842FGT+rokxIhe8xIUP1cfgrkt0as0vDLjDiMtr8w==", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "^2.1.5", + "xtend": "~4.0.1" + } + }, + "timed-out": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", + "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", + "dev": true + }, + "timers-browserify": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", + "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", + "dev": true, + "requires": { + "process": "~0.11.0" + } + }, + "to-arraybuffer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", + "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", + "dev": true + }, + "touch": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-1.0.0.tgz", + "integrity": "sha1-RJy+LbrlqMgDjjDXH6D/RklHxN4=", + "dev": true, + "requires": { + "nopt": "~1.0.10" + } + }, + "tough-cookie": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", + "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", + "dev": true, + "requires": { + "punycode": "^1.4.1" + } + }, + "ts-loader": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-2.3.2.tgz", + "integrity": "sha512-KcQvWwla5nviCMX1511iKVsLfrx97Hbah6l5awE1HNL6eiyAzb3gSO8b5yasB6fK/qGukLpu9czWcd/AGGFy/g==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "enhanced-resolve": "^3.0.0", + "loader-utils": "^1.0.2", + "semver": "^5.0.1" + } + }, + "ts-node": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-3.3.0.tgz", + "integrity": "sha1-wTxqMCTjC+EYDdUwOPwgkonUv2k=", + "requires": { + "arrify": "^1.0.0", + "chalk": "^2.0.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.0", + "tsconfig": "^6.0.0", + "v8flags": "^3.0.0", + "yn": "^2.0.0" + }, + "dependencies": { + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" + }, + "tsconfig": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-6.0.0.tgz", + "integrity": "sha1-aw6DdgA9evGGT434+J3QBZ/80DI=", + "requires": { + "strip-bom": "^3.0.0", + "strip-json-comments": "^2.0.0" + } + } + } + }, + "tsconfig": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-5.0.3.tgz", + "integrity": "sha1-X0J45wGACWeo/Dg/0ZZIh48qbjo=", + "dev": true, + "requires": { + "any-promise": "^1.3.0", + "parse-json": "^2.2.0", + "strip-bom": "^2.0.0", + "strip-json-comments": "^2.0.0" + } + }, + "tsify": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/tsify/-/tsify-3.0.1.tgz", + "integrity": "sha1-I1Cf87TnEQypZW9sJ8oT7IVgVvY=", + "dev": true, + "requires": { + "convert-source-map": "^1.1.0", + "fs.realpath": "^1.0.0", + "object-assign": "^4.1.0", + "semver": "^5.1.0", + "through2": "^2.0.0", + "tsconfig": "^5.0.3" + } + }, + "tty-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", + "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", + "dev": true + }, + "type-detect": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.3.tgz", + "integrity": "sha1-Dj8mcLRAmbC0bChNE2p+9Jx0wuo=" + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "typescript": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.4.2.tgz", + "integrity": "sha1-+DlfhdRZJ2BnyYiqQYN6j4KHCEQ=", + "dev": true + }, + "typings": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/typings/-/typings-2.1.1.tgz", + "integrity": "sha1-usxp0lWXCkeOCfdsf2iZddU1p4o=", + "dev": true, + "requires": { + "archy": "^1.0.0", + "bluebird": "^3.1.1", + "chalk": "^1.0.0", + "cli-truncate": "^1.0.0", + "columnify": "^1.5.2", + "elegant-spinner": "^1.0.1", + "has-unicode": "^2.0.1", + "listify": "^1.0.0", + "log-update": "^1.0.2", + "minimist": "^1.2.0", + "promise-finally": "^3.0.0", + "typings-core": "^2.3.3", + "update-notifier": "^2.0.0", + "wordwrap": "^1.0.0", + "xtend": "^4.0.1" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "typings-core": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/typings-core/-/typings-core-2.3.3.tgz", + "integrity": "sha1-CexUzVsR3V8e8vwKsx03ACyita0=", + "dev": true, + "requires": { + "array-uniq": "^1.0.2", + "configstore": "^3.0.0", + "debug": "^2.2.0", + "detect-indent": "^5.0.0", + "graceful-fs": "^4.1.2", + "has": "^1.0.1", + "invariant": "^2.2.0", + "is-absolute": "^0.2.3", + "jspm-config": "^0.3.0", + "listify": "^1.0.0", + "lockfile": "^1.0.1", + "make-error-cause": "^1.2.1", + "mkdirp": "^0.5.1", + "object.pick": "^1.1.1", + "parse-json": "^2.2.0", + "popsicle": "^9.0.0", + "popsicle-proxy-agent": "^3.0.0", + "popsicle-retry": "^3.2.0", + "popsicle-rewrite": "^1.0.0", + "popsicle-status": "^2.0.0", + "promise-finally": "^3.0.0", + "rc": "^1.1.5", + "rimraf": "^2.4.4", + "sort-keys": "^1.0.0", + "string-template": "^1.0.0", + "strip-bom": "^3.0.0", + "thenify": "^3.1.0", + "throat": "^3.0.0", + "touch": "^1.0.0", + "typescript": "^2.1.4", + "xtend": "^4.0.0", + "zip-object": "^0.1.0" + }, + "dependencies": { + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + } + } + }, + "uglify-js": { + "version": "2.7.5", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.7.5.tgz", + "integrity": "sha1-RhLAx7qu4rp8SH3kkErhIgefLKg=", + "dev": true, + "requires": { + "async": "~0.2.6", + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" + }, + "dependencies": { + "async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", + "dev": true + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true + }, + "umd": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz", + "integrity": "sha1-iuVW4RAR9jwllnCKiDclnwGz1g4=", + "dev": true + }, + "unc-path-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", + "dev": true + }, + "unique-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", + "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", + "dev": true, + "requires": { + "crypto-random-string": "^1.0.0" + } + }, + "unzip-response": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", + "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", + "dev": true + }, + "update-notifier": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.2.0.tgz", + "integrity": "sha1-G1g3z5DAc22IYncytmHBOPht5y8=", + "dev": true, + "requires": { + "boxen": "^1.0.0", + "chalk": "^1.0.0", + "configstore": "^3.0.0", + "import-lazy": "^2.1.0", + "is-npm": "^1.0.0", + "latest-version": "^3.0.0", + "semver-diff": "^2.0.0", + "xdg-basedir": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + } + } + }, + "url-parse-lax": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "dev": true, + "requires": { + "prepend-http": "^1.0.1" + } + }, + "user-home": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", + "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=" + }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "requires": { + "inherits": "2.0.1" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + } + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "v8flags": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.0.0.tgz", + "integrity": "sha512-AGl+C+4qpeSu2g3JxCD/mGFFOs/vVZ3XREkD3ibQXEqr4Y4zgIrPWW124/IKJFHOIVFIoH8miWrLf0o84HYjwA==", + "requires": { + "user-home": "^1.1.1" + } + }, + "vm-browserify": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", + "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", + "dev": true, + "requires": { + "indexof": "0.0.1" + } + }, + "watchpack": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-0.2.9.tgz", + "integrity": "sha1-Yuqkq15bo1/fwBgnVibjwPXj+ws=", + "dev": true, + "requires": { + "async": "^0.9.0", + "chokidar": "^1.0.0", + "graceful-fs": "^4.1.2" + }, + "dependencies": { + "async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", + "dev": true + } + } + }, + "wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=", + "dev": true, + "requires": { + "defaults": "^1.0.3" + } + }, + "webpack": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-1.15.0.tgz", + "integrity": "sha1-T/MfU9sDM55VFkqdRo7gMklo/pg=", + "dev": true, + "requires": { + "acorn": "^3.0.0", + "async": "^1.3.0", + "clone": "^1.0.2", + "enhanced-resolve": "~0.9.0", + "interpret": "^0.6.4", + "loader-utils": "^0.2.11", + "memory-fs": "~0.3.0", + "mkdirp": "~0.5.0", + "node-libs-browser": "^0.7.0", + "optimist": "~0.6.0", + "supports-color": "^3.1.0", + "tapable": "~0.1.8", + "uglify-js": "~2.7.3", + "watchpack": "^0.2.1", + "webpack-core": "~0.6.9" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + }, + "enhanced-resolve": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz", + "integrity": "sha1-TW5omzcl+GCQknzMhs2fFjW4ni4=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.2.0", + "tapable": "^0.1.8" + }, + "dependencies": { + "memory-fs": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.2.0.tgz", + "integrity": "sha1-8rslNovBIeORwlIN6Slpyu4KApA=", + "dev": true + } + } + }, + "loader-utils": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", + "integrity": "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=", + "dev": true, + "requires": { + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0", + "object-assign": "^4.0.1" + } + }, + "memory-fs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.3.0.tgz", + "integrity": "sha1-e8xrYp46Q+hx1+Kaymrop/FcuyA=", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "tapable": { + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.1.10.tgz", + "integrity": "sha1-KcNXB8K3DlDQdIK10gLo7URtr9Q=", + "dev": true + } + } + }, + "webpack-core": { + "version": "0.6.9", + "resolved": "https://registry.npmjs.org/webpack-core/-/webpack-core-0.6.9.tgz", + "integrity": "sha1-/FcViMhVjad76e+23r3Fo7FyvcI=", + "dev": true, + "requires": { + "source-list-map": "~0.1.7", + "source-map": "~0.4.1" + }, + "dependencies": { + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "requires": { + "amdefine": ">=0.0.4" + } + } + } + }, + "which": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "widest-line": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-1.0.0.tgz", + "integrity": "sha1-DAnIXCqUaD0Nfq+O4JfVZL8OEFw=", + "dev": true, + "requires": { + "string-width": "^1.0.1" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } + } + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write-file-atomic": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.1.0.tgz", + "integrity": "sha512-0TZ20a+xcIl4u0+Mj5xDH2yOWdmQiXlKf9Hm+TgDXjTMsEYb+gDrmb8e8UNAzMCitX8NBqG4Z/FUQIyzv/R1JQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "slide": "^1.1.5" + } + }, + "xdg-basedir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", + "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "requires": { + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", + "window-size": "0.1.0" + }, + "dependencies": { + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + } + } + }, + "yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=" + }, + "zip-object": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/zip-object/-/zip-object-0.1.0.tgz", + "integrity": "sha1-waDaBMiMg3dW4khoCgP/kC7D9To=", + "dev": true + } + } +} diff --git a/samples/client/petstore/typescript-fetch/tests/default/run_tests_via_browserify.html b/samples/client/petstore/typescript-fetch/tests/default/run_tests_via_browserify.html new file mode 100644 index 000000000000..5d378bac5825 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/run_tests_via_browserify.html @@ -0,0 +1,26 @@ + + + + Mocha Tests + + + +
+ + + + + + + + + diff --git a/samples/client/petstore/typescript-fetch/tests/default/run_tests_via_webpack.html b/samples/client/petstore/typescript-fetch/tests/default/run_tests_via_webpack.html new file mode 100644 index 000000000000..ace737c7ccd2 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/run_tests_via_webpack.html @@ -0,0 +1,27 @@ + + + + Mocha Tests + + + +
+ + + + + + + + + + diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts new file mode 100644 index 000000000000..8c89846d0072 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts @@ -0,0 +1,79 @@ +import { expect } from 'chai'; +import { PetApi, Pet, Category } from '@swagger/typescript-fetch-petstore'; + +describe('PetApi', () => { + + function runSuite(description: string, requestOptions?: any): void { + + describe(description, () => { + + let api: PetApi; + const fixture: Pet = createTestFixture(); + + beforeEach(() => { + api = new PetApi(); + }); + + it('should add and delete Pet', () => { + return api.addPet(fixture, requestOptions).then(() => { + }); + }); + + it('should get Pet by ID', () => { + return api.getPetById(fixture.id, requestOptions).then((result: Pet) => { + return expect(result).to.deep.equal(fixture); + }); + }); + + it('should update Pet by ID', () => { + return api.getPetById(fixture.id, requestOptions).then((result: Pet) => { + result.name = 'newname'; + return api.updatePet(result, requestOptions).then(() => { + return api.getPetById(fixture.id, requestOptions).then((result: Pet) => { + return expect(result.name).to.deep.equal('newname'); + }); + }); + }); + }); + + it('should delete Pet', () => { + return api.deletePet(fixture.id, requestOptions); + }); + + it('should not contain deleted Pet', () => { + return api.getPetById(fixture.id, requestOptions).then((result: Pet) => { + return expect(result).to.not.exist; + }, (err: any) => { + return expect(err).to.exist; + }); + }); + + }); + } + + runSuite('without custom request options'); + + runSuite('with custom request options', { + credentials: 'include', + mode: 'cors' + }); + +}); + +function createTestFixture(ts = Date.now()) { + const category: Category = { + 'id': ts, + 'name': `category${ts}`, + }; + + const pet: Pet = { + 'id': ts, + 'name': `pet${ts}`, + 'category': category, + 'photoUrls': ['http://foo.bar.com/1', 'http://foo.bar.com/2'], + 'status': Pet.StatusEnum.Available, + 'tags': [] + }; + + return pet; +}; diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts b/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts new file mode 100644 index 000000000000..35bcc98d874a --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts @@ -0,0 +1,91 @@ +import { expect } from 'chai'; +import { PetApiFactory, Pet, Category } from '@swagger/typescript-fetch-petstore'; +import { Configuration } from '@swagger/typescript-fetch-petstore'; + +let config: Configuration; + +before(function () { + config = new Configuration(); + config.accessToken = "foobar"; + config.apiKey = (securityName: string) => { + // for multiple apiKey security + if (securityName === "api_key") { + return "foobar"; + } + return; + }; + config.username = "foo"; + config.password = "bar"; +}); + +describe('PetApiFactory', () => { + + + function runSuite(description: string, requestOptions?: any): void { + + describe(description, () => { + + const fixture: Pet = createTestFixture(); + + it('should add and delete Pet', () => { + return PetApiFactory(config).addPet(fixture, requestOptions).then(() => { + }); + }); + + it('should get Pet by ID', () => { + return PetApiFactory(config).getPetById(fixture.id, requestOptions).then((result: Pet) => { + return expect(result).to.deep.equal(fixture); + }); + }); + + it('should update Pet by ID', () => { + return PetApiFactory(config).getPetById(fixture.id, requestOptions).then((result: Pet) => { + result.name = 'newname'; + return PetApiFactory(config).updatePet(result, requestOptions).then(() => { + return PetApiFactory(config).getPetById(fixture.id, requestOptions).then((result: Pet) => { + return expect(result.name).to.deep.equal('newname'); + }); + }); + }); + }); + + it('should delete Pet', () => { + return PetApiFactory(config).deletePet(fixture.id, requestOptions); + }); + + it('should not contain deleted Pet', () => { + return PetApiFactory(config).getPetById(fixture.id, requestOptions).then((result: Pet) => { + return expect(result).to.not.exist; + }, (err: any) => { + return expect(err).to.exist; + }); + }); + }); + } + + runSuite('without custom request options'); + + runSuite('with custom request options', { + credentials: 'include', + mode: 'cors' + }); + +}); + +function createTestFixture(ts = Date.now()) { + const category: Category = { + 'id': ts, + 'name': `category${ts}`, + }; + + const pet: Pet = { + 'id': ts, + 'name': `pet${ts}`, + 'category': category, + 'photoUrls': ['http://foo.bar.com/1', 'http://foo.bar.com/2'], + 'status': Pet.StatusEnum.Available, + 'tags': [] + }; + + return pet; +}; diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts new file mode 100644 index 000000000000..24f507173608 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts @@ -0,0 +1,31 @@ +import { expect } from 'chai'; +import { StoreApi } from '@swagger/typescript-fetch-petstore'; + +describe('StoreApi', function () { + + function runSuite(description: string, requestOptions?: any): void { + + describe(description, () => { + let api: StoreApi; + + beforeEach(function () { + api = new StoreApi(); + }); + + it('should get inventory', function () { + return api.getInventory(requestOptions).then((result: { [key: string]: number }) => { + expect(Object.keys(result)).to.not.be.empty; + }); + }); + + }); + } + + runSuite('without custom request options'); + + runSuite('with custom request options', { + credentials: 'include', + mode: 'cors' + }); + +}); diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts new file mode 100644 index 000000000000..d87bd020a857 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts @@ -0,0 +1,42 @@ +import { expect } from 'chai'; +import { StoreApiFactory } from '@swagger/typescript-fetch-petstore'; +import { Configuration } from '@swagger/typescript-fetch-petstore'; + +let config: Configuration; + +before(function () { + config = new Configuration(); + config.accessToken = "foobar"; + config.apiKey = (securityName: string) => { + // for multiple apiKey security + if (securityName === "api_key") { + return "foobar"; + } + return; + }; + config.username = "foo"; + config.password = "bar"; +}); + +describe('StoreApiFactory', function () { + function runSuite(description: string, requestOptions?: any): void { + + describe(description, () => { + + it('should get inventory', function () { + return StoreApiFactory(config).getInventory(requestOptions).then((result: { [key: string]: number }) => { + expect(Object.keys(result)).to.not.be.empty; + }); + }); + + }); + } + + runSuite('without custom request options'); + + runSuite('with custom request options', { + credentials: 'include', + mode: 'cors' + }); + +}); diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/index.ts b/samples/client/petstore/typescript-fetch/tests/default/test/index.ts new file mode 100644 index 000000000000..a3adb97ca810 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/test/index.ts @@ -0,0 +1,4 @@ +import './PetApi'; +import './StoreApi'; +import './PetApiFactory'; +import './StoreApiFactory'; diff --git a/samples/client/petstore/typescript-fetch/tests/default/tsconfig.json b/samples/client/petstore/typescript-fetch/tests/default/tsconfig.json new file mode 100644 index 000000000000..6524f781742b --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": true, + "sourceMap": false, + "outDir": "dist", + "types": [ + "mocha" + ], + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-fetch/tests/default/webpack.config.js b/samples/client/petstore/typescript-fetch/tests/default/webpack.config.js new file mode 100644 index 000000000000..1ae52808b86a --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/webpack.config.js @@ -0,0 +1,30 @@ +const webpack = require('webpack'); + +module.exports = { + entry: { + app: './test/index.ts', + vendor: [ + // libraries + '@swagger/typescript-fetch-petstore' + ], + }, + output: { + filename: './dist/test.webpack-bundle.js' + }, + plugins: [ + new webpack.optimize.CommonsChunkPlugin(/* chunkName= */'vendor', /* filename= */'./dist/vendor.webpack-bundle.js') + ], + resolve: { + // Add `.ts` and `.tsx` as a resolvable extension. + extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js'] + }, + module: { + loaders: [ + // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader` + { + test: /\.tsx?$/, + loader: 'ts-loader' + } + ] + } +}; From dae8b75c56fd782d2fa71b18808f8bb0e3983440 Mon Sep 17 00:00:00 2001 From: James Batt Date: Thu, 30 Aug 2018 14:58:28 +1000 Subject: [PATCH 18/39] updated configuration class to use property getters to allow clients to implement configuration values as getters --- .../typescript-fetch/runtime.mustache | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index f21776f1704d..2d4937ace2ac 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -119,28 +119,42 @@ export interface ConfigurationParameters { } export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} - basePath: string; - fetchApi: FetchAPI; - middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - - constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; - this.fetchApi = conf.fetchApi || window.fetch.bind(window); - this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; + get basePath(): string { + return this.configuration.basePath || BASE_PATH; + } + + get fetchApi(): FetchAPI { + return this.configuration.fetchApi || window.fetch.bind(window); + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): (name: string) => string | undefined { + const apiKey = this.configuration.apiKey; if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; + return typeof apiKey === 'function' ? apiKey : () => apiKey; } + return undefined; + } + + get accessToken(): (name: string, scopes?: string[]) => string | undefined { + const accessToken = this.configuration.accessToken; if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; + return typeof accessToken === 'function' ? accessToken : () => accessToken; } + return undefined; } } From 03999d4e7166d37283ef60ba2c947fc0bb95348c Mon Sep 17 00:00:00 2001 From: James Batt Date: Thu, 30 Aug 2018 15:39:21 +1000 Subject: [PATCH 19/39] added {{datatype}}ToJSON functions to handle serialization and naming conversions --- .../resources/typescript-fetch/apis.mustache | 5 ++--- .../typescript-fetch/modelEnum.mustache | 8 ++++++++ .../typescript-fetch/modelGeneric.mustache | 18 ++++++++++++++++++ .../typescript-fetch/runtime.mustache | 4 ++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index b912b34f63b4..ae6e511e3e9f 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -6,9 +6,8 @@ import * as runtime from '../runtime'; import { {{#imports}} {{className}}, - {{^isOriginalModelPropertyNaming}} {{className}}FromJSON, - {{/isOriginalModelPropertyNaming}} + {{className}}ToJSON, {{/imports}} } from '../models'; {{/imports.0}} @@ -174,7 +173,7 @@ export class {{classname}} extends runtime.BaseAPI { {{/hasQueryParams}} {{#hasBodyParam}} {{#bodyParam}} - body: requestParameters.{{paramName}}, + body: {{dataType}}ToJSON(requestParameters.{{paramName}}), {{/bodyParam}} {{/hasBodyParam}} {{#hasFormParams}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache index dc04cb0bd63d..596c3c31ee39 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache @@ -10,3 +10,11 @@ export enum {{classname}} { {{/enumVars}} {{/allowableValues}} } + +export function {{classname}}FromJSON(json: any): {{classname}} { + return json as {{classname}}; +} + +export function {{classname}}ToJSON(value: {{classname}}): any { + return value as any; +} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 09255ff2045f..577019692bff 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -45,6 +45,24 @@ export function {{classname}}FromJSON(json: any): {{classname}} { {{/vars}} }; } + +export function {{classname}}ToJSON(value: {{classname}}): any { + return { + {{#vars}} + {{#isPrimitiveType}} + '{{baseName}}': {{#isDate}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}value.{{name}}.toISOString(){{/isDate}}{{#isDateTime}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}value.{{name}}.toISOString(){{/isDateTime}}{{^isDate}}{{^isDateTime}}value.{{name}}{{/isDateTime}}{{/isDate}}, + {{/isPrimitiveType}} + {{^isPrimitiveType}} + {{#isContainer}} + '{{baseName}}': (value.name as Array).map({{#items}}{{datatype}}{{/items}}ToJSON), + {{/isContainer}} + {{^isContainer}} + '{{baseName}}': {{datatype}}ToJSON(value.{{name}}), + {{/isContainer}} + {{/isPrimitiveType}} + {{/vars}} + }; +} {{#hasEnums}} /** diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 2d4937ace2ac..eb9769210898 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -141,7 +141,7 @@ export class Configuration { return this.configuration.password; } - get apiKey(): (name: string) => string | undefined { + get apiKey(): ((name: string) => string) | undefined { const apiKey = this.configuration.apiKey; if (apiKey) { return typeof apiKey === 'function' ? apiKey : () => apiKey; @@ -149,7 +149,7 @@ export class Configuration { return undefined; } - get accessToken(): (name: string, scopes?: string[]) => string | undefined { + get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { const accessToken = this.configuration.accessToken; if (accessToken) { return typeof accessToken === 'function' ? accessToken : () => accessToken; From 7f0dcdfe12c554e70346ec79337d338193c218bb Mon Sep 17 00:00:00 2001 From: James Batt Date: Thu, 30 Aug 2018 16:49:31 +1000 Subject: [PATCH 20/39] fixed missing import --- .../main/resources/typescript-fetch/modelGeneric.mustache | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 577019692bff..348f4f396eec 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -2,9 +2,8 @@ import { {{#imports}} {{{.}}}, - {{^isOriginalModelPropertyNaming}} {{.}}FromJSON, - {{/isOriginalModelPropertyNaming}} + {{.}}ToJSON, {{/imports}} } from './'; @@ -54,7 +53,7 @@ export function {{classname}}ToJSON(value: {{classname}}): any { {{/isPrimitiveType}} {{^isPrimitiveType}} {{#isContainer}} - '{{baseName}}': (value.name as Array).map({{#items}}{{datatype}}{{/items}}ToJSON), + '{{baseName}}': (value.{{name}} as Array).map({{#items}}{{datatype}}{{/items}}ToJSON), {{/isContainer}} {{^isContainer}} '{{baseName}}': {{datatype}}ToJSON(value.{{name}}), From 5d74f0ae3fe79a9fe072020aaef2ed1b874d5c5e Mon Sep 17 00:00:00 2001 From: James Batt Date: Sat, 1 Sep 2018 22:06:42 +1000 Subject: [PATCH 21/39] fixed compilation error. updated samples --- .../gradle/plugin/OpenApiGeneratorPlugin.kt | 131 +++++ .../OpenApiGeneratorGenerateExtension.kt | 286 +++++++++ .../OpenApiGeneratorMetaExtension.kt | 48 ++ .../OpenApiGeneratorValidateExtension.kt | 32 + .../gradle/plugin/tasks/GenerateTask.kt | 554 ++++++++++++++++++ .../gradle/plugin/tasks/GeneratorsTask.kt | 71 +++ .../generator/gradle/plugin/tasks/MetaTask.kt | 132 +++++ .../gradle/plugin/tasks/ValidateTask.kt | 82 +++ .../bin/test/GenerateTaskDslTest.kt | 71 +++ .../bin/test/GeneratorsTaskDslTest.kt | 38 ++ .../bin/test/MetaTaskDslTest.kt | 58 ++ .../bin/test/TestBase.kt | 34 ++ .../bin/test/ValidateTaskDslTest.kt | 99 ++++ .../bin/test/specs/petstore-v3.0-invalid.yaml | 103 ++++ .../bin/test/specs/petstore-v3.0.yaml | 109 ++++ .../TypeScriptFetchClientCodegen.java | 2 + .../builds/default/apis/PetApi.ts | 6 +- .../builds/default/apis/StoreApi.ts | 3 +- .../builds/default/apis/UserApi.ts | 9 +- .../builds/default/models/ApiResponse.ts | 8 + .../builds/default/models/Category.ts | 7 + .../builds/default/models/Order.ts | 11 + .../builds/default/models/Pet.ts | 13 + .../builds/default/models/Tag.ts | 7 + .../builds/default/models/User.ts | 13 + .../builds/default/runtime.ts | 48 +- .../builds/es6-target/apis/PetApi.ts | 6 +- .../builds/es6-target/apis/StoreApi.ts | 3 +- .../builds/es6-target/apis/UserApi.ts | 9 +- .../builds/es6-target/models/ApiResponse.ts | 8 + .../builds/es6-target/models/Category.ts | 7 + .../builds/es6-target/models/Order.ts | 11 + .../builds/es6-target/models/Pet.ts | 13 + .../builds/es6-target/models/Tag.ts | 7 + .../builds/es6-target/models/User.ts | 13 + .../builds/es6-target/runtime.ts | 48 +- .../builds/with-interfaces/apis/PetApi.ts | 6 +- .../builds/with-interfaces/apis/StoreApi.ts | 3 +- .../builds/with-interfaces/apis/UserApi.ts | 9 +- .../with-interfaces/models/ApiResponse.ts | 8 + .../builds/with-interfaces/models/Category.ts | 7 + .../builds/with-interfaces/models/Order.ts | 11 + .../builds/with-interfaces/models/Pet.ts | 13 + .../builds/with-interfaces/models/Tag.ts | 7 + .../builds/with-interfaces/models/User.ts | 13 + .../builds/with-interfaces/runtime.ts | 48 +- .../builds/with-npm-version/apis/PetApi.ts | 6 +- .../builds/with-npm-version/apis/StoreApi.ts | 3 +- .../builds/with-npm-version/apis/UserApi.ts | 9 +- .../with-npm-version/models/ApiResponse.ts | 8 + .../with-npm-version/models/Category.ts | 7 + .../builds/with-npm-version/models/Order.ts | 11 + .../builds/with-npm-version/models/Pet.ts | 13 + .../builds/with-npm-version/models/Tag.ts | 7 + .../builds/with-npm-version/models/User.ts | 13 + .../builds/with-npm-version/runtime.ts | 48 +- 56 files changed, 2254 insertions(+), 96 deletions(-) create mode 100644 modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorMetaExtension.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorValidateExtension.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/GeneratorsTask.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/MetaTask.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/test/GenerateTaskDslTest.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/test/GeneratorsTaskDslTest.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/test/MetaTaskDslTest.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/test/TestBase.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/test/ValidateTaskDslTest.kt create mode 100644 modules/openapi-generator-gradle-plugin/bin/test/specs/petstore-v3.0-invalid.yaml create mode 100644 modules/openapi-generator-gradle-plugin/bin/test/specs/petstore-v3.0.yaml diff --git a/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt new file mode 100644 index 000000000000..b4a2089c11bb --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt @@ -0,0 +1,131 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.generator.gradle.plugin + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.invoke +import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGenerateExtension +import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorMetaExtension +import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorValidateExtension +import org.openapitools.generator.gradle.plugin.tasks.GenerateTask +import org.openapitools.generator.gradle.plugin.tasks.GeneratorsTask +import org.openapitools.generator.gradle.plugin.tasks.MetaTask +import org.openapitools.generator.gradle.plugin.tasks.ValidateTask + +/** + * A plugin providing common Open API Generator use cases. + * + * @author Jim Schubert + */ +@Suppress("unused") +class OpenApiGeneratorPlugin : Plugin { + override fun apply(project: Project) { + project.run { + val meta = extensions.create( + "openApiMeta", + OpenApiGeneratorMetaExtension::class.java, + project + ) + + val validate = extensions.create( + "openApiValidate", + OpenApiGeneratorValidateExtension::class.java, + project + ) + + val generate = extensions.create( + "openApiGenerate", + OpenApiGeneratorGenerateExtension::class.java, + project + ) + + generate.outputDir.set("$buildDir/generate-resources/main") + + tasks { + "openApiGenerators"(GeneratorsTask::class) { + group = pluginGroup + description = "Lists generators available via Open API Generators." + } + "openApiMeta"(MetaTask::class) { + group = pluginGroup + description = "Generates a new generator to be consumed via Open API Generator." + + generatorName.set(meta.generatorName) + packageName.set(meta.packageName) + outputFolder.set(meta.outputFolder) + } + "openApiValidate"(ValidateTask::class) { + group = pluginGroup + description = "Validates an Open API 2.0 or 3.x specification document." + + inputSpec.set(validate.inputSpec) + } + "openApiGenerate"(GenerateTask::class) { + group = pluginGroup + description = "Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents." + + verbose.set(generate.verbose) + validateSpec.set(generate.validateSpec) + generatorName.set(generate.generatorName) + outputDir.set(generate.outputDir) + inputSpec.set(generate.inputSpec) + templateDir.set(generate.templateDir) + auth.set(generate.auth) + systemProperties.set(generate.systemProperties) + configFile.set(generate.configFile) + skipOverwrite.set(generate.skipOverwrite) + apiPackage.set(generate.apiPackage) + modelPackage.set(generate.modelPackage) + modelNamePrefix.set(generate.modelNamePrefix) + modelNameSuffix.set(generate.modelNameSuffix) + instantiationTypes.set(generate.instantiationTypes) + typeMappings.set(generate.typeMappings) + additionalProperties.set(generate.additionalProperties) + languageSpecificPrimitives.set(generate.languageSpecificPrimitives) + importMappings.set(generate.importMappings) + invokerPackage.set(generate.invokerPackage) + groupId.set(generate.groupId) + id.set(generate.id) + version.set(generate.version) + library.set(generate.library) + gitUserId.set(generate.gitUserId) + gitRepoId.set(generate.gitRepoId) + releaseNote.set(generate.releaseNote) + httpUserAgent.set(generate.httpUserAgent) + reservedWordsMappings.set(generate.reservedWordsMappings) + ignoreFileOverride.set(generate.ignoreFileOverride) + removeOperationIdPrefix.set(generate.removeOperationIdPrefix) + apiFilesConstrainedTo.set(generate.apiFilesConstrainedTo) + modelFilesConstrainedTo.set(generate.modelFilesConstrainedTo) + supportingFilesConstrainedTo.set(generate.supportingFilesConstrainedTo) + generateModelTests.set(generate.generateModelTests) + generateModelDocumentation.set(generate.generateModelDocumentation) + generateApiTests.set(generate.generateApiTests) + generateApiDocumentation.set(generate.generateApiDocumentation) + withXml.set(generate.withXml) + configOptions.set(generate.configOptions) + } + } + } + } + + companion object { + const val pluginGroup = "OpenAPI Tools" + } +} + diff --git a/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt new file mode 100644 index 000000000000..fa7726542ccb --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt @@ -0,0 +1,286 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.generator.gradle.plugin.extensions + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.listProperty +import org.gradle.kotlin.dsl.property + +/** + * Gradle project level extension object definition for the generate task + * + * @author Jim Schubert + */ +open class OpenApiGeneratorGenerateExtension(project: Project) { + + /** + * The verbosity of generation + */ + val verbose = project.objects.property() + + /** + * Whether or not an input specification should be validated upon generation. + */ + val validateSpec = project.objects.property() + + /** + * The name of the generator which will handle codegen. (see "openApiGenerators" task) + */ + val generatorName = project.objects.property() + + /** + * The output target directory into which code will be generated. + */ + val outputDir = project.objects.property() + + /** + * The Open API 2.0/3.x specification location. + */ + val inputSpec = project.objects.property() + + /** + * The template directory holding a custom template. + */ + val templateDir = project.objects.property() + + /** + * Adds authorization headers when fetching the OpenAPI definitions remotely. + * Pass in a URL-encoded string of name:header with a comma separating multiple values + */ + val auth = project.objects.property() + + /** + * Sets specified system properties. + */ + val systemProperties = project.objects.property>() + + /** + * Path to json configuration file. + * File content should be in a json format { "optionKey":"optionValue", "optionKey1":"optionValue1"...} + * Supported options can be different for each language. Run config-help -g {generator name} command for language specific config options. + */ + val configFile = project.objects.property() + + /** + * Specifies if the existing files should be overwritten during the generation. + */ + val skipOverwrite = project.objects.property() + + /** + * Package for generated api classes + */ + val apiPackage = project.objects.property() + + /** + * Package for generated models + */ + val modelPackage = project.objects.property() + + /** + * Prefix that will be prepended to all model names. Default is the empty string. + */ + val modelNamePrefix = project.objects.property() + + /** + * Suffix that will be appended to all model names. Default is the empty string. + */ + val modelNameSuffix = project.objects.property() + + /** + * Sets instantiation type mappings. + */ + val instantiationTypes = project.objects.property>() + + /** + * Sets mappings between OpenAPI spec types and generated code types. + */ + val typeMappings = project.objects.property>() + + /** + * Sets additional properties that can be referenced by the mustache templates. + */ + val additionalProperties = project.objects.property>() + + /** + * Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double. + */ + val languageSpecificPrimitives = project.objects.listProperty() + + /** + * Specifies mappings between a given class and the import that should be used for that class. + */ + val importMappings = project.objects.property>() + + /** + * Root package for generated code. + */ + val invokerPackage = project.objects.property() + + /** + * GroupId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators. + */ + val groupId = project.objects.property() + + /** + * ArtifactId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators. + */ + val id = project.objects.property() + + /** + * Artifact version in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators. + */ + val version = project.objects.property() + + /** + * Reference the library template (sub-template) of a generator. + */ + val library = project.objects.property() + + /** + * Git user ID, e.g. openapitools. + */ + val gitUserId = project.objects.property() + + /** + * Git repo ID, e.g. openapi-generator. + */ + val gitRepoId = project.objects.property() + + /** + * Release note, default to 'Minor update'. + */ + val releaseNote = project.objects.property() + + /** + * HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}}/{language}' + */ + val httpUserAgent = project.objects.property() + + /** + * Specifies how a reserved name should be escaped to. Otherwise, the default _ is used. + */ + val reservedWordsMappings = project.objects.property>() + + /** + * Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation. + */ + val ignoreFileOverride = project.objects.property() + + /** + * Remove prefix of operationId, e.g. config_getId => getId + */ + val removeOperationIdPrefix = project.objects.property() + + /** + * Defines which API-related files should be generated. This allows you to create a subset of generated files (or none at all). + * + * NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results + * in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation. + * For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride]. + */ + val apiFilesConstrainedTo = project.objects.listProperty() + + /** + * Defines which model-related files should be generated. This allows you to create a subset of generated files (or none at all). + * + * NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results + * in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation. + * For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride]. + */ + val modelFilesConstrainedTo = project.objects.listProperty() + + /** + * Defines which supporting files should be generated. This allows you to create a subset of generated files (or none at all). + * + * Supporting files are those related to projects/frameworks which may be modified + * by consumers. + * + * NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results + * in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation. + * For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride]. + */ + val supportingFilesConstrainedTo = project.objects.listProperty() + + /** + * Defines whether or not model-related _test_ files should be generated. + * + * This option enables/disables generation of ALL model-related _test_ files. + * + * For more control over generation of individual files, configure an ignore file and + * refer to it via [ignoreFileOverride]. + */ + val generateModelTests = project.objects.property() + + /** + * Defines whether or not model-related _documentation_ files should be generated. + * + * This option enables/disables generation of ALL model-related _documentation_ files. + * + * For more control over generation of individual files, configure an ignore file and + * refer to it via [ignoreFileOverride]. + */ + val generateModelDocumentation = project.objects.property() + + /** + * Defines whether or not api-related _test_ files should be generated. + * + * This option enables/disables generation of ALL api-related _test_ files. + * + * For more control over generation of individual files, configure an ignore file and + * refer to it via [ignoreFileOverride]. + */ + val generateApiTests = project.objects.property() + + /** + * Defines whether or not api-related _documentation_ files should be generated. + * + * This option enables/disables generation of ALL api-related _documentation_ files. + * + * For more control over generation of individual files, configure an ignore file and + * refer to it via [ignoreFileOverride]. + */ + val generateApiDocumentation = project.objects.property() + + /** + * A special-case setting which configures some generators with XML support. In some cases, + * this forces json OR xml, so the default here is false. + */ + val withXml = project.objects.property() + + /** + * A map of options specific to a generator. + */ + val configOptions = project.objects.property>() + + init { + applyDefaults() + } + + @Suppress("MemberVisibilityCanBePrivate") + fun applyDefaults(){ + releaseNote.set("Minor update") + modelNamePrefix.set("") + modelNameSuffix.set("") + generateModelTests.set(true) + generateModelDocumentation.set(true) + generateApiTests.set(true) + generateApiDocumentation.set(true) + withXml.set(false) + configOptions.set(mapOf()) + validateSpec.set(true) + } +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorMetaExtension.kt b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorMetaExtension.kt new file mode 100644 index 000000000000..94d298a31b88 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorMetaExtension.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.generator.gradle.plugin.extensions + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.property + +/** + * Gradle project level extension object definition for the meta-generator task + * + * @author Jim Schubert + */ +open class OpenApiGeneratorMetaExtension(project: Project) { + /** + * The human-readable generator name of the newly created template generator. + */ + val generatorName = project.objects.property() + + /** + * The packageName generatorName to put the main class into (defaults to org.openapitools.codegen) + */ + val packageName = project.objects.property() + + /** + * Where to write the generated files (current dir by default). + */ + val outputFolder = project.objects.property() + + init { + generatorName.set("default") + packageName.set("org.openapitools.codegen") + outputFolder.set("") + } +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorValidateExtension.kt b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorValidateExtension.kt new file mode 100644 index 000000000000..3b4a1853b941 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorValidateExtension.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.generator.gradle.plugin.extensions + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.property + +/** + * Gradle project level extension object definition for the generators task + * + * @author Jim Schubert + */ +open class OpenApiGeneratorValidateExtension(project: Project) { + /** + * The input specification to validate. Supports all formats supported by the Parser. + */ + val inputSpec = project.objects.property() +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt new file mode 100644 index 000000000000..7c6ecd099da6 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt @@ -0,0 +1,554 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.generator.gradle.plugin.tasks + +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.TaskAction +import org.gradle.internal.logging.text.StyledTextOutput +import org.gradle.internal.logging.text.StyledTextOutputFactory +import org.gradle.kotlin.dsl.listProperty +import org.gradle.kotlin.dsl.property +import org.openapitools.codegen.CodegenConstants +import org.openapitools.codegen.DefaultGenerator +import org.openapitools.codegen.config.CodegenConfigurator + + +/** + * A task which generates the desired code. + * + * Example (CLI): + * + * ./gradlew -q openApiGenerate + * + * @author Jim Schubert + */ +open class GenerateTask : DefaultTask() { + + /** + * The verbosity of generation + */ + @get:Internal + val verbose = project.objects.property() + + /** + * Whether or not an input specification should be validated upon generation. + */ + @get:Internal + val validateSpec = project.objects.property() + + /** + * The name of the generator which will handle codegen. (see "openApiGenerators" task) + */ + @get:Internal + val generatorName = project.objects.property() + + /** + * The output target directory into which code will be generated. + */ + @get:Internal + val outputDir = project.objects.property() + + /** + * The Open API 2.0/3.x specification location. + */ + @get:Internal + val inputSpec = project.objects.property() + + /** + * The template directory holding a custom template. + */ + @get:Internal + val templateDir = project.objects.property() + + /** + * Adds authorization headers when fetching the OpenAPI definitions remotely. + * Pass in a URL-encoded string of name:header with a comma separating multiple values + */ + @get:Internal + val auth = project.objects.property() + + /** + * Sets specified system properties. + */ + @get:Internal + val systemProperties = project.objects.property>() + + /** + * Path to json configuration file. + * File content should be in a json format { "optionKey":"optionValue", "optionKey1":"optionValue1"...} + * Supported options can be different for each language. Run config-help -g {generator name} command for language specific config options. + */ + @get:Internal + val configFile = project.objects.property() + + /** + * Specifies if the existing files should be overwritten during the generation. + */ + @get:Internal + val skipOverwrite = project.objects.property() + + /** + * Package for generated api classes + */ + @get:Internal + val apiPackage = project.objects.property() + + /** + * Package for generated models + */ + @get:Internal + val modelPackage = project.objects.property() + + /** + * Prefix that will be prepended to all model names. Default is the empty string. + */ + @get:Internal + val modelNamePrefix = project.objects.property() + + /** + * Suffix that will be appended to all model names. Default is the empty string. + */ + @get:Internal + val modelNameSuffix = project.objects.property() + + /** + * Sets instantiation type mappings. + */ + @get:Internal + val instantiationTypes = project.objects.property>() + + /** + * Sets mappings between OpenAPI spec types and generated code types. + */ + @get:Internal + val typeMappings = project.objects.property>() + + /** + * Sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value. + * You can also have multiple occurrences of this option. + */ + @get:Internal + val additionalProperties = project.objects.property>() + + /** + * Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double. + */ + @get:Internal + val languageSpecificPrimitives = project.objects.listProperty() + + /** + * Specifies mappings between a given class and the import that should be used for that class. + */ + @get:Internal + val importMappings = project.objects.property>() + + /** + * Root package for generated code. + */ + @get:Internal + val invokerPackage = project.objects.property() + + /** + * GroupId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators. + */ + @get:Internal + val groupId = project.objects.property() + + /** + * ArtifactId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators. + */ + @get:Internal + val id = project.objects.property() + + /** + * Artifact version in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators. + */ + @get:Internal + val version = project.objects.property() + + /** + * Reference the library template (sub-template) of a generator. + */ + @get:Internal + val library = project.objects.property() + + /** + * Git user ID, e.g. openapitools. + */ + @get:Internal + val gitUserId = project.objects.property() + + /** + * Git repo ID, e.g. openapi-generator. + */ + @get:Internal + val gitRepoId = project.objects.property() + + /** + * Release note, default to 'Minor update'. + */ + @get:Internal + val releaseNote = project.objects.property() + + /** + * HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}}/{language}' + */ + @get:Internal + val httpUserAgent = project.objects.property() + + /** + * Specifies how a reserved name should be escaped to. + */ + @get:Internal + val reservedWordsMappings = project.objects.property>() + + /** + * Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation. + */ + @get:Internal + val ignoreFileOverride = project.objects.property() + + /** + * Remove prefix of operationId, e.g. config_getId => getId + */ + @get:Internal + val removeOperationIdPrefix = project.objects.property() + + /** + * Defines which API-related files should be generated. This allows you to create a subset of generated files (or none at all). + * + * This option enables/disables generation of ALL api-related files. + * + * NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results + * in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation. + * For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride]. + */ + @get:Internal + val apiFilesConstrainedTo = project.objects.listProperty() + + /** + * Defines which model-related files should be generated. This allows you to create a subset of generated files (or none at all). + * + * NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results + * in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation. + * For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride]. + */ + @get:Internal + val modelFilesConstrainedTo = project.objects.listProperty() + + /** + * Defines which supporting files should be generated. This allows you to create a subset of generated files (or none at all). + * + * Supporting files are those related to projects/frameworks which may be modified + * by consumers. + * + * NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results + * in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation. + * For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride]. + */ + @get:Internal + val supportingFilesConstrainedTo = project.objects.listProperty() + + /** + * Defines whether or not model-related _test_ files should be generated. + * + * This option enables/disables generation of ALL model-related _test_ files. + * + * For more control over generation of individual files, configure an ignore file and + * refer to it via [ignoreFileOverride]. + */ + @get:Internal + val generateModelTests = project.objects.property() + + /** + * Defines whether or not model-related _documentation_ files should be generated. + * + * This option enables/disables generation of ALL model-related _documentation_ files. + * + * For more control over generation of individual files, configure an ignore file and + * refer to it via [ignoreFileOverride]. + */ + @get:Internal + val generateModelDocumentation = project.objects.property() + + /** + * Defines whether or not api-related _test_ files should be generated. + * + * This option enables/disables generation of ALL api-related _test_ files. + * + * For more control over generation of individual files, configure an ignore file and + * refer to it via [ignoreFileOverride]. + */ + @get:Internal + val generateApiTests = project.objects.property() + + /** + * Defines whether or not api-related _documentation_ files should be generated. + * + * This option enables/disables generation of ALL api-related _documentation_ files. + * + * For more control over generation of individual files, configure an ignore file and + * refer to it via [ignoreFileOverride]. + */ + @get:Internal + val generateApiDocumentation = project.objects.property() + + /** + * A special-case setting which configures some generators with XML support. In some cases, + * this forces json OR xml, so the default here is false. + */ + @get:Internal + val withXml = project.objects.property() + + /** + * A dynamic map of options specific to a generator. + */ + @get:Internal + val configOptions = project.objects.property>() + + private val originalEnvironmentVariables = mutableMapOf() + + private fun Property.ifNotEmpty(block: Property.(T) -> Unit) { + if (isPresent) { + val item: T? = get() + if (item != null) { + when (get()) { + is String -> if ((get() as String).isNotEmpty()) { + block(get()) + } + is String? -> if (true == (get() as String?)?.isNotEmpty()) { + block(get()) + } + else -> block(get()) + } + } + } + } + + @Suppress("unused") + @TaskAction + fun doWork() { + val configurator: CodegenConfigurator = if (configFile.isPresent) { + CodegenConfigurator.fromFile(configFile.get()) + } else CodegenConfigurator() + + try { + if (systemProperties.isPresent) { + systemProperties.get().forEach { (key, value) -> + // System.setProperty returns the original value for a key, or null. + // Cache the original value or null…we will late put the properties back in their original state. + originalEnvironmentVariables[key] = System.setProperty(key, value) + configurator.addSystemProperty(key, value) + } + } + + if (supportingFilesConstrainedTo.isPresent && supportingFilesConstrainedTo.get().isNotEmpty()) { + System.setProperty(CodegenConstants.SUPPORTING_FILES, supportingFilesConstrainedTo.get().joinToString(",")) + } else { + System.clearProperty(CodegenConstants.SUPPORTING_FILES) + } + + if (modelFilesConstrainedTo.isPresent && modelFilesConstrainedTo.get().isNotEmpty()) { + System.setProperty(CodegenConstants.MODELS, modelFilesConstrainedTo.get().joinToString(",")) + } else { + System.clearProperty(CodegenConstants.MODELS) + } + + if (apiFilesConstrainedTo.isPresent && apiFilesConstrainedTo.get().isNotEmpty()) { + System.setProperty(CodegenConstants.APIS, apiFilesConstrainedTo.get().joinToString(",")) + } else { + System.clearProperty(CodegenConstants.APIS) + } + + System.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.get().toString()) + System.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.get().toString()) + System.setProperty(CodegenConstants.MODEL_TESTS, generateModelTests.get().toString()) + System.setProperty(CodegenConstants.API_TESTS, generateApiTests.get().toString()) + System.setProperty(CodegenConstants.WITH_XML, withXml.get().toString()) + + // now override with any specified parameters + verbose.ifNotEmpty { value -> + configurator.isVerbose = value + } + + validateSpec.ifNotEmpty { value -> + configurator.isValidateSpec = value + } + + skipOverwrite.ifNotEmpty { value -> + configurator.isSkipOverwrite = value ?: false + } + + inputSpec.ifNotEmpty { value -> + configurator.inputSpec = value + } + + generatorName.ifNotEmpty { value -> + configurator.generatorName = value + } + + outputDir.ifNotEmpty { value -> + configurator.outputDir = value + } + + auth.ifNotEmpty { value -> + configurator.auth = value + } + + templateDir.ifNotEmpty { value -> + configurator.templateDir = value + } + + apiPackage.ifNotEmpty { value -> + configurator.apiPackage = value + } + + modelPackage.ifNotEmpty { value -> + configurator.modelPackage = value + } + + modelNamePrefix.ifNotEmpty { value -> + configurator.modelNamePrefix = value + } + + modelNameSuffix.ifNotEmpty { value -> + configurator.modelNameSuffix = value + } + + invokerPackage.ifNotEmpty { value -> + configurator.invokerPackage = value + } + + groupId.ifNotEmpty { value -> + configurator.groupId = value + } + + id.ifNotEmpty { value -> + configurator.artifactId = value + } + + version.ifNotEmpty { value -> + configurator.artifactVersion = value + } + + library.ifNotEmpty { value -> + configurator.library = value + } + + gitUserId.ifNotEmpty { value -> + configurator.gitUserId = value + } + + gitRepoId.ifNotEmpty { value -> + configurator.gitRepoId = value + } + + releaseNote.ifNotEmpty { value -> + configurator.releaseNote = value + } + + httpUserAgent.ifNotEmpty { value -> + configurator.httpUserAgent = value + } + + ignoreFileOverride.ifNotEmpty { value -> + configurator.ignoreFileOverride = value + } + + removeOperationIdPrefix.ifNotEmpty { value -> + configurator.removeOperationIdPrefix = value!! + } + + if (systemProperties.isPresent) { + systemProperties.get().forEach { entry -> + configurator.addSystemProperty(entry.key, entry.value) + } + } + + if (instantiationTypes.isPresent) { + instantiationTypes.get().forEach { entry -> + configurator.addInstantiationType(entry.key, entry.value) + } + } + + if (importMappings.isPresent) { + importMappings.get().forEach { entry -> + configurator.addImportMapping(entry.key, entry.value) + } + } + + if (typeMappings.isPresent) { + typeMappings.get().forEach { entry -> + configurator.addTypeMapping(entry.key, entry.value) + } + } + + if (additionalProperties.isPresent) { + additionalProperties.get().forEach { entry -> + configurator.addAdditionalProperty(entry.key, entry.value) + } + } + + if (languageSpecificPrimitives.isPresent) { + languageSpecificPrimitives.get().forEach { + configurator.addLanguageSpecificPrimitive(it) + } + } + + if (reservedWordsMappings.isPresent) { + reservedWordsMappings.get().forEach { entry -> + configurator.addAdditionalReservedWordMapping(entry.key, entry.value) + } + } + + val clientOptInput = configurator.toClientOptInput() + val codgenConfig = clientOptInput.config + + if (configOptions.isPresent) { + val userSpecifiedConfigOptions = configOptions.get() + codgenConfig.cliOptions().forEach { + if (userSpecifiedConfigOptions.containsKey(it.opt)) { + clientOptInput.config.additionalProperties()[it.opt] = userSpecifiedConfigOptions[it.opt] + } + } + } + + try { + val out = services.get(StyledTextOutputFactory::class.java).create("openapi") + out.withStyle(StyledTextOutput.Style.Success) + + DefaultGenerator().opts(clientOptInput).generate() + + out.println("Successfully generated code to ${configurator.outputDir}") + } catch (e: RuntimeException) { + throw GradleException("Code generation failed.", e) + } + } finally { + // Reset all modified system properties back to their original state + originalEnvironmentVariables.forEach { + when { + it.value == null -> System.clearProperty(it.key) + else -> System.setProperty(it.key, it.value) + } + } + originalEnvironmentVariables.clear() + } + } +} diff --git a/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/GeneratorsTask.kt b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/GeneratorsTask.kt new file mode 100644 index 000000000000..08e821b83a53 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/GeneratorsTask.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.generator.gradle.plugin.tasks + +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.TaskAction +import org.gradle.internal.logging.text.StyledTextOutput +import org.gradle.internal.logging.text.StyledTextOutputFactory +import org.openapitools.codegen.CodegenConfigLoader +import org.openapitools.codegen.CodegenType + +/** + * A task which lists out the generators available in OpenAPI Generator + * + * Example (CLI): + * + * ./gradlew -q openApiGenerators + * + * @author Jim Schubert + */ +open class GeneratorsTask : DefaultTask() { + @Suppress("unused") + @TaskAction + fun doWork() { + val generators = CodegenConfigLoader.getAll() + + val out = services.get(StyledTextOutputFactory::class.java).create("openapi") + + StringBuilder().apply { + val types = CodegenType.values() + + append("The following generators are available:") + + append(System.lineSeparator()) + append(System.lineSeparator()) + + for (type in types) { + append(type.name).append(" generators:") + append(System.lineSeparator()) + + generators.filter { it.tag == type } + .sortedBy { it.name } + .forEach({ generator -> + append(" - ") + append(generator.name) + append(System.lineSeparator()) + }) + + append(System.lineSeparator()) + append(System.lineSeparator()) + } + + out.withStyle(StyledTextOutput.Style.Success) + out.formatln("%s%n", toString()) + } + } +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/MetaTask.kt b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/MetaTask.kt new file mode 100644 index 000000000000..7d11f4d8b6cc --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/MetaTask.kt @@ -0,0 +1,132 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.generator.gradle.plugin.tasks + +import com.samskivert.mustache.Mustache +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.TaskAction +import org.gradle.internal.logging.text.StyledTextOutput +import org.gradle.internal.logging.text.StyledTextOutputFactory +import org.gradle.kotlin.dsl.property +import org.openapitools.codegen.CodegenConfig +import org.openapitools.codegen.CodegenConstants +import org.openapitools.codegen.DefaultGenerator +import org.openapitools.codegen.SupportingFile +import java.io.File +import java.io.IOException +import java.nio.charset.Charset + +/** + * A task which generates a new generator (meta). Useful for redistributable generator packages. + * + * @author Jim Schubert + */ +open class MetaTask : DefaultTask() { + + @get:Internal + val generatorName = project.objects.property() + + @get:Internal + val packageName = project.objects.property() + + @get:Internal + val outputFolder = project.objects.property() + + @Suppress("unused") + @TaskAction + fun doWork() { + + val packageToPath = packageName.get().replace(".", File.separator) + val dir = File(outputFolder.get()) + val klass = "${generatorName.get().titleCasedTextOnly()}Generator" + + val templateResourceDir = generatorName.get().hyphenatedTextOnly() + + val out = services.get(StyledTextOutputFactory::class.java).create("openapi") + + out.withStyle(StyledTextOutput.Style.Info) + + logger.debug("package: {}", packageName.get()) + logger.debug("dir: {}", dir.absolutePath) + logger.debug("generator class: {}", klass) + + val supportingFiles = listOf( + SupportingFile("pom.mustache", "", "pom.xml"), + SupportingFile("generatorClass.mustache", dir("src", "main", "java", packageToPath), "$klass.java"), + SupportingFile("README.mustache", "", "README.md"), + SupportingFile("api.template", dir("src", "main", "resources", templateResourceDir), "api.mustache"), + SupportingFile("model.template", dir("src", "main", "resources", templateResourceDir), "model.mustache"), + SupportingFile("myFile.template", dir("src", "main", "resources", templateResourceDir), "myFile.mustache"), + SupportingFile("services.mustache", dir("src", "main", "resources", "META-INF", "services"), CodegenConfig::class.java.canonicalName)) + + val currentVersion = CodegenConstants::class.java.`package`.implementationVersion + + val data = mapOf("generatorPackage" to packageToPath, + "generatorClass" to klass, + "name" to templateResourceDir, + "fullyQualifiedGeneratorClass" to "${packageName.get()}.$klass", + "openapiGeneratorVersion" to currentVersion) + + val generator = DefaultGenerator() + supportingFiles.map { + try { + val destinationFolder = File(File(dir.absolutePath), it.folder) + destinationFolder.mkdirs() + val outputFile = File(destinationFolder, it.destinationFilename) + + val template = generator.readTemplate(File("codegen", it.templateFile).path) + var formatted = template + + if (it.templateFile.endsWith(".mustache")) { + formatted = Mustache.compiler() + .withLoader(loader(generator)) + .defaultValue("") + .compile(template).execute(data) + } + + outputFile.writeText(formatted, Charset.forName("UTF8")) + + out.formatln("Wrote file to %s", outputFile.absolutePath) + + // TODO: register outputs + // return outputFile + } catch (e: IOException) { + logger.error(e.message) + throw GradleException("Can't generate project", e) + } + } + out.withStyle(StyledTextOutput.Style.Success) + out.formatln("Created generator %s", klass) + } + + private fun loader(generator: DefaultGenerator): Mustache.TemplateLoader { + return Mustache.TemplateLoader { name -> + generator.getTemplateReader("codegen${File.separator}$name.mustache") + } + } + + private fun String.titleCasedTextOnly(): String = + this.split(Regex("[^a-zA-Z0-9]")).joinToString(separator = "", transform = String::capitalize) + + private fun String.hyphenatedTextOnly(): String = + this.split(Regex("[^a-zA-Z0-9]")).joinToString(separator = "-", transform = String::toLowerCase) + + private fun dir(vararg parts: String): String = + parts.joinToString(separator = File.separator) +} diff --git a/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt new file mode 100644 index 000000000000..0956ba22c265 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/main/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt @@ -0,0 +1,82 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.generator.gradle.plugin.tasks + +import io.swagger.parser.OpenAPIParser +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.options.Option +import org.gradle.internal.logging.text.StyledTextOutput +import org.gradle.internal.logging.text.StyledTextOutputFactory +import org.gradle.kotlin.dsl.property + +/** + * A generator which validates an Open API spec. This task outputs a list of validation issues and errors. + * + * Example: + * cli: + * + * ./gradlew openApiValidate --input=/path/to/file + * + * build.gradle: + * + * openApiMeta { + * inputSpec = "path/to/spec.yaml" + * } + * + * @author Jim Schubert + */ +open class ValidateTask : DefaultTask() { + @get:Internal + var inputSpec = project.objects.property() + + @Suppress("unused") + @get:Internal + @set:Option(option = "input", description = "The input specification.") + var input: String? = null + set(value) { + inputSpec.set(value) + } + + @Suppress("unused") + @TaskAction + fun doWork() { + val spec = inputSpec.get() + logger.quiet("Validating spec $spec") + val result = OpenAPIParser().readLocation(spec, null, null) + val messages = result.messages.toSet() + val out = services.get(StyledTextOutputFactory::class.java).create("openapi") + + if (messages.isNotEmpty()) { + + out.withStyle(StyledTextOutput.Style.Error) + out.println("\nSpec is invalid.\nIssues:\n") + + messages.forEach { + out.withStyle(StyledTextOutput.Style.Error) + out.println("\t$it\n") + } + + throw GradleException("Validation failed.") + } else { + out.withStyle(StyledTextOutput.Style.Success) + out.println("Spec is valid.") + } + } +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/test/GenerateTaskDslTest.kt b/modules/openapi-generator-gradle-plugin/bin/test/GenerateTaskDslTest.kt new file mode 100644 index 000000000000..c2a6e0244207 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/test/GenerateTaskDslTest.kt @@ -0,0 +1,71 @@ +package org.openapitools.generator.gradle.plugin + +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome +import org.testng.annotations.Test +import java.io.File +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class GenerateTaskDslTest : TestBase() { + override var temp: File = createTempDir(javaClass.simpleName) + + private val defaultBuildGradle = """ + plugins { + id 'org.openapi.generator' + } + openApiGenerate { + generatorName = "kotlin" + inputSpec = file("spec.yaml").absolutePath + outputDir = file("build/kotlin").absolutePath + apiPackage = "org.openapitools.example.api" + invokerPackage = "org.openapitools.example.invoker" + modelPackage = "org.openapitools.example.model" + configOptions = [ + dateLibrary: "java8" + ] + } + """.trimIndent() + + @Test + fun `openApiGenerate should create an expected file structure from DSL config`() { + // Arrange + val projectFiles = mapOf( + "spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml") + ) + withProject(defaultBuildGradle, projectFiles) + + // Act + val result = GradleRunner.create() + .withProjectDir(temp) + .withArguments("openApiGenerate") + .withPluginClasspath() + .build() + + // Assert + assertTrue(result.output.contains("Successfully generated code to"), "User friendly generate notice is missing.") + + listOf( + "build/kotlin/.openapi-generator-ignore", + "build/kotlin/docs/PetsApi.md", + "build/kotlin/docs/Pets.md", + "build/kotlin/docs/Error.md", + "build/kotlin/docs/Pet.md", + "build/kotlin/README.md", + "build/kotlin/build.gradle", + "build/kotlin/.openapi-generator/VERSION", + "build/kotlin/settings.gradle", + "build/kotlin/src/main/kotlin/org/openapitools/example/model/Pets.kt", + "build/kotlin/src/main/kotlin/org/openapitools/example/model/Pet.kt", + "build/kotlin/src/main/kotlin/org/openapitools/example/model/Error.kt", + "build/kotlin/src/main/kotlin/org/openapitools/example/api/PetsApi.kt", + "build/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt" + ).map { + val f = File(temp, it) + assertTrue(f.exists() && f.isFile, "An expected file was not generated when invoking the generation.") + } + + assertEquals(TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome, + "Expected a successful run, but found ${result.task(":openApiGenerate")?.outcome}") + } +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/test/GeneratorsTaskDslTest.kt b/modules/openapi-generator-gradle-plugin/bin/test/GeneratorsTaskDslTest.kt new file mode 100644 index 000000000000..f3373fd657e1 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/test/GeneratorsTaskDslTest.kt @@ -0,0 +1,38 @@ +package org.openapitools.generator.gradle.plugin + +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome +import org.testng.annotations.Test +import java.io.File +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class GeneratorsTaskDslTest : TestBase() { + override var temp: File = createTempDir(javaClass.simpleName) + + @Test + fun `openApiGenerators should list generators available to the user`() { + // Arrange + withProject(""" + | plugins { + | id 'org.openapi.generator' + | } + """.trimMargin()) + + // Act + val result = GradleRunner.create() + .withProjectDir(temp) + .withArguments("openApiGenerators") + .withPluginClasspath() + .build() + + // Assert + assertTrue(result.output.contains("The following generators are available:"), "User friendly generator notice is missing.") + assertTrue(result.output.contains("CLIENT generators:"), "Expected client generator header is missing.") + assertTrue(result.output.contains("android"), "Spot-checking listed client generators is missing a client generator.") + assertTrue(result.output.contains("SERVER generators:"), "Expected server generator header is missing.") + assertTrue(result.output.contains("kotlin-server"), "Spot-checking listed server generators is missing a server generator.") + assertEquals(TaskOutcome.SUCCESS, result.task(":openApiGenerators")?.outcome, + "Expected a successful run, but found ${result.task(":openApiGenerators")?.outcome}") + } +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/test/MetaTaskDslTest.kt b/modules/openapi-generator-gradle-plugin/bin/test/MetaTaskDslTest.kt new file mode 100644 index 000000000000..fe857d1b94a8 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/test/MetaTaskDslTest.kt @@ -0,0 +1,58 @@ +package org.openapitools.generator.gradle.plugin + +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome +import org.testng.annotations.Test +import java.io.File +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class MetaTaskDslTest : TestBase() { + override var temp: File = createTempDir(javaClass.simpleName) + + @Test + fun `openApiMeta should generate desired project contents`() { + // Arrange + val buildDirReplacement = "\$buildDir/meta" + withProject(""" + | plugins { + | id 'org.openapi.generator' + | } + | + | openApiMeta { + | generatorName = "Sample" + | packageName = "org.openapitools.example" + | outputFolder = "$buildDirReplacement".toString() + | } + """.trimMargin()) + + // Act + val result = GradleRunner.create() + .withProjectDir(temp) + .withArguments("openApiMeta") + .withPluginClasspath() + .build() + + // Assert + assertTrue(result.output.contains("Wrote file to"), "User friendly write notice is missing.") + + // To avoid any OS-specific output causing issues with our stdout comparisons, only compare on expected filenames. + listOf( + "SampleGenerator.java", + "README.md", + "api.mustache", + "model.mustache", + "myFile.mustache", + "org.openapitools.codegen.CodegenConfig", + "pom.xml" + ).map { + assertTrue(result.output.contains(it), "Expected $it to be listed in gradle stdout.") + } + + assertEquals( + TaskOutcome.SUCCESS, + result.task(":openApiMeta")?.outcome, + "Expected a successful run, but found ${result.task(":openApiMeta")?.outcome}" + ) + } +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/test/TestBase.kt b/modules/openapi-generator-gradle-plugin/bin/test/TestBase.kt new file mode 100644 index 000000000000..47a1bfba9ec9 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/test/TestBase.kt @@ -0,0 +1,34 @@ +package org.openapitools.generator.gradle.plugin + +import org.testng.annotations.AfterMethod +import org.testng.annotations.BeforeMethod +import java.io.File +import java.io.InputStream + +abstract class TestBase { + protected open lateinit var temp: File + + @BeforeMethod + protected fun before() { + temp = createTempDir(javaClass.simpleName) + temp.deleteOnExit() + } + + @AfterMethod + protected fun after(){ + temp.deleteRecursively() + } + + protected fun withProject( + buildContents: String, + projectFiles: Map = mapOf() + ) { + val buildFile = File(temp,"build.gradle") + buildFile.writeText(buildContents) + + projectFiles.forEach { entry -> + val target = File(temp, entry.key) + entry.value.copyTo(target.outputStream()) + } + } +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/test/ValidateTaskDslTest.kt b/modules/openapi-generator-gradle-plugin/bin/test/ValidateTaskDslTest.kt new file mode 100644 index 000000000000..acc066c98da3 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/test/ValidateTaskDslTest.kt @@ -0,0 +1,99 @@ +package org.openapitools.generator.gradle.plugin + +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome.FAILED +import org.gradle.testkit.runner.TaskOutcome.SUCCESS +import org.testng.annotations.Test +import java.io.File +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class ValidateTaskDslTest : TestBase() { + override var temp: File = createTempDir(javaClass.simpleName) + + @Test + fun `openApiValidate should fail on non-file spec`() { + // Arrange + withProject(""" + | plugins { + | id 'org.openapi.generator' + | } + | + | openApiValidate { + | inputSpec = "some_location" + | } + """.trimMargin()) + + // Act + val result = GradleRunner.create() + .withProjectDir(temp) + .withArguments("openApiValidate") + .withPluginClasspath() + .buildAndFail() + + // Assert + assertTrue(result.output.contains("unable to read location `some_location`"), "Unexpected/no message presented to the user for a spec pointing to an invalid URI.") + assertEquals(FAILED, result.task(":openApiValidate")?.outcome, + "Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}") + } + + @Test + fun `openApiValidate should succeed on valid spec`() { + // Arrange + val projectFiles = mapOf( + "spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml") + ) + + withProject(""" + | plugins { + | id 'org.openapi.generator' + | } + | + | openApiValidate { + | inputSpec = file("spec.yaml").absolutePath + | } + """.trimMargin(), projectFiles) + + // Act + val result = GradleRunner.create() + .withProjectDir(temp) + .withArguments("openApiValidate") + .withPluginClasspath() + .build() + + // Assert + assertTrue(result.output.contains("Spec is valid."), "Unexpected/no message presented to the user for a valid spec.") + assertEquals(SUCCESS, result.task(":openApiValidate")?.outcome, + "Expected a successful run, but found ${result.task(":openApiValidate")?.outcome}") + } + + @Test + fun `openApiValidate should fail on invalid spec`() { + // Arrange + val projectFiles = mapOf( + "spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml") + ) + withProject(""" + | plugins { + | id 'org.openapi.generator' + | } + | + | openApiValidate { + | inputSpec = file('spec.yaml').absolutePath + | } + """.trimMargin(), projectFiles) + + // Act + val result = GradleRunner.create() + .withProjectDir(temp) + .withArguments("openApiValidate") + .withPluginClasspath() + .buildAndFail() + + // Assert + assertTrue(result.output.contains("Spec is invalid."), "Unexpected/no message presented to the user for an invalid spec.") + assertEquals(FAILED, result.task(":openApiValidate")?.outcome, + "Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}") + } + +} \ No newline at end of file diff --git a/modules/openapi-generator-gradle-plugin/bin/test/specs/petstore-v3.0-invalid.yaml b/modules/openapi-generator-gradle-plugin/bin/test/specs/petstore-v3.0-invalid.yaml new file mode 100644 index 000000000000..0f5c6fc29829 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/test/specs/petstore-v3.0-invalid.yaml @@ -0,0 +1,103 @@ +openapi: "3.0.0" +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + get: + summary: List all pets + operationId: listPets + tags: + - pets + parameters: + - name: limit + in: query + description: How many items to return at one time (max 100) + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: A paged array of pets + headers: + x-next: + description: A link to the next page of responses + schema: + type: string + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a pet + tags: + - pets + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + schemas: + Pet: + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + Pets: + type: array + items: + $ref: "#/components/schemas/Pet" + Error: + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string diff --git a/modules/openapi-generator-gradle-plugin/bin/test/specs/petstore-v3.0.yaml b/modules/openapi-generator-gradle-plugin/bin/test/specs/petstore-v3.0.yaml new file mode 100644 index 000000000000..264dbeabff12 --- /dev/null +++ b/modules/openapi-generator-gradle-plugin/bin/test/specs/petstore-v3.0.yaml @@ -0,0 +1,109 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore + license: + name: MIT +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + get: + summary: List all pets + operationId: listPets + tags: + - pets + parameters: + - name: limit + in: query + description: How many items to return at one time (max 100) + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: A paged array of pets + headers: + x-next: + description: A link to the next page of responses + schema: + type: string + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a pet + operationId: createPets + tags: + - pets + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + schemas: + Pet: + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + Pets: + type: array + items: + $ref: "#/components/schemas/Pet" + Error: + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index bbbcd4747f48..d021fd91a0bd 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -31,6 +31,8 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; +import java.util.Map; +import java.util.List; public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodegen { private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT); diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts index 31c401e3e010..d23ba2e93031 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts @@ -16,8 +16,10 @@ import * as runtime from '../runtime'; import { ApiResponse, ApiResponseFromJSON, + ApiResponseToJSON, Pet, PetFromJSON, + PetToJSON, } from '../models'; export interface AddPetRequest { @@ -87,7 +89,7 @@ export class PetApi extends runtime.BaseAPI { path: `/pet`, method: 'POST', headers: headerParameters, - body: requestParameters.pet, + body: PetToJSON(requestParameters.pet), }); return response; } @@ -243,7 +245,7 @@ export class PetApi extends runtime.BaseAPI { path: `/pet`, method: 'PUT', headers: headerParameters, - body: requestParameters.pet, + body: PetToJSON(requestParameters.pet), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts index 36dcd092d1ef..58bf85a17376 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts @@ -16,6 +16,7 @@ import * as runtime from '../runtime'; import { Order, OrderFromJSON, + OrderToJSON, } from '../models'; export interface DeleteOrderRequest { @@ -108,7 +109,7 @@ export class StoreApi extends runtime.BaseAPI { path: `/store/order`, method: 'POST', headers: headerParameters, - body: requestParameters.order, + body: OrderToJSON(requestParameters.order), }); return OrderFromJSON(await response.json()); } diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts index ff5e783e6a1c..ef73103f3100 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts @@ -16,6 +16,7 @@ import * as runtime from '../runtime'; import { User, UserFromJSON, + UserToJSON, } from '../models'; export interface CreateUserRequest { @@ -70,7 +71,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: UserToJSON(requestParameters.user), }); return response; } @@ -91,7 +92,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: Array<User>ToJSON(requestParameters.user), }); return response; } @@ -112,7 +113,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithList`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: Array<User>ToJSON(requestParameters.user), }); return response; } @@ -222,7 +223,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, - body: requestParameters.user, + body: UserToJSON(requestParameters.user), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts index 14e27d99bf9c..3f7b15c31032 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts @@ -45,4 +45,12 @@ export function ApiResponseFromJSON(json: any): ApiResponse { }; } +export function ApiResponseToJSON(value: ApiResponse): any { + return { + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts index ac72fbd0d4cf..2f5c984709b3 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts @@ -38,4 +38,11 @@ export function CategoryFromJSON(json: any): Category { }; } +export function CategoryToJSON(value: Category): any { + return { + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts index 8e4f0edab49e..b95e8f837015 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts @@ -66,6 +66,17 @@ export function OrderFromJSON(json: any): Order { }; } +export function OrderToJSON(value: Order): any { + return { + 'id': value.id, + 'petId': value.petId, + 'quantity': value.quantity, + 'shipDate': value.shipDate === undefined ? undefined : value.shipDate.toISOString(), + 'status': value.status, + 'complete': value.complete, + }; +} + /** * @export * @namespace Order diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts index 41ef494fcbbd..f7df3c4d6d0d 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts @@ -14,8 +14,10 @@ import { Category, CategoryFromJSON, + CategoryToJSON, Tag, TagFromJSON, + TagToJSON, } from './'; /** @@ -73,6 +75,17 @@ export function PetFromJSON(json: any): Pet { }; } +export function PetToJSON(value: Pet): any { + return { + 'id': value.id, + 'category': CategoryToJSON(value.category), + 'name': value.name, + 'photoUrls': value.photoUrls, + 'tags': (value.tags as Array).map(TagToJSON), + 'status': value.status, + }; +} + /** * @export * @namespace Pet diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts index d425d79a08ab..d8b8d98a9c5d 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts @@ -38,4 +38,11 @@ export function TagFromJSON(json: any): Tag { }; } +export function TagToJSON(value: Tag): any { + return { + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts index 621e3aa44ed9..0496d10e31cf 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts @@ -80,4 +80,17 @@ export function UserFromJSON(json: any): User { }; } +export function UserToJSON(value: User): any { + return { + 'id': value.id, + 'username': value.username, + 'firstName': value.firstName, + 'lastName': value.lastName, + 'email': value.email, + 'password': value.password, + 'phone': value.phone, + 'userStatus': value.userStatus, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 556de28ec6c0..eded6cd0e398 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -130,28 +130,42 @@ export interface ConfigurationParameters { } export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} - basePath: string; - fetchApi: FetchAPI; - middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - - constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; - this.fetchApi = conf.fetchApi || window.fetch.bind(window); - this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; + get basePath(): string { + return this.configuration.basePath || BASE_PATH; + } + + get fetchApi(): FetchAPI { + return this.configuration.fetchApi || window.fetch.bind(window); + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; + return typeof apiKey === 'function' ? apiKey : () => apiKey; } + return undefined; + } + + get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { + const accessToken = this.configuration.accessToken; if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; + return typeof accessToken === 'function' ? accessToken : () => accessToken; } + return undefined; } } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts index 31c401e3e010..d23ba2e93031 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts @@ -16,8 +16,10 @@ import * as runtime from '../runtime'; import { ApiResponse, ApiResponseFromJSON, + ApiResponseToJSON, Pet, PetFromJSON, + PetToJSON, } from '../models'; export interface AddPetRequest { @@ -87,7 +89,7 @@ export class PetApi extends runtime.BaseAPI { path: `/pet`, method: 'POST', headers: headerParameters, - body: requestParameters.pet, + body: PetToJSON(requestParameters.pet), }); return response; } @@ -243,7 +245,7 @@ export class PetApi extends runtime.BaseAPI { path: `/pet`, method: 'PUT', headers: headerParameters, - body: requestParameters.pet, + body: PetToJSON(requestParameters.pet), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts index 36dcd092d1ef..58bf85a17376 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts @@ -16,6 +16,7 @@ import * as runtime from '../runtime'; import { Order, OrderFromJSON, + OrderToJSON, } from '../models'; export interface DeleteOrderRequest { @@ -108,7 +109,7 @@ export class StoreApi extends runtime.BaseAPI { path: `/store/order`, method: 'POST', headers: headerParameters, - body: requestParameters.order, + body: OrderToJSON(requestParameters.order), }); return OrderFromJSON(await response.json()); } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts index ff5e783e6a1c..ef73103f3100 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts @@ -16,6 +16,7 @@ import * as runtime from '../runtime'; import { User, UserFromJSON, + UserToJSON, } from '../models'; export interface CreateUserRequest { @@ -70,7 +71,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: UserToJSON(requestParameters.user), }); return response; } @@ -91,7 +92,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: Array<User>ToJSON(requestParameters.user), }); return response; } @@ -112,7 +113,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithList`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: Array<User>ToJSON(requestParameters.user), }); return response; } @@ -222,7 +223,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, - body: requestParameters.user, + body: UserToJSON(requestParameters.user), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts index 14e27d99bf9c..3f7b15c31032 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts @@ -45,4 +45,12 @@ export function ApiResponseFromJSON(json: any): ApiResponse { }; } +export function ApiResponseToJSON(value: ApiResponse): any { + return { + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts index ac72fbd0d4cf..2f5c984709b3 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts @@ -38,4 +38,11 @@ export function CategoryFromJSON(json: any): Category { }; } +export function CategoryToJSON(value: Category): any { + return { + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts index 8e4f0edab49e..b95e8f837015 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts @@ -66,6 +66,17 @@ export function OrderFromJSON(json: any): Order { }; } +export function OrderToJSON(value: Order): any { + return { + 'id': value.id, + 'petId': value.petId, + 'quantity': value.quantity, + 'shipDate': value.shipDate === undefined ? undefined : value.shipDate.toISOString(), + 'status': value.status, + 'complete': value.complete, + }; +} + /** * @export * @namespace Order diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts index 41ef494fcbbd..f7df3c4d6d0d 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts @@ -14,8 +14,10 @@ import { Category, CategoryFromJSON, + CategoryToJSON, Tag, TagFromJSON, + TagToJSON, } from './'; /** @@ -73,6 +75,17 @@ export function PetFromJSON(json: any): Pet { }; } +export function PetToJSON(value: Pet): any { + return { + 'id': value.id, + 'category': CategoryToJSON(value.category), + 'name': value.name, + 'photoUrls': value.photoUrls, + 'tags': (value.tags as Array).map(TagToJSON), + 'status': value.status, + }; +} + /** * @export * @namespace Pet diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts index d425d79a08ab..d8b8d98a9c5d 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts @@ -38,4 +38,11 @@ export function TagFromJSON(json: any): Tag { }; } +export function TagToJSON(value: Tag): any { + return { + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts index 621e3aa44ed9..0496d10e31cf 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts @@ -80,4 +80,17 @@ export function UserFromJSON(json: any): User { }; } +export function UserToJSON(value: User): any { + return { + 'id': value.id, + 'username': value.username, + 'firstName': value.firstName, + 'lastName': value.lastName, + 'email': value.email, + 'password': value.password, + 'phone': value.phone, + 'userStatus': value.userStatus, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts index 556de28ec6c0..eded6cd0e398 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts @@ -130,28 +130,42 @@ export interface ConfigurationParameters { } export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} - basePath: string; - fetchApi: FetchAPI; - middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - - constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; - this.fetchApi = conf.fetchApi || window.fetch.bind(window); - this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; + get basePath(): string { + return this.configuration.basePath || BASE_PATH; + } + + get fetchApi(): FetchAPI { + return this.configuration.fetchApi || window.fetch.bind(window); + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; + return typeof apiKey === 'function' ? apiKey : () => apiKey; } + return undefined; + } + + get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { + const accessToken = this.configuration.accessToken; if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; + return typeof accessToken === 'function' ? accessToken : () => accessToken; } + return undefined; } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts index 31c401e3e010..d23ba2e93031 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts @@ -16,8 +16,10 @@ import * as runtime from '../runtime'; import { ApiResponse, ApiResponseFromJSON, + ApiResponseToJSON, Pet, PetFromJSON, + PetToJSON, } from '../models'; export interface AddPetRequest { @@ -87,7 +89,7 @@ export class PetApi extends runtime.BaseAPI { path: `/pet`, method: 'POST', headers: headerParameters, - body: requestParameters.pet, + body: PetToJSON(requestParameters.pet), }); return response; } @@ -243,7 +245,7 @@ export class PetApi extends runtime.BaseAPI { path: `/pet`, method: 'PUT', headers: headerParameters, - body: requestParameters.pet, + body: PetToJSON(requestParameters.pet), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts index 36dcd092d1ef..58bf85a17376 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts @@ -16,6 +16,7 @@ import * as runtime from '../runtime'; import { Order, OrderFromJSON, + OrderToJSON, } from '../models'; export interface DeleteOrderRequest { @@ -108,7 +109,7 @@ export class StoreApi extends runtime.BaseAPI { path: `/store/order`, method: 'POST', headers: headerParameters, - body: requestParameters.order, + body: OrderToJSON(requestParameters.order), }); return OrderFromJSON(await response.json()); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts index ff5e783e6a1c..ef73103f3100 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts @@ -16,6 +16,7 @@ import * as runtime from '../runtime'; import { User, UserFromJSON, + UserToJSON, } from '../models'; export interface CreateUserRequest { @@ -70,7 +71,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: UserToJSON(requestParameters.user), }); return response; } @@ -91,7 +92,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: Array<User>ToJSON(requestParameters.user), }); return response; } @@ -112,7 +113,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithList`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: Array<User>ToJSON(requestParameters.user), }); return response; } @@ -222,7 +223,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, - body: requestParameters.user, + body: UserToJSON(requestParameters.user), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts index 14e27d99bf9c..3f7b15c31032 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts @@ -45,4 +45,12 @@ export function ApiResponseFromJSON(json: any): ApiResponse { }; } +export function ApiResponseToJSON(value: ApiResponse): any { + return { + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts index ac72fbd0d4cf..2f5c984709b3 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts @@ -38,4 +38,11 @@ export function CategoryFromJSON(json: any): Category { }; } +export function CategoryToJSON(value: Category): any { + return { + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts index 8e4f0edab49e..b95e8f837015 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts @@ -66,6 +66,17 @@ export function OrderFromJSON(json: any): Order { }; } +export function OrderToJSON(value: Order): any { + return { + 'id': value.id, + 'petId': value.petId, + 'quantity': value.quantity, + 'shipDate': value.shipDate === undefined ? undefined : value.shipDate.toISOString(), + 'status': value.status, + 'complete': value.complete, + }; +} + /** * @export * @namespace Order diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts index 41ef494fcbbd..f7df3c4d6d0d 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts @@ -14,8 +14,10 @@ import { Category, CategoryFromJSON, + CategoryToJSON, Tag, TagFromJSON, + TagToJSON, } from './'; /** @@ -73,6 +75,17 @@ export function PetFromJSON(json: any): Pet { }; } +export function PetToJSON(value: Pet): any { + return { + 'id': value.id, + 'category': CategoryToJSON(value.category), + 'name': value.name, + 'photoUrls': value.photoUrls, + 'tags': (value.tags as Array).map(TagToJSON), + 'status': value.status, + }; +} + /** * @export * @namespace Pet diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts index d425d79a08ab..d8b8d98a9c5d 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts @@ -38,4 +38,11 @@ export function TagFromJSON(json: any): Tag { }; } +export function TagToJSON(value: Tag): any { + return { + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts index 621e3aa44ed9..0496d10e31cf 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts @@ -80,4 +80,17 @@ export function UserFromJSON(json: any): User { }; } +export function UserToJSON(value: User): any { + return { + 'id': value.id, + 'username': value.username, + 'firstName': value.firstName, + 'lastName': value.lastName, + 'email': value.email, + 'password': value.password, + 'phone': value.phone, + 'userStatus': value.userStatus, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 556de28ec6c0..eded6cd0e398 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -130,28 +130,42 @@ export interface ConfigurationParameters { } export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} - basePath: string; - fetchApi: FetchAPI; - middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - - constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; - this.fetchApi = conf.fetchApi || window.fetch.bind(window); - this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; + get basePath(): string { + return this.configuration.basePath || BASE_PATH; + } + + get fetchApi(): FetchAPI { + return this.configuration.fetchApi || window.fetch.bind(window); + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; + return typeof apiKey === 'function' ? apiKey : () => apiKey; } + return undefined; + } + + get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { + const accessToken = this.configuration.accessToken; if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; + return typeof accessToken === 'function' ? accessToken : () => accessToken; } + return undefined; } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts index 31c401e3e010..d23ba2e93031 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts @@ -16,8 +16,10 @@ import * as runtime from '../runtime'; import { ApiResponse, ApiResponseFromJSON, + ApiResponseToJSON, Pet, PetFromJSON, + PetToJSON, } from '../models'; export interface AddPetRequest { @@ -87,7 +89,7 @@ export class PetApi extends runtime.BaseAPI { path: `/pet`, method: 'POST', headers: headerParameters, - body: requestParameters.pet, + body: PetToJSON(requestParameters.pet), }); return response; } @@ -243,7 +245,7 @@ export class PetApi extends runtime.BaseAPI { path: `/pet`, method: 'PUT', headers: headerParameters, - body: requestParameters.pet, + body: PetToJSON(requestParameters.pet), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts index 36dcd092d1ef..58bf85a17376 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts @@ -16,6 +16,7 @@ import * as runtime from '../runtime'; import { Order, OrderFromJSON, + OrderToJSON, } from '../models'; export interface DeleteOrderRequest { @@ -108,7 +109,7 @@ export class StoreApi extends runtime.BaseAPI { path: `/store/order`, method: 'POST', headers: headerParameters, - body: requestParameters.order, + body: OrderToJSON(requestParameters.order), }); return OrderFromJSON(await response.json()); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts index ff5e783e6a1c..ef73103f3100 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts @@ -16,6 +16,7 @@ import * as runtime from '../runtime'; import { User, UserFromJSON, + UserToJSON, } from '../models'; export interface CreateUserRequest { @@ -70,7 +71,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: UserToJSON(requestParameters.user), }); return response; } @@ -91,7 +92,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: Array<User>ToJSON(requestParameters.user), }); return response; } @@ -112,7 +113,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithList`, method: 'POST', headers: headerParameters, - body: requestParameters.user, + body: Array<User>ToJSON(requestParameters.user), }); return response; } @@ -222,7 +223,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, - body: requestParameters.user, + body: UserToJSON(requestParameters.user), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts index 14e27d99bf9c..3f7b15c31032 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts @@ -45,4 +45,12 @@ export function ApiResponseFromJSON(json: any): ApiResponse { }; } +export function ApiResponseToJSON(value: ApiResponse): any { + return { + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts index ac72fbd0d4cf..2f5c984709b3 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts @@ -38,4 +38,11 @@ export function CategoryFromJSON(json: any): Category { }; } +export function CategoryToJSON(value: Category): any { + return { + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts index 8e4f0edab49e..b95e8f837015 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts @@ -66,6 +66,17 @@ export function OrderFromJSON(json: any): Order { }; } +export function OrderToJSON(value: Order): any { + return { + 'id': value.id, + 'petId': value.petId, + 'quantity': value.quantity, + 'shipDate': value.shipDate === undefined ? undefined : value.shipDate.toISOString(), + 'status': value.status, + 'complete': value.complete, + }; +} + /** * @export * @namespace Order diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts index 41ef494fcbbd..f7df3c4d6d0d 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts @@ -14,8 +14,10 @@ import { Category, CategoryFromJSON, + CategoryToJSON, Tag, TagFromJSON, + TagToJSON, } from './'; /** @@ -73,6 +75,17 @@ export function PetFromJSON(json: any): Pet { }; } +export function PetToJSON(value: Pet): any { + return { + 'id': value.id, + 'category': CategoryToJSON(value.category), + 'name': value.name, + 'photoUrls': value.photoUrls, + 'tags': (value.tags as Array).map(TagToJSON), + 'status': value.status, + }; +} + /** * @export * @namespace Pet diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts index d425d79a08ab..d8b8d98a9c5d 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts @@ -38,4 +38,11 @@ export function TagFromJSON(json: any): Tag { }; } +export function TagToJSON(value: Tag): any { + return { + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts index 621e3aa44ed9..0496d10e31cf 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts @@ -80,4 +80,17 @@ export function UserFromJSON(json: any): User { }; } +export function UserToJSON(value: User): any { + return { + 'id': value.id, + 'username': value.username, + 'firstName': value.firstName, + 'lastName': value.lastName, + 'email': value.email, + 'password': value.password, + 'phone': value.phone, + 'userStatus': value.userStatus, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts index 556de28ec6c0..eded6cd0e398 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts @@ -130,28 +130,42 @@ export interface ConfigurationParameters { } export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} - basePath: string; - fetchApi: FetchAPI; - middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - - constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; - this.fetchApi = conf.fetchApi || window.fetch.bind(window); - this.middleware = conf.middleware || []; - this.username = conf.username; - this.password = conf.password; - const { apiKey, accessToken } = conf; + get basePath(): string { + return this.configuration.basePath || BASE_PATH; + } + + get fetchApi(): FetchAPI { + return this.configuration.fetchApi || window.fetch.bind(window); + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; if (apiKey) { - this.apiKey = typeof apiKey === 'function' ? apiKey : () => apiKey; + return typeof apiKey === 'function' ? apiKey : () => apiKey; } + return undefined; + } + + get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { + const accessToken = this.configuration.accessToken; if (accessToken) { - this.accessToken = typeof accessToken === 'function' ? accessToken : () => accessToken; + return typeof accessToken === 'function' ? accessToken : () => accessToken; } + return undefined; } } From 491f09ded6b58742fcdf2d4d8e423c717121cc0b Mon Sep 17 00:00:00 2001 From: James Batt Date: Sun, 2 Sep 2018 11:29:06 +1000 Subject: [PATCH 22/39] 1 character change to get CI to run again --- .../src/main/resources/typescript-fetch/modelGeneric.mustache | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 348f4f396eec..18c36db8fe65 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -63,7 +63,6 @@ export function {{classname}}ToJSON(value: {{classname}}): any { }; } {{#hasEnums}} - /** * @export * @namespace {{classname}} From 402a97736ec782ca6506e5d3bc59c11eee7991c9 Mon Sep 17 00:00:00 2001 From: James Batt Date: Sun, 2 Sep 2018 12:01:02 +1000 Subject: [PATCH 23/39] updated samples --- .../typescript-fetch/modelGeneric.mustache | 1 + .../typescript-fetch/builds/es6-target/api.ts | 1906 ----------------- .../builds/with-interfaces/api.ts | 1898 ---------------- .../builds/with-npm-version/api.ts | 1906 ----------------- 4 files changed, 1 insertion(+), 5710 deletions(-) delete mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/api.ts delete mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts delete mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 18c36db8fe65..348f4f396eec 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -63,6 +63,7 @@ export function {{classname}}ToJSON(value: {{classname}}): any { }; } {{#hasEnums}} + /** * @export * @namespace {{classname}} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts deleted file mode 100644 index 4a8a7c68eb0b..000000000000 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts +++ /dev/null @@ -1,1906 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * 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; -} - -/** - * A category for a pet - * @export - * @interface Category - */ -export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; -} - -/** - * 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' - } -} - -/** - * 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' - } -} - -/** - * A tag for a pet - * @export - * @interface Tag - */ -export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; -} - -/** - * 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; -} - - -<<<<<<< HEAD -export interface AddPetRequest { - pet: Pet; -} -======= -/** - * PetApi - fetch parameter creator - * @export - */ -export const PetApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface DeletePetRequest { - petId: number; - apiKey?: string; -} - -<<<<<<< HEAD -export interface FindPetsByStatusRequest { - status: Array<'available' | 'pending' | 'sold'>; -} -======= - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface FindPetsByTagsRequest { - tags: Array; -} - -<<<<<<< HEAD -export interface GetPetByIdRequest { - petId: number; -} -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options: any = {}): FetchArgs { - // verify required parameter 'status' is not null or undefined - if (status === null || status === undefined) { - throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); - } - const localVarPath = `/pet/findByStatus`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface UpdatePetRequest { - pet: Pet; -} - -export interface UpdatePetWithFormRequest { - petId: number; - name?: string; - status?: string; -} - -<<<<<<< HEAD -export interface UploadFileRequest { - petId: number; - additionalMetadata?: string; - file?: any; -} -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options: any = {}): FetchArgs { - // verify required parameter 'tags' is not null or undefined - if (tags === null || tags === undefined) { - throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); - } - const localVarPath = `/pet/findByTags`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface DeleteOrderRequest { - orderId: string; -} - -export interface GetOrderByIdRequest { - orderId: number; -} - -<<<<<<< HEAD -export interface PlaceOrderRequest { - order: Order; -} - -export interface CreateUserRequest { - user: User; -} -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getPetById(petId: number, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; - } - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'PUT' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface CreateUsersWithArrayInputRequest { - user: Array; -} - -<<<<<<< HEAD -export interface CreateUsersWithListInputRequest { - user: Array; -} -======= - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface DeleteUserRequest { - username: string; -} - -export interface GetUserByNameRequest { - username: string; -} - -<<<<<<< HEAD -export interface LoginUserRequest { - username: string; - password: string; -} - -export interface UpdateUserRequest { - username: string; - user: User; -} -======= - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling uploadFile.'); - } - const localVarPath = `/pet/{petId}/uploadImage` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - -/** - * This is the base class for all generated API classes. - */ -export class BaseAPI { - - private middleware: Middleware[]; - - constructor(protected configuration = new Configuration()) { - this.middleware = configuration.middleware; - } - - withMiddleware(this: T, ...middlewares: Middleware[]) { - const next = this.clone(); - next.middleware = next.middleware.concat(...middlewares); - return next; - } - - withPreMiddleware(this: T, ...preMiddlewares: Array) { - const middlewares = preMiddlewares.map((pre) => ({ pre })); - return this.withMiddleware(...middlewares); - } - - withPostMiddleware(this: T, ...postMiddlewares: Array) { - const middlewares = postMiddlewares.map((post) => ({ post })); - return this.withMiddleware(...middlewares); - } - - protected async request(context: RequestOpts): Promise { - const { url, init } = this.createFetchParams(context); - const response = await this.fetchApi(url, init); - if (response.status >= 200 && response.status < 300) { - switch(context.responseType) { - case 'JSON': - const result = await response.json() as T; - return transformPropertyNames(result, context.modelPropertyNaming); - case 'text': - return await response.text() as any as T; - default: - return response as any as T; - } - } - throw response; - } - - private createFetchParams(context: RequestOpts) { - let url = this.configuration.basePath + context.path; - if (context.query !== undefined && Object.keys(context.query).length !== 0) { - // only add the querystring to the URL if there are query parameters. - // this is done to avoid urls ending with a "?" character which buggy webservers - // do not handle correctly sometimes. - url += '?' + querystring(context.query); - } - const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); - const init = { - method: context.method, - headers: context.headers, - body, - }; - return { url, init }; - } - - private fetchApi = async (url: string, init: RequestInit) => { - let fetchParams = { url, init }; - for (const middleware of this.middleware) { - if (middleware.pre) { - fetchParams = await middleware.pre(this.fetchApi, fetchParams.url, fetchParams.init) || fetchParams; - } - } - let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); - for (const middleware of this.middleware) { - if (middleware.post) { - response = await middleware.post(this.fetchApi, url, init, response.clone()) || response; - } - } - return response; - } - - /** - * https://swagger.io/docs/specification/2-0/describing-responses/ - * - * If the response type for a given API is a 'string' we need to avoid - * parsing the response as json because JSON.parse("some string") will - * fail when the string isn't actually JSON. - */ - protected getResponseType(returnType: string): ResponseType { - switch (returnType) { - case 'string': - return 'text' - default: - return 'JSON' - } - } - - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - private clone(this: T): T { - const constructor = this.constructor as any; - const next = new constructor(this.configuration); - next.middleware = this.middleware.slice(); - return next; - } -}; - -export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } -} - - -/** - * no description - */ -export class PetApi extends BaseAPI { - - /** - * Add a new pet to the store - */ - async addPet(requestParameters: AddPetRequest): Promise { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request({ - path: `/pet`, - method: 'POST', - headers: headerParameters, - body: requestParameters.pet, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Deletes a pet - */ - async deletePet(requestParameters: DeletePetRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); - } - - const headerParameters: HTTPHeaders = {}; - - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); - } - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'DELETE', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Multiple status values can be provided with comma separated strings - * Finds Pets by status - */ - async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); - } - - const queryParameters: HTTPQuery = {}; - - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(COLLECTION_FORMATS["csv"]); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request>({ - path: `/pet/findByStatus`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - responseType: this.getResponseType('Array'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * Finds Pets by tags - */ - async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); - } - - const queryParameters: HTTPQuery = {}; - - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(COLLECTION_FORMATS["csv"]); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request>({ - path: `/pet/findByTags`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - responseType: this.getResponseType('Array'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Returns a single pet - * Find pet by ID - */ - async getPetById(requestParameters: GetPetByIdRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication - } - - return this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('Pet'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Update an existing pet - */ - async updatePet(requestParameters: UpdatePetRequest): Promise { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request({ - path: `/pet`, - method: 'PUT', - headers: headerParameters, - body: requestParameters.pet, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Updates a pet in the store with form data - */ - async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - const formData = new FormData(); - if (requestParameters.name !== undefined) { - formData.append('name', requestParameters.name as any); - } - - if (requestParameters.status !== undefined) { - formData.append('status', requestParameters.status as any); - } - - return this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'POST', - headers: headerParameters, - body: formData, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * uploads an image - */ - async uploadFile(requestParameters: UploadFileRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); - } - - const headerParameters: HTTPHeaders = {}; - -<<<<<<< HEAD - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; -======= -/** - * StoreApi - fetch parameter creator - * @export - */ -export const StoreApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling deleteOrder.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options: any = {}): FetchArgs { - const localVarPath = `/store/inventory`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - } - } - -<<<<<<< HEAD - const formData = new FormData(); - if (requestParameters.additionalMetadata !== undefined) { - formData.append('additionalMetadata', requestParameters.additionalMetadata as any); - } -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling getOrderById.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options: any = {}): FetchArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); - } - const localVarPath = `/store/order`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(order || {}) : (order || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - if (requestParameters.file !== undefined) { - formData.append('file', requestParameters.file as any); - } - - return this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'POST', - headers: headerParameters, - body: formData, - responseType: this.getResponseType('ApiResponse'), - modelPropertyNaming: 'camelCase', - }); - } - -} - -/** - * no description - */ -export class StoreApi extends BaseAPI { - - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * Delete purchase order by ID - */ - async deleteOrder(requestParameters: DeleteOrderRequest): Promise { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), - method: 'DELETE', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Returns a map of status codes to quantities - * Returns pet inventories by status - */ - async getInventory(): Promise<{ [key: string]: number; }> { - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication - } - - return this.request<{ [key: string]: number; }>({ - path: `/store/inventory`, - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('{ [key: string]: number; }'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * Find purchase order by ID - */ - async getOrderById(requestParameters: GetOrderByIdRequest): Promise { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('Order'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Place an order for a pet - */ -<<<<<<< HEAD - async placeOrder(requestParameters: PlaceOrderRequest): Promise { - if (requestParameters.order === null || requestParameters.order === undefined) { - throw new RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); - } -======= - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.fetch, this.basePath); - } - -} - -/** - * UserApi - fetch parameter creator - * @export - */ -export const UserApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); - } - const localVarPath = `/user`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); - } - const localVarPath = `/user/createWithArray`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); - } - const localVarPath = `/user/createWithList`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - deleteUser(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('password','Required parameter password was null or undefined when calling loginUser.'); - } - const localVarPath = `/user/login`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - if (username !== undefined) { - localVarQueryParameter['username'] = username; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - const headerParameters: HTTPHeaders = {}; - -<<<<<<< HEAD - headerParameters['Content-Type'] = 'application/json'; -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options: any = {}): FetchArgs { - const localVarPath = `/user/logout`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('user','Required parameter user was null or undefined when calling updateUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'PUT' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - return this.request({ - path: `/store/order`, - method: 'POST', - headers: headerParameters, - body: requestParameters.order, - responseType: this.getResponseType('Order'), - modelPropertyNaming: 'camelCase', - }); - } - -} - -/** - * no description - */ -export class UserApi extends BaseAPI { - - /** - * This can only be done by the logged in user. - * Create user - */ - async createUser(requestParameters: CreateUserRequest): Promise { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user`, - method: 'POST', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Creates list of users with given input array - */ - async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user/createWithArray`, - method: 'POST', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Creates list of users with given input array - */ - async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user/createWithList`, - method: 'POST', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * This can only be done by the logged in user. - * Delete user - */ - async deleteUser(requestParameters: DeleteUserRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), - method: 'DELETE', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Get user by user name - */ - async getUserByName(requestParameters: GetUserByNameRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('User'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Logs user into the system - */ - async loginUser(requestParameters: LoginUserRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); - } - - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); - } - - const queryParameters: HTTPQuery = {}; - - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; - } - - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/login`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - responseType: this.getResponseType('string'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Logs out current logged in user session - */ - async logoutUser(): Promise { - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/logout`, - method: 'GET', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * This can only be done by the logged in user. - * Updated user - */ - async updateUser(requestParameters: UpdateUserRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); - } - - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), - method: 'PUT', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - -} - - - -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -export type FetchAPI = GlobalFetch['fetch']; - -export interface ConfigurationParameters { - basePath?: string; // override base path - fetchApi?: FetchAPI; // 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 -} - -export class Configuration { - - basePath: string; - fetchApi: FetchAPI; - middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - - constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; - this.fetchApi = conf.fetchApi || window.fetch.bind(window); - 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; - } - } -} - -export type Json = any; -export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; -export type HTTPHeaders = { [key: string]: string }; -export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; -export type HTTPBody = Json | FormData; -export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; - -export interface FetchParams { - url: string; - init: RequestInit; -} - -type ResponseType = 'JSON' | 'text'; - -interface RequestOpts { - path: string; - method: HTTPMethod; - headers: HTTPHeaders; - query?: HTTPQuery; - body?: HTTPBody; - responseType?: ResponseType; - modelPropertyNaming: ModelPropertyNaming; -} - -function querystring(params: HTTPQuery) { - return Object.keys(params) - .map((key) => { - const value = params[key]; - if (value instanceof Array) { - const multiValue = value.join(`&${encodeURIComponent(key)}=`); - return `${encodeURIComponent(key)}=${multiValue}`; - } - return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` - }) - .join('&'); -} - -export interface Middleware { - pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; - post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; -} - -function capitalize(word: string) { - return word.charAt(0).toUpperCase() + word.slice(1); -} - -function toPascalCase(name: string) { - return name - .split('_') - .map(capitalize) - .join(''); -} - -function toCamelCase(name: string) { - const pascalCase = toPascalCase(name); - return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1); -} - -function applyPropertyNameConverter(json: any, converter: (name: string) => string) { - if (json instanceof Array) { - json.forEach((value) => { - if (typeof value === 'object') { - return applyPropertyNameConverter(value, converter); - } - }); - } else { - Object.keys(json).forEach((origKey) => { - if (json.hasOwnProperty(origKey)) { - let value = json[origKey]; - if (value instanceof Array || (value !== null && value.constructor === Object)) { - value = applyPropertyNameConverter(value, converter); - } - const newKey = converter(origKey); - json[newKey] = json[origKey]; - delete json[origKey]; - json[newKey] = value; - } - }); - } - return json; -} - -function transformPropertyNames(json: any, modelPropertyNaming: ModelPropertyNaming) { - switch (modelPropertyNaming) { - case 'camelCase': - return applyPropertyNameConverter(json, toCamelCase); - - case 'original': - default: - return json; - } -} diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts deleted file mode 100644 index 3c2f06711afa..000000000000 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts +++ /dev/null @@ -1,1898 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * 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; -} - -/** - * A category for a pet - * @export - * @interface Category - */ -export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; -} - -/** - * 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' - } -} - -/** - * 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' - } -} - -/** - * A tag for a pet - * @export - * @interface Tag - */ -export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; -} - -/** - * 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; -} - - -<<<<<<< HEAD -export interface AddPetRequest { - pet: Pet; -} -======= -/** - * PetApi - fetch parameter creator - * @export - */ -export const PetApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface DeletePetRequest { - petId: number; - apiKey?: string; -} - -<<<<<<< HEAD -export interface FindPetsByStatusRequest { - status: Array<'available' | 'pending' | 'sold'>; -} -======= - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface FindPetsByTagsRequest { - tags: Array; -} - -<<<<<<< HEAD -export interface GetPetByIdRequest { - petId: number; -} -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options: any = {}): FetchArgs { - // verify required parameter 'status' is not null or undefined - if (status === null || status === undefined) { - throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); - } - const localVarPath = `/pet/findByStatus`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface UpdatePetRequest { - pet: Pet; -} - -export interface UpdatePetWithFormRequest { - petId: number; - name?: string; - status?: string; -} - -<<<<<<< HEAD -export interface UploadFileRequest { - petId: number; - additionalMetadata?: string; - file?: any; -} -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options: any = {}): FetchArgs { - // verify required parameter 'tags' is not null or undefined - if (tags === null || tags === undefined) { - throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); - } - const localVarPath = `/pet/findByTags`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface DeleteOrderRequest { - orderId: string; -} - -export interface GetOrderByIdRequest { - orderId: number; -} - -<<<<<<< HEAD -export interface PlaceOrderRequest { - order: Order; -} - -export interface CreateUserRequest { - user: User; -} -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getPetById(petId: number, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; - } - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'PUT' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface CreateUsersWithArrayInputRequest { - user: Array; -} - -<<<<<<< HEAD -export interface CreateUsersWithListInputRequest { - user: Array; -} -======= - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface DeleteUserRequest { - username: string; -} - -export interface GetUserByNameRequest { - username: string; -} - -<<<<<<< HEAD -export interface LoginUserRequest { - username: string; - password: string; -} -======= - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling uploadFile.'); - } - const localVarPath = `/pet/{petId}/uploadImage` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface UpdateUserRequest { - username: string; - user: User; -} - - -/** - * This is the base class for all generated API classes. - */ -export class BaseAPI { - - private middleware: Middleware[]; - - constructor(protected configuration = new Configuration()) { - this.middleware = configuration.middleware; - } - - withMiddleware(this: T, ...middlewares: Middleware[]) { - const next = this.clone(); - next.middleware = next.middleware.concat(...middlewares); - return next; - } - - withPreMiddleware(this: T, ...preMiddlewares: Array) { - const middlewares = preMiddlewares.map((pre) => ({ pre })); - return this.withMiddleware(...middlewares); - } - - withPostMiddleware(this: T, ...postMiddlewares: Array) { - const middlewares = postMiddlewares.map((post) => ({ post })); - return this.withMiddleware(...middlewares); - } - - protected async request(context: RequestOpts): Promise { - const { url, init } = this.createFetchParams(context); - const response = await this.fetchApi(url, init); - if (response.status >= 200 && response.status < 300) { - switch(context.responseType) { - case 'JSON': - const result = await response.json() as T; - return transformPropertyNames(result, context.modelPropertyNaming); - case 'text': - return await response.text() as any as T; - default: - return response as any as T; - } - } - throw response; - } - - private createFetchParams(context: RequestOpts) { - let url = this.configuration.basePath + context.path; - if (context.query !== undefined && Object.keys(context.query).length !== 0) { - // only add the querystring to the URL if there are query parameters. - // this is done to avoid urls ending with a "?" character which buggy webservers - // do not handle correctly sometimes. - url += '?' + querystring(context.query); - } - const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); - const init = { - method: context.method, - headers: context.headers, - body, - }; - return { url, init }; - } - - private fetchApi = async (url: string, init: RequestInit) => { - let fetchParams = { url, init }; - for (const middleware of this.middleware) { - if (middleware.pre) { - fetchParams = await middleware.pre(this.fetchApi, fetchParams.url, fetchParams.init) || fetchParams; - } - } - let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); - for (const middleware of this.middleware) { - if (middleware.post) { - response = await middleware.post(this.fetchApi, url, init, response.clone()) || response; - } - } - return response; - } - - /** - * https://swagger.io/docs/specification/2-0/describing-responses/ - * - * If the response type for a given API is a 'string' we need to avoid - * parsing the response as json because JSON.parse("some string") will - * fail when the string isn't actually JSON. - */ - protected getResponseType(returnType: string): ResponseType { - switch (returnType) { - case 'string': - return 'text' - default: - return 'JSON' - } - } - - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - private clone(this: T): T { - const constructor = this.constructor as any; - const next = new constructor(this.configuration); - next.middleware = this.middleware.slice(); - return next; - } -}; - -export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } -} - - -/** - * no description - */ -export class PetApi extends BaseAPI { - - /** - * Add a new pet to the store - */ - async addPet(requestParameters: AddPetRequest): Promise { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request({ - path: `/pet`, - method: 'POST', - headers: headerParameters, - body: requestParameters.pet, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Deletes a pet - */ - async deletePet(requestParameters: DeletePetRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); - } - - const headerParameters: HTTPHeaders = {}; - - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); - } - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'DELETE', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Multiple status values can be provided with comma separated strings - * Finds Pets by status - */ - async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); - } - - const queryParameters: HTTPQuery = {}; - - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(COLLECTION_FORMATS["csv"]); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request>({ - path: `/pet/findByStatus`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - responseType: this.getResponseType('Array'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * Finds Pets by tags - */ - async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); - } - - const queryParameters: HTTPQuery = {}; - - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(COLLECTION_FORMATS["csv"]); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request>({ - path: `/pet/findByTags`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - responseType: this.getResponseType('Array'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Returns a single pet - * Find pet by ID - */ - async getPetById(requestParameters: GetPetByIdRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication - } - - return this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('Pet'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Update an existing pet - */ - async updatePet(requestParameters: UpdatePetRequest): Promise { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request({ - path: `/pet`, - method: 'PUT', - headers: headerParameters, - body: requestParameters.pet, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Updates a pet in the store with form data - */ - async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); - } - - const headerParameters: HTTPHeaders = {}; - -<<<<<<< HEAD - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; -======= -/** - * StoreApi - fetch parameter creator - * @export - */ -export const StoreApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling deleteOrder.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options: any = {}): FetchArgs { - const localVarPath = `/store/inventory`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - } - } - -<<<<<<< HEAD - const formData = new FormData(); - if (requestParameters.name !== undefined) { - formData.append('name', requestParameters.name as any); - } -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling getOrderById.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options: any = {}): FetchArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); - } - const localVarPath = `/store/order`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(order || {}) : (order || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - if (requestParameters.status !== undefined) { - formData.append('status', requestParameters.status as any); - } - - return this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'POST', - headers: headerParameters, - body: formData, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * uploads an image - */ - async uploadFile(requestParameters: UploadFileRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - const formData = new FormData(); - if (requestParameters.additionalMetadata !== undefined) { - formData.append('additionalMetadata', requestParameters.additionalMetadata as any); - } - - if (requestParameters.file !== undefined) { - formData.append('file', requestParameters.file as any); - } - - return this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'POST', - headers: headerParameters, - body: formData, - responseType: this.getResponseType('ApiResponse'), - modelPropertyNaming: 'camelCase', - }); - } - -} - -/** - * no description - */ -export class StoreApi extends BaseAPI { - - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * Delete purchase order by ID - */ - async deleteOrder(requestParameters: DeleteOrderRequest): Promise { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), - method: 'DELETE', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Returns a map of status codes to quantities - * Returns pet inventories by status - */ - async getInventory(): Promise<{ [key: string]: number; }> { - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication - } - - return this.request<{ [key: string]: number; }>({ - path: `/store/inventory`, - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('{ [key: string]: number; }'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * Find purchase order by ID - */ - async getOrderById(requestParameters: GetOrderByIdRequest): Promise { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('Order'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Place an order for a pet - */ - async placeOrder(requestParameters: PlaceOrderRequest): Promise { - if (requestParameters.order === null || requestParameters.order === undefined) { - throw new RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); - } - -<<<<<<< HEAD - const headerParameters: HTTPHeaders = {}; -======= -/** - * UserApi - fetch parameter creator - * @export - */ -export const UserApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); - } - const localVarPath = `/user`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); - } - const localVarPath = `/user/createWithArray`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); - } - const localVarPath = `/user/createWithList`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - deleteUser(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('password','Required parameter password was null or undefined when calling loginUser.'); - } - const localVarPath = `/user/login`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - if (username !== undefined) { - localVarQueryParameter['username'] = username; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - headerParameters['Content-Type'] = 'application/json'; - -<<<<<<< HEAD - return this.request({ - path: `/store/order`, - method: 'POST', - headers: headerParameters, - body: requestParameters.order, - responseType: this.getResponseType('Order'), - modelPropertyNaming: 'camelCase', - }); -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options: any = {}): FetchArgs { - const localVarPath = `/user/logout`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('user','Required parameter user was null or undefined when calling updateUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'PUT' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - } - -} - -/** - * no description - */ -export class UserApi extends BaseAPI { - - /** - * This can only be done by the logged in user. - * Create user - */ - async createUser(requestParameters: CreateUserRequest): Promise { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user`, - method: 'POST', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Creates list of users with given input array - */ - async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user/createWithArray`, - method: 'POST', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Creates list of users with given input array - */ - async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user/createWithList`, - method: 'POST', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * This can only be done by the logged in user. - * Delete user - */ - async deleteUser(requestParameters: DeleteUserRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), - method: 'DELETE', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Get user by user name - */ - async getUserByName(requestParameters: GetUserByNameRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('User'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Logs user into the system - */ - async loginUser(requestParameters: LoginUserRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); - } - - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); - } - - const queryParameters: HTTPQuery = {}; - - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; - } - - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/login`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - responseType: this.getResponseType('string'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Logs out current logged in user session - */ - async logoutUser(): Promise { - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/logout`, - method: 'GET', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * This can only be done by the logged in user. - * Updated user - */ - async updateUser(requestParameters: UpdateUserRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); - } - - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), - method: 'PUT', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - -} - - - -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -export type FetchAPI = GlobalFetch['fetch']; - -export interface ConfigurationParameters { - basePath?: string; // override base path - fetchApi?: FetchAPI; // 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 -} - -export class Configuration { - - basePath: string; - fetchApi: FetchAPI; - middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - - constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; - this.fetchApi = conf.fetchApi || window.fetch.bind(window); - 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; - } - } -} - -export type Json = any; -export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; -export type HTTPHeaders = { [key: string]: string }; -export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; -export type HTTPBody = Json | FormData; -export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; - -export interface FetchParams { - url: string; - init: RequestInit; -} - -type ResponseType = 'JSON' | 'text'; - -interface RequestOpts { - path: string; - method: HTTPMethod; - headers: HTTPHeaders; - query?: HTTPQuery; - body?: HTTPBody; - responseType?: ResponseType; - modelPropertyNaming: ModelPropertyNaming; -} - -function querystring(params: HTTPQuery) { - return Object.keys(params) - .map((key) => { - const value = params[key]; - if (value instanceof Array) { - const multiValue = value.join(`&${encodeURIComponent(key)}=`); - return `${encodeURIComponent(key)}=${multiValue}`; - } - return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` - }) - .join('&'); -} - -export interface Middleware { - pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; - post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; -} - -function capitalize(word: string) { - return word.charAt(0).toUpperCase() + word.slice(1); -} - -function toPascalCase(name: string) { - return name - .split('_') - .map(capitalize) - .join(''); -} - -function toCamelCase(name: string) { - const pascalCase = toPascalCase(name); - return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1); -} - -function applyPropertyNameConverter(json: any, converter: (name: string) => string) { - if (json instanceof Array) { - json.forEach((value) => { - if (typeof value === 'object') { - return applyPropertyNameConverter(value, converter); - } - }); - } else { - Object.keys(json).forEach((origKey) => { - if (json.hasOwnProperty(origKey)) { - let value = json[origKey]; - if (value instanceof Array || (value !== null && value.constructor === Object)) { - value = applyPropertyNameConverter(value, converter); - } - const newKey = converter(origKey); - json[newKey] = json[origKey]; - delete json[origKey]; - json[newKey] = value; - } - }); - } - return json; -} - -function transformPropertyNames(json: any, modelPropertyNaming: ModelPropertyNaming) { - switch (modelPropertyNaming) { - case 'camelCase': - return applyPropertyNameConverter(json, toCamelCase); - - case 'original': - default: - return json; - } -} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts deleted file mode 100644 index 4a8a7c68eb0b..000000000000 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts +++ /dev/null @@ -1,1906 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); - -/** - * 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; -} - -/** - * A category for a pet - * @export - * @interface Category - */ -export interface Category { - /** - * - * @type {number} - * @memberof Category - */ - id?: number; - /** - * - * @type {string} - * @memberof Category - */ - name?: string; -} - -/** - * 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' - } -} - -/** - * 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' - } -} - -/** - * A tag for a pet - * @export - * @interface Tag - */ -export interface Tag { - /** - * - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * - * @type {string} - * @memberof Tag - */ - name?: string; -} - -/** - * 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; -} - - -<<<<<<< HEAD -export interface AddPetRequest { - pet: Pet; -} -======= -/** - * PetApi - fetch parameter creator - * @export - */ -export const PetApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @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} - */ - addPet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling addPet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface DeletePetRequest { - petId: number; - apiKey?: string; -} - -<<<<<<< HEAD -export interface FindPetsByStatusRequest { - status: Array<'available' | 'pending' | 'sold'>; -} -======= - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Deletes a pet - * @param {number} petId Pet id to delete - * @param {string} [apiKey] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deletePet(petId: number, apiKey?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface FindPetsByTagsRequest { - tags: Array; -} - -<<<<<<< HEAD -export interface GetPetByIdRequest { - petId: number; -} -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options: any = {}): FetchArgs { - // verify required parameter 'status' is not null or undefined - if (status === null || status === undefined) { - throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); - } - const localVarPath = `/pet/findByStatus`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface UpdatePetRequest { - pet: Pet; -} - -export interface UpdatePetWithFormRequest { - petId: number; - name?: string; - status?: string; -} - -<<<<<<< HEAD -export interface UploadFileRequest { - petId: number; - additionalMetadata?: string; - file?: any; -} -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - findPetsByTags(tags: Array, options: any = {}): FetchArgs { - // verify required parameter 'tags' is not null or undefined - if (tags === null || tags === undefined) { - throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); - } - const localVarPath = `/pet/findByTags`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface DeleteOrderRequest { - orderId: string; -} - -export interface GetOrderByIdRequest { - orderId: number; -} - -<<<<<<< HEAD -export interface PlaceOrderRequest { - order: Order; -} - -export interface CreateUserRequest { - user: User; -} -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getPetById(petId: number, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; - } - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePet(pet: Pet, options: any = {}): FetchArgs { - // verify required parameter 'pet' is not null or undefined - if (pet === null || pet === undefined) { - throw new RequiredError('pet','Required parameter pet was null or undefined when calling updatePet.'); - } - const localVarPath = `/pet`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'PUT' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface CreateUsersWithArrayInputRequest { - user: Array; -} - -<<<<<<< HEAD -export interface CreateUsersWithListInputRequest { - user: Array; -} -======= - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(pet || {}) : (pet || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - updatePetWithForm(petId: number, name?: string, status?: string, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); - } - const localVarPath = `/pet/{petId}` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - -export interface DeleteUserRequest { - username: string; -} - -export interface GetUserByNameRequest { - username: string; -} - -<<<<<<< HEAD -export interface LoginUserRequest { - username: string; - password: string; -} - -export interface UpdateUserRequest { - username: string; - user: User; -} -======= - localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - localVarRequestOptions.body = localVarFormParams.toString(); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - uploadFile(petId: number, additionalMetadata?: string, file?: any, options: any = {}): FetchArgs { - // verify required parameter 'petId' is not null or undefined - if (petId === null || petId === undefined) { - throw new RequiredError('petId','Required parameter petId was null or undefined when calling uploadFile.'); - } - const localVarPath = `/pet/{petId}/uploadImage` - .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - const localVarFormParams = new url.URLSearchParams(); - - // authentication petstore_auth required - // oauth required - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) - : configuration.accessToken; - localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - -/** - * This is the base class for all generated API classes. - */ -export class BaseAPI { - - private middleware: Middleware[]; - - constructor(protected configuration = new Configuration()) { - this.middleware = configuration.middleware; - } - - withMiddleware(this: T, ...middlewares: Middleware[]) { - const next = this.clone(); - next.middleware = next.middleware.concat(...middlewares); - return next; - } - - withPreMiddleware(this: T, ...preMiddlewares: Array) { - const middlewares = preMiddlewares.map((pre) => ({ pre })); - return this.withMiddleware(...middlewares); - } - - withPostMiddleware(this: T, ...postMiddlewares: Array) { - const middlewares = postMiddlewares.map((post) => ({ post })); - return this.withMiddleware(...middlewares); - } - - protected async request(context: RequestOpts): Promise { - const { url, init } = this.createFetchParams(context); - const response = await this.fetchApi(url, init); - if (response.status >= 200 && response.status < 300) { - switch(context.responseType) { - case 'JSON': - const result = await response.json() as T; - return transformPropertyNames(result, context.modelPropertyNaming); - case 'text': - return await response.text() as any as T; - default: - return response as any as T; - } - } - throw response; - } - - private createFetchParams(context: RequestOpts) { - let url = this.configuration.basePath + context.path; - if (context.query !== undefined && Object.keys(context.query).length !== 0) { - // only add the querystring to the URL if there are query parameters. - // this is done to avoid urls ending with a "?" character which buggy webservers - // do not handle correctly sometimes. - url += '?' + querystring(context.query); - } - const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); - const init = { - method: context.method, - headers: context.headers, - body, - }; - return { url, init }; - } - - private fetchApi = async (url: string, init: RequestInit) => { - let fetchParams = { url, init }; - for (const middleware of this.middleware) { - if (middleware.pre) { - fetchParams = await middleware.pre(this.fetchApi, fetchParams.url, fetchParams.init) || fetchParams; - } - } - let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); - for (const middleware of this.middleware) { - if (middleware.post) { - response = await middleware.post(this.fetchApi, url, init, response.clone()) || response; - } - } - return response; - } - - /** - * https://swagger.io/docs/specification/2-0/describing-responses/ - * - * If the response type for a given API is a 'string' we need to avoid - * parsing the response as json because JSON.parse("some string") will - * fail when the string isn't actually JSON. - */ - protected getResponseType(returnType: string): ResponseType { - switch (returnType) { - case 'string': - return 'text' - default: - return 'JSON' - } - } - - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - private clone(this: T): T { - const constructor = this.constructor as any; - const next = new constructor(this.configuration); - next.middleware = this.middleware.slice(); - return next; - } -}; - -export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; - constructor(public field: string, msg?: string) { - super(msg); - } -} - - -/** - * no description - */ -export class PetApi extends BaseAPI { - - /** - * Add a new pet to the store - */ - async addPet(requestParameters: AddPetRequest): Promise { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request({ - path: `/pet`, - method: 'POST', - headers: headerParameters, - body: requestParameters.pet, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Deletes a pet - */ - async deletePet(requestParameters: DeletePetRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); - } - - const headerParameters: HTTPHeaders = {}; - - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); - } - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'DELETE', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Multiple status values can be provided with comma separated strings - * Finds Pets by status - */ - async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); - } - - const queryParameters: HTTPQuery = {}; - - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(COLLECTION_FORMATS["csv"]); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request>({ - path: `/pet/findByStatus`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - responseType: this.getResponseType('Array'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * Finds Pets by tags - */ - async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); - } - - const queryParameters: HTTPQuery = {}; - - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(COLLECTION_FORMATS["csv"]); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request>({ - path: `/pet/findByTags`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - responseType: this.getResponseType('Array'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Returns a single pet - * Find pet by ID - */ - async getPetById(requestParameters: GetPetByIdRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication - } - - return this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('Pet'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Update an existing pet - */ - async updatePet(requestParameters: UpdatePetRequest): Promise { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - return this.request({ - path: `/pet`, - method: 'PUT', - headers: headerParameters, - body: requestParameters.pet, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Updates a pet in the store with form data - */ - async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); - } - - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } - } - - const formData = new FormData(); - if (requestParameters.name !== undefined) { - formData.append('name', requestParameters.name as any); - } - - if (requestParameters.status !== undefined) { - formData.append('status', requestParameters.status as any); - } - - return this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'POST', - headers: headerParameters, - body: formData, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * uploads an image - */ - async uploadFile(requestParameters: UploadFileRequest): Promise { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); - } - - const headerParameters: HTTPHeaders = {}; - -<<<<<<< HEAD - if (this.configuration && this.configuration.accessToken) { - // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; -======= -/** - * StoreApi - fetch parameter creator - * @export - */ -export const StoreApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - deleteOrder(orderId: string, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling deleteOrder.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a map of status codes to quantities - * @summary Returns pet inventories by status - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getInventory(options: any = {}): FetchArgs { - const localVarPath = `/store/inventory`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication api_key required - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("api_key") - : configuration.apiKey; - localVarHeaderParameter["api_key"] = localVarApiKeyValue; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - } - } - -<<<<<<< HEAD - const formData = new FormData(); - if (requestParameters.additionalMetadata !== undefined) { - formData.append('additionalMetadata', requestParameters.additionalMetadata as any); - } -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - getOrderById(orderId: number, options: any = {}): FetchArgs { - // verify required parameter 'orderId' is not null or undefined - if (orderId === null || orderId === undefined) { - throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling getOrderById.'); - } - const localVarPath = `/store/order/{orderId}` - .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Place an order for a pet - * @param {Order} order order placed for purchasing the pet - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - placeOrder(order: Order, options: any = {}): FetchArgs { - // verify required parameter 'order' is not null or undefined - if (order === null || order === undefined) { - throw new RequiredError('order','Required parameter order was null or undefined when calling placeOrder.'); - } - const localVarPath = `/store/order`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(order || {}) : (order || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - if (requestParameters.file !== undefined) { - formData.append('file', requestParameters.file as any); - } - - return this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), - method: 'POST', - headers: headerParameters, - body: formData, - responseType: this.getResponseType('ApiResponse'), - modelPropertyNaming: 'camelCase', - }); - } - -} - -/** - * no description - */ -export class StoreApi extends BaseAPI { - - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * Delete purchase order by ID - */ - async deleteOrder(requestParameters: DeleteOrderRequest): Promise { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), - method: 'DELETE', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Returns a map of status codes to quantities - * Returns pet inventories by status - */ - async getInventory(): Promise<{ [key: string]: number; }> { - const headerParameters: HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication - } - - return this.request<{ [key: string]: number; }>({ - path: `/store/inventory`, - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('{ [key: string]: number; }'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * Find purchase order by ID - */ - async getOrderById(requestParameters: GetOrderByIdRequest): Promise { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('Order'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Place an order for a pet - */ -<<<<<<< HEAD - async placeOrder(requestParameters: PlaceOrderRequest): Promise { - if (requestParameters.order === null || requestParameters.order === undefined) { - throw new RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); - } -======= - public placeOrder(order: Order, options?: any) { - return StoreApiFp(this.configuration).placeOrder(order, options)(this.fetch, this.basePath); - } - -} - -/** - * UserApi - fetch parameter creator - * @export - */ -export const UserApiFetchParamCreator = function (configuration?: Configuration) { - return { - /** - * 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} - */ - createUser(user: User, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUser.'); - } - const localVarPath = `/user`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithArrayInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithArrayInput.'); - } - const localVarPath = `/user/createWithArray`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Creates list of users with given input array - * @param {Array} user List of user object - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createUsersWithListInput(user: Array, options: any = {}): FetchArgs { - // verify required parameter 'user' is not null or undefined - if (user === null || user === undefined) { - throw new RequiredError('user','Required parameter user was null or undefined when calling createUsersWithListInput.'); - } - const localVarPath = `/user/createWithList`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - deleteUser(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - getUserByName(username: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @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} - */ - loginUser(username: string, password: string, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('password','Required parameter password was null or undefined when calling loginUser.'); - } - const localVarPath = `/user/login`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - if (username !== undefined) { - localVarQueryParameter['username'] = username; - } ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - const headerParameters: HTTPHeaders = {}; - -<<<<<<< HEAD - headerParameters['Content-Type'] = 'application/json'; -======= - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Logs out current logged in user session - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - logoutUser(options: any = {}): FetchArgs { - const localVarPath = `/user/logout`; - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 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} - */ - updateUser(username: string, user: User, options: any = {}): FetchArgs { - // verify required parameter 'username' is not null or undefined - if (username === null || username === undefined) { - throw new RequiredError('username','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('user','Required parameter user was null or undefined when calling updateUser.'); - } - const localVarPath = `/user/{username}` - .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const localVarUrlObj = url.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = Object.assign({ method: 'PUT' }, baseOptions, options); - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); - // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; - localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); - const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.body = needsSerialization ? JSON.stringify(user || {}) : (user || ""); - - return { - url: url.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; ->>>>>>> d327c5be464d02aa31e24d2ef6eae959e0563a86 - - return this.request({ - path: `/store/order`, - method: 'POST', - headers: headerParameters, - body: requestParameters.order, - responseType: this.getResponseType('Order'), - modelPropertyNaming: 'camelCase', - }); - } - -} - -/** - * no description - */ -export class UserApi extends BaseAPI { - - /** - * This can only be done by the logged in user. - * Create user - */ - async createUser(requestParameters: CreateUserRequest): Promise { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user`, - method: 'POST', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Creates list of users with given input array - */ - async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user/createWithArray`, - method: 'POST', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Creates list of users with given input array - */ - async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user/createWithList`, - method: 'POST', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * This can only be done by the logged in user. - * Delete user - */ - async deleteUser(requestParameters: DeleteUserRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), - method: 'DELETE', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Get user by user name - */ - async getUserByName(requestParameters: GetUserByNameRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), - method: 'GET', - headers: headerParameters, - responseType: this.getResponseType('User'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Logs user into the system - */ - async loginUser(requestParameters: LoginUserRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); - } - - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); - } - - const queryParameters: HTTPQuery = {}; - - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; - } - - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; - } - - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/login`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - responseType: this.getResponseType('string'), - modelPropertyNaming: 'camelCase', - }); - } - - /** - * Logs out current logged in user session - */ - async logoutUser(): Promise { - const headerParameters: HTTPHeaders = {}; - - return this.request({ - path: `/user/logout`, - method: 'GET', - headers: headerParameters, - modelPropertyNaming: 'camelCase', - }); - } - - /** - * This can only be done by the logged in user. - * Updated user - */ - async updateUser(requestParameters: UpdateUserRequest): Promise { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); - } - - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); - } - - const headerParameters: HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - return this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), - method: 'PUT', - headers: headerParameters, - body: requestParameters.user, - modelPropertyNaming: 'camelCase', - }); - } - -} - - - -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -export type FetchAPI = GlobalFetch['fetch']; - -export interface ConfigurationParameters { - basePath?: string; // override base path - fetchApi?: FetchAPI; // 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 -} - -export class Configuration { - - basePath: string; - fetchApi: FetchAPI; - middleware: Middleware[]; - username?: string; - password?: string; - apiKey?: (name: string) => string; - accessToken?: (name: string, scopes?: string[]) => string; - - constructor(conf: ConfigurationParameters = {}) { - this.basePath = conf.basePath !== undefined ? conf.basePath : BASE_PATH; - this.fetchApi = conf.fetchApi || window.fetch.bind(window); - 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; - } - } -} - -export type Json = any; -export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; -export type HTTPHeaders = { [key: string]: string }; -export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; -export type HTTPBody = Json | FormData; -export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; - -export interface FetchParams { - url: string; - init: RequestInit; -} - -type ResponseType = 'JSON' | 'text'; - -interface RequestOpts { - path: string; - method: HTTPMethod; - headers: HTTPHeaders; - query?: HTTPQuery; - body?: HTTPBody; - responseType?: ResponseType; - modelPropertyNaming: ModelPropertyNaming; -} - -function querystring(params: HTTPQuery) { - return Object.keys(params) - .map((key) => { - const value = params[key]; - if (value instanceof Array) { - const multiValue = value.join(`&${encodeURIComponent(key)}=`); - return `${encodeURIComponent(key)}=${multiValue}`; - } - return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` - }) - .join('&'); -} - -export interface Middleware { - pre?(fetch: FetchAPI, url: string, init: RequestInit): Promise; - post?(fetch: FetchAPI, url: string, init: RequestInit, response: Response): Promise; -} - -function capitalize(word: string) { - return word.charAt(0).toUpperCase() + word.slice(1); -} - -function toPascalCase(name: string) { - return name - .split('_') - .map(capitalize) - .join(''); -} - -function toCamelCase(name: string) { - const pascalCase = toPascalCase(name); - return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1); -} - -function applyPropertyNameConverter(json: any, converter: (name: string) => string) { - if (json instanceof Array) { - json.forEach((value) => { - if (typeof value === 'object') { - return applyPropertyNameConverter(value, converter); - } - }); - } else { - Object.keys(json).forEach((origKey) => { - if (json.hasOwnProperty(origKey)) { - let value = json[origKey]; - if (value instanceof Array || (value !== null && value.constructor === Object)) { - value = applyPropertyNameConverter(value, converter); - } - const newKey = converter(origKey); - json[newKey] = json[origKey]; - delete json[origKey]; - json[newKey] = value; - } - }); - } - return json; -} - -function transformPropertyNames(json: any, modelPropertyNaming: ModelPropertyNaming) { - switch (modelPropertyNaming) { - case 'camelCase': - return applyPropertyNameConverter(json, toCamelCase); - - case 'original': - default: - return json; - } -} From 6bcf91205a1e47485c98942c26b1eb93a1f975ef Mon Sep 17 00:00:00 2001 From: James Batt Date: Sun, 2 Sep 2018 12:43:52 +1000 Subject: [PATCH 24/39] added support for array type request body --- .../src/main/resources/typescript-fetch/apis.mustache | 5 +++++ .../petstore/typescript-fetch/builds/default/apis/UserApi.ts | 4 ++-- .../typescript-fetch/builds/es6-target/apis/UserApi.ts | 4 ++-- .../typescript-fetch/builds/with-interfaces/apis/UserApi.ts | 4 ++-- .../typescript-fetch/builds/with-npm-version/apis/UserApi.ts | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index ae6e511e3e9f..76a96e3a3f08 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -173,7 +173,12 @@ export class {{classname}} extends runtime.BaseAPI { {{/hasQueryParams}} {{#hasBodyParam}} {{#bodyParam}} + {{#isContainer}} + body: requestParameters.{{paramName}}.map({{#items}}{{datatype}}{{/items}}ToJSON), + {{/isContainer}} + {{^isContainer}} body: {{dataType}}ToJSON(requestParameters.{{paramName}}), + {{/isContainer}} {{/bodyParam}} {{/hasBodyParam}} {{#hasFormParams}} diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts index ef73103f3100..61ad2b3e63ec 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts @@ -92,7 +92,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, - body: Array<User>ToJSON(requestParameters.user), + body: requestParameters.user.map(UserToJSON), }); return response; } @@ -113,7 +113,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithList`, method: 'POST', headers: headerParameters, - body: Array<User>ToJSON(requestParameters.user), + body: requestParameters.user.map(UserToJSON), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts index ef73103f3100..61ad2b3e63ec 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts @@ -92,7 +92,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, - body: Array<User>ToJSON(requestParameters.user), + body: requestParameters.user.map(UserToJSON), }); return response; } @@ -113,7 +113,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithList`, method: 'POST', headers: headerParameters, - body: Array<User>ToJSON(requestParameters.user), + body: requestParameters.user.map(UserToJSON), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts index ef73103f3100..61ad2b3e63ec 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts @@ -92,7 +92,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, - body: Array<User>ToJSON(requestParameters.user), + body: requestParameters.user.map(UserToJSON), }); return response; } @@ -113,7 +113,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithList`, method: 'POST', headers: headerParameters, - body: Array<User>ToJSON(requestParameters.user), + body: requestParameters.user.map(UserToJSON), }); return response; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts index ef73103f3100..61ad2b3e63ec 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts @@ -92,7 +92,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, - body: Array<User>ToJSON(requestParameters.user), + body: requestParameters.user.map(UserToJSON), }); return response; } @@ -113,7 +113,7 @@ export class UserApi extends runtime.BaseAPI { path: `/user/createWithList`, method: 'POST', headers: headerParameters, - body: Array<User>ToJSON(requestParameters.user), + body: requestParameters.user.map(UserToJSON), }); return response; } From c8a9ce24cd46a3a0d023b0de461bc0bae94dd93f Mon Sep 17 00:00:00 2001 From: James Batt Date: Sun, 2 Sep 2018 14:04:36 +1000 Subject: [PATCH 25/39] updated tests --- .../tests/default/package-lock.json | 49 +--------- .../tests/default/test/PetApi.ts | 21 ++--- .../tests/default/test/PetApiFactory.ts | 91 ------------------- .../tests/default/test/StoreApi.ts | 9 +- .../tests/default/test/StoreApiFactory.ts | 42 --------- .../tests/default/test/index.ts | 4 +- 6 files changed, 12 insertions(+), 204 deletions(-) delete mode 100644 samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts delete mode 100644 samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts diff --git a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json index c16f4968148d..9f49d0c93083 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json +++ b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json @@ -5,54 +5,7 @@ "requires": true, "dependencies": { "@swagger/typescript-fetch-petstore": { - "version": "file:../../builds/with-npm-version", - "requires": { - "portable-fetch": "^3.0.0" - }, - "dependencies": { - "encoding": { - "version": "0.1.12", - "bundled": true, - "requires": { - "iconv-lite": "~0.4.13" - } - }, - "iconv-lite": { - "version": "0.4.23", - "bundled": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "is-stream": { - "version": "1.1.0", - "bundled": true - }, - "node-fetch": { - "version": "1.7.3", - "bundled": true, - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } - }, - "portable-fetch": { - "version": "3.0.0", - "bundled": true, - "requires": { - "node-fetch": "^1.0.1", - "whatwg-fetch": ">=0.10.0" - } - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true - }, - "whatwg-fetch": { - "version": "2.0.4", - "bundled": true - } - } + "version": "file:../../builds/with-npm-version" }, "@types/chai": { "version": "4.0.2", diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts index 8c89846d0072..1deeede2b6e0 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts @@ -3,7 +3,7 @@ import { PetApi, Pet, Category } from '@swagger/typescript-fetch-petstore'; describe('PetApi', () => { - function runSuite(description: string, requestOptions?: any): void { + function runSuite(description: string): void { describe(description, () => { @@ -15,21 +15,21 @@ describe('PetApi', () => { }); it('should add and delete Pet', () => { - return api.addPet(fixture, requestOptions).then(() => { + return api.addPet({ pet: fixture }).then(() => { }); }); it('should get Pet by ID', () => { - return api.getPetById(fixture.id, requestOptions).then((result: Pet) => { + return api.getPetById({ petId: fixture.id }).then((result: Pet) => { return expect(result).to.deep.equal(fixture); }); }); it('should update Pet by ID', () => { - return api.getPetById(fixture.id, requestOptions).then((result: Pet) => { + return api.getPetById({ petId: fixture.id }).then((result: Pet) => { result.name = 'newname'; - return api.updatePet(result, requestOptions).then(() => { - return api.getPetById(fixture.id, requestOptions).then((result: Pet) => { + return api.updatePet({ pet: result }).then(() => { + return api.getPetById({ petId: fixture.id }).then((result: Pet) => { return expect(result.name).to.deep.equal('newname'); }); }); @@ -37,11 +37,11 @@ describe('PetApi', () => { }); it('should delete Pet', () => { - return api.deletePet(fixture.id, requestOptions); + return api.deletePet({ petId: fixture.id }); }); it('should not contain deleted Pet', () => { - return api.getPetById(fixture.id, requestOptions).then((result: Pet) => { + return api.getPetById({ petId: fixture.id }).then((result: Pet) => { return expect(result).to.not.exist; }, (err: any) => { return expect(err).to.exist; @@ -53,11 +53,6 @@ describe('PetApi', () => { runSuite('without custom request options'); - runSuite('with custom request options', { - credentials: 'include', - mode: 'cors' - }); - }); function createTestFixture(ts = Date.now()) { diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts b/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts deleted file mode 100644 index 35bcc98d874a..000000000000 --- a/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { expect } from 'chai'; -import { PetApiFactory, Pet, Category } from '@swagger/typescript-fetch-petstore'; -import { Configuration } from '@swagger/typescript-fetch-petstore'; - -let config: Configuration; - -before(function () { - config = new Configuration(); - config.accessToken = "foobar"; - config.apiKey = (securityName: string) => { - // for multiple apiKey security - if (securityName === "api_key") { - return "foobar"; - } - return; - }; - config.username = "foo"; - config.password = "bar"; -}); - -describe('PetApiFactory', () => { - - - function runSuite(description: string, requestOptions?: any): void { - - describe(description, () => { - - const fixture: Pet = createTestFixture(); - - it('should add and delete Pet', () => { - return PetApiFactory(config).addPet(fixture, requestOptions).then(() => { - }); - }); - - it('should get Pet by ID', () => { - return PetApiFactory(config).getPetById(fixture.id, requestOptions).then((result: Pet) => { - return expect(result).to.deep.equal(fixture); - }); - }); - - it('should update Pet by ID', () => { - return PetApiFactory(config).getPetById(fixture.id, requestOptions).then((result: Pet) => { - result.name = 'newname'; - return PetApiFactory(config).updatePet(result, requestOptions).then(() => { - return PetApiFactory(config).getPetById(fixture.id, requestOptions).then((result: Pet) => { - return expect(result.name).to.deep.equal('newname'); - }); - }); - }); - }); - - it('should delete Pet', () => { - return PetApiFactory(config).deletePet(fixture.id, requestOptions); - }); - - it('should not contain deleted Pet', () => { - return PetApiFactory(config).getPetById(fixture.id, requestOptions).then((result: Pet) => { - return expect(result).to.not.exist; - }, (err: any) => { - return expect(err).to.exist; - }); - }); - }); - } - - runSuite('without custom request options'); - - runSuite('with custom request options', { - credentials: 'include', - mode: 'cors' - }); - -}); - -function createTestFixture(ts = Date.now()) { - const category: Category = { - 'id': ts, - 'name': `category${ts}`, - }; - - const pet: Pet = { - 'id': ts, - 'name': `pet${ts}`, - 'category': category, - 'photoUrls': ['http://foo.bar.com/1', 'http://foo.bar.com/2'], - 'status': Pet.StatusEnum.Available, - 'tags': [] - }; - - return pet; -}; diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts index 24f507173608..3016b8f65094 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts @@ -3,7 +3,7 @@ import { StoreApi } from '@swagger/typescript-fetch-petstore'; describe('StoreApi', function () { - function runSuite(description: string, requestOptions?: any): void { + function runSuite(description: string): void { describe(description, () => { let api: StoreApi; @@ -13,7 +13,7 @@ describe('StoreApi', function () { }); it('should get inventory', function () { - return api.getInventory(requestOptions).then((result: { [key: string]: number }) => { + return api.getInventory().then((result: { [key: string]: number }) => { expect(Object.keys(result)).to.not.be.empty; }); }); @@ -23,9 +23,4 @@ describe('StoreApi', function () { runSuite('without custom request options'); - runSuite('with custom request options', { - credentials: 'include', - mode: 'cors' - }); - }); diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts deleted file mode 100644 index d87bd020a857..000000000000 --- a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { expect } from 'chai'; -import { StoreApiFactory } from '@swagger/typescript-fetch-petstore'; -import { Configuration } from '@swagger/typescript-fetch-petstore'; - -let config: Configuration; - -before(function () { - config = new Configuration(); - config.accessToken = "foobar"; - config.apiKey = (securityName: string) => { - // for multiple apiKey security - if (securityName === "api_key") { - return "foobar"; - } - return; - }; - config.username = "foo"; - config.password = "bar"; -}); - -describe('StoreApiFactory', function () { - function runSuite(description: string, requestOptions?: any): void { - - describe(description, () => { - - it('should get inventory', function () { - return StoreApiFactory(config).getInventory(requestOptions).then((result: { [key: string]: number }) => { - expect(Object.keys(result)).to.not.be.empty; - }); - }); - - }); - } - - runSuite('without custom request options'); - - runSuite('with custom request options', { - credentials: 'include', - mode: 'cors' - }); - -}); diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/index.ts b/samples/client/petstore/typescript-fetch/tests/default/test/index.ts index a3adb97ca810..134fa030435a 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/index.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/index.ts @@ -1,4 +1,2 @@ import './PetApi'; -import './StoreApi'; -import './PetApiFactory'; -import './StoreApiFactory'; +import './StoreApi'; From 70e0b918466ad794341402fcd43a26f03ab1cb32 Mon Sep 17 00:00:00 2001 From: James Batt Date: Tue, 18 Sep 2018 14:19:54 +1000 Subject: [PATCH 26/39] support for optional request bodies --- .../src/main/resources/typescript-fetch/apis.mustache | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index ae6e511e3e9f..d5e9a0f071a5 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -173,7 +173,12 @@ export class {{classname}} extends runtime.BaseAPI { {{/hasQueryParams}} {{#hasBodyParam}} {{#bodyParam}} + {{#required}} body: {{dataType}}ToJSON(requestParameters.{{paramName}}), + {{/required}} + {{^required}} + body: requestParameters.{{paramName}} !== undefined ? {{dataType}}ToJSON(requestParameters.{{paramName}}) : undefined, + {{/required}} {{/bodyParam}} {{/hasBodyParam}} {{#hasFormParams}} From 71d8b90ad5e6e6743e311f69c95b8a808db25a08 Mon Sep 17 00:00:00 2001 From: James Batt Date: Tue, 18 Sep 2018 15:53:11 +1000 Subject: [PATCH 27/39] updated models json converters to handle undefined inputs (to simplify usage in optional contexts like optional request bodies) --- .../resources/typescript-fetch/modelGeneric.mustache | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 5354390f6cf7..51900be63ec5 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -28,6 +28,7 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ } export function {{classname}}FromJSON(json: any): {{classname}} { + {{#hasVars}} return { {{#vars}} {{#isPrimitiveType}} @@ -43,9 +44,14 @@ export function {{classname}}FromJSON(json: any): {{classname}} { {{/isPrimitiveType}} {{/vars}} }; + {{/hasVars}} + {{^hasVars}} + return json; + {{/hasVars}} } export function {{classname}}ToJSON(value?: {{classname}}): any { + {{#hasVars}} if (value === undefined) { return undefined; } @@ -64,6 +70,10 @@ export function {{classname}}ToJSON(value?: {{classname}}): any { {{/isPrimitiveType}} {{/vars}} }; + {{/hasVars}} + {{^hasVars}} + return value; + {{/hasVars}} } {{#hasEnums}} From 71ee3d91dbd78092957a1c351a313090054b1ea3 Mon Sep 17 00:00:00 2001 From: James Batt Date: Mon, 24 Sep 2018 20:05:15 +1000 Subject: [PATCH 28/39] updated samples --- .../typescript-fetch/builds/default/models/ApiResponse.ts | 5 ++++- .../typescript-fetch/builds/default/models/Category.ts | 5 ++++- .../petstore/typescript-fetch/builds/default/models/Order.ts | 5 ++++- .../petstore/typescript-fetch/builds/default/models/Pet.ts | 5 ++++- .../petstore/typescript-fetch/builds/default/models/Tag.ts | 5 ++++- .../petstore/typescript-fetch/builds/default/models/User.ts | 5 ++++- .../typescript-fetch/builds/es6-target/models/ApiResponse.ts | 5 ++++- .../typescript-fetch/builds/es6-target/models/Category.ts | 5 ++++- .../typescript-fetch/builds/es6-target/models/Order.ts | 5 ++++- .../typescript-fetch/builds/es6-target/models/Pet.ts | 5 ++++- .../typescript-fetch/builds/es6-target/models/Tag.ts | 5 ++++- .../typescript-fetch/builds/es6-target/models/User.ts | 5 ++++- .../builds/with-interfaces/models/ApiResponse.ts | 5 ++++- .../builds/with-interfaces/models/Category.ts | 5 ++++- .../typescript-fetch/builds/with-interfaces/models/Order.ts | 5 ++++- .../typescript-fetch/builds/with-interfaces/models/Pet.ts | 5 ++++- .../typescript-fetch/builds/with-interfaces/models/Tag.ts | 5 ++++- .../typescript-fetch/builds/with-interfaces/models/User.ts | 5 ++++- .../builds/with-npm-version/models/ApiResponse.ts | 5 ++++- .../builds/with-npm-version/models/Category.ts | 5 ++++- .../typescript-fetch/builds/with-npm-version/models/Order.ts | 5 ++++- .../typescript-fetch/builds/with-npm-version/models/Pet.ts | 5 ++++- .../typescript-fetch/builds/with-npm-version/models/Tag.ts | 5 ++++- .../typescript-fetch/builds/with-npm-version/models/User.ts | 5 ++++- 24 files changed, 96 insertions(+), 24 deletions(-) diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts index 3f7b15c31032..0ead72296825 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts @@ -45,7 +45,10 @@ export function ApiResponseFromJSON(json: any): ApiResponse { }; } -export function ApiResponseToJSON(value: ApiResponse): any { +export function ApiResponseToJSON(value?: ApiResponse): any { + if (value === undefined) { + return undefined; + } return { 'code': value.code, 'type': value.type, diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts index 2f5c984709b3..5790eddf0496 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts @@ -38,7 +38,10 @@ export function CategoryFromJSON(json: any): Category { }; } -export function CategoryToJSON(value: Category): any { +export function CategoryToJSON(value?: Category): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts index b95e8f837015..6266cb5efdc3 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts @@ -66,7 +66,10 @@ export function OrderFromJSON(json: any): Order { }; } -export function OrderToJSON(value: Order): any { +export function OrderToJSON(value?: Order): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'petId': value.petId, diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts index f7df3c4d6d0d..d0564c69cfd8 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts @@ -75,7 +75,10 @@ export function PetFromJSON(json: any): Pet { }; } -export function PetToJSON(value: Pet): any { +export function PetToJSON(value?: Pet): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'category': CategoryToJSON(value.category), diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts index d8b8d98a9c5d..538b27ad01b8 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts @@ -38,7 +38,10 @@ export function TagFromJSON(json: any): Tag { }; } -export function TagToJSON(value: Tag): any { +export function TagToJSON(value?: Tag): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts index 0496d10e31cf..4e0b3491eaed 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts @@ -80,7 +80,10 @@ export function UserFromJSON(json: any): User { }; } -export function UserToJSON(value: User): any { +export function UserToJSON(value?: User): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'username': value.username, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts index 3f7b15c31032..0ead72296825 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts @@ -45,7 +45,10 @@ export function ApiResponseFromJSON(json: any): ApiResponse { }; } -export function ApiResponseToJSON(value: ApiResponse): any { +export function ApiResponseToJSON(value?: ApiResponse): any { + if (value === undefined) { + return undefined; + } return { 'code': value.code, 'type': value.type, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts index 2f5c984709b3..5790eddf0496 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts @@ -38,7 +38,10 @@ export function CategoryFromJSON(json: any): Category { }; } -export function CategoryToJSON(value: Category): any { +export function CategoryToJSON(value?: Category): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts index b95e8f837015..6266cb5efdc3 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts @@ -66,7 +66,10 @@ export function OrderFromJSON(json: any): Order { }; } -export function OrderToJSON(value: Order): any { +export function OrderToJSON(value?: Order): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'petId': value.petId, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts index f7df3c4d6d0d..d0564c69cfd8 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts @@ -75,7 +75,10 @@ export function PetFromJSON(json: any): Pet { }; } -export function PetToJSON(value: Pet): any { +export function PetToJSON(value?: Pet): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'category': CategoryToJSON(value.category), diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts index d8b8d98a9c5d..538b27ad01b8 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts @@ -38,7 +38,10 @@ export function TagFromJSON(json: any): Tag { }; } -export function TagToJSON(value: Tag): any { +export function TagToJSON(value?: Tag): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts index 0496d10e31cf..4e0b3491eaed 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts @@ -80,7 +80,10 @@ export function UserFromJSON(json: any): User { }; } -export function UserToJSON(value: User): any { +export function UserToJSON(value?: User): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'username': value.username, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts index 3f7b15c31032..0ead72296825 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts @@ -45,7 +45,10 @@ export function ApiResponseFromJSON(json: any): ApiResponse { }; } -export function ApiResponseToJSON(value: ApiResponse): any { +export function ApiResponseToJSON(value?: ApiResponse): any { + if (value === undefined) { + return undefined; + } return { 'code': value.code, 'type': value.type, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts index 2f5c984709b3..5790eddf0496 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts @@ -38,7 +38,10 @@ export function CategoryFromJSON(json: any): Category { }; } -export function CategoryToJSON(value: Category): any { +export function CategoryToJSON(value?: Category): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts index b95e8f837015..6266cb5efdc3 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts @@ -66,7 +66,10 @@ export function OrderFromJSON(json: any): Order { }; } -export function OrderToJSON(value: Order): any { +export function OrderToJSON(value?: Order): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'petId': value.petId, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts index f7df3c4d6d0d..d0564c69cfd8 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts @@ -75,7 +75,10 @@ export function PetFromJSON(json: any): Pet { }; } -export function PetToJSON(value: Pet): any { +export function PetToJSON(value?: Pet): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'category': CategoryToJSON(value.category), diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts index d8b8d98a9c5d..538b27ad01b8 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts @@ -38,7 +38,10 @@ export function TagFromJSON(json: any): Tag { }; } -export function TagToJSON(value: Tag): any { +export function TagToJSON(value?: Tag): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts index 0496d10e31cf..4e0b3491eaed 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts @@ -80,7 +80,10 @@ export function UserFromJSON(json: any): User { }; } -export function UserToJSON(value: User): any { +export function UserToJSON(value?: User): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'username': value.username, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts index 3f7b15c31032..0ead72296825 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts @@ -45,7 +45,10 @@ export function ApiResponseFromJSON(json: any): ApiResponse { }; } -export function ApiResponseToJSON(value: ApiResponse): any { +export function ApiResponseToJSON(value?: ApiResponse): any { + if (value === undefined) { + return undefined; + } return { 'code': value.code, 'type': value.type, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts index 2f5c984709b3..5790eddf0496 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts @@ -38,7 +38,10 @@ export function CategoryFromJSON(json: any): Category { }; } -export function CategoryToJSON(value: Category): any { +export function CategoryToJSON(value?: Category): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts index b95e8f837015..6266cb5efdc3 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts @@ -66,7 +66,10 @@ export function OrderFromJSON(json: any): Order { }; } -export function OrderToJSON(value: Order): any { +export function OrderToJSON(value?: Order): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'petId': value.petId, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts index f7df3c4d6d0d..d0564c69cfd8 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts @@ -75,7 +75,10 @@ export function PetFromJSON(json: any): Pet { }; } -export function PetToJSON(value: Pet): any { +export function PetToJSON(value?: Pet): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'category': CategoryToJSON(value.category), diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts index d8b8d98a9c5d..538b27ad01b8 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts @@ -38,7 +38,10 @@ export function TagFromJSON(json: any): Tag { }; } -export function TagToJSON(value: Tag): any { +export function TagToJSON(value?: Tag): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts index 0496d10e31cf..4e0b3491eaed 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts @@ -80,7 +80,10 @@ export function UserFromJSON(json: any): User { }; } -export function UserToJSON(value: User): any { +export function UserToJSON(value?: User): any { + if (value === undefined) { + return undefined; + } return { 'id': value.id, 'username': value.username, From d770f24ff57a37c8ffbe746dacd4d322399efb15 Mon Sep 17 00:00:00 2001 From: James Batt Date: Tue, 25 Sep 2018 18:45:19 +1000 Subject: [PATCH 29/39] updated tests --- .../tests/default/configuration.ts | 4 ++ .../typescript-fetch/tests/default/mocks.ts | 5 ++ .../tests/default/package-lock.json | 52 ++++++++++++++----- .../tests/default/package.json | 6 ++- .../tests/default/test/PetApi.ts | 3 +- .../tests/default/test/StoreApi.ts | 3 +- .../tests/default/tsconfig.json | 3 +- 7 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 samples/client/petstore/typescript-fetch/tests/default/configuration.ts create mode 100644 samples/client/petstore/typescript-fetch/tests/default/mocks.ts diff --git a/samples/client/petstore/typescript-fetch/tests/default/configuration.ts b/samples/client/petstore/typescript-fetch/tests/default/configuration.ts new file mode 100644 index 000000000000..155b98ca5b0e --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/configuration.ts @@ -0,0 +1,4 @@ +import { Configuration } from "@swagger/typescript-fetch-petstore"; +import fetch from 'node-fetch'; + +export const config = new Configuration({ fetchApi: fetch as any }); diff --git a/samples/client/petstore/typescript-fetch/tests/default/mocks.ts b/samples/client/petstore/typescript-fetch/tests/default/mocks.ts new file mode 100644 index 000000000000..c140489d8f72 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/tests/default/mocks.ts @@ -0,0 +1,5 @@ +import * as FormData from 'form-data'; + +const globals = global as any; + +globals.FormData = FormData; diff --git a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json index 9f49d0c93083..53e18eee6f00 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json +++ b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json @@ -13,6 +13,15 @@ "integrity": "sha512-0pHNZTD0SpQhz1kUM4Muhgdn4acxq21kp726pZfWMmKYGbmmv8XkGTt3k/0QDklhTUYBD6hknZ/1YFokyP/G7Q==", "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==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/isomorphic-fetch": { "version": "0.0.34", "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", @@ -31,6 +40,15 @@ "integrity": "sha512-VRQB+Q0L3YZWs45uRdpN9oWr82meL/8TrJ6faoKT5tp0uub2l/aRMhtm5fo68h7kjYKH60f9/bay1nF7ZpTW5g==", "dev": true }, + "@types/node-fetch": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.1.2.tgz", + "integrity": "sha512-XroxUzLpKuL+CVkQqXlffRkEPi4Gh3Oui/mWyS7ztKiyqVxiU+h3imCW5I2NQmde5jK+3q++36/Q96cyRWsweg==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "JSONStream": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", @@ -691,9 +709,9 @@ } }, "combined-stream": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "version": "1.0.6", + "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "dev": true, "requires": { "delayed-stream": "~1.0.0" @@ -1187,13 +1205,13 @@ } }, "form-data": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.2.0.tgz", - "integrity": "sha1-ml47kpX5gLJiPPZPojixTOvKcHs=", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "dev": true, "requires": { "asynckit": "^0.4.0", - "combined-stream": "^1.0.5", + "combined-stream": "1.0.6", "mime-types": "^2.1.12" } }, @@ -2517,18 +2535,18 @@ } }, "mime-db": { - "version": "1.29.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.29.0.tgz", - "integrity": "sha1-SNJtI1WJZRcErFkWygYAGRQmaHg=", + "version": "1.36.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", + "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==", "dev": true }, "mime-types": { - "version": "2.1.16", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.16.tgz", - "integrity": "sha1-K4WKUuXs1RbbiXrCvodIeDBpjiM=", + "version": "2.1.20", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", + "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", "dev": true, "requires": { - "mime-db": "~1.29.0" + "mime-db": "~1.36.0" } }, "min-document": { @@ -2652,6 +2670,12 @@ "dev": true, "optional": true }, + "node-fetch": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz", + "integrity": "sha512-OayFWziIxiHY8bCUyLX6sTpDH8Jsbp4FfYd1j1f7vZyfgkcOnAyM4oQR16f8a0s7Gl/viMGRey8eScYk4V4EZA==", + "dev": true + }, "node-libs-browser": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-0.7.0.tgz", diff --git a/samples/client/petstore/typescript-fetch/tests/default/package.json b/samples/client/petstore/typescript-fetch/tests/default/package.json index 96ac38788f23..965353b0876e 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/package.json +++ b/samples/client/petstore/typescript-fetch/tests/default/package.json @@ -7,18 +7,22 @@ }, "scripts": { "prepublish": "npm install ../../builds/with-npm-version && npm run build && npm run webpack && npm run browserify", - "test": "mocha test/*.ts --compilers ts:ts-node/register --timeout 10000", + "test": "mocha test/*.ts --compilers ts:ts-node/register --require mocks.ts --timeout 10000", "build": "tsc", "webpack": "webpack", "browserify": "browserify test -p [ tsify ] > ./dist/test.browserify-bundle.js" }, "devDependencies": { "@types/chai": "^4.0.1", + "@types/form-data": "^2.2.1", "@types/isomorphic-fetch": "0.0.34", "@types/mocha": "^2.2.41", "@types/node": "^8.0.14", + "@types/node-fetch": "^2.1.2", "browserify": "^14.4.0", + "form-data": "^2.3.2", "mocha": "^3.4.2", + "node-fetch": "^2.2.0", "ts-loader": "^2.3.0", "tsify": "^3.0.1", "typescript": "^2.4.1", diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts index 1deeede2b6e0..d5680c1e1de3 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; import { PetApi, Pet, Category } from '@swagger/typescript-fetch-petstore'; +import { config } from '../configuration'; describe('PetApi', () => { @@ -11,7 +12,7 @@ describe('PetApi', () => { const fixture: Pet = createTestFixture(); beforeEach(() => { - api = new PetApi(); + api = new PetApi(config); }); it('should add and delete Pet', () => { diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts index 3016b8f65094..3f00b1c39c5e 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; import { StoreApi } from '@swagger/typescript-fetch-petstore'; +import { config } from '../configuration'; describe('StoreApi', function () { @@ -9,7 +10,7 @@ describe('StoreApi', function () { let api: StoreApi; beforeEach(function () { - api = new StoreApi(); + api = new StoreApi(config); }); it('should get inventory', function () { diff --git a/samples/client/petstore/typescript-fetch/tests/default/tsconfig.json b/samples/client/petstore/typescript-fetch/tests/default/tsconfig.json index 6524f781742b..3470aabd0c3c 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/tsconfig.json +++ b/samples/client/petstore/typescript-fetch/tests/default/tsconfig.json @@ -6,7 +6,8 @@ "sourceMap": false, "outDir": "dist", "types": [ - "mocha" + "mocha", + "node" ], "lib": [ "es6", From f1258477fabc9690bf0661ea0002e63b1e68cc3d Mon Sep 17 00:00:00 2001 From: James Batt Date: Fri, 28 Sep 2018 13:45:04 +1000 Subject: [PATCH 30/39] changed to typescript version 2.4 --- .../src/main/resources/typescript-fetch/package.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache index 99bd327a22f0..3e3c2cea19df 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache @@ -10,7 +10,7 @@ "prepublishOnly": "npm run build" }, "devDependencies": { - "typescript": "^2.9" + "typescript": "^2.4" }{{#npmRepository}},{{/npmRepository}} {{#npmRepository}} "publishConfig":{ From 691bad003327b91448c5a1ce755aecc1376bfb04 Mon Sep 17 00:00:00 2001 From: James Batt Date: Fri, 28 Sep 2018 14:24:44 +1000 Subject: [PATCH 31/39] updated samples --- .../petstore/typescript-fetch/builds/es6-target/package.json | 2 +- .../typescript-fetch/builds/with-npm-version/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/package.json b/samples/client/petstore/typescript-fetch/builds/es6-target/package.json index cdac1209c010..d6873c34ad45 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/package.json +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/package.json @@ -10,7 +10,7 @@ "prepublishOnly": "npm run build" }, "devDependencies": { - "typescript": "^2.9" + "typescript": "^2.4" }, "publishConfig":{ "registry":"https://skimdb.npmjs.com/registry" diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json index cdac1209c010..d6873c34ad45 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json @@ -10,7 +10,7 @@ "prepublishOnly": "npm run build" }, "devDependencies": { - "typescript": "^2.9" + "typescript": "^2.4" }, "publishConfig":{ "registry":"https://skimdb.npmjs.com/registry" From 6a6e9ae61458c33a73f66aec1ad5b0a9a14ad01e Mon Sep 17 00:00:00 2001 From: James Batt Date: Fri, 28 Sep 2018 21:37:28 +1000 Subject: [PATCH 32/39] support for optional properties being null, undefined or omitted --- .../typescript-fetch/modelGeneric.mustache | 17 ++++++++++++++--- .../resources/typescript-fetch/runtime.mustache | 5 +++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 51900be63ec5..407105ec3188 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -1,3 +1,4 @@ +import { exists } from '../runtime'; {{#hasImports}} import { {{#imports}} @@ -32,14 +33,24 @@ export function {{classname}}FromJSON(json: any): {{classname}} { return { {{#vars}} {{#isPrimitiveType}} - '{{name}}': {{#isDate}}{{^required}}json['{{baseName}}'] === undefined ? undefined : {{/required}}new Date(json['{{baseName}}']){{/isDate}}{{#isDateTime}}{{^required}}json['{{baseName}}'] === undefined ? undefined : {{/required}}new Date(json['{{baseName}}']){{/isDateTime}}{{^isDate}}{{^isDateTime}}json['{{baseName}}']{{/isDateTime}}{{/isDate}}, + {{#isDate}} + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}new Date(json['{{baseName}}']), + {{/isDate}} + {{#isDateTime}} + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}new Date(json['{{baseName}}']), + {{/isDateTime}} + {{^isDate}} + {{^isDateTime}} + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}json['{{baseName}}'], + {{/isDateTime}} + {{/isDate}} {{/isPrimitiveType}} {{^isPrimitiveType}} {{#isContainer}} - '{{name}}': (json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}(json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON), {{/isContainer}} {{^isContainer}} - '{{name}}': {{datatype}}FromJSON(json['{{baseName}}']), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}{{datatype}}FromJSON(json['{{baseName}}']), {{/isContainer}} {{/isPrimitiveType}} {{/vars}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index eb9769210898..1611e1b3f9a8 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -178,6 +178,11 @@ export interface RequestOpts { body?: HTTPBody; } +export function exists(json: any, key: string) { + const value = json['key']; + return value !== null && value !== undefined; +} + function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { From 43f0db2349b8ac9c32ef342b7e191bd23a1ea9fe Mon Sep 17 00:00:00 2001 From: James Batt Date: Fri, 28 Sep 2018 21:37:49 +1000 Subject: [PATCH 33/39] updated samples --- .../builds/default/models/ApiResponse.ts | 7 ++++--- .../builds/default/models/Category.ts | 5 +++-- .../builds/default/models/Order.ts | 13 +++++++------ .../builds/default/models/Pet.ts | 9 +++++---- .../builds/default/models/Tag.ts | 5 +++-- .../builds/default/models/User.ts | 17 +++++++++-------- .../typescript-fetch/builds/default/runtime.ts | 5 +++++ .../builds/es6-target/models/ApiResponse.ts | 7 ++++--- .../builds/es6-target/models/Category.ts | 5 +++-- .../builds/es6-target/models/Order.ts | 13 +++++++------ .../builds/es6-target/models/Pet.ts | 9 +++++---- .../builds/es6-target/models/Tag.ts | 5 +++-- .../builds/es6-target/models/User.ts | 17 +++++++++-------- .../builds/es6-target/runtime.ts | 5 +++++ .../with-interfaces/models/ApiResponse.ts | 7 ++++--- .../builds/with-interfaces/models/Category.ts | 5 +++-- .../builds/with-interfaces/models/Order.ts | 13 +++++++------ .../builds/with-interfaces/models/Pet.ts | 9 +++++---- .../builds/with-interfaces/models/Tag.ts | 5 +++-- .../builds/with-interfaces/models/User.ts | 17 +++++++++-------- .../builds/with-interfaces/runtime.ts | 5 +++++ .../with-npm-version/models/ApiResponse.ts | 7 ++++--- .../builds/with-npm-version/models/Category.ts | 5 +++-- .../builds/with-npm-version/models/Order.ts | 13 +++++++------ .../builds/with-npm-version/models/Pet.ts | 9 +++++---- .../builds/with-npm-version/models/Tag.ts | 5 +++-- .../builds/with-npm-version/models/User.ts | 17 +++++++++-------- .../builds/with-npm-version/runtime.ts | 5 +++++ 28 files changed, 144 insertions(+), 100 deletions(-) diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts index 0ead72296825..2275473e610b 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/ApiResponse.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * Describes the result of uploading an image resource * @export @@ -39,9 +40,9 @@ export interface ApiResponse { export function ApiResponseFromJSON(json: any): ApiResponse { return { - 'code': json['code'], - 'type': json['type'], - 'message': json['message'], + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts index 5790eddf0496..0c2fa5ccdcd8 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A category for a pet * @export @@ -33,8 +34,8 @@ export interface Category { export function CategoryFromJSON(json: any): Category { return { - 'id': json['id'], - 'name': json['name'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts index 6266cb5efdc3..6a77a95173d4 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * An order for a pets from the pet store * @export @@ -57,12 +58,12 @@ export interface Order { export function OrderFromJSON(json: any): Order { return { - 'id': json['id'], - 'petId': json['petId'], - 'quantity': json['quantity'], - 'shipDate': json['shipDate'] === undefined ? undefined : new Date(json['shipDate']), - 'status': json['status'], - 'complete': json['complete'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'petId': !exists(json, 'petId') ? undefined : json['petId'], + 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], + 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'status': !exists(json, 'status') ? undefined : json['status'], + 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts index d0564c69cfd8..7090b2fab2e7 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; import { Category, CategoryFromJSON, @@ -66,12 +67,12 @@ export interface Pet { export function PetFromJSON(json: any): Pet { return { - 'id': json['id'], - 'category': CategoryFromJSON(json['category']), + 'id': !exists(json, 'id') ? undefined : json['id'], + 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': (json['tags'] as Array).map(TagFromJSON), - 'status': json['status'], + 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'status': !exists(json, 'status') ? undefined : json['status'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts index 538b27ad01b8..39f76e6ddc99 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A tag for a pet * @export @@ -33,8 +34,8 @@ export interface Tag { export function TagFromJSON(json: any): Tag { return { - 'id': json['id'], - 'name': json['name'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts index 4e0b3491eaed..6fe285d7222d 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A User who is purchasing from the pet store * @export @@ -69,14 +70,14 @@ export interface User { export function UserFromJSON(json: any): User { return { - 'id': json['id'], - 'username': json['username'], - 'firstName': json['firstName'], - 'lastName': json['lastName'], - 'email': json['email'], - 'password': json['password'], - 'phone': json['phone'], - 'userStatus': json['userStatus'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'username': !exists(json, 'username') ? undefined : json['username'], + 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], + 'lastName': !exists(json, 'lastName') ? undefined : json['lastName'], + 'email': !exists(json, 'email') ? undefined : json['email'], + 'password': !exists(json, 'password') ? undefined : json['password'], + 'phone': !exists(json, 'phone') ? undefined : json['phone'], + 'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index eded6cd0e398..33355cd4657e 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -189,6 +189,11 @@ export interface RequestOpts { body?: HTTPBody; } +export function exists(json: any, key: string) { + const value = json['key']; + return value !== null && value !== undefined; +} + function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts index 0ead72296825..2275473e610b 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ApiResponse.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * Describes the result of uploading an image resource * @export @@ -39,9 +40,9 @@ export interface ApiResponse { export function ApiResponseFromJSON(json: any): ApiResponse { return { - 'code': json['code'], - 'type': json['type'], - 'message': json['message'], + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts index 5790eddf0496..0c2fa5ccdcd8 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A category for a pet * @export @@ -33,8 +34,8 @@ export interface Category { export function CategoryFromJSON(json: any): Category { return { - 'id': json['id'], - 'name': json['name'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts index 6266cb5efdc3..6a77a95173d4 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * An order for a pets from the pet store * @export @@ -57,12 +58,12 @@ export interface Order { export function OrderFromJSON(json: any): Order { return { - 'id': json['id'], - 'petId': json['petId'], - 'quantity': json['quantity'], - 'shipDate': json['shipDate'] === undefined ? undefined : new Date(json['shipDate']), - 'status': json['status'], - 'complete': json['complete'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'petId': !exists(json, 'petId') ? undefined : json['petId'], + 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], + 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'status': !exists(json, 'status') ? undefined : json['status'], + 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts index d0564c69cfd8..7090b2fab2e7 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; import { Category, CategoryFromJSON, @@ -66,12 +67,12 @@ export interface Pet { export function PetFromJSON(json: any): Pet { return { - 'id': json['id'], - 'category': CategoryFromJSON(json['category']), + 'id': !exists(json, 'id') ? undefined : json['id'], + 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': (json['tags'] as Array).map(TagFromJSON), - 'status': json['status'], + 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'status': !exists(json, 'status') ? undefined : json['status'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts index 538b27ad01b8..39f76e6ddc99 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A tag for a pet * @export @@ -33,8 +34,8 @@ export interface Tag { export function TagFromJSON(json: any): Tag { return { - 'id': json['id'], - 'name': json['name'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts index 4e0b3491eaed..6fe285d7222d 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A User who is purchasing from the pet store * @export @@ -69,14 +70,14 @@ export interface User { export function UserFromJSON(json: any): User { return { - 'id': json['id'], - 'username': json['username'], - 'firstName': json['firstName'], - 'lastName': json['lastName'], - 'email': json['email'], - 'password': json['password'], - 'phone': json['phone'], - 'userStatus': json['userStatus'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'username': !exists(json, 'username') ? undefined : json['username'], + 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], + 'lastName': !exists(json, 'lastName') ? undefined : json['lastName'], + 'email': !exists(json, 'email') ? undefined : json['email'], + 'password': !exists(json, 'password') ? undefined : json['password'], + 'phone': !exists(json, 'phone') ? undefined : json['phone'], + 'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts index eded6cd0e398..33355cd4657e 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts @@ -189,6 +189,11 @@ export interface RequestOpts { body?: HTTPBody; } +export function exists(json: any, key: string) { + const value = json['key']; + return value !== null && value !== undefined; +} + function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts index 0ead72296825..2275473e610b 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ApiResponse.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * Describes the result of uploading an image resource * @export @@ -39,9 +40,9 @@ export interface ApiResponse { export function ApiResponseFromJSON(json: any): ApiResponse { return { - 'code': json['code'], - 'type': json['type'], - 'message': json['message'], + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts index 5790eddf0496..0c2fa5ccdcd8 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A category for a pet * @export @@ -33,8 +34,8 @@ export interface Category { export function CategoryFromJSON(json: any): Category { return { - 'id': json['id'], - 'name': json['name'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts index 6266cb5efdc3..6a77a95173d4 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * An order for a pets from the pet store * @export @@ -57,12 +58,12 @@ export interface Order { export function OrderFromJSON(json: any): Order { return { - 'id': json['id'], - 'petId': json['petId'], - 'quantity': json['quantity'], - 'shipDate': json['shipDate'] === undefined ? undefined : new Date(json['shipDate']), - 'status': json['status'], - 'complete': json['complete'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'petId': !exists(json, 'petId') ? undefined : json['petId'], + 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], + 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'status': !exists(json, 'status') ? undefined : json['status'], + 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts index d0564c69cfd8..7090b2fab2e7 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; import { Category, CategoryFromJSON, @@ -66,12 +67,12 @@ export interface Pet { export function PetFromJSON(json: any): Pet { return { - 'id': json['id'], - 'category': CategoryFromJSON(json['category']), + 'id': !exists(json, 'id') ? undefined : json['id'], + 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': (json['tags'] as Array).map(TagFromJSON), - 'status': json['status'], + 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'status': !exists(json, 'status') ? undefined : json['status'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts index 538b27ad01b8..39f76e6ddc99 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A tag for a pet * @export @@ -33,8 +34,8 @@ export interface Tag { export function TagFromJSON(json: any): Tag { return { - 'id': json['id'], - 'name': json['name'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts index 4e0b3491eaed..6fe285d7222d 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A User who is purchasing from the pet store * @export @@ -69,14 +70,14 @@ export interface User { export function UserFromJSON(json: any): User { return { - 'id': json['id'], - 'username': json['username'], - 'firstName': json['firstName'], - 'lastName': json['lastName'], - 'email': json['email'], - 'password': json['password'], - 'phone': json['phone'], - 'userStatus': json['userStatus'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'username': !exists(json, 'username') ? undefined : json['username'], + 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], + 'lastName': !exists(json, 'lastName') ? undefined : json['lastName'], + 'email': !exists(json, 'email') ? undefined : json['email'], + 'password': !exists(json, 'password') ? undefined : json['password'], + 'phone': !exists(json, 'phone') ? undefined : json['phone'], + 'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index eded6cd0e398..33355cd4657e 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -189,6 +189,11 @@ export interface RequestOpts { body?: HTTPBody; } +export function exists(json: any, key: string) { + const value = json['key']; + return value !== null && value !== undefined; +} + function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts index 0ead72296825..2275473e610b 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ApiResponse.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * Describes the result of uploading an image resource * @export @@ -39,9 +40,9 @@ export interface ApiResponse { export function ApiResponseFromJSON(json: any): ApiResponse { return { - 'code': json['code'], - 'type': json['type'], - 'message': json['message'], + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts index 5790eddf0496..0c2fa5ccdcd8 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A category for a pet * @export @@ -33,8 +34,8 @@ export interface Category { export function CategoryFromJSON(json: any): Category { return { - 'id': json['id'], - 'name': json['name'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts index 6266cb5efdc3..6a77a95173d4 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * An order for a pets from the pet store * @export @@ -57,12 +58,12 @@ export interface Order { export function OrderFromJSON(json: any): Order { return { - 'id': json['id'], - 'petId': json['petId'], - 'quantity': json['quantity'], - 'shipDate': json['shipDate'] === undefined ? undefined : new Date(json['shipDate']), - 'status': json['status'], - 'complete': json['complete'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'petId': !exists(json, 'petId') ? undefined : json['petId'], + 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], + 'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']), + 'status': !exists(json, 'status') ? undefined : json['status'], + 'complete': !exists(json, 'complete') ? undefined : json['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts index d0564c69cfd8..7090b2fab2e7 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; import { Category, CategoryFromJSON, @@ -66,12 +67,12 @@ export interface Pet { export function PetFromJSON(json: any): Pet { return { - 'id': json['id'], - 'category': CategoryFromJSON(json['category']), + 'id': !exists(json, 'id') ? undefined : json['id'], + 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], 'photoUrls': json['photoUrls'], - 'tags': (json['tags'] as Array).map(TagFromJSON), - 'status': json['status'], + 'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array).map(TagFromJSON), + 'status': !exists(json, 'status') ? undefined : json['status'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts index 538b27ad01b8..39f76e6ddc99 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A tag for a pet * @export @@ -33,8 +34,8 @@ export interface Tag { export function TagFromJSON(json: any): Tag { return { - 'id': json['id'], - 'name': json['name'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts index 4e0b3491eaed..6fe285d7222d 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts @@ -11,6 +11,7 @@ * Do not edit the class manually. */ +import { exists } from '../runtime'; /** * A User who is purchasing from the pet store * @export @@ -69,14 +70,14 @@ export interface User { export function UserFromJSON(json: any): User { return { - 'id': json['id'], - 'username': json['username'], - 'firstName': json['firstName'], - 'lastName': json['lastName'], - 'email': json['email'], - 'password': json['password'], - 'phone': json['phone'], - 'userStatus': json['userStatus'], + 'id': !exists(json, 'id') ? undefined : json['id'], + 'username': !exists(json, 'username') ? undefined : json['username'], + 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], + 'lastName': !exists(json, 'lastName') ? undefined : json['lastName'], + 'email': !exists(json, 'email') ? undefined : json['email'], + 'password': !exists(json, 'password') ? undefined : json['password'], + 'phone': !exists(json, 'phone') ? undefined : json['phone'], + 'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts index eded6cd0e398..33355cd4657e 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts @@ -189,6 +189,11 @@ export interface RequestOpts { body?: HTTPBody; } +export function exists(json: any, key: string) { + const value = json['key']; + return value !== null && value !== undefined; +} + function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { From fc33670e3a027bbf6e5b1b3063a428d8f6c3e16a Mon Sep 17 00:00:00 2001 From: James Batt Date: Fri, 28 Sep 2018 23:15:35 +1000 Subject: [PATCH 34/39] bug fix --- .../src/main/resources/typescript-fetch/runtime.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 1611e1b3f9a8..ce15a46f5d70 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -179,7 +179,7 @@ export interface RequestOpts { } export function exists(json: any, key: string) { - const value = json['key']; + const value = json[key]; return value !== null && value !== undefined; } From 79408a908400a203475da6e2cbdbd0be3046e161 Mon Sep 17 00:00:00 2001 From: James Batt Date: Fri, 28 Sep 2018 23:50:09 +1000 Subject: [PATCH 35/39] bug fix --- .../tests/default/package-lock.json | 1043 ++++++++++++++++- 1 file changed, 1042 insertions(+), 1 deletion(-) diff --git a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json index 53e18eee6f00..cec588a82c8e 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json +++ b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json @@ -5,7 +5,1048 @@ "requires": true, "dependencies": { "@swagger/typescript-fetch-petstore": { - "version": "file:../../builds/with-npm-version" + "version": "file:../../builds/with-npm-version", + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "bundled": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "arr-diff": { + "version": "4.0.0", + "bundled": true + }, + "arr-flatten": { + "version": "1.1.0", + "bundled": true + }, + "arr-union": { + "version": "3.1.0", + "bundled": true + }, + "array-unique": { + "version": "0.3.2", + "bundled": true + }, + "assign-symbols": { + "version": "1.0.0", + "bundled": true + }, + "atob": { + "version": "2.1.2", + "bundled": true + }, + "base": { + "version": "0.11.2", + "bundled": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "bundled": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "bundled": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "bundled": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "bundled": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "big.js": { + "version": "3.2.0", + "bundled": true + }, + "braces": { + "version": "2.3.2", + "bundled": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "bundled": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "cache-base": { + "version": "1.0.1", + "bundled": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, + "chalk": { + "version": "2.4.1", + "bundled": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "class-utils": { + "version": "0.3.6", + "bundled": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "bundled": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "collection-visit": { + "version": "1.0.0", + "bundled": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "bundled": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "bundled": true + }, + "component-emitter": { + "version": "1.2.1", + "bundled": true + }, + "copy-descriptor": { + "version": "0.1.1", + "bundled": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "requires": { + "ms": "2.0.0" + } + }, + "decode-uri-component": { + "version": "0.2.0", + "bundled": true + }, + "define-property": { + "version": "2.0.2", + "bundled": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "bundled": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "bundled": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "bundled": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "emojis-list": { + "version": "2.1.0", + "bundled": true + }, + "encoding": { + "version": "0.1.12", + "bundled": true, + "requires": { + "iconv-lite": "~0.4.13" + } + }, + "enhanced-resolve": { + "version": "4.1.0", + "bundled": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.4.0", + "tapable": "^1.0.0" + } + }, + "errno": { + "version": "0.1.7", + "bundled": true, + "requires": { + "prr": "~1.0.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "bundled": true + }, + "expand-brackets": { + "version": "2.1.4", + "bundled": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "bundled": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "bundled": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "extend-shallow": { + "version": "3.0.2", + "bundled": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "bundled": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "extglob": { + "version": "2.0.4", + "bundled": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "bundled": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "bundled": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "bundled": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "bundled": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "bundled": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "fill-range": { + "version": "4.0.0", + "bundled": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "bundled": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "for-in": { + "version": "1.0.2", + "bundled": true + }, + "fragment-cache": { + "version": "0.2.1", + "bundled": true, + "requires": { + "map-cache": "^0.2.2" + } + }, + "get-value": { + "version": "2.0.6", + "bundled": true + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true + }, + "has-flag": { + "version": "3.0.0", + "bundled": true + }, + "has-value": { + "version": "1.0.0", + "bundled": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "bundled": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "kind-of": { + "version": "4.0.0", + "bundled": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "iconv-lite": { + "version": "0.4.24", + "bundled": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "bundled": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "bundled": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-buffer": { + "version": "1.1.6", + "bundled": true + }, + "is-data-descriptor": { + "version": "0.1.4", + "bundled": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "bundled": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "bundled": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "bundled": true + } + } + }, + "is-extendable": { + "version": "0.1.1", + "bundled": true + }, + "is-number": { + "version": "3.0.0", + "bundled": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "bundled": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-plain-object": { + "version": "2.0.4", + "bundled": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-stream": { + "version": "1.1.0", + "bundled": true + }, + "is-windows": { + "version": "1.0.2", + "bundled": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true + }, + "isobject": { + "version": "3.0.1", + "bundled": true + }, + "json5": { + "version": "0.5.1", + "bundled": true + }, + "kind-of": { + "version": "6.0.2", + "bundled": true + }, + "loader-utils": { + "version": "1.1.0", + "bundled": true, + "requires": { + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0" + } + }, + "map-cache": { + "version": "0.2.2", + "bundled": true + }, + "map-visit": { + "version": "1.0.0", + "bundled": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "memory-fs": { + "version": "0.4.1", + "bundled": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "micromatch": { + "version": "3.1.10", + "bundled": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "mixin-deep": { + "version": "1.3.1", + "bundled": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "bundled": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "ms": { + "version": "2.0.0", + "bundled": true + }, + "nanomatch": { + "version": "1.2.13", + "bundled": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "node-fetch": { + "version": "1.7.3", + "bundled": true, + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + }, + "object-copy": { + "version": "0.1.0", + "bundled": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "bundled": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "bundled": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "object-visit": { + "version": "1.0.1", + "bundled": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.pick": { + "version": "1.3.0", + "bundled": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "pascalcase": { + "version": "0.1.1", + "bundled": true + }, + "portable-fetch": { + "version": "3.0.0", + "bundled": true, + "requires": { + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" + } + }, + "posix-character-classes": { + "version": "0.1.1", + "bundled": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true + }, + "prr": { + "version": "1.0.1", + "bundled": true + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "regex-not": { + "version": "1.0.2", + "bundled": true, + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + }, + "repeat-element": { + "version": "1.1.3", + "bundled": true + }, + "repeat-string": { + "version": "1.6.1", + "bundled": true + }, + "resolve-url": { + "version": "0.2.1", + "bundled": true + }, + "ret": { + "version": "0.1.15", + "bundled": true + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true + }, + "safe-regex": { + "version": "1.1.0", + "bundled": true, + "requires": { + "ret": "~0.1.10" + } + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true + }, + "semver": { + "version": "5.5.1", + "bundled": true + }, + "set-value": { + "version": "2.0.0", + "bundled": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "bundled": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "snapdragon": { + "version": "0.8.2", + "bundled": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "bundled": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "bundled": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "bundled": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "bundled": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "bundled": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "bundled": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "bundled": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "bundled": true, + "requires": { + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "bundled": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "source-map": { + "version": "0.5.7", + "bundled": true + }, + "source-map-resolve": { + "version": "0.5.2", + "bundled": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-url": { + "version": "0.4.0", + "bundled": true + }, + "split-string": { + "version": "3.1.0", + "bundled": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "static-extend": { + "version": "0.1.2", + "bundled": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "bundled": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "supports-color": { + "version": "5.5.0", + "bundled": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "tapable": { + "version": "1.1.0", + "bundled": true + }, + "to-object-path": { + "version": "0.3.0", + "bundled": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "bundled": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "bundled": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "bundled": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "ts-loader": { + "version": "5.2.0", + "bundled": true, + "requires": { + "chalk": "^2.3.0", + "enhanced-resolve": "^4.0.0", + "loader-utils": "^1.0.2", + "micromatch": "^3.1.4", + "semver": "^5.0.1" + } + }, + "typescript": { + "version": "2.9.2", + "bundled": true + }, + "union-value": { + "version": "1.0.0", + "bundled": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "bundled": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "set-value": { + "version": "0.4.3", + "bundled": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" + } + } + } + }, + "unset-value": { + "version": "1.0.0", + "bundled": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "bundled": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "bundled": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "bundled": true + } + } + }, + "urix": { + "version": "0.1.0", + "bundled": true + }, + "use": { + "version": "3.1.1", + "bundled": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true + }, + "whatwg-fetch": { + "version": "3.0.0", + "bundled": true + } + } }, "@types/chai": { "version": "4.0.2", From 6f121ccb46c93fa9f47649eb71edb997d27dc010 Mon Sep 17 00:00:00 2001 From: James Batt Date: Sat, 29 Sep 2018 13:46:12 +1000 Subject: [PATCH 36/39] updated samples --- .../client/petstore/typescript-fetch/builds/default/runtime.ts | 2 +- .../petstore/typescript-fetch/builds/es6-target/runtime.ts | 2 +- .../petstore/typescript-fetch/builds/with-interfaces/runtime.ts | 2 +- .../typescript-fetch/builds/with-npm-version/runtime.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 33355cd4657e..924d34da3706 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -190,7 +190,7 @@ export interface RequestOpts { } export function exists(json: any, key: string) { - const value = json['key']; + const value = json[key]; return value !== null && value !== undefined; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts index 33355cd4657e..924d34da3706 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts @@ -190,7 +190,7 @@ export interface RequestOpts { } export function exists(json: any, key: string) { - const value = json['key']; + const value = json[key]; return value !== null && value !== undefined; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 33355cd4657e..924d34da3706 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -190,7 +190,7 @@ export interface RequestOpts { } export function exists(json: any, key: string) { - const value = json['key']; + const value = json[key]; return value !== null && value !== undefined; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts index 33355cd4657e..924d34da3706 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts @@ -190,7 +190,7 @@ export interface RequestOpts { } export function exists(json: any, key: string) { - const value = json['key']; + const value = json[key]; return value !== null && value !== undefined; } From 05393c49453e8fc9341b9dab5f92c0d47d9971a3 Mon Sep 17 00:00:00 2001 From: James Batt Date: Mon, 15 Oct 2018 18:48:31 +1100 Subject: [PATCH 37/39] ran npm install in test project --- .../builds/with-npm-version/package-lock.json | 14 ++++++++++++++ .../builds/with-npm-version/package.json | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/package-lock.json diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package-lock.json b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package-lock.json new file mode 100644 index 000000000000..e8dc0d00b2f3 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package-lock.json @@ -0,0 +1,14 @@ +{ + "name": "@swagger/typescript-fetch-petstore", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "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 + } + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json index d6873c34ad45..59b60da2e855 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json @@ -5,14 +5,14 @@ "author": "OpenAPI-Generator", "main": "./dist/index.js", "typings": "./dist/index.d.ts", - "scripts" : { + "scripts": { "build": "tsc --outDir dist/", "prepublishOnly": "npm run build" }, "devDependencies": { "typescript": "^2.4" }, - "publishConfig":{ - "registry":"https://skimdb.npmjs.com/registry" + "publishConfig": { + "registry": "https://skimdb.npmjs.com/registry" } } From 889a61fbdcab4da348b5d287cbb1a898ec989175 Mon Sep 17 00:00:00 2001 From: James Batt Date: Mon, 15 Oct 2018 20:20:23 +1100 Subject: [PATCH 38/39] patch to get tests running --- .../typescript-fetch/package.mustache | 2 +- .../builds/es6-target/package.json | 2 +- .../builds/with-npm-version/package.json | 8 +- .../tests/default/package-lock.json | 3606 +++++++++-------- .../tests/default/package.json | 4 +- 5 files changed, 1877 insertions(+), 1745 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache index 3e3c2cea19df..1abb2697c722 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache @@ -7,7 +7,7 @@ "typings": "./dist/index.d.ts", "scripts" : { "build": "tsc --outDir dist/", - "prepublishOnly": "npm run build" + "prepare": "npm run build" }, "devDependencies": { "typescript": "^2.4" diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/package.json b/samples/client/petstore/typescript-fetch/builds/es6-target/package.json index d6873c34ad45..6a7e0fb6ff40 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/package.json +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/package.json @@ -7,7 +7,7 @@ "typings": "./dist/index.d.ts", "scripts" : { "build": "tsc --outDir dist/", - "prepublishOnly": "npm run build" + "prepare": "npm run build" }, "devDependencies": { "typescript": "^2.4" diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json index 59b60da2e855..6a7e0fb6ff40 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json @@ -5,14 +5,14 @@ "author": "OpenAPI-Generator", "main": "./dist/index.js", "typings": "./dist/index.d.ts", - "scripts": { + "scripts" : { "build": "tsc --outDir dist/", - "prepublishOnly": "npm run build" + "prepare": "npm run build" }, "devDependencies": { "typescript": "^2.4" }, - "publishConfig": { - "registry": "https://skimdb.npmjs.com/registry" + "publishConfig":{ + "registry":"https://skimdb.npmjs.com/registry" } } diff --git a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json index cec588a82c8e..574f6929aecd 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json +++ b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json @@ -7,1051 +7,16 @@ "@swagger/typescript-fetch-petstore": { "version": "file:../../builds/with-npm-version", "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "bundled": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "arr-diff": { - "version": "4.0.0", - "bundled": true - }, - "arr-flatten": { - "version": "1.1.0", - "bundled": true - }, - "arr-union": { - "version": "3.1.0", - "bundled": true - }, - "array-unique": { - "version": "0.3.2", - "bundled": true - }, - "assign-symbols": { - "version": "1.0.0", - "bundled": true - }, - "atob": { - "version": "2.1.2", - "bundled": true - }, - "base": { - "version": "0.11.2", - "bundled": true, - "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "bundled": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "bundled": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "bundled": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "bundled": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "big.js": { - "version": "3.2.0", - "bundled": true - }, - "braces": { - "version": "2.3.2", - "bundled": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "bundled": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "cache-base": { - "version": "1.0.1", - "bundled": true, - "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - } - }, - "chalk": { - "version": "2.4.1", - "bundled": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "class-utils": { - "version": "0.3.6", - "bundled": true, - "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "bundled": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "collection-visit": { - "version": "1.0.0", - "bundled": true, - "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" - } - }, - "color-convert": { - "version": "1.9.3", - "bundled": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "bundled": true - }, - "component-emitter": { - "version": "1.2.1", - "bundled": true - }, - "copy-descriptor": { - "version": "0.1.1", - "bundled": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true - }, - "debug": { - "version": "2.6.9", - "bundled": true, - "requires": { - "ms": "2.0.0" - } - }, - "decode-uri-component": { - "version": "0.2.0", - "bundled": true - }, - "define-property": { - "version": "2.0.2", - "bundled": true, - "requires": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "bundled": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "bundled": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "bundled": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "emojis-list": { - "version": "2.1.0", - "bundled": true - }, - "encoding": { - "version": "0.1.12", - "bundled": true, - "requires": { - "iconv-lite": "~0.4.13" - } - }, - "enhanced-resolve": { - "version": "4.1.0", - "bundled": true, - "requires": { - "graceful-fs": "^4.1.2", - "memory-fs": "^0.4.0", - "tapable": "^1.0.0" - } - }, - "errno": { - "version": "0.1.7", - "bundled": true, - "requires": { - "prr": "~1.0.1" - } - }, - "escape-string-regexp": { - "version": "1.0.5", - "bundled": true - }, - "expand-brackets": { - "version": "2.1.4", - "bundled": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "bundled": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "bundled": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "extend-shallow": { - "version": "3.0.2", - "bundled": true, - "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "bundled": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "extglob": { - "version": "2.0.4", - "bundled": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "bundled": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "bundled": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "bundled": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "bundled": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "bundled": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "bundled": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "bundled": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "for-in": { - "version": "1.0.2", - "bundled": true - }, - "fragment-cache": { - "version": "0.2.1", - "bundled": true, - "requires": { - "map-cache": "^0.2.2" - } - }, - "get-value": { - "version": "2.0.6", - "bundled": true - }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true - }, - "has-flag": { - "version": "3.0.0", - "bundled": true - }, - "has-value": { - "version": "1.0.0", - "bundled": true, - "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "has-values": { - "version": "1.0.0", - "bundled": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "bundled": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "iconv-lite": { - "version": "0.4.24", - "bundled": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "bundled": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "bundled": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-buffer": { - "version": "1.1.6", - "bundled": true - }, - "is-data-descriptor": { - "version": "0.1.4", - "bundled": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "bundled": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "bundled": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "bundled": true - } - } - }, - "is-extendable": { - "version": "0.1.1", - "bundled": true - }, - "is-number": { - "version": "3.0.0", - "bundled": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "bundled": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-plain-object": { - "version": "2.0.4", - "bundled": true, - "requires": { - "isobject": "^3.0.1" - } - }, - "is-stream": { - "version": "1.1.0", - "bundled": true - }, - "is-windows": { - "version": "1.0.2", - "bundled": true - }, - "isarray": { - "version": "1.0.0", - "bundled": true - }, - "isobject": { - "version": "3.0.1", - "bundled": true - }, - "json5": { - "version": "0.5.1", - "bundled": true - }, - "kind-of": { - "version": "6.0.2", - "bundled": true - }, - "loader-utils": { - "version": "1.1.0", - "bundled": true, - "requires": { - "big.js": "^3.1.3", - "emojis-list": "^2.0.0", - "json5": "^0.5.0" - } - }, - "map-cache": { - "version": "0.2.2", - "bundled": true - }, - "map-visit": { - "version": "1.0.0", - "bundled": true, - "requires": { - "object-visit": "^1.0.0" - } - }, - "memory-fs": { - "version": "0.4.1", - "bundled": true, - "requires": { - "errno": "^0.1.3", - "readable-stream": "^2.0.1" - } - }, - "micromatch": { - "version": "3.1.10", - "bundled": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, - "mixin-deep": { - "version": "1.3.1", - "bundled": true, - "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "bundled": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "ms": { - "version": "2.0.0", - "bundled": true - }, - "nanomatch": { - "version": "1.2.13", - "bundled": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - } - }, - "node-fetch": { - "version": "1.7.3", - "bundled": true, - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } - }, - "object-copy": { - "version": "0.1.0", - "bundled": true, - "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "bundled": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "kind-of": { - "version": "3.2.2", - "bundled": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "object-visit": { - "version": "1.0.1", - "bundled": true, - "requires": { - "isobject": "^3.0.0" - } - }, - "object.pick": { - "version": "1.3.0", - "bundled": true, - "requires": { - "isobject": "^3.0.1" - } - }, - "pascalcase": { - "version": "0.1.1", - "bundled": true - }, - "portable-fetch": { - "version": "3.0.0", - "bundled": true, - "requires": { - "node-fetch": "^1.0.1", - "whatwg-fetch": ">=0.10.0" - } - }, - "posix-character-classes": { - "version": "0.1.1", - "bundled": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true - }, - "prr": { - "version": "1.0.1", - "bundled": true - }, - "readable-stream": { - "version": "2.3.6", - "bundled": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "regex-not": { - "version": "1.0.2", - "bundled": true, - "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" - } - }, - "repeat-element": { - "version": "1.1.3", - "bundled": true - }, - "repeat-string": { - "version": "1.6.1", - "bundled": true - }, - "resolve-url": { - "version": "0.2.1", - "bundled": true - }, - "ret": { - "version": "0.1.15", - "bundled": true - }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true - }, - "safe-regex": { - "version": "1.1.0", - "bundled": true, - "requires": { - "ret": "~0.1.10" - } - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true - }, - "semver": { - "version": "5.5.1", - "bundled": true - }, - "set-value": { - "version": "2.0.0", - "bundled": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "bundled": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "snapdragon": { - "version": "0.8.2", - "bundled": true, - "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "bundled": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "bundled": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "bundled": true, - "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "bundled": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "bundled": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "bundled": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "bundled": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "bundled": true, - "requires": { - "kind-of": "^3.2.0" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "bundled": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "source-map": { - "version": "0.5.7", - "bundled": true - }, - "source-map-resolve": { - "version": "0.5.2", - "bundled": true, - "requires": { - "atob": "^2.1.1", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, - "source-map-url": { - "version": "0.4.0", - "bundled": true - }, - "split-string": { - "version": "3.1.0", - "bundled": true, - "requires": { - "extend-shallow": "^3.0.0" - } - }, - "static-extend": { - "version": "0.1.2", - "bundled": true, - "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "bundled": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "string_decoder": { - "version": "1.1.1", - "bundled": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "supports-color": { - "version": "5.5.0", - "bundled": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "tapable": { - "version": "1.1.0", - "bundled": true - }, - "to-object-path": { - "version": "0.3.0", - "bundled": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "bundled": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "to-regex": { - "version": "3.0.2", - "bundled": true, - "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "bundled": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - }, - "ts-loader": { - "version": "5.2.0", - "bundled": true, - "requires": { - "chalk": "^2.3.0", - "enhanced-resolve": "^4.0.0", - "loader-utils": "^1.0.2", - "micromatch": "^3.1.4", - "semver": "^5.0.1" - } - }, "typescript": { "version": "2.9.2", "bundled": true - }, - "union-value": { - "version": "1.0.0", - "bundled": true, - "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "bundled": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "bundled": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } - } - }, - "unset-value": { - "version": "1.0.0", - "bundled": true, - "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "bundled": true, - "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "bundled": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "bundled": true - } - } - }, - "urix": { - "version": "0.1.0", - "bundled": true - }, - "use": { - "version": "3.1.1", - "bundled": true - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true - }, - "whatwg-fetch": { - "version": "3.0.0", - "bundled": true } } }, "@types/chai": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.0.2.tgz", - "integrity": "sha512-0pHNZTD0SpQhz1kUM4Muhgdn4acxq21kp726pZfWMmKYGbmmv8XkGTt3k/0QDklhTUYBD6hknZ/1YFokyP/G7Q==", + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz", + "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", "dev": true }, "@types/form-data": { @@ -1070,15 +35,15 @@ "dev": true }, "@types/mocha": { - "version": "2.2.41", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.41.tgz", - "integrity": "sha1-4nzwgXFT658nE7LT9saPHhw8pgg=", + "version": "2.2.48", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz", + "integrity": "sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==", "dev": true }, "@types/node": { - "version": "8.0.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.19.tgz", - "integrity": "sha512-VRQB+Q0L3YZWs45uRdpN9oWr82meL/8TrJ6faoKT5tp0uub2l/aRMhtm5fo68h7kjYKH60f9/bay1nF7ZpTW5g==", + "version": "8.10.36", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.36.tgz", + "integrity": "sha512-SL6KhfM7PTqiFmbCW3eVNwVBZ+88Mrzbuvn9olPsfv43mbiWaFY+nRcz/TGGku0/lc2FepdMbImdMY1JrQ+zbw==", "dev": true }, "@types/node-fetch": { @@ -1091,9 +56,9 @@ } }, "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", "dev": true, "requires": { "jsonparse": "^1.2.0", @@ -1101,15 +66,32 @@ } }, "abbrev": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", - "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true }, "acorn": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", - "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.2.tgz", + "integrity": "sha512-GXmKIvbrN3TV7aVqAzVFaMW8F8wzVX7voEBRO3bDA64+EX37YSayggRJP5Xig6HYHBkWKpFg9W5gg6orklubhg==", + "dev": true + }, + "acorn-node": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.6.0.tgz", + "integrity": "sha512-ZsysjEh+Y3i14f7YXCAKJy99RXbd56wHKYBzN4FlFtICIZyFpYwK6OwNJhcz8A/FMtxoUZkJofH1v9KIfNgWmw==", + "dev": true, + "requires": { + "acorn": "^6.0.1", + "acorn-walk": "^6.0.1", + "xtend": "^4.0.1" + } + }, + "acorn-walk": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.0.tgz", + "integrity": "sha512-ugTb7Lq7u4GfWSqqpwE0bGyoBZNMTok/zDBXxfEG0QM50jNlGhIWjRC1pPN7bvV1anhF+bs+/gNcRw+o55Evbg==", "dev": true }, "agent-base": { @@ -1124,7 +106,7 @@ "dependencies": { "semver": { "version": "5.0.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz", + "resolved": "http://registry.npmjs.org/semver/-/semver-5.0.3.tgz", "integrity": "sha1-d0Zt5YnNXTyV8TiqeLxWmjy10no=", "dev": true } @@ -1169,9 +151,9 @@ "dev": true }, "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "requires": { "color-convert": "^1.9.0" } @@ -1213,6 +195,12 @@ "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, "array-filter": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz", @@ -1249,9 +237,9 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" }, "asn1.js": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", - "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, "requires": { "bn.js": "^4.0.0", @@ -1266,25 +254,39 @@ "dev": true, "requires": { "util": "0.10.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "requires": { + "inherits": "2.0.1" + } + } } }, "assertion-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz", - "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" }, - "astw": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz", - "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", - "dev": true, - "requires": { - "acorn": "^4.0.3" - } + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true }, "async": { "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "resolved": "http://registry.npmjs.org/async/-/async-1.5.2.tgz", "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, @@ -1300,46 +302,113 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "dev": true + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "base64-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", - "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", "dev": true }, "big.js": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz", - "integrity": "sha1-TK2iGTZS6zyp7I5VyQFWacmAaXg=", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", + "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", "dev": true }, "binary-extensions": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.9.0.tgz", - "integrity": "sha1-ZlBsFs5vTWkopbPNajPKQelB43s=", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.12.0.tgz", + "integrity": "sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg==", "dev": true }, "bluebird": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", - "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.2.tgz", + "integrity": "sha512-dhHTWMI7kMx5whMQntl7Vr9C6BvV10lFXDAasnqnrMYhXVCzzk6IO9Fo2L75jXHT07WrOngL1WDXOp+yYS91Yg==", "dev": true }, "bn.js": { - "version": "4.11.7", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.7.tgz", - "integrity": "sha512-LxFiV5mefv0ley0SzqkOPR1bC4EbpPx8LkOz5vMe/Yi15t5hzwgO/G+tc7wOtL4PZTYjwHu8JnEiSLumuSjSfA==", + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", "dev": true }, "boxen": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.2.1.tgz", - "integrity": "sha1-DxHn/jRO25OXl3/BPt5/ZNlWSB0=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz", + "integrity": "sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw==", "dev": true, "requires": { "ansi-align": "^2.0.0", @@ -1348,13 +417,13 @@ "cli-boxes": "^1.0.0", "string-width": "^2.0.0", "term-size": "^1.2.0", - "widest-line": "^1.0.0" + "widest-line": "^2.0.0" } }, "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "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", @@ -1379,22 +448,23 @@ "dev": true }, "browser-pack": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.0.2.tgz", - "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", + "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, "requires": { "JSONStream": "^1.0.3", - "combine-source-map": "~0.7.1", + "combine-source-map": "~0.8.0", "defined": "^1.0.0", + "safe-buffer": "^5.1.1", "through2": "^2.0.0", "umd": "^3.0.0" } }, "browser-resolve": { - "version": "1.11.2", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz", - "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=", + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", + "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", "dev": true, "requires": { "resolve": "1.1.7" @@ -1415,16 +485,16 @@ "dev": true }, "browserify": { - "version": "14.4.0", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.4.0.tgz", - "integrity": "sha1-CJo0Y69Y0OSNjNQHCz90ZU1avKk=", + "version": "14.5.0", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.5.0.tgz", + "integrity": "sha512-gKfOsNQv/toWz+60nSPfYzuwSEdzvV2WdxrVPUbPD/qui44rAkB3t3muNtmmGYHqrG56FGwX9SUEQmzNLAeS7g==", "dev": true, "requires": { "JSONStream": "^1.0.3", "assert": "^1.4.0", "browser-pack": "^6.0.1", "browser-resolve": "^1.11.0", - "browserify-zlib": "~0.1.2", + "browserify-zlib": "~0.2.0", "buffer": "^5.0.2", "cached-path-relative": "^1.0.0", "concat-stream": "~1.5.1", @@ -1444,7 +514,7 @@ "insert-module-globals": "^7.0.0", "labeled-stream-splicer": "^2.0.0", "module-deps": "^4.0.8", - "os-browserify": "~0.1.1", + "os-browserify": "~0.3.0", "parents": "^1.0.1", "path-browserify": "~0.0.0", "process": "~0.11.0", @@ -1470,22 +540,23 @@ } }, "browserify-aes": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.0.6.tgz", - "integrity": "sha1-Xncl297x/Vkw1OurSFZ85FHEigo=", + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { - "buffer-xor": "^1.0.2", + "buffer-xor": "^1.0.3", "cipher-base": "^1.0.0", "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.0", - "inherits": "^2.0.1" + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "browserify-cipher": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", - "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, "requires": { "browserify-aes": "^1.0.4", @@ -1494,19 +565,20 @@ } }, "browserify-des": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", - "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, "requires": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" } }, "browserify-rsa": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { @@ -1530,24 +602,30 @@ } }, "browserify-zlib": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", - "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, "requires": { - "pako": "~0.2.0" + "pako": "~1.0.5" } }, "buffer": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.7.tgz", - "integrity": "sha512-NeeHXWh5pCbPQCt2/6rLvXqapZfVsqw/YgRgaHpT3H9Uzgs+S0lSg5SQzouIuDvcmlQRqBe8hOO2scKCu3cxrg==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", + "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", "dev": true, "requires": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" } }, + "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 + }, "buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", @@ -1560,6 +638,23 @@ "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, "cached-path-relative": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz", @@ -1573,9 +668,9 @@ "dev": true }, "capture-stack-trace": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz", - "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz", + "integrity": "sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw==", "dev": true }, "center-align": { @@ -1589,41 +684,26 @@ } }, "chai": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.0.tgz", - "integrity": "sha1-MxoDkbVcOvh0CunDt0WLwcOAXm0=", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^2.0.1", + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", "get-func-name": "^2.0.0", - "pathval": "^1.0.0", - "type-detect": "^4.0.0" + "pathval": "^1.1.0", + "type-detect": "^4.0.5" } }, "chalk": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.0.1.tgz", - "integrity": "sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0g==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "requires": { - "ansi-styles": "^3.1.0", + "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", - "supports-color": "^4.0.0" - }, - "dependencies": { - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" - }, - "supports-color": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.1.tgz", - "integrity": "sha512-qxzYsob3yv6U+xMzPrv170y8AwGP7i74g+pbixCfD6rgso8BscLT2qXIuz6TpOaiJZ3mFgT5O9lyT9nMU4LfaA==", - "requires": { - "has-flag": "^2.0.0" - } - } + "supports-color": "^5.3.0" } }, "check-error": { @@ -1648,6 +728,12 @@ "readdirp": "^2.0.0" } }, + "ci-info": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.6.0.tgz", + "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==", + "dev": true + }, "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", @@ -1658,6 +744,29 @@ "safe-buffer": "^5.0.1" } }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, "cli-boxes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", @@ -1703,23 +812,27 @@ } }, "clone": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", - "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "dev": true }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } }, "color-convert": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", - "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "requires": { - "color-name": "^1.1.1" + "color-name": "1.1.3" } }, "color-name": { @@ -1738,9 +851,9 @@ } }, "combine-source-map": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.7.2.tgz", - "integrity": "sha1-CHAxKFazB6h8xKxIbzqaYq7MwJ4=", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", + "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, "requires": { "convert-source-map": "~1.1.0", @@ -1760,13 +873,19 @@ }, "commander": { "version": "2.9.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.9.0.tgz", "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "dev": true, "requires": { "graceful-readlink": ">= 1.0.0" } }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1784,9 +903,15 @@ "typedarray": "~0.0.5" }, "dependencies": { + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, "readable-stream": { "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", "dev": true, "requires": { @@ -1807,9 +932,9 @@ } }, "configstore": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.1.tgz", - "integrity": "sha512-5oNkD/L++l0O6xGXxb1EWS7SivtjfGQlRyxJsYgE0Z495/L81e2h4/d3r969hoPXuFItzNOKMtsXgYG4c7dYvw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz", + "integrity": "sha512-vtv5HtGjcYUgFrXc6Kx747B83MRRVS5R1VTEQoXvuP+kMI+if6uywV0nDGoiydJRy4yk7h9od5Og0kxx4zUXmw==", "dev": true, "requires": { "dot-prop": "^4.1.0", @@ -1837,10 +962,16 @@ }, "convert-source-map": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", "dev": true }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -1848,9 +979,9 @@ "dev": true }, "create-ecdh": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz", - "integrity": "sha1-iIxyNZbN92EvZJgjPuvXo1MBc30=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", + "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, "requires": { "bn.js": "^4.1.0", @@ -1867,21 +998,22 @@ } }, "create-hash": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", - "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", - "ripemd160": "^2.0.0", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", "sha.js": "^2.4.0" } }, "create-hmac": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.6.tgz", - "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", + "version": "1.1.7", + "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { "cipher-base": "^1.0.3", @@ -1904,9 +1036,9 @@ } }, "crypto-browserify": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.1.tgz", - "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { "browserify-cipher": "^1.0.0", @@ -1918,7 +1050,8 @@ "inherits": "^2.0.1", "pbkdf2": "^3.0.3", "public-encrypt": "^4.0.0", - "randombytes": "^2.0.0" + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" } }, "crypto-random-string": { @@ -1948,25 +1081,24 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, "deep-eql": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-2.0.2.tgz", - "integrity": "sha1-sbrAblbwp2d3aG1Qyf63XC7XZ5o=", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", "requires": { - "type-detect": "^3.0.0" - }, - "dependencies": { - "type-detect": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-3.0.0.tgz", - "integrity": "sha1-RtDMhVOrt7E6NSsNbeov1Y8tm1U=" - } + "type-detect": "^4.0.0" } }, "deep-extend": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", - "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "dev": true }, "defaults": { @@ -1978,6 +1110,53 @@ "clone": "^1.0.2" } }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", @@ -2019,24 +1198,32 @@ "dev": true }, "detective": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.5.0.tgz", - "integrity": "sha1-blqMaybmx6JUsca210kNmOyR7dE=", + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", + "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", "dev": true, "requires": { - "acorn": "^4.0.3", + "acorn": "^5.2.1", "defined": "^1.0.0" + }, + "dependencies": { + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", + "dev": true + } } }, "diff": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", - "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=" + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" }, "diffie-hellman": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz", - "integrity": "sha1-tYNXOScM/ias9jIJn97SoH8gnl4=", + "version": "5.0.3", + "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { "bn.js": "^4.1.0", @@ -2044,12 +1231,6 @@ "randombytes": "^2.0.0" } }, - "dom-walk": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", - "integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=", - "dev": true - }, "domain-browser": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", @@ -2087,9 +1268,9 @@ "dev": true }, "elliptic": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", - "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", + "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", "dev": true, "requires": { "bn.js": "^4.4.0", @@ -2120,18 +1301,18 @@ } }, "errno": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz", - "integrity": "sha1-uJbiOp5ei6M4cfyZar02NfyaHH0=", + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", "dev": true, "requires": { - "prr": "~0.0.0" + "prr": "~1.0.1" } }, "error-ex": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", - "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", "dev": true, "requires": { "is-arrayish": "^0.2.1" @@ -2144,17 +1325,18 @@ }, "events": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", "dev": true }, "evp_bytestokey": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.0.tgz", - "integrity": "sha1-SXtmrZ/vZc18CKYYCCS6FHa2blM=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { - "create-hash": "^1.1.1" + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" } }, "execa": { @@ -2197,11 +1379,32 @@ } }, "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, "extglob": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", @@ -2218,16 +1421,27 @@ "dev": true }, "fill-range": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", - "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", + "integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==", "dev": true, "requires": { "is-number": "^2.1.0", "isobject": "^2.0.0", - "randomatic": "^1.1.3", + "randomatic": "^3.0.0", "repeat-element": "^1.1.2", "repeat-string": "^1.5.2" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } } }, "for-in": { @@ -2256,6 +1470,15 @@ "mime-types": "^2.1.12" } }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "^0.2.2" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2303,12 +1526,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2323,17 +1548,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2450,7 +1678,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2462,6 +1691,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2476,6 +1706,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2483,12 +1714,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2507,6 +1740,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2587,7 +1821,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2599,6 +1834,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2720,6 +1956,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2792,9 +2029,15 @@ } }, "function-bind": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.0.tgz", - "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "get-assigned-identifiers": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", + "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", "dev": true }, "get-func-name": { @@ -2804,14 +2047,20 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -2841,27 +2090,18 @@ "is-glob": "^2.0.0" } }, - "global": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz", - "integrity": "sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8=", + "global-dirs": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", + "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", "dev": true, "requires": { - "min-document": "^2.19.0", - "process": "~0.5.1" - }, - "dependencies": { - "process": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz", - "integrity": "sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8=", - "dev": true - } + "ini": "^1.3.4" } }, "got": { "version": "6.7.1", - "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", + "resolved": "http://registry.npmjs.org/got/-/got-6.7.1.tgz", "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", "dev": true, "requires": { @@ -2897,12 +2137,12 @@ "dev": true }, "has": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", - "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, "requires": { - "function-bind": "^1.0.2" + "function-bind": "^1.1.1" } }, "has-ansi": { @@ -2915,10 +2155,9 @@ } }, "has-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", - "dev": true + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, "has-unicode": { "version": "2.0.1", @@ -2926,25 +2165,84 @@ "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "dev": true }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, "hash-base": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", - "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "hash.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz", + "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==", "dev": true, "requires": { "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.1" } }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -2956,6 +2254,14 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "homedir-polyfill": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", + "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "requires": { + "parse-passwd": "^1.0.0" + } + }, "htmlescape": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", @@ -2991,9 +2297,9 @@ } }, "ieee754": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", - "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", + "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==", "dev": true }, "import-lazy": { @@ -3031,9 +2337,9 @@ "dev": true }, "ini": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inline-source-map": { @@ -3046,19 +2352,35 @@ } }, "insert-module-globals": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.0.1.tgz", - "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", + "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, "requires": { "JSONStream": "^1.0.3", - "combine-source-map": "~0.7.1", - "concat-stream": "~1.5.1", + "acorn-node": "^1.5.2", + "combine-source-map": "^0.8.0", + "concat-stream": "^1.6.1", "is-buffer": "^1.1.0", - "lexical-scope": "^1.2.0", + "path-is-absolute": "^1.0.1", "process": "~0.11.0", "through2": "^2.0.0", + "undeclared-identifiers": "^1.1.2", "xtend": "^4.0.0" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + } } }, "interpret": { @@ -3068,9 +2390,9 @@ "dev": true }, "invariant": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.2.tgz", - "integrity": "sha1-nh9WrArNtr8wMwbzOL47IErmA2A=", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", "dev": true, "requires": { "loose-envify": "^1.0.0" @@ -3086,6 +2408,15 @@ "is-windows": "^0.2.0" } }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + } + }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -3102,11 +2433,48 @@ } }, "is-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", - "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, + "is-ci": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", + "integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==", + "dev": true, + "requires": { + "ci-info": "^1.5.0" + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, "is-dotfile": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", @@ -3149,6 +2517,16 @@ "is-extglob": "^1.0.0" } }, + "is-installed-globally": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", + "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", + "dev": true, + "requires": { + "global-dirs": "^0.1.0", + "is-path-inside": "^1.0.0" + } + }, "is-npm": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", @@ -3166,16 +2544,34 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "dev": true, + "requires": { + "path-is-inside": "^1.0.1" + } + }, "is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", "dev": true }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, "is-posix-bracket": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", @@ -3249,18 +2645,15 @@ "dev": true }, "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true }, "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, "json-stable-stringify": { @@ -3280,7 +2673,7 @@ }, "json5": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, @@ -3311,14 +2704,6 @@ "thenify": "^3.2.0", "throat": "^3.0.0", "xtend": "^4.0.1" - }, - "dependencies": { - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - } } }, "kind-of": { @@ -3331,20 +2716,20 @@ } }, "labeled-stream-splicer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.0.tgz", - "integrity": "sha1-pS4dE4AkwAuGscDJH2d5GLiuClk=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz", + "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", "dev": true, "requires": { "inherits": "^2.0.1", - "isarray": "~0.0.1", + "isarray": "^2.0.4", "stream-splicer": "^2.0.0" }, "dependencies": { "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz", + "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==", "dev": true } } @@ -3364,15 +2749,6 @@ "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", "dev": true }, - "lexical-scope": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", - "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", - "dev": true, - "requires": { - "astw": "^2.0.0" - } - }, "listify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/listify/-/listify-1.0.0.tgz", @@ -3391,10 +2767,13 @@ } }, "lockfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.3.tgz", - "integrity": "sha1-Jjj8OaAzHpysGgS3F5mTHJxQ33k=", - "dev": true + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.4.tgz", + "integrity": "sha512-cvbTwETRfsFh4nHsL1eGWapU1XFi5Ot9E85sWAwia7Y7EgB7vfqcZhTKZ+l7hCGxSPoushMv5GKhT5PdLv03WA==", + "dev": true, + "requires": { + "signal-exit": "^3.0.2" + } }, "lodash._baseassign": { "version": "3.2.0", @@ -3487,24 +2866,24 @@ "dev": true }, "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "dev": true, "requires": { - "js-tokens": "^3.0.0" + "js-tokens": "^3.0.0 || ^4.0.0" } }, "lowercase-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", - "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", "dev": true }, "lru-cache": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", - "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", + "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", "dev": true, "requires": { "pseudomap": "^1.0.2", @@ -3512,18 +2891,18 @@ } }, "make-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.0.0.tgz", - "integrity": "sha1-l6ARdR6R3YfPre9Ygy67BJNt6Xg=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", "dev": true, "requires": { - "pify": "^2.3.0" + "pify": "^3.0.0" } }, "make-error": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.0.tgz", - "integrity": "sha1-Uq06M5zPEM5itAQLcI/nByRLi5Y=" + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", + "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==" }, "make-error-cause": { "version": "1.2.2", @@ -3534,6 +2913,38 @@ "make-error": "^1.2.0" } }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "math-random": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz", + "integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w=", + "dev": true + }, + "md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "dev": true, + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, "memory-fs": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", @@ -3566,9 +2977,9 @@ } }, "miller-rabin": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.0.tgz", - "integrity": "sha1-SmL7HUKTPAVYOYL0xxb2+55sbT0=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, "requires": { "bn.js": "^4.0.0", @@ -3590,19 +3001,10 @@ "mime-db": "~1.36.0" } }, - "min-document": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", - "integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=", - "dev": true, - "requires": { - "dom-walk": "^0.1.0" - } - }, "minimalistic-assert": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz", - "integrity": "sha1-cCvi3aazf0g2vLP121ZkG2Sh09M=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "dev": true }, "minimalistic-crypto-utils": { @@ -3622,12 +3024,33 @@ }, "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, + "mixin-deep": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", + "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -3635,15 +3058,15 @@ "dependencies": { "minimist": { "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" } } }, "mocha": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.0.tgz", - "integrity": "sha512-pIU2PJjrPYvYRqVpjXzj76qltO9uBYI7woYAMoxbSefsa+vqAfptjoeevd6bUgwD0mPIO+hv9f7ltvsNreL2PA==", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz", + "integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==", "dev": true, "requires": { "browser-stdout": "1.3.0", @@ -3653,12 +3076,19 @@ "escape-string-regexp": "1.0.5", "glob": "7.1.1", "growl": "1.9.2", + "he": "1.1.1", "json3": "3.3.2", "lodash.create": "3.1.1", "mkdirp": "0.5.1", "supports-color": "3.1.2" }, "dependencies": { + "diff": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", + "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", + "dev": true + }, "glob": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", @@ -3672,6 +3102,21 @@ "once": "^1.3.0", "path-is-absolute": "^1.0.0" } + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "supports-color": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "dev": true, + "requires": { + "has-flag": "^1.0.0" + } } } }, @@ -3705,12 +3150,57 @@ "dev": true }, "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", + "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==", "dev": true, "optional": true }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "node-fetch": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz", @@ -3750,16 +3240,25 @@ "dependencies": { "browserify-aes": { "version": "0.4.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-0.4.0.tgz", + "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-0.4.0.tgz", "integrity": "sha1-BnFJtmjfMcS1hTPgLQHoBthgjiw=", "dev": true, "requires": { "inherits": "^2.0.1" } }, + "browserify-zlib": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", + "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "dev": true, + "requires": { + "pako": "~0.2.0" + } + }, "buffer": { "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "dev": true, "requires": { @@ -3770,7 +3269,7 @@ }, "crypto-browserify": { "version": "3.3.0", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.3.0.tgz", + "resolved": "http://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.3.0.tgz", "integrity": "sha1-ufx1u0oO1h3PHNXa6W6zDJw+UGw=", "dev": true, "requires": { @@ -3792,15 +3291,27 @@ "integrity": "sha1-Y/xMzuXS13Y9Jrv4YBB45sLgBE8=", "dev": true }, + "pako": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", + "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", + "dev": true + }, + "path-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", + "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "dev": true + }, "ripemd160": { "version": "0.2.0", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-0.2.0.tgz", + "resolved": "http://registry.npmjs.org/ripemd160/-/ripemd160-0.2.0.tgz", "integrity": "sha1-K/GYveFnys+lHAqSjoS2i74XH84=", "dev": true }, "sha.js": { "version": "2.2.6", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.2.6.tgz", + "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.2.6.tgz", "integrity": "sha1-F93t3F9yL7ZlAWWIlUYZd4ZzFbo=", "dev": true }, @@ -3811,14 +3322,19 @@ "dev": true }, "timers-browserify": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.3.tgz", - "integrity": "sha512-+JAqyNgg+M8+gXIrq2EeUr4kZqRz47Ysco7X5QKRGScRE9HIHckyHD1asozSFGeqx2nmPCgA8T5tIGVO0ML7/w==", + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.10.tgz", + "integrity": "sha512-YvC1SV1XdOUaL6gx5CoGroT3Gu49pK9+TZ38ErPldOWW4j49GI1HKs9DV+KGq/w6y+LZ72W1c8cKz2vzY+qpzg==", "dev": true, "requires": { - "global": "^4.3.2", "setimmediate": "^1.0.4" } + }, + "tty-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", + "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", + "dev": true } } }, @@ -3849,18 +3365,43 @@ "path-key": "^2.0.0" } }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, "object.omit": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", @@ -3872,12 +3413,12 @@ } }, "object.pick": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.2.0.tgz", - "integrity": "sha1-tTkr7peC2m2ft9avr1OXefEjTCs=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, "requires": { - "isobject": "^2.1.0" + "isobject": "^3.0.1" } }, "once": { @@ -3891,7 +3432,7 @@ }, "onetime": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", "dev": true }, @@ -3907,7 +3448,7 @@ "dependencies": { "minimist": { "version": "0.0.10", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true }, @@ -3920,9 +3461,9 @@ } }, "os-browserify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.1.2.tgz", - "integrity": "sha1-ScoCk+CxlZCl9d4Qx/JlphfY/lQ=", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", "dev": true }, "p-finally": { @@ -3944,9 +3485,9 @@ } }, "pako": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", - "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", + "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==", "dev": true }, "parents": { @@ -3959,9 +3500,9 @@ } }, "parse-asn1": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.0.tgz", - "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", + "version": "5.1.1", + "resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", + "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "dev": true, "requires": { "asn1.js": "^4.0.0", @@ -3992,10 +3533,21 @@ "error-ex": "^1.2.0" } }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, "path-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", - "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", + "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, "path-is-absolute": { @@ -4004,6 +3556,12 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", @@ -4011,9 +3569,9 @@ "dev": true }, "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, "path-platform": { @@ -4028,9 +3586,9 @@ "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=" }, "pbkdf2": { - "version": "3.0.13", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.13.tgz", - "integrity": "sha512-+dCHxDH+djNtjgWmvVC/my3SYBAKpKNqKSjLkp+GtWWYe4XPE+e/PSD2aCanlEZZnqPk2uekTKNC/ccbwd2X2Q==", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, "requires": { "create-hash": "^1.1.2", @@ -4042,20 +3600,20 @@ }, "pbkdf2-compat": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pbkdf2-compat/-/pbkdf2-compat-2.0.1.tgz", + "resolved": "http://registry.npmjs.org/pbkdf2-compat/-/pbkdf2-compat-2.0.1.tgz", "integrity": "sha1-tuDI+plJTZTgURV1gCpZpcFC8og=", "dev": true }, "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "dev": true }, "popsicle": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/popsicle/-/popsicle-9.1.0.tgz", - "integrity": "sha1-T5APONV6V07BcO2kBJbjZAgr/2Y=", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/popsicle/-/popsicle-9.2.0.tgz", + "integrity": "sha512-petRj39w05GvH1WKuGFmzxR9+k+R9E7zX5XWTFee7P/qf88hMuLT7aAO/RsmldpQMtJsWQISkTQlfMRECKlxhw==", "dev": true, "requires": { "concat-stream": "^1.4.7", @@ -4096,6 +3654,12 @@ "integrity": "sha1-jdcMT+fGlBCa3XhP/oDqysHnso0=", "dev": true }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, "prepend-http": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", @@ -4115,9 +3679,9 @@ "dev": true }, "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "promise-finally": { @@ -4127,9 +3691,9 @@ "dev": true }, "prr": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz", - "integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", "dev": true }, "pseudomap": { @@ -4138,17 +3702,24 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, + "psl": { + "version": "1.1.29", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", + "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==", + "dev": true + }, "public-encrypt": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", - "integrity": "sha1-OfaZ86RlYN1eusvKaTyvfGXBjMY=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, "requires": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1" + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" } }, "punycode": { @@ -4170,15 +3741,328 @@ "dev": true }, "randomatic": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.0.tgz", + "integrity": "sha512-KnGPVE0lo2WoXxIZ7cPR8YBpiol4gsSuOwDSg410oHh80ZMp5EiypNqL2K4Z77vJn6lB5rap7IkAmcUlalcnBQ==", "dev": true, "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" + "is-number": "^4.0.0", + "kind-of": "^6.0.0", + "math-random": "^1.0.1" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, + "randombytes": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", + "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dev": true, + "requires": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "dev": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + } + }, + "read-only-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", + "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", + "dev": true, + "requires": { + "readable-stream": "^2.0.2" + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" }, "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + } + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + }, "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", @@ -4200,87 +4084,57 @@ } }, "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" } } } }, - "randombytes": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", - "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", - "dev": true, - "requires": { - "safe-buffer": "^5.1.0" - } - }, - "rc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.1.tgz", - "integrity": "sha1-LgPo5C7kULjLPc5lvhv4l04d/ZU=", - "dev": true, - "requires": { - "deep-extend": "~0.4.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - } - }, - "read-only-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", - "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", - "dev": true, - "requires": { - "readable-stream": "^2.0.2" - } - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.0.3", - "util-deprecate": "~1.0.1" - } - }, - "readdirp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "regex-cache": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "minimatch": "^3.0.2", - "readable-stream": "^2.0.2", - "set-immediate-shim": "^1.0.1" + "is-equal-shallow": "^0.1.3" } }, - "regex-cache": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", - "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=", + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, "requires": { - "is-equal-shallow": "^0.1.3", - "is-primitive": "^2.0.0" + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" } }, "registry-auth-token": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.1.tgz", - "integrity": "sha1-+w0yie4Nmtosu1KvXf5mywcNMAY=", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.2.tgz", + "integrity": "sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==", "dev": true, "requires": { "rc": "^1.1.6", @@ -4297,15 +4151,15 @@ } }, "remove-trailing-separator": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz", - "integrity": "sha1-abBi2XhyetFNxrVrpKt3L9jXBRE=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", "dev": true }, "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", "dev": true }, "repeat-string": { @@ -4315,14 +4169,20 @@ "dev": true }, "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { "path-parse": "^1.0.5" } }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, "restore-cursor": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", @@ -4333,6 +4193,12 @@ "onetime": "^1.0.0" } }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, "right-align": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", @@ -4343,34 +4209,43 @@ } }, "rimraf": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", - "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "^7.0.5" } }, "ripemd160": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", - "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { - "hash-base": "^2.0.0", + "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true }, "semver-diff": { @@ -4382,11 +4257,28 @@ "semver": "^5.0.3" } }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true + "set-value": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", + "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } }, "setimmediate": { "version": "1.0.5", @@ -4395,17 +4287,18 @@ "dev": true }, "sha.js": { - "version": "2.4.8", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.8.tgz", - "integrity": "sha1-NwaMLEdra69ALRSknGf1l5IfY08=", + "version": "2.4.11", + "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "shasum": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, "requires": { @@ -4440,27 +4333,129 @@ "jsonify": "~0.0.0" } }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - }, - "slice-ansi": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", - "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", + "dev": true + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0" + } + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0" + "kind-of": "^3.2.0" } }, - "slide": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz", - "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=", - "dev": true - }, "sort-keys": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", @@ -4477,18 +4472,67 @@ "dev": true }, "source-map": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=" + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + }, + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } }, "source-map-support": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.15.tgz", - "integrity": "sha1-AyAt9lwG0r2MfsI2KhkwVv7407E=", + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "requires": { "source-map": "^0.5.6" } }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, "stream-browserify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", @@ -4510,14 +4554,14 @@ } }, "stream-http": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz", - "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", + "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", "dev": true, "requires": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.1", - "readable-stream": "^2.2.6", + "readable-stream": "^2.3.6", "to-arraybuffer": "^1.0.0", "xtend": "^4.0.0" } @@ -4576,7 +4620,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -4584,13 +4628,9 @@ } }, "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" }, "strip-eof": { "version": "1.0.0", @@ -4613,21 +4653,20 @@ } }, "supports-color": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", - "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", - "dev": true, + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "requires": { - "has-flag": "^1.0.0" + "has-flag": "^3.0.0" } }, "syntax-error": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.3.0.tgz", - "integrity": "sha1-HtkmbE1AvnXcVb+bsct3Biu5bKE=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", + "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, "requires": { - "acorn": "^4.0.3" + "acorn-node": "^1.2.0" } }, "tapable": { @@ -4662,7 +4701,7 @@ }, "through": { "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, @@ -4697,6 +4736,48 @@ "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", "dev": true }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + } + } + } + }, "touch": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/touch/-/touch-1.0.0.tgz", @@ -4707,18 +4788,19 @@ } }, "tough-cookie": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", - "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", "dev": true, "requires": { + "psl": "^1.1.24", "punycode": "^1.4.1" } }, "ts-loader": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-2.3.2.tgz", - "integrity": "sha512-KcQvWwla5nviCMX1511iKVsLfrx97Hbah6l5awE1HNL6eiyAzb3gSO8b5yasB6fK/qGukLpu9czWcd/AGGFy/g==", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-2.3.7.tgz", + "integrity": "sha512-8t3bu2FcEkXb+D4L+Cn8qiK2E2C6Ms4/GQChvz6IMbVurcFHLXrhW4EMtfaol1a1ASQACZGDUGit4NHnX9g7hQ==", "dev": true, "requires": { "chalk": "^2.0.1", @@ -4742,40 +4824,21 @@ "tsconfig": "^6.0.0", "v8flags": "^3.0.0", "yn": "^2.0.0" - }, - "dependencies": { - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" - }, - "tsconfig": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-6.0.0.tgz", - "integrity": "sha1-aw6DdgA9evGGT434+J3QBZ/80DI=", - "requires": { - "strip-bom": "^3.0.0", - "strip-json-comments": "^2.0.0" - } - } } }, "tsconfig": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-5.0.3.tgz", - "integrity": "sha1-X0J45wGACWeo/Dg/0ZZIh48qbjo=", - "dev": true, + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-6.0.0.tgz", + "integrity": "sha1-aw6DdgA9evGGT434+J3QBZ/80DI=", "requires": { - "any-promise": "^1.3.0", - "parse-json": "^2.2.0", - "strip-bom": "^2.0.0", + "strip-bom": "^3.0.0", "strip-json-comments": "^2.0.0" } }, "tsify": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/tsify/-/tsify-3.0.1.tgz", - "integrity": "sha1-I1Cf87TnEQypZW9sJ8oT7IVgVvY=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/tsify/-/tsify-3.0.4.tgz", + "integrity": "sha512-y75+qgB41YS8HJck+jmSIn395I4qRGtm5ZELzvNh80Llzh8ojPWp47jm0ZoIJesNYVzbqEyLzgYXV9d/calvVg==", "dev": true, "requires": { "convert-source-map": "^1.1.0", @@ -4784,18 +4847,41 @@ "semver": "^5.1.0", "through2": "^2.0.0", "tsconfig": "^5.0.3" + }, + "dependencies": { + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, + "requires": { + "is-utf8": "^0.2.0" + } + }, + "tsconfig": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-5.0.3.tgz", + "integrity": "sha1-X0J45wGACWeo/Dg/0ZZIh48qbjo=", + "dev": true, + "requires": { + "any-promise": "^1.3.0", + "parse-json": "^2.2.0", + "strip-bom": "^2.0.0", + "strip-json-comments": "^2.0.0" + } + } } }, "tty-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", - "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", + "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", "dev": true }, "type-detect": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.3.tgz", - "integrity": "sha1-Dj8mcLRAmbC0bChNE2p+9Jx0wuo=" + "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==" }, "typedarray": { "version": "0.0.6", @@ -4804,9 +4890,9 @@ "dev": true }, "typescript": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.4.2.tgz", - "integrity": "sha1-+DlfhdRZJ2BnyYiqQYN6j4KHCEQ=", + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", "dev": true }, "typings": { @@ -4840,7 +4926,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -4897,19 +4983,11 @@ "typescript": "^2.1.4", "xtend": "^4.0.0", "zip-object": "^0.1.0" - }, - "dependencies": { - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - } } }, "uglify-js": { "version": "2.7.5", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.7.5.tgz", + "resolved": "http://registry.npmjs.org/uglify-js/-/uglify-js-2.7.5.tgz", "integrity": "sha1-RhLAx7qu4rp8SH3kkErhIgefLKg=", "dev": true, "requires": { @@ -4921,7 +4999,7 @@ "dependencies": { "async": { "version": "0.2.10", - "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "resolved": "http://registry.npmjs.org/async/-/async-0.2.10.tgz", "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", "dev": true } @@ -4934,9 +5012,9 @@ "dev": true }, "umd": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz", - "integrity": "sha1-iuVW4RAR9jwllnCKiDclnwGz1g4=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", + "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", "dev": true }, "unc-path-regex": { @@ -4945,6 +5023,53 @@ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", "dev": true }, + "undeclared-identifiers": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz", + "integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==", + "dev": true, + "requires": { + "acorn-node": "^1.3.0", + "get-assigned-identifiers": "^1.2.0", + "simple-concat": "^1.0.0", + "xtend": "^4.0.1" + } + }, + "union-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", + "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "set-value": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", + "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" + } + } + } + }, "unique-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", @@ -4954,6 +5079,46 @@ "crypto-random-string": "^1.0.0" } }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + } + } + }, "unzip-response": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", @@ -4961,48 +5126,29 @@ "dev": true }, "update-notifier": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.2.0.tgz", - "integrity": "sha1-G1g3z5DAc22IYncytmHBOPht5y8=", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.5.0.tgz", + "integrity": "sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw==", "dev": true, "requires": { - "boxen": "^1.0.0", - "chalk": "^1.0.0", + "boxen": "^1.2.1", + "chalk": "^2.0.1", "configstore": "^3.0.0", "import-lazy": "^2.1.0", + "is-ci": "^1.0.10", + "is-installed-globally": "^0.1.0", "is-npm": "^1.0.0", "latest-version": "^3.0.0", "semver-diff": "^2.0.0", "xdg-basedir": "^3.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } } }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, "url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", @@ -5030,26 +5176,19 @@ "prepend-http": "^1.0.1" } }, - "user-home": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", - "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=" + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true }, "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, "requires": { - "inherits": "2.0.1" - }, - "dependencies": { - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true - } + "inherits": "2.0.3" } }, "util-deprecate": { @@ -5059,11 +5198,11 @@ "dev": true }, "v8flags": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.0.0.tgz", - "integrity": "sha512-AGl+C+4qpeSu2g3JxCD/mGFFOs/vVZ3XREkD3ibQXEqr4Y4zgIrPWW124/IKJFHOIVFIoH8miWrLf0o84HYjwA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.1.tgz", + "integrity": "sha512-iw/1ViSEaff8NJ3HLyEjawk/8hjJib3E7pvG4pddVXfUg1983s3VGsiClDjhK64MQVDGqc1Q8r18S4VKQZS9EQ==", "requires": { - "user-home": "^1.1.1" + "homedir-polyfill": "^1.0.1" } }, "vm-browserify": { @@ -5088,7 +5227,7 @@ "dependencies": { "async": { "version": "0.9.2", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "resolved": "http://registry.npmjs.org/async/-/async-0.9.2.tgz", "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", "dev": true } @@ -5128,7 +5267,7 @@ "dependencies": { "acorn": { "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", "dev": true }, @@ -5151,6 +5290,12 @@ } } }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, "loader-utils": { "version": "0.2.17", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", @@ -5173,9 +5318,18 @@ "readable-stream": "^2.0.1" } }, + "supports-color": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", + "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "dev": true, + "requires": { + "has-flag": "^1.0.0" + } + }, "tapable": { "version": "0.1.10", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.1.10.tgz", + "resolved": "http://registry.npmjs.org/tapable/-/tapable-0.1.10.tgz", "integrity": "sha1-KcNXB8K3DlDQdIK10gLo7URtr9Q=", "dev": true } @@ -5203,43 +5357,21 @@ } }, "which": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, "requires": { "isexe": "^2.0.0" } }, "widest-line": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-1.0.0.tgz", - "integrity": "sha1-DAnIXCqUaD0Nfq+O4JfVZL8OEFw=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-2.0.0.tgz", + "integrity": "sha1-AUKk6KJD+IgsAjOqDgKBqnYVInM=", "dev": true, "requires": { - "string-width": "^1.0.1" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - } + "string-width": "^2.1.1" } }, "window-size": { @@ -5261,14 +5393,14 @@ "dev": true }, "write-file-atomic": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.1.0.tgz", - "integrity": "sha512-0TZ20a+xcIl4u0+Mj5xDH2yOWdmQiXlKf9Hm+TgDXjTMsEYb+gDrmb8e8UNAzMCitX8NBqG4Z/FUQIyzv/R1JQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", + "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", "dev": true, "requires": { "graceful-fs": "^4.1.11", "imurmurhash": "^0.1.4", - "slide": "^1.1.5" + "signal-exit": "^3.0.2" } }, "xdg-basedir": { @@ -5291,7 +5423,7 @@ }, "yargs": { "version": "3.10.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "resolved": "http://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", "dev": true, "requires": { diff --git a/samples/client/petstore/typescript-fetch/tests/default/package.json b/samples/client/petstore/typescript-fetch/tests/default/package.json index 965353b0876e..fee4a03b8557 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/package.json +++ b/samples/client/petstore/typescript-fetch/tests/default/package.json @@ -6,7 +6,7 @@ "ts-node": "^3.3.0" }, "scripts": { - "prepublish": "npm install ../../builds/with-npm-version && npm run build && npm run webpack && npm run browserify", + "prepublish": "npm install ../../builds/with-npm-version && npm run build --prefix ../../builds/with-npm-version && npm run build && npm run webpack && npm run browserify", "test": "mocha test/*.ts --compilers ts:ts-node/register --require mocks.ts --timeout 10000", "build": "tsc", "webpack": "webpack", @@ -24,7 +24,7 @@ "mocha": "^3.4.2", "node-fetch": "^2.2.0", "ts-loader": "^2.3.0", - "tsify": "^3.0.1", + "tsify": "^3.0.4", "typescript": "^2.4.1", "typings": "^2.1.1", "webpack": "^1.13.0" From a38a6930e385e8ad32a4b5eb943b8ad1e760c938 Mon Sep 17 00:00:00 2001 From: James Batt Date: Tue, 16 Oct 2018 21:41:48 +1100 Subject: [PATCH 39/39] added support for retrieving raw response. added support for binary request bodies. added support for blob data type for files/binary. --- .../TypeScriptFetchClientCodegen.java | 32 ++++- .../resources/typescript-fetch/apis.mustache | 41 +++++-- .../typescript-fetch/runtime.mustache | 43 ++++++- .../builds/default/apis/PetApi.ts | 113 ++++++++++++++---- .../builds/default/apis/StoreApi.ts | 54 +++++++-- .../builds/default/apis/UserApi.ts | 101 +++++++++++++--- .../builds/default/models/ModelApiResponse.ts | 60 ++++++++++ .../builds/default/models/index.ts | 2 +- .../builds/default/runtime.ts | 43 ++++++- .../builds/es6-target/apis/PetApi.ts | 113 ++++++++++++++---- .../builds/es6-target/apis/StoreApi.ts | 54 +++++++-- .../builds/es6-target/apis/UserApi.ts | 101 +++++++++++++--- .../es6-target/models/ModelApiResponse.ts | 60 ++++++++++ .../builds/es6-target/models/index.ts | 2 +- .../builds/es6-target/runtime.ts | 43 ++++++- .../builds/with-interfaces/apis/PetApi.ts | 113 ++++++++++++++---- .../builds/with-interfaces/apis/StoreApi.ts | 54 +++++++-- .../builds/with-interfaces/apis/UserApi.ts | 101 +++++++++++++--- .../models/ModelApiResponse.ts | 60 ++++++++++ .../builds/with-interfaces/models/index.ts | 2 +- .../builds/with-interfaces/runtime.ts | 43 ++++++- .../builds/with-npm-version/apis/PetApi.ts | 113 ++++++++++++++---- .../builds/with-npm-version/apis/StoreApi.ts | 54 +++++++-- .../builds/with-npm-version/apis/UserApi.ts | 101 +++++++++++++--- .../models/ModelApiResponse.ts | 60 ++++++++++ .../builds/with-npm-version/models/index.ts | 2 +- .../builds/with-npm-version/runtime.ts | 43 ++++++- .../tests/default/package-lock.json | 28 ++--- 28 files changed, 1410 insertions(+), 226 deletions(-) create mode 100644 samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/es6-target/models/ModelApiResponse.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ModelApiResponse.ts diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index d021fd91a0bd..ff6f0bd3d6c9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -61,7 +61,7 @@ public TypeScriptFetchClientCodegen() { this.apiTemplateFiles.put("apis.mustache", ".ts"); this.modelPackage = "models"; this.modelTemplateFiles.put("models.mustache", ".ts"); - + this.addExtraReservedWords(); this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); @@ -129,9 +129,9 @@ public String getTypeDeclaration(Schema p) { inner = ModelUtils.getAdditionalProperties(p); return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }"; } else if (ModelUtils.isFileSchema(p)) { - return "any"; + return "Blob"; } else if (ModelUtils.isBinarySchema(p)) { - return "any"; + return "Blob"; } else { return super.getTypeDeclaration(p); } @@ -196,4 +196,30 @@ private void addOperationModelImportInfomation(Map operations) { } } + private void addExtraReservedWords() { + this.reservedWords.add("BASE_PATH"); + this.reservedWords.add("BaseAPI"); + this.reservedWords.add("RequiredError"); + this.reservedWords.add("COLLECTION_FORMATS"); + this.reservedWords.add("FetchAPI"); + this.reservedWords.add("ConfigurationParameters"); + this.reservedWords.add("Configuration"); + this.reservedWords.add("HTTPMethod"); + this.reservedWords.add("HTTPHeaders"); + this.reservedWords.add("HTTPQuery"); + this.reservedWords.add("HTTPBody"); + this.reservedWords.add("ModelPropertyNaming"); + this.reservedWords.add("FetchParams"); + this.reservedWords.add("RequestOpts"); + this.reservedWords.add("exists"); + this.reservedWords.add("RequestContext"); + this.reservedWords.add("ResponseContext"); + this.reservedWords.add("Middleware"); + this.reservedWords.add("ApiResponse"); + this.reservedWords.add("ResponseTransformer"); + this.reservedWords.add("JSONApiResponse"); + this.reservedWords.add("VoidApiResponse"); + this.reservedWords.add("BlobApiResponse"); + this.reservedWords.add("TextApiResponse"); + } } diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index 76a96e3a3f08..e2d460f69402 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -39,7 +39,7 @@ export class {{classname}} extends runtime.BaseAPI { * {{&summary}} {{/summary}} */ - async {{nickname}}({{#allParams.0}}requestParameters: {{operationIdCamelCase}}Request{{/allParams.0}}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { + async {{nickname}}Raw({{#allParams.0}}requestParameters: {{operationIdCamelCase}}Request{{/allParams.0}}): Promise> { {{#allParams}} {{#required}} if (requestParameters.{{paramName}} === null || requestParameters.{{paramName}} === undefined) { @@ -177,7 +177,12 @@ export class {{classname}} extends runtime.BaseAPI { body: requestParameters.{{paramName}}.map({{#items}}{{datatype}}{{/items}}ToJSON), {{/isContainer}} {{^isContainer}} + {{^isPrimitiveType}} body: {{dataType}}ToJSON(requestParameters.{{paramName}}), + {{/isPrimitiveType}} + {{#isPrimitiveType}} + body: requestParameters.{{paramName}} as any, + {{/isPrimitiveType}} {{/isContainer}} {{/bodyParam}} {{/hasBodyParam}} @@ -185,35 +190,53 @@ export class {{classname}} extends runtime.BaseAPI { body: formData, {{/hasFormParams}} }); + {{#returnType}} {{#isResponseFile}} - return response.blob(); + return new runtime.BlobApiResponse(response); {{/isResponseFile}} {{^isResponseFile}} {{#returnTypeIsPrimitive}} {{#isMapContainer}} - return response.json(); + return new runtime.JSONApiResponse(response); {{/isMapContainer}} {{#isListContainer}} - return response.json(); + return new runtime.JSONApiResponse(response); {{/isListContainer}} {{#returnSimpleType}} - return response.text(); + return new runtime.TextApiResponse(response); {{/returnSimpleType}} {{/returnTypeIsPrimitive}} {{^returnTypeIsPrimitive}} {{#isListContainer}} - const json = await response.json() as Array; - return json.map({{returnBaseType}}FromJSON); + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map({{returnBaseType}}FromJSON)); {{/isListContainer}} {{^isListContainer}} - return {{returnBaseType}}FromJSON(await response.json()); + return new runtime.JSONApiResponse(response, (jsonValue) => {{returnBaseType}}FromJSON(jsonValue)); {{/isListContainer}} {{/returnTypeIsPrimitive}} {{/isResponseFile}} {{/returnType}} {{^returnType}} - return response; + return new runtime.VoidApiResponse(response); + {{/returnType}} + } + + /** + {{#notes}} + * {{¬es}} + {{/notes}} + {{#summary}} + * {{&summary}} + {{/summary}} + */ + async {{nickname}}({{#allParams.0}}requestParameters: {{operationIdCamelCase}}Request{{/allParams.0}}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { + {{#returnType}} + const response = await this.{{nickname}}Raw({{#allParams.0}}requestParameters{{/allParams.0}}); + return await response.value(); + {{/returnType}} + {{^returnType}} + await this.{{nickname}}Raw({{#allParams.0}}requestParameters{{/allParams.0}}); {{/returnType}} } diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index ce15a46f5d70..f21aa4bf313d 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -183,7 +183,7 @@ export function exists(json: any, key: string) { return value !== null && value !== undefined; } -function querystring(params: HTTPQuery) { +export function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { const value = params[key]; @@ -213,3 +213,44 @@ export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; } + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value() { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value() { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.text(); + }; +} diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts index d23ba2e93031..a676e0d0062c 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts @@ -14,9 +14,9 @@ import * as runtime from '../runtime'; import { - ApiResponse, - ApiResponseFromJSON, - ApiResponseToJSON, + ModelApiResponse, + ModelApiResponseFromJSON, + ModelApiResponseToJSON, Pet, PetFromJSON, PetToJSON, @@ -56,7 +56,7 @@ export interface UpdatePetWithFormRequest { export interface UploadFileRequest { petId: number; additionalMetadata?: string; - file?: any; + file?: Blob; } /** @@ -67,7 +67,7 @@ export class PetApi extends runtime.BaseAPI { /** * Add a new pet to the store */ - async addPet(requestParameters: AddPetRequest): Promise { + async addPetRaw(requestParameters: AddPetRequest): Promise> { if (requestParameters.pet === null || requestParameters.pet === undefined) { throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); } @@ -91,13 +91,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: PetToJSON(requestParameters.pet), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest): Promise { + await this.addPetRaw(requestParameters); } /** * Deletes a pet */ - async deletePet(requestParameters: DeletePetRequest): Promise { + async deletePetRaw(requestParameters: DeletePetRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); } @@ -122,14 +130,22 @@ export class PetApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest): Promise { + await this.deletePetRaw(requestParameters); } /** * Multiple status values can be provided with comma separated strings * Finds Pets by status */ - async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest): Promise>> { if (requestParameters.status === null || requestParameters.status === undefined) { throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); } @@ -157,15 +173,24 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - const json = await response.json() as Array; - return json.map(PetFromJSON); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + const response = await this.findPetsByStatusRaw(requestParameters); + return await response.value(); } /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags */ - async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest): Promise>> { if (requestParameters.tags === null || requestParameters.tags === undefined) { throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); } @@ -193,15 +218,24 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - const json = await response.json() as Array; - return json.map(PetFromJSON); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + const response = await this.findPetsByTagsRaw(requestParameters); + return await response.value(); } /** * Returns a single pet * Find pet by ID */ - async getPetById(requestParameters: GetPetByIdRequest): Promise { + async getPetByIdRaw(requestParameters: GetPetByIdRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); } @@ -217,13 +251,23 @@ export class PetApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return PetFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest): Promise { + const response = await this.getPetByIdRaw(requestParameters); + return await response.value(); } /** * Update an existing pet */ - async updatePet(requestParameters: UpdatePetRequest): Promise { + async updatePetRaw(requestParameters: UpdatePetRequest): Promise> { if (requestParameters.pet === null || requestParameters.pet === undefined) { throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); } @@ -247,13 +291,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: PetToJSON(requestParameters.pet), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest): Promise { + await this.updatePetRaw(requestParameters); } /** * Updates a pet in the store with form data */ - async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); } @@ -284,13 +336,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: formData, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + await this.updatePetWithFormRaw(requestParameters); } /** * uploads an image */ - async uploadFile(requestParameters: UploadFileRequest): Promise { + async uploadFileRaw(requestParameters: UploadFileRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); } @@ -321,7 +381,16 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: formData, }); - return ApiResponseFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest): Promise { + const response = await this.uploadFileRaw(requestParameters); + return await response.value(); } } diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts index 58bf85a17376..1eb35777264f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts @@ -40,7 +40,7 @@ export class StoreApi extends runtime.BaseAPI { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * Delete purchase order by ID */ - async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + async deleteOrderRaw(requestParameters: DeleteOrderRequest): Promise> { if (requestParameters.orderId === null || requestParameters.orderId === undefined) { throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); } @@ -52,14 +52,23 @@ export class StoreApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + await this.deleteOrderRaw(requestParameters); } /** * Returns a map of status codes to quantities * Returns pet inventories by status */ - async getInventory(): Promise<{ [key: string]: number; }> { + async getInventoryRaw(): Promise> { const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { @@ -71,14 +80,24 @@ export class StoreApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return response.json(); + + return new runtime.JSONApiResponse(response); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(): Promise<{ [key: string]: number; }> { + const response = await this.getInventoryRaw(); + return await response.value(); } /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * Find purchase order by ID */ - async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + async getOrderByIdRaw(requestParameters: GetOrderByIdRequest): Promise> { if (requestParameters.orderId === null || requestParameters.orderId === undefined) { throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); } @@ -90,13 +109,23 @@ export class StoreApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return OrderFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + const response = await this.getOrderByIdRaw(requestParameters); + return await response.value(); } /** * Place an order for a pet */ - async placeOrder(requestParameters: PlaceOrderRequest): Promise { + async placeOrderRaw(requestParameters: PlaceOrderRequest): Promise> { if (requestParameters.order === null || requestParameters.order === undefined) { throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); } @@ -111,7 +140,16 @@ export class StoreApi extends runtime.BaseAPI { headers: headerParameters, body: OrderToJSON(requestParameters.order), }); - return OrderFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + const response = await this.placeOrderRaw(requestParameters); + return await response.value(); } } diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts index 61ad2b3e63ec..407500ed2d0f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts @@ -58,7 +58,7 @@ export class UserApi extends runtime.BaseAPI { * This can only be done by the logged in user. * Create user */ - async createUser(requestParameters: CreateUserRequest): Promise { + async createUserRaw(requestParameters: CreateUserRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); } @@ -73,13 +73,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: UserToJSON(requestParameters.user), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest): Promise { + await this.createUserRaw(requestParameters); } /** * Creates list of users with given input array */ - async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); } @@ -94,13 +103,21 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: requestParameters.user.map(UserToJSON), }); - return response; + + return new runtime.VoidApiResponse(response); } /** * Creates list of users with given input array */ - async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + await this.createUsersWithArrayInputRaw(requestParameters); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); } @@ -115,14 +132,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: requestParameters.user.map(UserToJSON), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + await this.createUsersWithListInputRaw(requestParameters); } /** * This can only be done by the logged in user. * Delete user */ - async deleteUser(requestParameters: DeleteUserRequest): Promise { + async deleteUserRaw(requestParameters: DeleteUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); } @@ -134,13 +159,22 @@ export class UserApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest): Promise { + await this.deleteUserRaw(requestParameters); } /** * Get user by user name */ - async getUserByName(requestParameters: GetUserByNameRequest): Promise { + async getUserByNameRaw(requestParameters: GetUserByNameRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); } @@ -152,13 +186,22 @@ export class UserApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return UserFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + const response = await this.getUserByNameRaw(requestParameters); + return await response.value(); } /** * Logs user into the system */ - async loginUser(requestParameters: LoginUserRequest): Promise { + async loginUserRaw(requestParameters: LoginUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); } @@ -185,13 +228,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - return response.text(); + + return new runtime.TextApiResponse(response); + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest): Promise { + const response = await this.loginUserRaw(requestParameters); + return await response.value(); } /** * Logs out current logged in user session */ - async logoutUser(): Promise { + async logoutUserRaw(): Promise> { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ @@ -199,14 +251,22 @@ export class UserApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(): Promise { + await this.logoutUserRaw(); } /** * This can only be done by the logged in user. * Updated user */ - async updateUser(requestParameters: UpdateUserRequest): Promise { + async updateUserRaw(requestParameters: UpdateUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); } @@ -225,7 +285,16 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: UserToJSON(requestParameters.user), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest): Promise { + await this.updateUserRaw(requestParameters); } } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts new file mode 100644 index 000000000000..fdfab390edd1 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts @@ -0,0 +1,60 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists } from '../runtime'; +/** + * Describes the result of uploading an image resource + * @export + * @interface ModelApiResponse + */ +export interface ModelApiResponse { + /** + * + * @type {number} + * @memberof ModelApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + message?: string; +} + +export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return { + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], + }; +} + +export function ModelApiResponseToJSON(value?: ModelApiResponse): any { + if (value === undefined) { + return undefined; + } + return { + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/index.ts b/samples/client/petstore/typescript-fetch/builds/default/models/index.ts index f53c1dd42bdd..b07ddc8446a0 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/index.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/index.ts @@ -1,5 +1,5 @@ -export * from './ApiResponse'; export * from './Category'; +export * from './ModelApiResponse'; export * from './Order'; export * from './Pet'; export * from './Tag'; diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 924d34da3706..415564cfd090 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -194,7 +194,7 @@ export function exists(json: any, key: string) { return value !== null && value !== undefined; } -function querystring(params: HTTPQuery) { +export function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { const value = params[key]; @@ -224,3 +224,44 @@ export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; } + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value() { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value() { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.text(); + }; +} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts index d23ba2e93031..a676e0d0062c 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/PetApi.ts @@ -14,9 +14,9 @@ import * as runtime from '../runtime'; import { - ApiResponse, - ApiResponseFromJSON, - ApiResponseToJSON, + ModelApiResponse, + ModelApiResponseFromJSON, + ModelApiResponseToJSON, Pet, PetFromJSON, PetToJSON, @@ -56,7 +56,7 @@ export interface UpdatePetWithFormRequest { export interface UploadFileRequest { petId: number; additionalMetadata?: string; - file?: any; + file?: Blob; } /** @@ -67,7 +67,7 @@ export class PetApi extends runtime.BaseAPI { /** * Add a new pet to the store */ - async addPet(requestParameters: AddPetRequest): Promise { + async addPetRaw(requestParameters: AddPetRequest): Promise> { if (requestParameters.pet === null || requestParameters.pet === undefined) { throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); } @@ -91,13 +91,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: PetToJSON(requestParameters.pet), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest): Promise { + await this.addPetRaw(requestParameters); } /** * Deletes a pet */ - async deletePet(requestParameters: DeletePetRequest): Promise { + async deletePetRaw(requestParameters: DeletePetRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); } @@ -122,14 +130,22 @@ export class PetApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest): Promise { + await this.deletePetRaw(requestParameters); } /** * Multiple status values can be provided with comma separated strings * Finds Pets by status */ - async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest): Promise>> { if (requestParameters.status === null || requestParameters.status === undefined) { throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); } @@ -157,15 +173,24 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - const json = await response.json() as Array; - return json.map(PetFromJSON); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + const response = await this.findPetsByStatusRaw(requestParameters); + return await response.value(); } /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags */ - async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest): Promise>> { if (requestParameters.tags === null || requestParameters.tags === undefined) { throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); } @@ -193,15 +218,24 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - const json = await response.json() as Array; - return json.map(PetFromJSON); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + const response = await this.findPetsByTagsRaw(requestParameters); + return await response.value(); } /** * Returns a single pet * Find pet by ID */ - async getPetById(requestParameters: GetPetByIdRequest): Promise { + async getPetByIdRaw(requestParameters: GetPetByIdRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); } @@ -217,13 +251,23 @@ export class PetApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return PetFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest): Promise { + const response = await this.getPetByIdRaw(requestParameters); + return await response.value(); } /** * Update an existing pet */ - async updatePet(requestParameters: UpdatePetRequest): Promise { + async updatePetRaw(requestParameters: UpdatePetRequest): Promise> { if (requestParameters.pet === null || requestParameters.pet === undefined) { throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); } @@ -247,13 +291,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: PetToJSON(requestParameters.pet), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest): Promise { + await this.updatePetRaw(requestParameters); } /** * Updates a pet in the store with form data */ - async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); } @@ -284,13 +336,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: formData, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + await this.updatePetWithFormRaw(requestParameters); } /** * uploads an image */ - async uploadFile(requestParameters: UploadFileRequest): Promise { + async uploadFileRaw(requestParameters: UploadFileRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); } @@ -321,7 +381,16 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: formData, }); - return ApiResponseFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest): Promise { + const response = await this.uploadFileRaw(requestParameters); + return await response.value(); } } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts index 58bf85a17376..1eb35777264f 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/StoreApi.ts @@ -40,7 +40,7 @@ export class StoreApi extends runtime.BaseAPI { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * Delete purchase order by ID */ - async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + async deleteOrderRaw(requestParameters: DeleteOrderRequest): Promise> { if (requestParameters.orderId === null || requestParameters.orderId === undefined) { throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); } @@ -52,14 +52,23 @@ export class StoreApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + await this.deleteOrderRaw(requestParameters); } /** * Returns a map of status codes to quantities * Returns pet inventories by status */ - async getInventory(): Promise<{ [key: string]: number; }> { + async getInventoryRaw(): Promise> { const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { @@ -71,14 +80,24 @@ export class StoreApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return response.json(); + + return new runtime.JSONApiResponse(response); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(): Promise<{ [key: string]: number; }> { + const response = await this.getInventoryRaw(); + return await response.value(); } /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * Find purchase order by ID */ - async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + async getOrderByIdRaw(requestParameters: GetOrderByIdRequest): Promise> { if (requestParameters.orderId === null || requestParameters.orderId === undefined) { throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); } @@ -90,13 +109,23 @@ export class StoreApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return OrderFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + const response = await this.getOrderByIdRaw(requestParameters); + return await response.value(); } /** * Place an order for a pet */ - async placeOrder(requestParameters: PlaceOrderRequest): Promise { + async placeOrderRaw(requestParameters: PlaceOrderRequest): Promise> { if (requestParameters.order === null || requestParameters.order === undefined) { throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); } @@ -111,7 +140,16 @@ export class StoreApi extends runtime.BaseAPI { headers: headerParameters, body: OrderToJSON(requestParameters.order), }); - return OrderFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + const response = await this.placeOrderRaw(requestParameters); + return await response.value(); } } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts index 61ad2b3e63ec..407500ed2d0f 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/apis/UserApi.ts @@ -58,7 +58,7 @@ export class UserApi extends runtime.BaseAPI { * This can only be done by the logged in user. * Create user */ - async createUser(requestParameters: CreateUserRequest): Promise { + async createUserRaw(requestParameters: CreateUserRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); } @@ -73,13 +73,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: UserToJSON(requestParameters.user), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest): Promise { + await this.createUserRaw(requestParameters); } /** * Creates list of users with given input array */ - async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); } @@ -94,13 +103,21 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: requestParameters.user.map(UserToJSON), }); - return response; + + return new runtime.VoidApiResponse(response); } /** * Creates list of users with given input array */ - async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + await this.createUsersWithArrayInputRaw(requestParameters); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); } @@ -115,14 +132,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: requestParameters.user.map(UserToJSON), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + await this.createUsersWithListInputRaw(requestParameters); } /** * This can only be done by the logged in user. * Delete user */ - async deleteUser(requestParameters: DeleteUserRequest): Promise { + async deleteUserRaw(requestParameters: DeleteUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); } @@ -134,13 +159,22 @@ export class UserApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest): Promise { + await this.deleteUserRaw(requestParameters); } /** * Get user by user name */ - async getUserByName(requestParameters: GetUserByNameRequest): Promise { + async getUserByNameRaw(requestParameters: GetUserByNameRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); } @@ -152,13 +186,22 @@ export class UserApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return UserFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + const response = await this.getUserByNameRaw(requestParameters); + return await response.value(); } /** * Logs user into the system */ - async loginUser(requestParameters: LoginUserRequest): Promise { + async loginUserRaw(requestParameters: LoginUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); } @@ -185,13 +228,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - return response.text(); + + return new runtime.TextApiResponse(response); + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest): Promise { + const response = await this.loginUserRaw(requestParameters); + return await response.value(); } /** * Logs out current logged in user session */ - async logoutUser(): Promise { + async logoutUserRaw(): Promise> { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ @@ -199,14 +251,22 @@ export class UserApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(): Promise { + await this.logoutUserRaw(); } /** * This can only be done by the logged in user. * Updated user */ - async updateUser(requestParameters: UpdateUserRequest): Promise { + async updateUserRaw(requestParameters: UpdateUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); } @@ -225,7 +285,16 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: UserToJSON(requestParameters.user), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest): Promise { + await this.updateUserRaw(requestParameters); } } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ModelApiResponse.ts new file mode 100644 index 000000000000..fdfab390edd1 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ModelApiResponse.ts @@ -0,0 +1,60 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists } from '../runtime'; +/** + * Describes the result of uploading an image resource + * @export + * @interface ModelApiResponse + */ +export interface ModelApiResponse { + /** + * + * @type {number} + * @memberof ModelApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + message?: string; +} + +export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return { + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], + }; +} + +export function ModelApiResponseToJSON(value?: ModelApiResponse): any { + if (value === undefined) { + return undefined; + } + return { + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/index.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/index.ts index f53c1dd42bdd..b07ddc8446a0 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/index.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/index.ts @@ -1,5 +1,5 @@ -export * from './ApiResponse'; export * from './Category'; +export * from './ModelApiResponse'; export * from './Order'; export * from './Pet'; export * from './Tag'; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts index 924d34da3706..415564cfd090 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts @@ -194,7 +194,7 @@ export function exists(json: any, key: string) { return value !== null && value !== undefined; } -function querystring(params: HTTPQuery) { +export function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { const value = params[key]; @@ -224,3 +224,44 @@ export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; } + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value() { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value() { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.text(); + }; +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts index d23ba2e93031..a676e0d0062c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts @@ -14,9 +14,9 @@ import * as runtime from '../runtime'; import { - ApiResponse, - ApiResponseFromJSON, - ApiResponseToJSON, + ModelApiResponse, + ModelApiResponseFromJSON, + ModelApiResponseToJSON, Pet, PetFromJSON, PetToJSON, @@ -56,7 +56,7 @@ export interface UpdatePetWithFormRequest { export interface UploadFileRequest { petId: number; additionalMetadata?: string; - file?: any; + file?: Blob; } /** @@ -67,7 +67,7 @@ export class PetApi extends runtime.BaseAPI { /** * Add a new pet to the store */ - async addPet(requestParameters: AddPetRequest): Promise { + async addPetRaw(requestParameters: AddPetRequest): Promise> { if (requestParameters.pet === null || requestParameters.pet === undefined) { throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); } @@ -91,13 +91,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: PetToJSON(requestParameters.pet), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest): Promise { + await this.addPetRaw(requestParameters); } /** * Deletes a pet */ - async deletePet(requestParameters: DeletePetRequest): Promise { + async deletePetRaw(requestParameters: DeletePetRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); } @@ -122,14 +130,22 @@ export class PetApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest): Promise { + await this.deletePetRaw(requestParameters); } /** * Multiple status values can be provided with comma separated strings * Finds Pets by status */ - async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest): Promise>> { if (requestParameters.status === null || requestParameters.status === undefined) { throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); } @@ -157,15 +173,24 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - const json = await response.json() as Array; - return json.map(PetFromJSON); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + const response = await this.findPetsByStatusRaw(requestParameters); + return await response.value(); } /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags */ - async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest): Promise>> { if (requestParameters.tags === null || requestParameters.tags === undefined) { throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); } @@ -193,15 +218,24 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - const json = await response.json() as Array; - return json.map(PetFromJSON); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + const response = await this.findPetsByTagsRaw(requestParameters); + return await response.value(); } /** * Returns a single pet * Find pet by ID */ - async getPetById(requestParameters: GetPetByIdRequest): Promise { + async getPetByIdRaw(requestParameters: GetPetByIdRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); } @@ -217,13 +251,23 @@ export class PetApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return PetFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest): Promise { + const response = await this.getPetByIdRaw(requestParameters); + return await response.value(); } /** * Update an existing pet */ - async updatePet(requestParameters: UpdatePetRequest): Promise { + async updatePetRaw(requestParameters: UpdatePetRequest): Promise> { if (requestParameters.pet === null || requestParameters.pet === undefined) { throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); } @@ -247,13 +291,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: PetToJSON(requestParameters.pet), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest): Promise { + await this.updatePetRaw(requestParameters); } /** * Updates a pet in the store with form data */ - async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); } @@ -284,13 +336,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: formData, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + await this.updatePetWithFormRaw(requestParameters); } /** * uploads an image */ - async uploadFile(requestParameters: UploadFileRequest): Promise { + async uploadFileRaw(requestParameters: UploadFileRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); } @@ -321,7 +381,16 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: formData, }); - return ApiResponseFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest): Promise { + const response = await this.uploadFileRaw(requestParameters); + return await response.value(); } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts index 58bf85a17376..1eb35777264f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts @@ -40,7 +40,7 @@ export class StoreApi extends runtime.BaseAPI { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * Delete purchase order by ID */ - async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + async deleteOrderRaw(requestParameters: DeleteOrderRequest): Promise> { if (requestParameters.orderId === null || requestParameters.orderId === undefined) { throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); } @@ -52,14 +52,23 @@ export class StoreApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + await this.deleteOrderRaw(requestParameters); } /** * Returns a map of status codes to quantities * Returns pet inventories by status */ - async getInventory(): Promise<{ [key: string]: number; }> { + async getInventoryRaw(): Promise> { const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { @@ -71,14 +80,24 @@ export class StoreApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return response.json(); + + return new runtime.JSONApiResponse(response); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(): Promise<{ [key: string]: number; }> { + const response = await this.getInventoryRaw(); + return await response.value(); } /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * Find purchase order by ID */ - async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + async getOrderByIdRaw(requestParameters: GetOrderByIdRequest): Promise> { if (requestParameters.orderId === null || requestParameters.orderId === undefined) { throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); } @@ -90,13 +109,23 @@ export class StoreApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return OrderFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + const response = await this.getOrderByIdRaw(requestParameters); + return await response.value(); } /** * Place an order for a pet */ - async placeOrder(requestParameters: PlaceOrderRequest): Promise { + async placeOrderRaw(requestParameters: PlaceOrderRequest): Promise> { if (requestParameters.order === null || requestParameters.order === undefined) { throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); } @@ -111,7 +140,16 @@ export class StoreApi extends runtime.BaseAPI { headers: headerParameters, body: OrderToJSON(requestParameters.order), }); - return OrderFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + const response = await this.placeOrderRaw(requestParameters); + return await response.value(); } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts index 61ad2b3e63ec..407500ed2d0f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts @@ -58,7 +58,7 @@ export class UserApi extends runtime.BaseAPI { * This can only be done by the logged in user. * Create user */ - async createUser(requestParameters: CreateUserRequest): Promise { + async createUserRaw(requestParameters: CreateUserRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); } @@ -73,13 +73,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: UserToJSON(requestParameters.user), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest): Promise { + await this.createUserRaw(requestParameters); } /** * Creates list of users with given input array */ - async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); } @@ -94,13 +103,21 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: requestParameters.user.map(UserToJSON), }); - return response; + + return new runtime.VoidApiResponse(response); } /** * Creates list of users with given input array */ - async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + await this.createUsersWithArrayInputRaw(requestParameters); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); } @@ -115,14 +132,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: requestParameters.user.map(UserToJSON), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + await this.createUsersWithListInputRaw(requestParameters); } /** * This can only be done by the logged in user. * Delete user */ - async deleteUser(requestParameters: DeleteUserRequest): Promise { + async deleteUserRaw(requestParameters: DeleteUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); } @@ -134,13 +159,22 @@ export class UserApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest): Promise { + await this.deleteUserRaw(requestParameters); } /** * Get user by user name */ - async getUserByName(requestParameters: GetUserByNameRequest): Promise { + async getUserByNameRaw(requestParameters: GetUserByNameRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); } @@ -152,13 +186,22 @@ export class UserApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return UserFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + const response = await this.getUserByNameRaw(requestParameters); + return await response.value(); } /** * Logs user into the system */ - async loginUser(requestParameters: LoginUserRequest): Promise { + async loginUserRaw(requestParameters: LoginUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); } @@ -185,13 +228,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - return response.text(); + + return new runtime.TextApiResponse(response); + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest): Promise { + const response = await this.loginUserRaw(requestParameters); + return await response.value(); } /** * Logs out current logged in user session */ - async logoutUser(): Promise { + async logoutUserRaw(): Promise> { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ @@ -199,14 +251,22 @@ export class UserApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(): Promise { + await this.logoutUserRaw(); } /** * This can only be done by the logged in user. * Updated user */ - async updateUser(requestParameters: UpdateUserRequest): Promise { + async updateUserRaw(requestParameters: UpdateUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); } @@ -225,7 +285,16 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: UserToJSON(requestParameters.user), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest): Promise { + await this.updateUserRaw(requestParameters); } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts new file mode 100644 index 000000000000..fdfab390edd1 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts @@ -0,0 +1,60 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists } from '../runtime'; +/** + * Describes the result of uploading an image resource + * @export + * @interface ModelApiResponse + */ +export interface ModelApiResponse { + /** + * + * @type {number} + * @memberof ModelApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + message?: string; +} + +export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return { + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], + }; +} + +export function ModelApiResponseToJSON(value?: ModelApiResponse): any { + if (value === undefined) { + return undefined; + } + return { + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/index.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/index.ts index f53c1dd42bdd..b07ddc8446a0 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/index.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/index.ts @@ -1,5 +1,5 @@ -export * from './ApiResponse'; export * from './Category'; +export * from './ModelApiResponse'; export * from './Order'; export * from './Pet'; export * from './Tag'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 924d34da3706..415564cfd090 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -194,7 +194,7 @@ export function exists(json: any, key: string) { return value !== null && value !== undefined; } -function querystring(params: HTTPQuery) { +export function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { const value = params[key]; @@ -224,3 +224,44 @@ export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; } + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value() { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value() { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.text(); + }; +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts index d23ba2e93031..a676e0d0062c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/PetApi.ts @@ -14,9 +14,9 @@ import * as runtime from '../runtime'; import { - ApiResponse, - ApiResponseFromJSON, - ApiResponseToJSON, + ModelApiResponse, + ModelApiResponseFromJSON, + ModelApiResponseToJSON, Pet, PetFromJSON, PetToJSON, @@ -56,7 +56,7 @@ export interface UpdatePetWithFormRequest { export interface UploadFileRequest { petId: number; additionalMetadata?: string; - file?: any; + file?: Blob; } /** @@ -67,7 +67,7 @@ export class PetApi extends runtime.BaseAPI { /** * Add a new pet to the store */ - async addPet(requestParameters: AddPetRequest): Promise { + async addPetRaw(requestParameters: AddPetRequest): Promise> { if (requestParameters.pet === null || requestParameters.pet === undefined) { throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); } @@ -91,13 +91,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: PetToJSON(requestParameters.pet), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest): Promise { + await this.addPetRaw(requestParameters); } /** * Deletes a pet */ - async deletePet(requestParameters: DeletePetRequest): Promise { + async deletePetRaw(requestParameters: DeletePetRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); } @@ -122,14 +130,22 @@ export class PetApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest): Promise { + await this.deletePetRaw(requestParameters); } /** * Multiple status values can be provided with comma separated strings * Finds Pets by status */ - async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest): Promise>> { if (requestParameters.status === null || requestParameters.status === undefined) { throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); } @@ -157,15 +173,24 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - const json = await response.json() as Array; - return json.map(PetFromJSON); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise> { + const response = await this.findPetsByStatusRaw(requestParameters); + return await response.value(); } /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags */ - async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest): Promise>> { if (requestParameters.tags === null || requestParameters.tags === undefined) { throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); } @@ -193,15 +218,24 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - const json = await response.json() as Array; - return json.map(PetFromJSON); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise> { + const response = await this.findPetsByTagsRaw(requestParameters); + return await response.value(); } /** * Returns a single pet * Find pet by ID */ - async getPetById(requestParameters: GetPetByIdRequest): Promise { + async getPetByIdRaw(requestParameters: GetPetByIdRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); } @@ -217,13 +251,23 @@ export class PetApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return PetFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest): Promise { + const response = await this.getPetByIdRaw(requestParameters); + return await response.value(); } /** * Update an existing pet */ - async updatePet(requestParameters: UpdatePetRequest): Promise { + async updatePetRaw(requestParameters: UpdatePetRequest): Promise> { if (requestParameters.pet === null || requestParameters.pet === undefined) { throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); } @@ -247,13 +291,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: PetToJSON(requestParameters.pet), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest): Promise { + await this.updatePetRaw(requestParameters); } /** * Updates a pet in the store with form data */ - async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); } @@ -284,13 +336,21 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: formData, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise { + await this.updatePetWithFormRaw(requestParameters); } /** * uploads an image */ - async uploadFile(requestParameters: UploadFileRequest): Promise { + async uploadFileRaw(requestParameters: UploadFileRequest): Promise> { if (requestParameters.petId === null || requestParameters.petId === undefined) { throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); } @@ -321,7 +381,16 @@ export class PetApi extends runtime.BaseAPI { headers: headerParameters, body: formData, }); - return ApiResponseFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest): Promise { + const response = await this.uploadFileRaw(requestParameters); + return await response.value(); } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts index 58bf85a17376..1eb35777264f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/StoreApi.ts @@ -40,7 +40,7 @@ export class StoreApi extends runtime.BaseAPI { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * Delete purchase order by ID */ - async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + async deleteOrderRaw(requestParameters: DeleteOrderRequest): Promise> { if (requestParameters.orderId === null || requestParameters.orderId === undefined) { throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); } @@ -52,14 +52,23 @@ export class StoreApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest): Promise { + await this.deleteOrderRaw(requestParameters); } /** * Returns a map of status codes to quantities * Returns pet inventories by status */ - async getInventory(): Promise<{ [key: string]: number; }> { + async getInventoryRaw(): Promise> { const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { @@ -71,14 +80,24 @@ export class StoreApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return response.json(); + + return new runtime.JSONApiResponse(response); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(): Promise<{ [key: string]: number; }> { + const response = await this.getInventoryRaw(); + return await response.value(); } /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * Find purchase order by ID */ - async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + async getOrderByIdRaw(requestParameters: GetOrderByIdRequest): Promise> { if (requestParameters.orderId === null || requestParameters.orderId === undefined) { throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); } @@ -90,13 +109,23 @@ export class StoreApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return OrderFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest): Promise { + const response = await this.getOrderByIdRaw(requestParameters); + return await response.value(); } /** * Place an order for a pet */ - async placeOrder(requestParameters: PlaceOrderRequest): Promise { + async placeOrderRaw(requestParameters: PlaceOrderRequest): Promise> { if (requestParameters.order === null || requestParameters.order === undefined) { throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); } @@ -111,7 +140,16 @@ export class StoreApi extends runtime.BaseAPI { headers: headerParameters, body: OrderToJSON(requestParameters.order), }); - return OrderFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest): Promise { + const response = await this.placeOrderRaw(requestParameters); + return await response.value(); } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts index 61ad2b3e63ec..407500ed2d0f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/apis/UserApi.ts @@ -58,7 +58,7 @@ export class UserApi extends runtime.BaseAPI { * This can only be done by the logged in user. * Create user */ - async createUser(requestParameters: CreateUserRequest): Promise { + async createUserRaw(requestParameters: CreateUserRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); } @@ -73,13 +73,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: UserToJSON(requestParameters.user), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest): Promise { + await this.createUserRaw(requestParameters); } /** * Creates list of users with given input array */ - async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); } @@ -94,13 +103,21 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: requestParameters.user.map(UserToJSON), }); - return response; + + return new runtime.VoidApiResponse(response); } /** * Creates list of users with given input array */ - async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise { + await this.createUsersWithArrayInputRaw(requestParameters); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest): Promise> { if (requestParameters.user === null || requestParameters.user === undefined) { throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); } @@ -115,14 +132,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: requestParameters.user.map(UserToJSON), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise { + await this.createUsersWithListInputRaw(requestParameters); } /** * This can only be done by the logged in user. * Delete user */ - async deleteUser(requestParameters: DeleteUserRequest): Promise { + async deleteUserRaw(requestParameters: DeleteUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); } @@ -134,13 +159,22 @@ export class UserApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest): Promise { + await this.deleteUserRaw(requestParameters); } /** * Get user by user name */ - async getUserByName(requestParameters: GetUserByNameRequest): Promise { + async getUserByNameRaw(requestParameters: GetUserByNameRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); } @@ -152,13 +186,22 @@ export class UserApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return UserFromJSON(await response.json()); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest): Promise { + const response = await this.getUserByNameRaw(requestParameters); + return await response.value(); } /** * Logs user into the system */ - async loginUser(requestParameters: LoginUserRequest): Promise { + async loginUserRaw(requestParameters: LoginUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); } @@ -185,13 +228,22 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, query: queryParameters, }); - return response.text(); + + return new runtime.TextApiResponse(response); + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest): Promise { + const response = await this.loginUserRaw(requestParameters); + return await response.value(); } /** * Logs out current logged in user session */ - async logoutUser(): Promise { + async logoutUserRaw(): Promise> { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ @@ -199,14 +251,22 @@ export class UserApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(): Promise { + await this.logoutUserRaw(); } /** * This can only be done by the logged in user. * Updated user */ - async updateUser(requestParameters: UpdateUserRequest): Promise { + async updateUserRaw(requestParameters: UpdateUserRequest): Promise> { if (requestParameters.username === null || requestParameters.username === undefined) { throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); } @@ -225,7 +285,16 @@ export class UserApi extends runtime.BaseAPI { headers: headerParameters, body: UserToJSON(requestParameters.user), }); - return response; + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest): Promise { + await this.updateUserRaw(requestParameters); } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ModelApiResponse.ts new file mode 100644 index 000000000000..fdfab390edd1 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ModelApiResponse.ts @@ -0,0 +1,60 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists } from '../runtime'; +/** + * Describes the result of uploading an image resource + * @export + * @interface ModelApiResponse + */ +export interface ModelApiResponse { + /** + * + * @type {number} + * @memberof ModelApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + message?: string; +} + +export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return { + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], + }; +} + +export function ModelApiResponseToJSON(value?: ModelApiResponse): any { + if (value === undefined) { + return undefined; + } + return { + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + + diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/index.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/index.ts index f53c1dd42bdd..b07ddc8446a0 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/index.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/index.ts @@ -1,5 +1,5 @@ -export * from './ApiResponse'; export * from './Category'; +export * from './ModelApiResponse'; export * from './Order'; export * from './Pet'; export * from './Tag'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts index 924d34da3706..415564cfd090 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts @@ -194,7 +194,7 @@ export function exists(json: any, key: string) { return value !== null && value !== undefined; } -function querystring(params: HTTPQuery) { +export function querystring(params: HTTPQuery) { return Object.keys(params) .map((key) => { const value = params[key]; @@ -224,3 +224,44 @@ export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; } + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value() { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value() { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.text(); + }; +} diff --git a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json index 574f6929aecd..5310ef1dfba1 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json +++ b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json @@ -1526,14 +1526,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1548,20 +1546,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -1678,8 +1673,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -1691,7 +1685,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1706,7 +1699,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1714,14 +1706,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -1740,7 +1730,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -1821,8 +1810,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -1834,7 +1822,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -1956,7 +1943,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",