diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index c74876f1242..8e4b6d52a53 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -52,7 +52,7 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.{{httpMethod}}); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params {{#queryParams}} @@ -96,9 +96,9 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { {{#node}} localVarFormParams.append('{{baseName}}', {{paramName}}.data, {{paramName}}.name); {{/node}} - {{^node}} + {{#browser}} localVarFormParams.append('{{baseName}}', {{paramName}}, {{paramName}}.name); - {{/node}} + {{/browser}} {{/platforms}} {{/isFile}} } @@ -110,15 +110,14 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory { // Body Params {{#bodyParam}} - {{^consumes}} - requestContext.setHeaderParam("Content-Type", "application/json"); - {{/consumes}} - {{#consumes.0}} - requestContext.setHeaderParam("Content-Type", "{{{mediaType}}}"); - {{/consumes.0}} - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("{{dataType}}" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}} || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([{{#consumes}} + "{{{mediaType}}}"{{#hasMore}},{{/hasMore}} + {{/consumes}}]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}", "{{dataFormat}}"), + contentType + ); requestContext.setBody(serializedBody); {{/bodyParam}} @@ -153,12 +152,20 @@ export class {{classname}}ResponseProcessor { * @params response Response returned by the server for a request to {{nickname}} * @throws ApiException if the response code was not in [200, 299] */ - public {{nickname}}(response: ResponseContext): {{#returnType}} {{{returnType}}}{{/returnType}} {{^returnType}} void {{/returnType}} { + public async {{nickname}}(response: ResponseContext): Promise<{{#returnType}}{{{returnType}}}{{/returnType}} {{^returnType}}void{{/returnType}}> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); {{#responses}} if (isCodeInRange("{{code}}", response.httpStatusCode)) { {{#dataType}} - const jsonBody = JSON.parse(response.body); - const body: {{{dataType}}} = ObjectSerializer.deserialize(jsonBody, "{{{dataType}}}", "{{returnFormat}}") as {{{dataType}}}; + {{#isBinary}} + const body: {{{dataType}}} = await response.getBodyAsFile() as any as {{{returnType}}}; + {{/isBinary}} + {{^isBinary}} + const body: {{{dataType}}} = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{{{dataType}}}", "{{returnFormat}}" + ) as {{{dataType}}}; + {{/isBinary}} {{#isSuccessCode}} return body; {{/isSuccessCode}} @@ -173,21 +180,29 @@ export class {{classname}}ResponseProcessor { {{^isSuccessCode}} throw new ApiException(response.httpStatusCode, "{{message}}"); {{/isSuccessCode}} - {{/dataType}} + {{/dataType}} } {{/responses}} - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - {{#returnType}} - const jsonBody = JSON.parse(response.body); - const body: {{{returnType}}} = ObjectSerializer.deserialize(jsonBody, "{{{returnType}}}", "{{returnFormat}}") as {{{returnType}}}; - return body; - {{/returnType}} - {{^returnType}} - return; - {{/returnType}} + {{#returnType}} + {{#isBinary}} + const body: {{{returnType}}} = await response.getBodyAsFile() as any as {{{returnType}}}; + {{/isBinary}} + {{^isBinary}} + const body: {{{returnType}}} = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{{{returnType}}}", "{{returnFormat}}" + ) as {{{returnType}}}; + {{/isBinary}} + return body; + {{/returnType}} + {{^returnType}} + return; + {{/returnType}} } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 2850e31dabb..66bdb2e5c2c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -43,9 +43,9 @@ export type HttpFile = { name: string }; {{/node}} -{{^node}} +{{#browser}} export type HttpFile = {{{fileContentDataType}}} & { readonly name: string }; -{{/node}} +{{/browser}} {{/platforms}} @@ -141,12 +141,104 @@ export class RequestContext { } } -export class ResponseContext { +export interface ResponseBody { + text(): Promise; + binary(): Promise<{{{fileContentDataType}}}>; +} - public constructor(public httpStatusCode: number, - public headers: { [key: string]: string }, public body: string) { + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise<{{{fileContentDataType}}}>) {} + + binary(): Promise<{{{fileContentDataType}}}> { + return this.dataSource; + } + + async text(): Promise { + const data: {{{fileContentDataType}}} = await this.dataSource; + {{#platforms}} + {{#node}} + return data.toString(); + {{/node}} + {{#browser}} + // @ts-ignore + if (data.text) { + // @ts-ignore + return data.text(); + } + + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.addEventListener("load", () => resolve(reader.result)); + reader.addEventListener("error", () => reject(reader.error)); + reader.readAsText(data); + }); + {{/browser}} + {{/platforms}} + } +} + +export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } + + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + {{#platforms}} + {{#node}} + return { data, name: fileName }; + {{/node}} + {{#browser}} + const contentType = this.headers["content-type"] || ""; + try { + return new File([data], fileName, { type: contentType }); + } catch (error) { + /** Fallback for when the File constructor is not available */ + return Object.assign(data, { + name: fileName, + type: contentType + }); + } + {{/browser}} + {{/platforms}} } - } export interface HttpLibrary { diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index f25e141554e..691b8187ccd 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -1,33 +1,52 @@ -declare var fetch: any; - import {HttpLibrary, RequestContext, ResponseContext} from './http'; -import 'es6-promise/auto'; import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; -import 'isomorphic-fetch'; +{{#platforms}} +{{#node}} +import fetch from "node-fetch"; +{{/node}} +{{#browser}} +import "whatwg-fetch"; +{{/browser}} +{{/platforms}} export class IsomorphicFetchHttpLibrary implements HttpLibrary { public send(request: RequestContext): Observable { let method = request.getHttpMethod().toString(); let body = request.getBody(); - + const resultPromise = fetch(request.getUrl(), { method: method, body: body as any, headers: request.getHeaders(), + {{#platforms}} + {{#browser}} credentials: "same-origin" + {{/browser}} + {{/platforms}} }).then((resp: any) => { - // hack - let headers = (resp.headers as any)._headers; - for (let key in headers) { - headers[key] = (headers[key] as Array).join("; "); - } - - return resp.text().then((body: string) => { - return new ResponseContext(resp.status, headers, body) + const headers: { [name: string]: string } = {}; + resp.headers.forEach((value: string, name: string) => { + headers[name] = value; }); + + {{#platforms}} + {{#node}} + const body = { + text: () => resp.text(), + binary: () => resp.buffer() + }; + {{/node}} + {{^node}} + const body = { + text: () => resp.text(), + binary: () => resp.blob() + }; + {{/node}} + {{/platforms}} + return new ResponseContext(resp.status, headers, body); }); - + return from>(resultPromise); } diff --git a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache index 63fc7d39185..d6a25d993ec 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/jquery.mustache @@ -1,13 +1,9 @@ -import {HttpLibrary, RequestContext, ResponseContext, HttpException} from './http'; +import { HttpLibrary, RequestContext, ResponseContext, HttpException, SelfDecodingBody } from './http'; import * as e6p from 'es6-promise' import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub'{{/useRxJS}}; e6p.polyfill(); import * as $ from 'jquery'; -{{#platforms}} -{{#node}} -import * as FormData from "form-data"; -{{/node}} -{{/platforms}} + export class JQueryHttpLibrary implements HttpLibrary { @@ -21,10 +17,20 @@ export class JQueryHttpLibrary implements HttpLibrary { type: method, headers: request.getHeaders(), processData: false, - xhrFields: { withCredentials: true }, + xhrFields: { withCredentials: true }, data: body }; + /** + * Allow receiving binary data with jquery ajax + * + * Source: https://keyangxiang.com/2017/09/01/HTML5-XHR-download-binary-content-as-Blob/ + */ + requestOptions.beforeSend = (jqXHR: any, settings: any) => { + settings.xhr().responseType = "blob"; + }; + + if (request.getHeaders()['Content-Type']) { requestOptions.contentType = headerParams['Content-Type']; } @@ -48,9 +54,12 @@ export class JQueryHttpLibrary implements HttpLibrary { const sentRequest = $.ajax(requestOptions); const resultPromise = new Promise((resolve, reject) => { - sentRequest.done((resp, _, jqXHR) => { - const headers = this.getResponseHeaders(jqXHR) - const result = new ResponseContext(jqXHR.status, headers, JSON.stringify(resp)); + sentRequest.done((data, _, jqXHR) => { + const result = new ResponseContext( + jqXHR.status, + this.getResponseHeaders(jqXHR), + new SelfDecodingBody(Promise.resolve(data)) + ); resolve(result); }) sentRequest.fail((jqXHR: any) => { diff --git a/modules/openapi-generator/src/main/resources/typescript/index.mustache b/modules/openapi-generator/src/main/resources/typescript/index.mustache index b1e833cf960..3ac251c10ce 100644 --- a/modules/openapi-generator/src/main/resources/typescript/index.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/index.mustache @@ -1,3 +1,5 @@ +import 'es6-promise/auto'; + export * from './http/http'; export * from './auth/auth'; export * from './models/all'; diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index e751e2d047c..5a14d7ac344 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -21,6 +21,12 @@ let primitives = [ "number", "any" ]; + +const supportedMediaTypes: { [mediaType: string]: number } = { + "application/json": Infinity, + "application/octet-stream": 0 +} + let enumsMap: Set = new Set([ {{#models}} @@ -162,4 +168,73 @@ export class ObjectSerializer { return instance; } } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (!mediaTypes) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + let selectedMediaType: string | undefined = undefined; + let selectedRank: number = -Infinity; + for (const mediaType of normalMediaTypes) { + if (supportedMediaTypes[mediaType!] > selectedRank) { + selectedMediaType = mediaType; + selectedRank = supportedMediaTypes[mediaType!]; + } + } + + if (selectedMediaType === undefined) { + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + return selectedMediaType!; + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (mediaType === "application/json") { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (mediaType === "application/json") { + return JSON.parse(rawData); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } } diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 67d11757208..608318ea2df 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -19,8 +19,15 @@ "dependencies": { {{#frameworks}} {{#fetch-api}} - "isomorphic-fetch": "^2.2.1", - "@types/isomorphic-fetch": "0.0.34", + {{#platforms}} + {{#node}} + "node-fetch": "^2.6.0", + "@types/node-fetch": "^2.5.7", + {{/node}} + {{#browser}} + "whatwg-fetch": "^3.0.0", + {{/browser}} + {{/platforms}} {{/fetch-api}} {{#jquery}} "@types/jquery": "^3.3.29", diff --git a/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache index 103a5de8635..5831f2409da 100644 --- a/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/tsconfig.mustache @@ -16,7 +16,14 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, + {{#platforms}} + {{#node}} + "lib": [ "es6" ] + {{/node}} + {{#browser}} "lib": [ "es6", "dom" ] + {{/browser}} + {{/platforms}} }, "exclude": [ "dist", diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts index 8744f0909be..f86ca7a612e 100644 --- a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -33,7 +33,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -43,10 +43,16 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Pet", ""), + contentType + ); requestContext.setBody(serializedBody); let authMethod = null; @@ -80,7 +86,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -121,7 +127,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (status !== undefined) { @@ -164,7 +170,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (tags !== undefined) { @@ -208,7 +214,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -247,7 +253,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -257,10 +263,16 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Pet", ""), + contentType + ); requestContext.setBody(serializedBody); let authMethod = null; @@ -296,7 +308,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -350,7 +362,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -394,15 +406,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to addPet * @throws ApiException if the response code was not in [200, 299] */ - public addPet(response: ResponseContext): void { + public async addPet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -414,15 +428,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to deletePet * @throws ApiException if the response code was not in [200, 299] */ - public deletePet(response: ResponseContext): void { + public async deletePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid pet value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -434,22 +450,28 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to findPetsByStatus * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByStatus(response: ResponseContext): Array { + public async findPetsByStatus(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid status value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; - return body; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -461,22 +483,28 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to findPetsByTags * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByTags(response: ResponseContext): Array { + public async findPetsByTags(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid tag value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; - return body; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -488,10 +516,13 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to getPetById * @throws ApiException if the response code was not in [200, 299] */ - public getPetById(response: ResponseContext): Pet { + public async getPetById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -500,13 +531,16 @@ export class PetApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Pet not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; - return body; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -518,7 +552,8 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePet * @throws ApiException if the response code was not in [200, 299] */ - public updatePet(response: ResponseContext): void { + public async updatePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } @@ -528,11 +563,12 @@ export class PetApiResponseProcessor { if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Validation exception"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -544,15 +580,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePetWithForm * @throws ApiException if the response code was not in [200, 299] */ - public updatePetWithForm(response: ResponseContext): void { + public async updatePetWithForm(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -564,19 +602,25 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to uploadFile * @throws ApiException if the response code was not in [200, 299] */ - public uploadFile(response: ResponseContext): ApiResponse { + public async uploadFile(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; return body; } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; - return body; + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts index 2168c95ddb9..6e92f2ac33f 100644 --- a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -34,7 +34,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -62,7 +62,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -103,7 +103,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -137,7 +137,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -147,10 +147,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Order", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -171,18 +173,20 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to deleteOrder * @throws ApiException if the response code was not in [200, 299] */ - public deleteOrder(response: ResponseContext): void { + public async deleteOrder(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Order not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -194,19 +198,25 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to getInventory * @throws ApiException if the response code was not in [200, 299] */ - public getInventory(response: ResponseContext): { [key: string]: number; } { + public async getInventory(response: ResponseContext): Promise<{ [key: string]: number; } > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; return body; } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; - return body; + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -218,10 +228,13 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to getOrderById * @throws ApiException if the response code was not in [200, 299] */ - public getOrderById(response: ResponseContext): Order { + public async getOrderById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -230,13 +243,16 @@ export class StoreApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Order not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; - return body; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -248,22 +264,28 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to placeOrder * @throws ApiException if the response code was not in [200, 299] */ - public placeOrder(response: ResponseContext): Order { + public async placeOrder(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid Order"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; - return body; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts index 9a4c150a22f..efce92585dc 100644 --- a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -33,7 +33,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -43,10 +43,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "User", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -72,7 +74,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -82,10 +84,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Array", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -111,7 +115,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -121,10 +125,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Array", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -152,7 +158,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -187,7 +193,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -228,7 +234,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (username !== undefined) { @@ -261,7 +267,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -304,7 +310,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -314,10 +320,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "User", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -338,15 +346,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUser * @throws ApiException if the response code was not in [200, 299] */ - public createUser(response: ResponseContext): void { + public async createUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -358,15 +368,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUsersWithArrayInput * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithArrayInput(response: ResponseContext): void { + public async createUsersWithArrayInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -378,15 +390,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUsersWithListInput * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithListInput(response: ResponseContext): void { + public async createUsersWithListInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -398,18 +412,20 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to deleteUser * @throws ApiException if the response code was not in [200, 299] */ - public deleteUser(response: ResponseContext): void { + public async deleteUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -421,10 +437,13 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to getUserByName * @throws ApiException if the response code was not in [200, 299] */ - public getUserByName(response: ResponseContext): User { + public async getUserByName(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -433,13 +452,16 @@ export class UserApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; - return body; + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -451,22 +473,28 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to loginUser * @throws ApiException if the response code was not in [200, 299] */ - public loginUser(response: ResponseContext): string { + public async loginUser(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username/password supplied"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; - return body; + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -478,15 +506,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to logoutUser * @throws ApiException if the response code was not in [200, 299] */ - public logoutUser(response: ResponseContext): void { + public async logoutUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -498,18 +528,20 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to updateUser * @throws ApiException if the response code was not in [200, 299] */ - public updateUser(response: ResponseContext): void { + public async updateUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid user supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/default/http/http.ts b/samples/client/petstore/typescript/builds/default/http/http.ts index 7549c847aa3..6de17431aa2 100644 --- a/samples/client/petstore/typescript/builds/default/http/http.ts +++ b/samples/client/petstore/typescript/builds/default/http/http.ts @@ -123,12 +123,70 @@ export class RequestContext { } } -export class ResponseContext { +export interface ResponseBody { + text(): Promise; + binary(): Promise; +} - public constructor(public httpStatusCode: number, - public headers: { [key: string]: string }, public body: string) { + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise) {} + + binary(): Promise { + return this.dataSource; + } + + async text(): Promise { + const data: Buffer = await this.dataSource; + return data.toString(); + } +} + +export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } + + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + return { data, name: fileName }; } - } export interface HttpLibrary { diff --git a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts index f7e6474c253..ed390df7ce1 100644 --- a/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts +++ b/samples/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts @@ -1,33 +1,30 @@ -declare var fetch: any; - import {HttpLibrary, RequestContext, ResponseContext} from './http'; -import 'es6-promise/auto'; import { from, Observable } from '../rxjsStub'; -import 'isomorphic-fetch'; +import fetch from "node-fetch"; export class IsomorphicFetchHttpLibrary implements HttpLibrary { public send(request: RequestContext): Observable { let method = request.getHttpMethod().toString(); let body = request.getBody(); - + const resultPromise = fetch(request.getUrl(), { method: method, body: body as any, headers: request.getHeaders(), - credentials: "same-origin" }).then((resp: any) => { - // hack - let headers = (resp.headers as any)._headers; - for (let key in headers) { - headers[key] = (headers[key] as Array).join("; "); - } - - return resp.text().then((body: string) => { - return new ResponseContext(resp.status, headers, body) + const headers: { [name: string]: string } = {}; + resp.headers.forEach((value: string, name: string) => { + headers[name] = value; }); + + const body = { + text: () => resp.text(), + binary: () => resp.buffer() + }; + return new ResponseContext(resp.status, headers, body); }); - + return from>(resultPromise); } diff --git a/samples/client/petstore/typescript/builds/default/index.ts b/samples/client/petstore/typescript/builds/default/index.ts index fd12234aa0e..575141afce1 100644 --- a/samples/client/petstore/typescript/builds/default/index.ts +++ b/samples/client/petstore/typescript/builds/default/index.ts @@ -1,3 +1,5 @@ +import 'es6-promise/auto'; + export * from './http/http'; export * from './auth/auth'; export * from './models/all'; diff --git a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index f6ca619bf10..6eef999baaa 100644 --- a/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -23,6 +23,12 @@ let primitives = [ "number", "any" ]; + +const supportedMediaTypes: { [mediaType: string]: number } = { + "application/json": Infinity, + "application/octet-stream": 0 +} + let enumsMap: Set = new Set([ "OrderStatusEnum", @@ -156,4 +162,73 @@ export class ObjectSerializer { return instance; } } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (!mediaTypes) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + let selectedMediaType: string | undefined = undefined; + let selectedRank: number = -Infinity; + for (const mediaType of normalMediaTypes) { + if (supportedMediaTypes[mediaType!] > selectedRank) { + selectedMediaType = mediaType; + selectedRank = supportedMediaTypes[mediaType!]; + } + } + + if (selectedMediaType === undefined) { + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + return selectedMediaType!; + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (mediaType === "application/json") { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (mediaType === "application/json") { + return JSON.parse(rawData); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } } diff --git a/samples/client/petstore/typescript/builds/default/package-lock.json b/samples/client/petstore/typescript/builds/default/package-lock.json index e91cff7ebba..94caf0f4b22 100644 --- a/samples/client/petstore/typescript/builds/default/package-lock.json +++ b/samples/client/petstore/typescript/builds/default/package-lock.json @@ -4,16 +4,32 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/isomorphic-fetch": { - "version": "0.0.34", - "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz", - "integrity": "sha1-PDSD5gbAQTeEOOlRRk8A5OYHBtY=" - }, "@types/node": { "version": "12.12.7", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==" }, + "@types/node-fetch": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.7.tgz", + "integrity": "sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw==", + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -37,14 +53,6 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "~0.4.13" - } - }, "es6-promise": { "version": "4.2.5", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", @@ -60,28 +68,6 @@ "mime-types": "^2.1.12" } }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", - "requires": { - "node-fetch": "^1.0.1", - "whatwg-fetch": ">=0.10.0" - } - }, "mime-db": { "version": "1.40.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", @@ -96,13 +82,9 @@ } }, "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "querystringify": { "version": "2.1.0", @@ -114,14 +96,9 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, "typescript": { "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "resolved": false, "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", "dev": true }, @@ -133,11 +110,6 @@ "querystringify": "^2.0.0", "requires-port": "^1.0.0" } - }, - "whatwg-fetch": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", - "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" } } } diff --git a/samples/client/petstore/typescript/builds/default/package.json b/samples/client/petstore/typescript/builds/default/package.json index 70b348648e1..7bcc9bd25a1 100644 --- a/samples/client/petstore/typescript/builds/default/package.json +++ b/samples/client/petstore/typescript/builds/default/package.json @@ -17,8 +17,8 @@ "prepublishOnly": "npm run build" }, "dependencies": { - "isomorphic-fetch": "^2.2.1", - "@types/isomorphic-fetch": "0.0.34", + "node-fetch": "^2.6.0", + "@types/node-fetch": "^2.5.7", "@types/node": "*", "form-data": "^2.5.0", "btoa": "^1.2.1", diff --git a/samples/client/petstore/typescript/builds/default/tsconfig.json b/samples/client/petstore/typescript/builds/default/tsconfig.json index 142f3fa631a..0f376008e1a 100644 --- a/samples/client/petstore/typescript/builds/default/tsconfig.json +++ b/samples/client/petstore/typescript/builds/default/tsconfig.json @@ -16,7 +16,7 @@ "sourceMap": true, "outDir": "./dist", "noLib": false, - "lib": [ "es6", "dom" ] + "lib": [ "es6" ] }, "exclude": [ "dist", diff --git a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts index e786d5ed8b9..6fec1ad3d23 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/PetApi.ts @@ -32,7 +32,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -42,10 +42,16 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Pet", ""), + contentType + ); requestContext.setBody(serializedBody); let authMethod = null; @@ -79,7 +85,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -120,7 +126,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (status !== undefined) { @@ -163,7 +169,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (tags !== undefined) { @@ -207,7 +213,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -246,7 +252,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -256,10 +262,16 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Pet" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + + "application/xml" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Pet", ""), + contentType + ); requestContext.setBody(serializedBody); let authMethod = null; @@ -295,7 +307,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -349,7 +361,7 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -393,15 +405,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to addPet * @throws ApiException if the response code was not in [200, 299] */ - public addPet(response: ResponseContext): void { + public async addPet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -413,15 +427,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to deletePet * @throws ApiException if the response code was not in [200, 299] */ - public deletePet(response: ResponseContext): void { + public async deletePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid pet value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -433,22 +449,28 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to findPetsByStatus * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByStatus(response: ResponseContext): Array { + public async findPetsByStatus(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid status value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; - return body; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -460,22 +482,28 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to findPetsByTags * @throws ApiException if the response code was not in [200, 299] */ - public findPetsByTags(response: ResponseContext): Array { + public async findPetsByTags(response: ResponseContext): Promise > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid tag value"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Array = ObjectSerializer.deserialize(jsonBody, "Array", "") as Array; - return body; + const body: Array = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Array", "" + ) as Array; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -487,10 +515,13 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to getPetById * @throws ApiException if the response code was not in [200, 299] */ - public getPetById(response: ResponseContext): Pet { + public async getPetById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -499,13 +530,16 @@ export class PetApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Pet not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet", "") as Pet; - return body; + const body: Pet = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Pet", "" + ) as Pet; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -517,7 +551,8 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePet * @throws ApiException if the response code was not in [200, 299] */ - public updatePet(response: ResponseContext): void { + public async updatePet(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } @@ -527,11 +562,12 @@ export class PetApiResponseProcessor { if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Validation exception"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -543,15 +579,17 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to updatePetWithForm * @throws ApiException if the response code was not in [200, 299] */ - public updatePetWithForm(response: ResponseContext): void { + public async updatePetWithForm(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("405", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid input"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -563,19 +601,25 @@ export class PetApiResponseProcessor { * @params response Response returned by the server for a request to uploadFile * @throws ApiException if the response code was not in [200, 299] */ - public uploadFile(response: ResponseContext): ApiResponse { + public async uploadFile(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; return body; } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse", "") as ApiResponse; - return body; + const body: ApiResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "ApiResponse", "" + ) as ApiResponse; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts index 89a778f6dff..c7cca9dc1d8 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/StoreApi.ts @@ -33,7 +33,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -61,7 +61,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -102,7 +102,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -136,7 +136,7 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -146,10 +146,12 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Order" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Order", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -170,18 +172,20 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to deleteOrder * @throws ApiException if the response code was not in [200, 299] */ - public deleteOrder(response: ResponseContext): void { + public async deleteOrder(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid ID supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Order not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -193,19 +197,25 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to getInventory * @throws ApiException if the response code was not in [200, 299] */ - public getInventory(response: ResponseContext): { [key: string]: number; } { + public async getInventory(response: ResponseContext): Promise<{ [key: string]: number; } > { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; return body; } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }", "int32") as { [key: string]: number; }; - return body; + const body: { [key: string]: number; } = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "{ [key: string]: number; }", "int32" + ) as { [key: string]: number; }; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -217,10 +227,13 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to getOrderById * @throws ApiException if the response code was not in [200, 299] */ - public getOrderById(response: ResponseContext): Order { + public async getOrderById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -229,13 +242,16 @@ export class StoreApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Order not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; - return body; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -247,22 +263,28 @@ export class StoreApiResponseProcessor { * @params response Response returned by the server for a request to placeOrder * @throws ApiException if the response code was not in [200, 299] */ - public placeOrder(response: ResponseContext): Order { + public async placeOrder(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid Order"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: Order = ObjectSerializer.deserialize(jsonBody, "Order", "") as Order; - return body; + const body: Order = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Order", "" + ) as Order; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts index 39b12334412..46222492ed8 100644 --- a/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts +++ b/samples/client/petstore/typescript/builds/jquery/apis/UserApi.ts @@ -32,7 +32,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -42,10 +42,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "User", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -71,7 +73,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -81,10 +83,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Array", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -110,7 +114,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -120,10 +124,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("Array<User>" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "Array", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -151,7 +157,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -186,7 +192,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -227,7 +233,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params if (username !== undefined) { @@ -260,7 +266,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -303,7 +309,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Make Request Context const requestContext = config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); - requestContext.setHeaderParam("Accept", "application/json") + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") // Query Params @@ -313,10 +319,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Body Params - requestContext.setHeaderParam("Content-Type", "application/json"); - // TODO: Should this be handled by ObjectSerializer? imo yes => confidential information included in local object should not be sent - const needsSerialization = ("User" !== "string") || requestContext.getHeaders()['Content-Type'] === 'application/json'; - const serializedBody = needsSerialization ? JSON.stringify(body || {}) : (body || "").toString(); // TODO: `toString` call is unnecessary + const contentType = ObjectSerializer.getPreferredMediaType([]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "User", ""), + contentType + ); requestContext.setBody(serializedBody); // Apply auth methods @@ -337,15 +345,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUser * @throws ApiException if the response code was not in [200, 299] */ - public createUser(response: ResponseContext): void { + public async createUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -357,15 +367,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUsersWithArrayInput * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithArrayInput(response: ResponseContext): void { + public async createUsersWithArrayInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -377,15 +389,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to createUsersWithListInput * @throws ApiException if the response code was not in [200, 299] */ - public createUsersWithListInput(response: ResponseContext): void { + public async createUsersWithListInput(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -397,18 +411,20 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to deleteUser * @throws ApiException if the response code was not in [200, 299] */ - public deleteUser(response: ResponseContext): void { + public async deleteUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -420,10 +436,13 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to getUserByName * @throws ApiException if the response code was not in [200, 299] */ - public getUserByName(response: ResponseContext): User { + public async getUserByName(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; return body; } if (isCodeInRange("400", response.httpStatusCode)) { @@ -432,13 +451,16 @@ export class UserApiResponseProcessor { if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: User = ObjectSerializer.deserialize(jsonBody, "User", "") as User; - return body; + const body: User = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "User", "" + ) as User; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -450,22 +472,28 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to loginUser * @throws ApiException if the response code was not in [200, 299] */ - public loginUser(response: ResponseContext): string { + public async loginUser(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { - const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; return body; } if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid username/password supplied"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const jsonBody = JSON.parse(response.body); - const body: string = ObjectSerializer.deserialize(jsonBody, "string", "") as string; - return body; + const body: string = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "string", "" + ) as string; + return body; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -477,15 +505,17 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to logoutUser * @throws ApiException if the response code was not in [200, 299] */ - public logoutUser(response: ResponseContext): void { + public async logoutUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("0", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "successful operation"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } @@ -497,18 +527,20 @@ export class UserApiResponseProcessor { * @params response Response returned by the server for a request to updateUser * @throws ApiException if the response code was not in [200, 299] */ - public updateUser(response: ResponseContext): void { + public async updateUser(response: ResponseContext): Promise< void> { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("400", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "Invalid user supplied"); } if (isCodeInRange("404", response.httpStatusCode)) { throw new ApiException(response.httpStatusCode, "User not found"); } - - // Work around for incorrect api specification in petstore.yaml + + // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; + return; } + let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } diff --git a/samples/client/petstore/typescript/builds/jquery/http/http.ts b/samples/client/petstore/typescript/builds/jquery/http/http.ts index 2fe01724d50..225d72814d7 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/http.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/http.ts @@ -118,12 +118,90 @@ export class RequestContext { } } -export class ResponseContext { +export interface ResponseBody { + text(): Promise; + binary(): Promise; +} - public constructor(public httpStatusCode: number, - public headers: { [key: string]: string }, public body: string) { + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise) {} + + binary(): Promise { + return this.dataSource; + } + + async text(): Promise { + const data: Blob = await this.dataSource; + // @ts-ignore + if (data.text) { + // @ts-ignore + return data.text(); + } + + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.addEventListener("load", () => resolve(reader.result)); + reader.addEventListener("error", () => reject(reader.error)); + reader.readAsText(data); + }); + } +} + +export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } + + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + const contentType = this.headers["content-type"] || ""; + try { + return new File([data], fileName, { type: contentType }); + } catch (error) { + /** Fallback for when the File constructor is not available */ + return Object.assign(data, { + name: fileName, + type: contentType + }); + } } - } export interface HttpLibrary { diff --git a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts index 4b144a79e2c..238eef3be08 100644 --- a/samples/client/petstore/typescript/builds/jquery/http/jquery.ts +++ b/samples/client/petstore/typescript/builds/jquery/http/jquery.ts @@ -1,9 +1,10 @@ -import {HttpLibrary, RequestContext, ResponseContext, HttpException} from './http'; +import { HttpLibrary, RequestContext, ResponseContext, HttpException, SelfDecodingBody } from './http'; import * as e6p from 'es6-promise' import { from, Observable } from '../rxjsStub'; e6p.polyfill(); import * as $ from 'jquery'; + export class JQueryHttpLibrary implements HttpLibrary { public send(request: RequestContext): Observable { @@ -16,10 +17,20 @@ export class JQueryHttpLibrary implements HttpLibrary { type: method, headers: request.getHeaders(), processData: false, - xhrFields: { withCredentials: true }, + xhrFields: { withCredentials: true }, data: body }; + /** + * Allow receiving binary data with jquery ajax + * + * Source: https://keyangxiang.com/2017/09/01/HTML5-XHR-download-binary-content-as-Blob/ + */ + requestOptions.beforeSend = (jqXHR: any, settings: any) => { + settings.xhr().responseType = "blob"; + }; + + if (request.getHeaders()['Content-Type']) { requestOptions.contentType = headerParams['Content-Type']; } @@ -43,9 +54,12 @@ export class JQueryHttpLibrary implements HttpLibrary { const sentRequest = $.ajax(requestOptions); const resultPromise = new Promise((resolve, reject) => { - sentRequest.done((resp, _, jqXHR) => { - const headers = this.getResponseHeaders(jqXHR) - const result = new ResponseContext(jqXHR.status, headers, JSON.stringify(resp)); + sentRequest.done((data, _, jqXHR) => { + const result = new ResponseContext( + jqXHR.status, + this.getResponseHeaders(jqXHR), + new SelfDecodingBody(Promise.resolve(data)) + ); resolve(result); }) sentRequest.fail((jqXHR: any) => { diff --git a/samples/client/petstore/typescript/builds/jquery/index.ts b/samples/client/petstore/typescript/builds/jquery/index.ts index fd12234aa0e..575141afce1 100644 --- a/samples/client/petstore/typescript/builds/jquery/index.ts +++ b/samples/client/petstore/typescript/builds/jquery/index.ts @@ -1,3 +1,5 @@ +import 'es6-promise/auto'; + export * from './http/http'; export * from './auth/auth'; export * from './models/all'; diff --git a/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts b/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts index f6ca619bf10..6eef999baaa 100644 --- a/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts +++ b/samples/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts @@ -23,6 +23,12 @@ let primitives = [ "number", "any" ]; + +const supportedMediaTypes: { [mediaType: string]: number } = { + "application/json": Infinity, + "application/octet-stream": 0 +} + let enumsMap: Set = new Set([ "OrderStatusEnum", @@ -156,4 +162,73 @@ export class ObjectSerializer { return instance; } } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (!mediaTypes) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + let selectedMediaType: string | undefined = undefined; + let selectedRank: number = -Infinity; + for (const mediaType of normalMediaTypes) { + if (supportedMediaTypes[mediaType!] > selectedRank) { + selectedMediaType = mediaType; + selectedRank = supportedMediaTypes[mediaType!]; + } + } + + if (selectedMediaType === undefined) { + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + return selectedMediaType!; + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (mediaType === "application/json") { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (mediaType === "application/json") { + return JSON.parse(rawData); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } } diff --git a/samples/client/petstore/typescript/builds/jquery/package-lock.json b/samples/client/petstore/typescript/builds/jquery/package-lock.json index cdbe4eeddc4..dd9642223ad 100644 --- a/samples/client/petstore/typescript/builds/jquery/package-lock.json +++ b/samples/client/petstore/typescript/builds/jquery/package-lock.json @@ -28,9 +28,9 @@ "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" }, "jquery": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", - "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz", + "integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==" }, "querystringify": { "version": "2.1.1", diff --git a/samples/client/petstore/typescript/tests/default/package-lock.json b/samples/client/petstore/typescript/tests/default/package-lock.json index 23c63616b5d..6bd3eb97155 100644 --- a/samples/client/petstore/typescript/tests/default/package-lock.json +++ b/samples/client/petstore/typescript/tests/default/package-lock.json @@ -34,9 +34,9 @@ "integrity": "sha512-uD0j/AQOa5le7afuK+u+woi8jNKF1vf3DN0H7LCJhft/lNNibUr7VcAesdgtWfEKveZol3ZG1CJqwx2Bhrnl8w==" }, "acorn": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", - "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==" }, "acorn-jsx": { "version": "3.0.1", @@ -748,9 +748,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "lru-cache": { "version": "4.1.5", @@ -803,23 +803,16 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "mkdirp": { - "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - } + "minimist": "^1.2.5" } }, "mocha": { @@ -841,6 +834,21 @@ "supports-color": "5.4.0" }, "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, "supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", @@ -1215,12 +1223,11 @@ "ts-petstore-client": { "version": "file:../../builds/default", "requires": { - "@types/isomorphic-fetch": "0.0.34", "@types/node": "*", "btoa": "^1.2.1", "es6-promise": "^4.2.4", "form-data": "^2.5.0", - "isomorphic-fetch": "^2.2.1", + "node-fetch": "^2.6.0", "url-parse": "^1.4.3" }, "dependencies": { @@ -1257,14 +1264,6 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "~0.4.13" - } - }, "es6-promise": { "version": "4.2.5", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", @@ -1280,25 +1279,11 @@ "mime-types": "^2.1.12" } }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, "isomorphic-fetch": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", "requires": { - "node-fetch": "^1.0.1", "whatwg-fetch": ">=0.10.0" } }, @@ -1316,13 +1301,9 @@ } }, "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "querystringify": { "version": "2.1.0", @@ -1334,11 +1315,6 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, "typescript": { "version": "2.9.2", "resolved": false, diff --git a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts index 974ebd2d134..7c4e142747f 100644 --- a/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/http/isomorphic-fetch.test.ts @@ -18,17 +18,15 @@ for (let libName in libs) { requestContext.addCookie("test-cookie", "cookie-value"); lib.send(requestContext).toPromise().then((resp: petstore.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - let body = JSON.parse(resp.body); + return resp.body.text(); + }).then((bodyText: string) => { + let body = JSON.parse(bodyText); expect(body["headers"]).to.exist; expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); done(); - }, - (e: any) => { - done(e); - } - ) - }) + }).catch(done) + }); it("POST-Request", (done) => { let requestContext = new petstore.RequestContext("http://httpbin.org/post", petstore.HttpMethod.POST); @@ -42,17 +40,16 @@ for (let libName in libs) { lib.send(requestContext).toPromise().then( (resp: petstore.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - let body = JSON.parse(resp.body); + return resp.body.text(); + }).then((bodyText: string) => { + let body = JSON.parse(bodyText); expect(body["headers"]).to.exist; expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); expect(body["files"]["testFile"]).to.equal("abc"); expect(body["form"]["test"]).to.equal("test2"); done(); - }, - (e: any) => { - done(e); - }) + }).catch(done) }); it("Cookies-Request", (done) => { @@ -62,13 +59,12 @@ for (let libName in libs) { lib.send(requestContext).toPromise().then( (resp: petstore.ResponseContext) => { expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - let body = JSON.parse(resp.body); + return resp.body.text(); + }).then((bodyText: string) => { + let body = JSON.parse(bodyText); expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); done(); - }, - (e: any) => { - done(e); - }) + }).catch(done) }) }) } \ No newline at end of file diff --git a/samples/client/petstore/typescript/tests/jquery/package-lock.json b/samples/client/petstore/typescript/tests/jquery/package-lock.json index 75916fc8781..b947dee2738 100644 --- a/samples/client/petstore/typescript/tests/jquery/package-lock.json +++ b/samples/client/petstore/typescript/tests/jquery/package-lock.json @@ -216,9 +216,9 @@ "integrity": "sha512-sY5AXXVZv4Y1VACTtR11UJCPHHudgY5i26Qj5TypE6DKlIApbwb5uqhXcJ5UUGbvZNRh7EeIoW+LrJumBsKp7w==" }, "acorn": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", - "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==" + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", + "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==" }, "acorn-globals": { "version": "4.3.2", @@ -250,9 +250,9 @@ "integrity": "sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==" }, "agent-base": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", - "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", "requires": { "es6-promisify": "^5.0.0" } @@ -294,22 +294,13 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" }, "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "optional": true, "requires": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "requires": { - "remove-trailing-separator": "^1.0.1" - } - } + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" } }, "aproba": { @@ -410,7 +401,8 @@ "async-each": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", - "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==" + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", + "optional": true }, "async-limiter": { "version": "1.0.0", @@ -543,14 +535,15 @@ "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==" }, "binary-extensions": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", - "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", + "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", + "optional": true }, "bluebird": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.1.tgz", - "integrity": "sha512-DdmyoGCleJnkbp3nkbxTLJ18rjDsE4yCggEwKNXkeV123sPNfOCYeDoeuOY+F2FrSjO1YXcTU+dsy96KMy+gcg==" + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, "bn.js": { "version": "4.11.8", @@ -678,6 +671,11 @@ "isarray": "^1.0.0" } }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -694,9 +692,9 @@ "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=" }, "cacache": { - "version": "12.0.3", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.3.tgz", - "integrity": "sha512-kqdmfXEGFepesTuROHMs3MpFLWrPkSSpRqOw80RCflZXy/khxaArvFrQ7uJxSUduzAufc6G0g1VUCOZXxWavPw==", + "version": "12.0.4", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.4.tgz", + "integrity": "sha512-a0tMB40oefvuInr4Cwb3GerbL9xTj1D5yg0T5xrjGCGyfvbxseIXX7BAO/u/hIXdafzOI5JC3wDwHyf24buOAQ==", "requires": { "bluebird": "^3.5.5", "chownr": "^1.1.1", @@ -816,28 +814,60 @@ "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" }, "chokidar": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", - "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.0.tgz", + "integrity": "sha512-aXAaho2VJtisB/1fg1+3nlLJqGOuewTzQpd/Tz0yTg2R0e4IGtshYvtjowyEumcBv2z+y4+kc75Mz7j5xJskcQ==", + "optional": true, "requires": { - "anymatch": "^2.0.0", - "async-each": "^1.0.1", - "braces": "^2.3.2", - "fsevents": "^1.2.7", - "glob-parent": "^3.1.0", - "inherits": "^2.0.3", - "is-binary-path": "^1.0.0", - "is-glob": "^4.0.0", - "normalize-path": "^3.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.2.1", - "upath": "^1.1.1" + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.2", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.4.0" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "optional": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "optional": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "optional": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "optional": true, + "requires": { + "is-number": "^7.0.0" + } + } } }, "chownr": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", - "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, "chrome-trace-event": { "version": "1.0.2", @@ -1318,9 +1348,9 @@ } }, "es6-promise": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", - "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" }, "es6-promisify": { "version": "5.0.0", @@ -1447,9 +1477,9 @@ }, "dependencies": { "acorn": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", - "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==" } } }, @@ -1673,14 +1703,14 @@ } }, "extract-zip": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", - "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", + "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", "requires": { - "concat-stream": "1.6.2", - "debug": "2.6.9", - "mkdirp": "0.5.1", - "yauzl": "2.4.1" + "concat-stream": "^1.6.2", + "debug": "^2.6.9", + "mkdirp": "^0.5.4", + "yauzl": "^2.10.0" }, "dependencies": { "debug": { @@ -1719,17 +1749,17 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, "fd-slicer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", "requires": { "pend": "~1.2.0" } }, "figgy-pudding": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz", - "integrity": "sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w==" + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz", + "integrity": "sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw==" }, "figures": { "version": "2.0.0", @@ -1872,485 +1902,10 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", - "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", - "optional": true, - "requires": { - "nan": "^2.12.1", - "node-pre-gyp": "^0.12.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "optional": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.5", - "bundled": true, - "optional": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "optional": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "chownr": { - "version": "1.1.1", - "bundled": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "optional": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "optional": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "optional": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "debug": { - "version": "4.1.1", - "bundled": true, - "optional": true, - "requires": { - "ms": "^2.1.1" - } - }, - "deep-extend": { - "version": "0.6.0", - "bundled": true, - "optional": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true, - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "bundled": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "bundled": 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.3", - "bundled": 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, - "optional": true - }, - "iconv-lite": { - "version": "0.4.24", - "bundled": true, - "optional": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ignore-walk": { - "version": "3.0.1", - "bundled": true, - "optional": true, - "requires": { - "minimatch": "^3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "optional": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "optional": true - }, - "ini": { - "version": "1.3.5", - "bundled": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "optional": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "optional": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "optional": true - }, - "minipass": { - "version": "2.3.5", - "bundled": true, - "optional": true, - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.2.1", - "bundled": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "optional": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.1.1", - "bundled": true, - "optional": true - }, - "needle": { - "version": "2.3.0", - "bundled": true, - "optional": true, - "requires": { - "debug": "^4.1.0", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - } - }, - "node-pre-gyp": { - "version": "0.12.0", - "bundled": true, - "optional": true, - "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "optional": true, - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, - "npm-bundled": { - "version": "1.0.6", - "bundled": true, - "optional": true - }, - "npm-packlist": { - "version": "1.4.1", - "bundled": true, - "optional": true, - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": 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, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "optional": true, - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "optional": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true, - "optional": true - }, - "rc": { - "version": "1.2.8", - "bundled": true, - "optional": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "bundled": 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.3", - "bundled": true, - "optional": true, - "requires": { - "glob": "^7.1.3" - } - }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true, - "optional": true - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true, - "optional": true - }, - "sax": { - "version": "1.2.4", - "bundled": true, - "optional": true - }, - "semver": { - "version": "5.7.0", - "bundled": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "optional": true - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "optional": 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, - "optional": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "optional": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "optional": true - }, - "tar": { - "version": "4.4.8", - "bundled": true, - "optional": true, - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "wide-align": { - "version": "1.1.3", - "bundled": true, - "optional": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "yallist": { - "version": "3.0.3", - "bundled": true, - "optional": true - } - } + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "optional": true }, "functional-red-black-tree": { "version": "1.0.1", @@ -2397,22 +1952,12 @@ } }, "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "optional": true, "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "requires": { - "is-extglob": "^2.1.0" - } - } + "is-glob": "^4.0.1" } }, "global-modules": { @@ -2573,11 +2118,11 @@ "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=" }, "https-proxy-agent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", - "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", + "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", "requires": { - "agent-base": "^4.1.0", + "agent-base": "^4.3.0", "debug": "^3.1.0" }, "dependencies": { @@ -2702,11 +2247,12 @@ } }, "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=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "optional": true, "requires": { - "binary-extensions": "^1.0.0" + "binary-extensions": "^2.0.0" } }, "is-buffer": { @@ -2953,9 +2499,9 @@ }, "dependencies": { "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" } } }, @@ -2971,9 +2517,9 @@ } }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" }, "lcid": { "version": "2.0.0", @@ -3017,9 +2563,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "lodash.sortby": { "version": "4.7.0", @@ -3141,9 +2687,9 @@ } }, "mime": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", - "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==" + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.5.tgz", + "integrity": "sha512-3hQhEUF027BuxZjQA3s7rIv/7VCQPa27hN9u9g87sEkWaKwQPuXOkVKtOeiyUrnWqTDiOs8Ed2rwg733mB0R5w==" }, "mime-db": { "version": "1.40.0", @@ -3182,9 +2728,9 @@ } }, "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "mississippi": { "version": "3.0.0", @@ -3204,9 +2750,9 @@ } }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "requires": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -3223,11 +2769,11 @@ } }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" } }, "move-concurrently": { @@ -3253,12 +2799,6 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" }, - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", - "optional": true - }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -3346,7 +2886,8 @@ "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "optional": true }, "npm-run-path": { "version": "2.0.2", @@ -3551,7 +3092,8 @@ "path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=" + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "optional": true }, "path-exists": { "version": "3.0.0", @@ -3600,6 +3142,12 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "optional": true + }, "pify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", @@ -3654,9 +3202,9 @@ "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" }, "proxy-from-env": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", - "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, "prr": { "version": "1.0.1", @@ -3722,9 +3270,9 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "puppeteer": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.15.0.tgz", - "integrity": "sha512-D2y5kwA9SsYkNUmcBzu9WZ4V1SGHiQTmgvDZSx6sRYFsgV25IebL4V6FaHjF6MbwLK9C6f3G3pmck9qmwM8H3w==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.20.0.tgz", + "integrity": "sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ==", "requires": { "debug": "^4.1.0", "extract-zip": "^1.6.6", @@ -3841,13 +3389,12 @@ } }, "readdirp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", - "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", + "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==", + "optional": true, "requires": { - "graceful-fs": "^4.1.11", - "micromatch": "^3.1.10", - "readable-stream": "^2.0.2" + "picomatch": "^2.2.1" } }, "regex-not": { @@ -3867,7 +3414,8 @@ "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=" + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "optional": true }, "repeat-element": { "version": "1.1.3", @@ -4145,9 +3693,9 @@ "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" }, "serialize-javascript": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.9.1.tgz", - "integrity": "sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz", + "integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==" }, "set-blocking": { "version": "2.0.0", @@ -4155,9 +3703,9 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -4464,9 +4012,9 @@ } }, "stream-shift": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", - "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", + "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==" }, "string-width": { "version": "2.1.1", @@ -4567,9 +4115,9 @@ "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==" }, "terser": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.4.0.tgz", - "integrity": "sha512-oDG16n2WKm27JO8h4y/w3iqBGAOSCtq7k8dRmrn4Wf9NouL0b2WpMHGChFGZq4nFAQy1FsNJrVQHfurXOSTmOA==", + "version": "4.6.13", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.6.13.tgz", + "integrity": "sha512-wMvqukYgVpQlymbnNbabVZbtM6PN63AzqexpwJL8tbh/mRT9LE5o+ruVduAGL7D6Fpjl+Q+06U5I9Ul82odAhw==", "requires": { "commander": "^2.20.0", "source-map": "~0.6.1", @@ -4582,9 +4130,9 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, "source-map-support": { - "version": "0.5.16", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz", - "integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==", + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -4593,15 +4141,15 @@ } }, "terser-webpack-plugin": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.1.tgz", - "integrity": "sha512-ZXmmfiwtCLfz8WKZyYUuuHf3dMYEjg8NrjHMb0JqHVHVOSkzp3cW2/XG1fP3tRhqEqSzMwzzRQGtAPbs4Cncxg==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz", + "integrity": "sha512-QMxecFz/gHQwteWwSo5nTc6UaICqN1bMedC5sMtUc7y3Ha3Q8y6ZO0iCR8pq4RJC8Hjf0FEPEHZqcMB/+DFCrA==", "requires": { "cacache": "^12.0.2", "find-cache-dir": "^2.1.0", "is-wsl": "^1.1.0", "schema-utils": "^1.0.0", - "serialize-javascript": "^1.7.0", + "serialize-javascript": "^2.1.2", "source-map": "^0.6.1", "terser": "^4.1.2", "webpack-sources": "^1.4.0", @@ -4734,9 +4282,9 @@ }, "dependencies": { "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" } } }, @@ -4746,7 +4294,7 @@ "@types/jquery": "^3.3.29", "btoa": "^1.2.1", "es6-promise": "^4.2.4", - "jquery": "^3.4.1", + "jquery": "^3.5.1", "url-parse": "^1.4.3" }, "dependencies": { @@ -4928,9 +4476,9 @@ } }, "jquery": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", - "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz", + "integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==" }, "mime-db": { "version": "1.40.0", @@ -5036,35 +4584,14 @@ "dev": true }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "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=", - "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=", - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "unique-filename": { @@ -5122,7 +4649,8 @@ "upath": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", - "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==" + "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", + "optional": true }, "uri-js": { "version": "4.2.2", @@ -5223,13 +4751,119 @@ } }, "watchpack": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", - "integrity": "sha512-i6dHe3EyLjMmDlU1/bGQpEw25XSjkJULPuAVKCbNRefQVq48yXKUpwg538F7AZTf9kyr57zj++pQFltUa5H7yA==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.2.tgz", + "integrity": "sha512-ymVbbQP40MFTp+cNMvpyBpBtygHnPzPkHqoIwRRj/0B8KhqQwV8LaKjtbaxF2lK4vl8zN9wCxS46IFCU5K4W0g==", "requires": { - "chokidar": "^2.0.2", + "chokidar": "^3.4.0", "graceful-fs": "^4.1.2", - "neo-async": "^2.5.0" + "neo-async": "^2.5.0", + "watchpack-chokidar2": "^2.0.0" + } + }, + "watchpack-chokidar2": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/watchpack-chokidar2/-/watchpack-chokidar2-2.0.0.tgz", + "integrity": "sha512-9TyfOyN/zLUbA288wZ8IsMZ+6cbzvsNyEzSBp6e/zkifi6xxbl8SmQ/CxQq32k8NNqrdVEVUVSEf56L4rQ/ZxA==", + "optional": true, + "requires": { + "chokidar": "^2.1.8" + }, + "dependencies": { + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "optional": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "optional": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, + "binary-extensions": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", + "optional": true + }, + "chokidar": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", + "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", + "optional": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" + } + }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "optional": true + }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "optional": true, + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "optional": true, + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "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=", + "optional": true, + "requires": { + "binary-extensions": "^1.0.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==", + "optional": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" + } + } } }, "webidl-conversions": { @@ -5268,9 +4902,9 @@ }, "dependencies": { "acorn": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", - "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==" + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", + "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==" }, "ajv": { "version": "6.10.2", @@ -5530,20 +5164,21 @@ } }, "yargs-parser": { - "version": "13.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", - "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", "requires": { "camelcase": "^5.0.0", "decamelize": "^1.2.0" } }, "yauzl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", - "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", "requires": { - "fd-slicer": "~1.0.1" + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" } }, "yn": {