From 41a7aaffcc4c3cf42e96678f6c3cdf38acd778e2 Mon Sep 17 00:00:00 2001 From: Alec Hill Date: Mon, 17 Oct 2016 23:05:57 +0200 Subject: [PATCH] Support passing custom RequestInit options in typescript-fetch client, to enable fetch API specific options (eg including credentials, enabling CORS etc) --- .../resources/TypeScript-Fetch/api.mustache | 18 +- .../typescript-fetch/api.ts | 59 ++-- .../typescript-fetch/builds/default/api.ts | 322 +++++++++--------- .../typescript-fetch/builds/es6-target/api.ts | 322 +++++++++--------- .../builds/with-npm-version/api.ts | 322 +++++++++--------- .../tests/default/test/PetApi.ts | 76 +++-- .../tests/default/test/PetApiFactory.ts | 67 ++-- .../tests/default/test/StoreApi.ts | 32 +- .../tests/default/test/StoreApiFactory.ts | 24 +- 9 files changed, 659 insertions(+), 583 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache index f1aa9e6c4bde..d89fa901bdbe 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache @@ -14,7 +14,7 @@ const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ''); export interface FetchArgs { url: string; - options: any; + options: any; } export class BaseAPI { @@ -70,7 +70,7 @@ export const {{classname}}FetchParamCreactor = { * {{notes}}{{/notes}}{{#allParams}} * @param {{paramName}} {{description}}{{/allParams}} */ - {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}): FetchArgs { + {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }, {{/hasParams}}options?: any): FetchArgs { {{#allParams}} {{#required}} // verify required parameter "{{paramName}}" is set @@ -87,7 +87,7 @@ export const {{classname}}FetchParamCreactor = { "{{baseName}}": params.{{paramName}},{{/queryParams}} }); {{/hasQueryParams}} - let fetchOptions: RequestInit = { method: "{{httpMethod}}" }; + let fetchOptions: RequestInit = {{#supportsES6}}Object.{{/supportsES6}}assign({}, { method: "{{httpMethod}}" }, options); let contentTypeHeader: Dictionary; {{#hasFormParams}} @@ -131,8 +131,8 @@ export const {{classname}}Fp = { * {{notes}}{{/notes}}{{#allParams}} * @param {{paramName}} {{description}}{{/allParams}} */ - {{nickname}}({{#hasParams}}params: { {{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; {{/allParams}} }{{/hasParams}}): (fetch: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}> { - const fetchArgs = {{classname}}FetchParamCreactor.{{nickname}}({{#hasParams}}params{{/hasParams}}); + {{nickname}}({{#hasParams}}params: { {{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; {{/allParams}} }, {{/hasParams}}options?: any): (fetch: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}> { + const fetchArgs = {{classname}}FetchParamCreactor.{{nickname}}({{#hasParams}}params, {{/hasParams}}options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -157,8 +157,8 @@ export class {{classname}} extends BaseAPI { * {{notes}}{{/notes}}{{#allParams}} * @param {{paramName}} {{description}}{{/allParams}} */ - {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}) { - return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(this.fetch, this.basePath); + {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }, {{/hasParams}}options?: any) { + return {{classname}}Fp.{{nickname}}({{#hasParams}}params, {{/hasParams}}options)(this.fetch, this.basePath); } {{/operation}} }; @@ -175,8 +175,8 @@ export const {{classname}}Factory = function (fetch?: FetchAPI, basePath?: strin * {{notes}}{{/notes}}{{#allParams}} * @param {{paramName}} {{description}}{{/allParams}} */ - {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}) { - return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(fetch, basePath); + {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }, {{/hasParams}}options?: any) { + return {{classname}}Fp.{{nickname}}({{#hasParams}}params, {{/hasParams}}options)(fetch, basePath); }, {{/operation}} } diff --git a/samples/client/petstore-security-test/typescript-fetch/api.ts b/samples/client/petstore-security-test/typescript-fetch/api.ts index b439ec1d8ed5..e935898c22f8 100644 --- a/samples/client/petstore-security-test/typescript-fetch/api.ts +++ b/samples/client/petstore-security-test/typescript-fetch/api.ts @@ -1,9 +1,9 @@ /** - * Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end + * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- * - * OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r - * Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r + * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -31,11 +31,11 @@ import * as assign from "core-js/library/fn/object/assign"; interface Dictionary { [index: string]: T; } export interface FetchAPI { (url: string, init?: any): Promise; } -const BASE_PATH = "https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r"; +const BASE_PATH = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r".replace(/\/+$/, ''); export interface FetchArgs { url: string; - options: any; + options: any; } export class BaseAPI { @@ -49,11 +49,11 @@ export class BaseAPI { } /** - * Model for testing reserved words *_/ ' \" =end \\r\\n \\n \\r + * Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r */ export interface ModelReturn { /** - * property description *_/ ' \" =end \\r\\n \\n \\r + * property description *_/ ' \" =end -- \\r\\n \\n \\r */ "return"?: number; } @@ -65,18 +65,18 @@ export interface ModelReturn { */ export const FakeApiFetchParamCreactor = { /** - * To test code injection *_/ ' \" =end \\r\\n \\n \\r - * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end \\r\\n \\n \\r + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r */ - testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }): FetchArgs { + testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }, options?: any): FetchArgs { const baseUrl = `/fake`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "PUT" }; + let fetchOptions: RequestInit = assign({}, { method: "PUT" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" }; fetchOptions.body = querystring.stringify({ - "test code inject */ ' " =end \r\n \n \r": params.test code inject * ' " =end rn n r, + "test code inject */ ' " =end -- \r\n \n \r": params.test code inject * ' " =end rn n r, }); if (contentTypeHeader) { fetchOptions.headers = contentTypeHeader; @@ -93,11 +93,11 @@ export const FakeApiFetchParamCreactor = { */ export const FakeApiFp = { /** - * To test code injection *_/ ' \" =end \\r\\n \\n \\r - * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end \\r\\n \\n \\r + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r */ - testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = FakeApiFetchParamCreactor.testCodeInjectEndRnNR(params); + testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = FakeApiFetchParamCreactor.testCodeInjectEndRnNR(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -115,11 +115,26 @@ export const FakeApiFp = { */ export class FakeApi extends BaseAPI { /** - * To test code injection *_/ ' \" =end \\r\\n \\n \\r - * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end \\r\\n \\n \\r + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r */ - testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }) { - return FakeApiFp.testCodeInjectEndRnNR(params)(this.fetch, this.basePath); + testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }, options?: any) { + return FakeApiFp.testCodeInjectEndRnNR(params, options)(this.fetch, this.basePath); } -} +}; + +/** + * FakeApi - factory interface + */ +export const FakeApiFactory = function (fetch?: FetchAPI, basePath?: string) { + return { + /** + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + */ + testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }, options?: any) { + return FakeApiFp.testCodeInjectEndRnNR(params, options)(fetch, basePath); + }, + } +}; diff --git a/samples/client/petstore/typescript-fetch/builds/default/api.ts b/samples/client/petstore/typescript-fetch/builds/default/api.ts index f37307f73522..020820e1ac23 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -35,7 +35,7 @@ const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ''); export interface FetchArgs { url: string; - options: any; + options: any; } export class BaseAPI { @@ -109,10 +109,10 @@ export const PetApiFetchParamCreactor = { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }): FetchArgs { + addPet(params: { body?: Pet; }, options?: any): FetchArgs { const baseUrl = `/pet`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -133,7 +133,7 @@ export const PetApiFetchParamCreactor = { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }): FetchArgs { + deletePet(params: { petId: number; apiKey?: string; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling deletePet"); @@ -141,7 +141,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "DELETE" }; + let fetchOptions: RequestInit = assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; fetchOptions.headers = assign({ @@ -157,13 +157,13 @@ export const PetApiFetchParamCreactor = { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }): FetchArgs { + findPetsByStatus(params: { status?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByStatus`; let urlObj = url.parse(baseUrl, true); urlObj.query = assign({}, urlObj.query, { "status": params.status, }); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -179,13 +179,13 @@ export const PetApiFetchParamCreactor = { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }): FetchArgs { + findPetsByTags(params: { tags?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByTags`; let urlObj = url.parse(baseUrl, true); urlObj.query = assign({}, urlObj.query, { "tags": params.tags, }); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -201,7 +201,7 @@ export const PetApiFetchParamCreactor = { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }): FetchArgs { + getPetById(params: { petId: number; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling getPetById"); @@ -209,7 +209,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -225,10 +225,10 @@ export const PetApiFetchParamCreactor = { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }): FetchArgs { + updatePet(params: { body?: Pet; }, options?: any): FetchArgs { const baseUrl = `/pet`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "PUT" }; + let fetchOptions: RequestInit = assign({}, { method: "PUT" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -250,7 +250,7 @@ export const PetApiFetchParamCreactor = { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }): FetchArgs { + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling updatePetWithForm"); @@ -258,7 +258,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" }; @@ -281,7 +281,7 @@ export const PetApiFetchParamCreactor = { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): FetchArgs { + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling uploadFile"); @@ -289,7 +289,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}/uploadImage` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" }; @@ -316,8 +316,8 @@ export const PetApiFp = { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.addPet(params); + addPet(params: { body?: Pet; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.addPet(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -334,8 +334,8 @@ export const PetApiFp = { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.deletePet(params); + deletePet(params: { petId: number; apiKey?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.deletePet(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -351,8 +351,8 @@ export const PetApiFp = { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise> { - const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params); + findPetsByStatus(params: { status?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise> { + const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -368,8 +368,8 @@ export const PetApiFp = { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise> { - const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params); + findPetsByTags(params: { tags?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise> { + const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -385,8 +385,8 @@ export const PetApiFp = { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.getPetById(params); + getPetById(params: { petId: number; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.getPetById(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -402,8 +402,8 @@ export const PetApiFp = { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.updatePet(params); + updatePet(params: { body?: Pet; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.updatePet(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -421,8 +421,8 @@ export const PetApiFp = { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params); + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -440,8 +440,8 @@ export const PetApiFp = { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.uploadFile(params); + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -463,8 +463,8 @@ export class PetApi extends BaseAPI { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }) { - return PetApiFp.addPet(params)(this.fetch, this.basePath); + addPet(params: { body?: Pet; }, options?: any) { + return PetApiFp.addPet(params, options)(this.fetch, this.basePath); } /** * Deletes a pet @@ -472,40 +472,40 @@ export class PetApi extends BaseAPI { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }) { - return PetApiFp.deletePet(params)(this.fetch, this.basePath); + deletePet(params: { petId: number; apiKey?: string; }, options?: any) { + return PetApiFp.deletePet(params, options)(this.fetch, this.basePath); } /** * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }) { - return PetApiFp.findPetsByStatus(params)(this.fetch, this.basePath); + findPetsByStatus(params: { status?: Array; }, options?: any) { + return PetApiFp.findPetsByStatus(params, options)(this.fetch, this.basePath); } /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }) { - return PetApiFp.findPetsByTags(params)(this.fetch, this.basePath); + findPetsByTags(params: { tags?: Array; }, options?: any) { + return PetApiFp.findPetsByTags(params, options)(this.fetch, this.basePath); } /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }) { - return PetApiFp.getPetById(params)(this.fetch, this.basePath); + getPetById(params: { petId: number; }, options?: any) { + return PetApiFp.getPetById(params, options)(this.fetch, this.basePath); } /** * Update an existing pet * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }) { - return PetApiFp.updatePet(params)(this.fetch, this.basePath); + updatePet(params: { body?: Pet; }, options?: any) { + return PetApiFp.updatePet(params, options)(this.fetch, this.basePath); } /** * Updates a pet in the store with form data @@ -514,8 +514,8 @@ export class PetApi extends BaseAPI { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { - return PetApiFp.updatePetWithForm(params)(this.fetch, this.basePath); + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any) { + return PetApiFp.updatePetWithForm(params, options)(this.fetch, this.basePath); } /** * uploads an image @@ -524,8 +524,8 @@ export class PetApi extends BaseAPI { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { - return PetApiFp.uploadFile(params)(this.fetch, this.basePath); + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any) { + return PetApiFp.uploadFile(params, options)(this.fetch, this.basePath); } }; @@ -539,8 +539,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }) { - return PetApiFp.addPet(params)(fetch, basePath); + addPet(params: { body?: Pet; }, options?: any) { + return PetApiFp.addPet(params, options)(fetch, basePath); }, /** * Deletes a pet @@ -548,40 +548,40 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }) { - return PetApiFp.deletePet(params)(fetch, basePath); + deletePet(params: { petId: number; apiKey?: string; }, options?: any) { + return PetApiFp.deletePet(params, options)(fetch, basePath); }, /** * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }) { - return PetApiFp.findPetsByStatus(params)(fetch, basePath); + findPetsByStatus(params: { status?: Array; }, options?: any) { + return PetApiFp.findPetsByStatus(params, options)(fetch, basePath); }, /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }) { - return PetApiFp.findPetsByTags(params)(fetch, basePath); + findPetsByTags(params: { tags?: Array; }, options?: any) { + return PetApiFp.findPetsByTags(params, options)(fetch, basePath); }, /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }) { - return PetApiFp.getPetById(params)(fetch, basePath); + getPetById(params: { petId: number; }, options?: any) { + return PetApiFp.getPetById(params, options)(fetch, basePath); }, /** * Update an existing pet * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }) { - return PetApiFp.updatePet(params)(fetch, basePath); + updatePet(params: { body?: Pet; }, options?: any) { + return PetApiFp.updatePet(params, options)(fetch, basePath); }, /** * Updates a pet in the store with form data @@ -590,8 +590,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { - return PetApiFp.updatePetWithForm(params)(fetch, basePath); + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any) { + return PetApiFp.updatePetWithForm(params, options)(fetch, basePath); }, /** * uploads an image @@ -600,8 +600,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { - return PetApiFp.uploadFile(params)(fetch, basePath); + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any) { + return PetApiFp.uploadFile(params, options)(fetch, basePath); }, } }; @@ -616,7 +616,7 @@ export const StoreApiFetchParamCreactor = { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }): FetchArgs { + deleteOrder(params: { orderId: string; }, options?: any): FetchArgs { // verify required parameter "orderId" is set if (params["orderId"] == null) { throw new Error("Missing required parameter orderId when calling deleteOrder"); @@ -624,7 +624,7 @@ export const StoreApiFetchParamCreactor = { const baseUrl = `/store/order/{orderId}` .replace(`{${"orderId"}}`, `${ params.orderId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "DELETE" }; + let fetchOptions: RequestInit = assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -639,10 +639,10 @@ export const StoreApiFetchParamCreactor = { * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory(): FetchArgs { + getInventory(options?: any): FetchArgs { const baseUrl = `/store/inventory`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -658,7 +658,7 @@ export const StoreApiFetchParamCreactor = { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }): FetchArgs { + getOrderById(params: { orderId: string; }, options?: any): FetchArgs { // verify required parameter "orderId" is set if (params["orderId"] == null) { throw new Error("Missing required parameter orderId when calling getOrderById"); @@ -666,7 +666,7 @@ export const StoreApiFetchParamCreactor = { const baseUrl = `/store/order/{orderId}` .replace(`{${"orderId"}}`, `${ params.orderId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -682,10 +682,10 @@ export const StoreApiFetchParamCreactor = { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }): FetchArgs { + placeOrder(params: { body?: Order; }, options?: any): FetchArgs { const baseUrl = `/store/order`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -711,8 +711,8 @@ export const StoreApiFp = { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreactor.deleteOrder(params); + deleteOrder(params: { orderId: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = StoreApiFetchParamCreactor.deleteOrder(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -727,8 +727,8 @@ export const StoreApiFp = { * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory(): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { - const fetchArgs = StoreApiFetchParamCreactor.getInventory(); + getInventory(options?: any): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { + const fetchArgs = StoreApiFetchParamCreactor.getInventory(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -744,8 +744,8 @@ export const StoreApiFp = { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params); + getOrderById(params: { orderId: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -761,8 +761,8 @@ export const StoreApiFp = { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params); + placeOrder(params: { body?: Order; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -784,31 +784,31 @@ export class StoreApi extends BaseAPI { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }) { - return StoreApiFp.deleteOrder(params)(this.fetch, this.basePath); + deleteOrder(params: { orderId: string; }, options?: any) { + return StoreApiFp.deleteOrder(params, options)(this.fetch, this.basePath); } /** * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory() { - return StoreApiFp.getInventory()(this.fetch, this.basePath); + getInventory(options?: any) { + return StoreApiFp.getInventory(options)(this.fetch, this.basePath); } /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }) { - return StoreApiFp.getOrderById(params)(this.fetch, this.basePath); + getOrderById(params: { orderId: string; }, options?: any) { + return StoreApiFp.getOrderById(params, options)(this.fetch, this.basePath); } /** * Place an order for a pet * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }) { - return StoreApiFp.placeOrder(params)(this.fetch, this.basePath); + placeOrder(params: { body?: Order; }, options?: any) { + return StoreApiFp.placeOrder(params, options)(this.fetch, this.basePath); } }; @@ -822,31 +822,31 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }) { - return StoreApiFp.deleteOrder(params)(fetch, basePath); + deleteOrder(params: { orderId: string; }, options?: any) { + return StoreApiFp.deleteOrder(params, options)(fetch, basePath); }, /** * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory() { - return StoreApiFp.getInventory()(fetch, basePath); + getInventory(options?: any) { + return StoreApiFp.getInventory(options)(fetch, basePath); }, /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }) { - return StoreApiFp.getOrderById(params)(fetch, basePath); + getOrderById(params: { orderId: string; }, options?: any) { + return StoreApiFp.getOrderById(params, options)(fetch, basePath); }, /** * Place an order for a pet * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }) { - return StoreApiFp.placeOrder(params)(fetch, basePath); + placeOrder(params: { body?: Order; }, options?: any) { + return StoreApiFp.placeOrder(params, options)(fetch, basePath); }, } }; @@ -861,10 +861,10 @@ export const UserApiFetchParamCreactor = { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }): FetchArgs { + createUser(params: { body?: User; }, options?: any): FetchArgs { const baseUrl = `/user`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -884,10 +884,10 @@ export const UserApiFetchParamCreactor = { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }): FetchArgs { + createUsersWithArrayInput(params: { body?: Array; }, options?: any): FetchArgs { const baseUrl = `/user/createWithArray`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -907,10 +907,10 @@ export const UserApiFetchParamCreactor = { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }): FetchArgs { + createUsersWithListInput(params: { body?: Array; }, options?: any): FetchArgs { const baseUrl = `/user/createWithList`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -930,7 +930,7 @@ export const UserApiFetchParamCreactor = { * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }): FetchArgs { + deleteUser(params: { username: string; }, options?: any): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling deleteUser"); @@ -938,7 +938,7 @@ export const UserApiFetchParamCreactor = { const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "DELETE" }; + let fetchOptions: RequestInit = assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -954,7 +954,7 @@ export const UserApiFetchParamCreactor = { * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }): FetchArgs { + getUserByName(params: { username: string; }, options?: any): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling getUserByName"); @@ -962,7 +962,7 @@ export const UserApiFetchParamCreactor = { const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -979,14 +979,14 @@ export const UserApiFetchParamCreactor = { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }): FetchArgs { + loginUser(params: { username?: string; password?: string; }, options?: any): FetchArgs { const baseUrl = `/user/login`; let urlObj = url.parse(baseUrl, true); urlObj.query = assign({}, urlObj.query, { "username": params.username, "password": params.password, }); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -1001,10 +1001,10 @@ export const UserApiFetchParamCreactor = { * Logs out current logged in user session * */ - logoutUser(): FetchArgs { + logoutUser(options?: any): FetchArgs { const baseUrl = `/user/logout`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -1021,7 +1021,7 @@ export const UserApiFetchParamCreactor = { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }): FetchArgs { + updateUser(params: { username: string; body?: User; }, options?: any): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling updateUser"); @@ -1029,7 +1029,7 @@ export const UserApiFetchParamCreactor = { const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "PUT" }; + let fetchOptions: RequestInit = assign({}, { method: "PUT" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -1055,8 +1055,8 @@ export const UserApiFp = { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.createUser(params); + createUser(params: { body?: User; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.createUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1072,8 +1072,8 @@ export const UserApiFp = { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params); + createUsersWithArrayInput(params: { body?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1089,8 +1089,8 @@ export const UserApiFp = { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params); + createUsersWithListInput(params: { body?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1106,8 +1106,8 @@ export const UserApiFp = { * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.deleteUser(params); + deleteUser(params: { username: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.deleteUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1123,8 +1123,8 @@ export const UserApiFp = { * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.getUserByName(params); + getUserByName(params: { username: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.getUserByName(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1141,8 +1141,8 @@ export const UserApiFp = { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.loginUser(params); + loginUser(params: { username?: string; password?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.loginUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1157,8 +1157,8 @@ export const UserApiFp = { * Logs out current logged in user session * */ - logoutUser(): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.logoutUser(); + logoutUser(options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.logoutUser(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1175,8 +1175,8 @@ export const UserApiFp = { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.updateUser(params); + updateUser(params: { username: string; body?: User; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.updateUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1198,40 +1198,40 @@ export class UserApi extends BaseAPI { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }) { - return UserApiFp.createUser(params)(this.fetch, this.basePath); + createUser(params: { body?: User; }, options?: any) { + return UserApiFp.createUser(params, options)(this.fetch, this.basePath); } /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath); + createUsersWithArrayInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithArrayInput(params, options)(this.fetch, this.basePath); } /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath); + createUsersWithListInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithListInput(params, options)(this.fetch, this.basePath); } /** * Delete user * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }) { - return UserApiFp.deleteUser(params)(this.fetch, this.basePath); + deleteUser(params: { username: string; }, options?: any) { + return UserApiFp.deleteUser(params, options)(this.fetch, this.basePath); } /** * Get user by user name * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }) { - return UserApiFp.getUserByName(params)(this.fetch, this.basePath); + getUserByName(params: { username: string; }, options?: any) { + return UserApiFp.getUserByName(params, options)(this.fetch, this.basePath); } /** * Logs user into the system @@ -1239,15 +1239,15 @@ export class UserApi extends BaseAPI { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }) { - return UserApiFp.loginUser(params)(this.fetch, this.basePath); + loginUser(params: { username?: string; password?: string; }, options?: any) { + return UserApiFp.loginUser(params, options)(this.fetch, this.basePath); } /** * Logs out current logged in user session * */ - logoutUser() { - return UserApiFp.logoutUser()(this.fetch, this.basePath); + logoutUser(options?: any) { + return UserApiFp.logoutUser(options)(this.fetch, this.basePath); } /** * Updated user @@ -1255,8 +1255,8 @@ export class UserApi extends BaseAPI { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }) { - return UserApiFp.updateUser(params)(this.fetch, this.basePath); + updateUser(params: { username: string; body?: User; }, options?: any) { + return UserApiFp.updateUser(params, options)(this.fetch, this.basePath); } }; @@ -1270,40 +1270,40 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }) { - return UserApiFp.createUser(params)(fetch, basePath); + createUser(params: { body?: User; }, options?: any) { + return UserApiFp.createUser(params, options)(fetch, basePath); }, /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath); + createUsersWithArrayInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithArrayInput(params, options)(fetch, basePath); }, /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithListInput(params)(fetch, basePath); + createUsersWithListInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithListInput(params, options)(fetch, basePath); }, /** * Delete user * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }) { - return UserApiFp.deleteUser(params)(fetch, basePath); + deleteUser(params: { username: string; }, options?: any) { + return UserApiFp.deleteUser(params, options)(fetch, basePath); }, /** * Get user by user name * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }) { - return UserApiFp.getUserByName(params)(fetch, basePath); + getUserByName(params: { username: string; }, options?: any) { + return UserApiFp.getUserByName(params, options)(fetch, basePath); }, /** * Logs user into the system @@ -1311,15 +1311,15 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }) { - return UserApiFp.loginUser(params)(fetch, basePath); + loginUser(params: { username?: string; password?: string; }, options?: any) { + return UserApiFp.loginUser(params, options)(fetch, basePath); }, /** * Logs out current logged in user session * */ - logoutUser() { - return UserApiFp.logoutUser()(fetch, basePath); + logoutUser(options?: any) { + return UserApiFp.logoutUser(options)(fetch, basePath); }, /** * Updated user @@ -1327,8 +1327,8 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }) { - return UserApiFp.updateUser(params)(fetch, basePath); + updateUser(params: { username: string; body?: User; }, options?: any) { + return UserApiFp.updateUser(params, options)(fetch, basePath); }, } }; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts index fa7d5153c101..f58443103de9 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts @@ -34,7 +34,7 @@ const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ''); export interface FetchArgs { url: string; - options: any; + options: any; } export class BaseAPI { @@ -108,10 +108,10 @@ export const PetApiFetchParamCreactor = { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }): FetchArgs { + addPet(params: { body?: Pet; }, options?: any): FetchArgs { const baseUrl = `/pet`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -132,7 +132,7 @@ export const PetApiFetchParamCreactor = { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }): FetchArgs { + deletePet(params: { petId: number; apiKey?: string; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling deletePet"); @@ -140,7 +140,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "DELETE" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; fetchOptions.headers = Object.assign({ @@ -156,13 +156,13 @@ export const PetApiFetchParamCreactor = { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }): FetchArgs { + findPetsByStatus(params: { status?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByStatus`; let urlObj = url.parse(baseUrl, true); urlObj.query = Object.assign({}, urlObj.query, { "status": params.status, }); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -178,13 +178,13 @@ export const PetApiFetchParamCreactor = { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }): FetchArgs { + findPetsByTags(params: { tags?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByTags`; let urlObj = url.parse(baseUrl, true); urlObj.query = Object.assign({}, urlObj.query, { "tags": params.tags, }); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -200,7 +200,7 @@ export const PetApiFetchParamCreactor = { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }): FetchArgs { + getPetById(params: { petId: number; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling getPetById"); @@ -208,7 +208,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -224,10 +224,10 @@ export const PetApiFetchParamCreactor = { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }): FetchArgs { + updatePet(params: { body?: Pet; }, options?: any): FetchArgs { const baseUrl = `/pet`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "PUT" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "PUT" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -249,7 +249,7 @@ export const PetApiFetchParamCreactor = { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }): FetchArgs { + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling updatePetWithForm"); @@ -257,7 +257,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" }; @@ -280,7 +280,7 @@ export const PetApiFetchParamCreactor = { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): FetchArgs { + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling uploadFile"); @@ -288,7 +288,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}/uploadImage` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" }; @@ -315,8 +315,8 @@ export const PetApiFp = { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.addPet(params); + addPet(params: { body?: Pet; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.addPet(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -333,8 +333,8 @@ export const PetApiFp = { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.deletePet(params); + deletePet(params: { petId: number; apiKey?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.deletePet(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -350,8 +350,8 @@ export const PetApiFp = { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise> { - const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params); + findPetsByStatus(params: { status?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise> { + const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -367,8 +367,8 @@ export const PetApiFp = { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise> { - const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params); + findPetsByTags(params: { tags?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise> { + const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -384,8 +384,8 @@ export const PetApiFp = { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.getPetById(params); + getPetById(params: { petId: number; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.getPetById(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -401,8 +401,8 @@ export const PetApiFp = { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.updatePet(params); + updatePet(params: { body?: Pet; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.updatePet(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -420,8 +420,8 @@ export const PetApiFp = { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params); + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -439,8 +439,8 @@ export const PetApiFp = { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.uploadFile(params); + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -462,8 +462,8 @@ export class PetApi extends BaseAPI { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }) { - return PetApiFp.addPet(params)(this.fetch, this.basePath); + addPet(params: { body?: Pet; }, options?: any) { + return PetApiFp.addPet(params, options)(this.fetch, this.basePath); } /** * Deletes a pet @@ -471,40 +471,40 @@ export class PetApi extends BaseAPI { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }) { - return PetApiFp.deletePet(params)(this.fetch, this.basePath); + deletePet(params: { petId: number; apiKey?: string; }, options?: any) { + return PetApiFp.deletePet(params, options)(this.fetch, this.basePath); } /** * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }) { - return PetApiFp.findPetsByStatus(params)(this.fetch, this.basePath); + findPetsByStatus(params: { status?: Array; }, options?: any) { + return PetApiFp.findPetsByStatus(params, options)(this.fetch, this.basePath); } /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }) { - return PetApiFp.findPetsByTags(params)(this.fetch, this.basePath); + findPetsByTags(params: { tags?: Array; }, options?: any) { + return PetApiFp.findPetsByTags(params, options)(this.fetch, this.basePath); } /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }) { - return PetApiFp.getPetById(params)(this.fetch, this.basePath); + getPetById(params: { petId: number; }, options?: any) { + return PetApiFp.getPetById(params, options)(this.fetch, this.basePath); } /** * Update an existing pet * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }) { - return PetApiFp.updatePet(params)(this.fetch, this.basePath); + updatePet(params: { body?: Pet; }, options?: any) { + return PetApiFp.updatePet(params, options)(this.fetch, this.basePath); } /** * Updates a pet in the store with form data @@ -513,8 +513,8 @@ export class PetApi extends BaseAPI { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { - return PetApiFp.updatePetWithForm(params)(this.fetch, this.basePath); + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any) { + return PetApiFp.updatePetWithForm(params, options)(this.fetch, this.basePath); } /** * uploads an image @@ -523,8 +523,8 @@ export class PetApi extends BaseAPI { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { - return PetApiFp.uploadFile(params)(this.fetch, this.basePath); + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any) { + return PetApiFp.uploadFile(params, options)(this.fetch, this.basePath); } }; @@ -538,8 +538,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }) { - return PetApiFp.addPet(params)(fetch, basePath); + addPet(params: { body?: Pet; }, options?: any) { + return PetApiFp.addPet(params, options)(fetch, basePath); }, /** * Deletes a pet @@ -547,40 +547,40 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }) { - return PetApiFp.deletePet(params)(fetch, basePath); + deletePet(params: { petId: number; apiKey?: string; }, options?: any) { + return PetApiFp.deletePet(params, options)(fetch, basePath); }, /** * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }) { - return PetApiFp.findPetsByStatus(params)(fetch, basePath); + findPetsByStatus(params: { status?: Array; }, options?: any) { + return PetApiFp.findPetsByStatus(params, options)(fetch, basePath); }, /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }) { - return PetApiFp.findPetsByTags(params)(fetch, basePath); + findPetsByTags(params: { tags?: Array; }, options?: any) { + return PetApiFp.findPetsByTags(params, options)(fetch, basePath); }, /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }) { - return PetApiFp.getPetById(params)(fetch, basePath); + getPetById(params: { petId: number; }, options?: any) { + return PetApiFp.getPetById(params, options)(fetch, basePath); }, /** * Update an existing pet * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }) { - return PetApiFp.updatePet(params)(fetch, basePath); + updatePet(params: { body?: Pet; }, options?: any) { + return PetApiFp.updatePet(params, options)(fetch, basePath); }, /** * Updates a pet in the store with form data @@ -589,8 +589,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { - return PetApiFp.updatePetWithForm(params)(fetch, basePath); + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any) { + return PetApiFp.updatePetWithForm(params, options)(fetch, basePath); }, /** * uploads an image @@ -599,8 +599,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { - return PetApiFp.uploadFile(params)(fetch, basePath); + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any) { + return PetApiFp.uploadFile(params, options)(fetch, basePath); }, } }; @@ -615,7 +615,7 @@ export const StoreApiFetchParamCreactor = { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }): FetchArgs { + deleteOrder(params: { orderId: string; }, options?: any): FetchArgs { // verify required parameter "orderId" is set if (params["orderId"] == null) { throw new Error("Missing required parameter orderId when calling deleteOrder"); @@ -623,7 +623,7 @@ export const StoreApiFetchParamCreactor = { const baseUrl = `/store/order/{orderId}` .replace(`{${"orderId"}}`, `${ params.orderId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "DELETE" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -638,10 +638,10 @@ export const StoreApiFetchParamCreactor = { * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory(): FetchArgs { + getInventory(options?: any): FetchArgs { const baseUrl = `/store/inventory`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -657,7 +657,7 @@ export const StoreApiFetchParamCreactor = { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }): FetchArgs { + getOrderById(params: { orderId: string; }, options?: any): FetchArgs { // verify required parameter "orderId" is set if (params["orderId"] == null) { throw new Error("Missing required parameter orderId when calling getOrderById"); @@ -665,7 +665,7 @@ export const StoreApiFetchParamCreactor = { const baseUrl = `/store/order/{orderId}` .replace(`{${"orderId"}}`, `${ params.orderId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -681,10 +681,10 @@ export const StoreApiFetchParamCreactor = { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }): FetchArgs { + placeOrder(params: { body?: Order; }, options?: any): FetchArgs { const baseUrl = `/store/order`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -710,8 +710,8 @@ export const StoreApiFp = { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreactor.deleteOrder(params); + deleteOrder(params: { orderId: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = StoreApiFetchParamCreactor.deleteOrder(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -726,8 +726,8 @@ export const StoreApiFp = { * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory(): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { - const fetchArgs = StoreApiFetchParamCreactor.getInventory(); + getInventory(options?: any): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { + const fetchArgs = StoreApiFetchParamCreactor.getInventory(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -743,8 +743,8 @@ export const StoreApiFp = { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params); + getOrderById(params: { orderId: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -760,8 +760,8 @@ export const StoreApiFp = { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params); + placeOrder(params: { body?: Order; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -783,31 +783,31 @@ export class StoreApi extends BaseAPI { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }) { - return StoreApiFp.deleteOrder(params)(this.fetch, this.basePath); + deleteOrder(params: { orderId: string; }, options?: any) { + return StoreApiFp.deleteOrder(params, options)(this.fetch, this.basePath); } /** * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory() { - return StoreApiFp.getInventory()(this.fetch, this.basePath); + getInventory(options?: any) { + return StoreApiFp.getInventory(options)(this.fetch, this.basePath); } /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }) { - return StoreApiFp.getOrderById(params)(this.fetch, this.basePath); + getOrderById(params: { orderId: string; }, options?: any) { + return StoreApiFp.getOrderById(params, options)(this.fetch, this.basePath); } /** * Place an order for a pet * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }) { - return StoreApiFp.placeOrder(params)(this.fetch, this.basePath); + placeOrder(params: { body?: Order; }, options?: any) { + return StoreApiFp.placeOrder(params, options)(this.fetch, this.basePath); } }; @@ -821,31 +821,31 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }) { - return StoreApiFp.deleteOrder(params)(fetch, basePath); + deleteOrder(params: { orderId: string; }, options?: any) { + return StoreApiFp.deleteOrder(params, options)(fetch, basePath); }, /** * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory() { - return StoreApiFp.getInventory()(fetch, basePath); + getInventory(options?: any) { + return StoreApiFp.getInventory(options)(fetch, basePath); }, /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }) { - return StoreApiFp.getOrderById(params)(fetch, basePath); + getOrderById(params: { orderId: string; }, options?: any) { + return StoreApiFp.getOrderById(params, options)(fetch, basePath); }, /** * Place an order for a pet * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }) { - return StoreApiFp.placeOrder(params)(fetch, basePath); + placeOrder(params: { body?: Order; }, options?: any) { + return StoreApiFp.placeOrder(params, options)(fetch, basePath); }, } }; @@ -860,10 +860,10 @@ export const UserApiFetchParamCreactor = { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }): FetchArgs { + createUser(params: { body?: User; }, options?: any): FetchArgs { const baseUrl = `/user`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -883,10 +883,10 @@ export const UserApiFetchParamCreactor = { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }): FetchArgs { + createUsersWithArrayInput(params: { body?: Array; }, options?: any): FetchArgs { const baseUrl = `/user/createWithArray`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -906,10 +906,10 @@ export const UserApiFetchParamCreactor = { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }): FetchArgs { + createUsersWithListInput(params: { body?: Array; }, options?: any): FetchArgs { const baseUrl = `/user/createWithList`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -929,7 +929,7 @@ export const UserApiFetchParamCreactor = { * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }): FetchArgs { + deleteUser(params: { username: string; }, options?: any): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling deleteUser"); @@ -937,7 +937,7 @@ export const UserApiFetchParamCreactor = { const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "DELETE" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -953,7 +953,7 @@ export const UserApiFetchParamCreactor = { * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }): FetchArgs { + getUserByName(params: { username: string; }, options?: any): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling getUserByName"); @@ -961,7 +961,7 @@ export const UserApiFetchParamCreactor = { const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -978,14 +978,14 @@ export const UserApiFetchParamCreactor = { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }): FetchArgs { + loginUser(params: { username?: string; password?: string; }, options?: any): FetchArgs { const baseUrl = `/user/login`; let urlObj = url.parse(baseUrl, true); urlObj.query = Object.assign({}, urlObj.query, { "username": params.username, "password": params.password, }); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -1000,10 +1000,10 @@ export const UserApiFetchParamCreactor = { * Logs out current logged in user session * */ - logoutUser(): FetchArgs { + logoutUser(options?: any): FetchArgs { const baseUrl = `/user/logout`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -1020,7 +1020,7 @@ export const UserApiFetchParamCreactor = { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }): FetchArgs { + updateUser(params: { username: string; body?: User; }, options?: any): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling updateUser"); @@ -1028,7 +1028,7 @@ export const UserApiFetchParamCreactor = { const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "PUT" }; + let fetchOptions: RequestInit = Object.assign({}, { method: "PUT" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -1054,8 +1054,8 @@ export const UserApiFp = { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.createUser(params); + createUser(params: { body?: User; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.createUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1071,8 +1071,8 @@ export const UserApiFp = { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params); + createUsersWithArrayInput(params: { body?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1088,8 +1088,8 @@ export const UserApiFp = { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params); + createUsersWithListInput(params: { body?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1105,8 +1105,8 @@ export const UserApiFp = { * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.deleteUser(params); + deleteUser(params: { username: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.deleteUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1122,8 +1122,8 @@ export const UserApiFp = { * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.getUserByName(params); + getUserByName(params: { username: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.getUserByName(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1140,8 +1140,8 @@ export const UserApiFp = { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.loginUser(params); + loginUser(params: { username?: string; password?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.loginUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1156,8 +1156,8 @@ export const UserApiFp = { * Logs out current logged in user session * */ - logoutUser(): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.logoutUser(); + logoutUser(options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.logoutUser(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1174,8 +1174,8 @@ export const UserApiFp = { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.updateUser(params); + updateUser(params: { username: string; body?: User; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.updateUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1197,40 +1197,40 @@ export class UserApi extends BaseAPI { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }) { - return UserApiFp.createUser(params)(this.fetch, this.basePath); + createUser(params: { body?: User; }, options?: any) { + return UserApiFp.createUser(params, options)(this.fetch, this.basePath); } /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath); + createUsersWithArrayInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithArrayInput(params, options)(this.fetch, this.basePath); } /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath); + createUsersWithListInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithListInput(params, options)(this.fetch, this.basePath); } /** * Delete user * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }) { - return UserApiFp.deleteUser(params)(this.fetch, this.basePath); + deleteUser(params: { username: string; }, options?: any) { + return UserApiFp.deleteUser(params, options)(this.fetch, this.basePath); } /** * Get user by user name * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }) { - return UserApiFp.getUserByName(params)(this.fetch, this.basePath); + getUserByName(params: { username: string; }, options?: any) { + return UserApiFp.getUserByName(params, options)(this.fetch, this.basePath); } /** * Logs user into the system @@ -1238,15 +1238,15 @@ export class UserApi extends BaseAPI { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }) { - return UserApiFp.loginUser(params)(this.fetch, this.basePath); + loginUser(params: { username?: string; password?: string; }, options?: any) { + return UserApiFp.loginUser(params, options)(this.fetch, this.basePath); } /** * Logs out current logged in user session * */ - logoutUser() { - return UserApiFp.logoutUser()(this.fetch, this.basePath); + logoutUser(options?: any) { + return UserApiFp.logoutUser(options)(this.fetch, this.basePath); } /** * Updated user @@ -1254,8 +1254,8 @@ export class UserApi extends BaseAPI { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }) { - return UserApiFp.updateUser(params)(this.fetch, this.basePath); + updateUser(params: { username: string; body?: User; }, options?: any) { + return UserApiFp.updateUser(params, options)(this.fetch, this.basePath); } }; @@ -1269,40 +1269,40 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }) { - return UserApiFp.createUser(params)(fetch, basePath); + createUser(params: { body?: User; }, options?: any) { + return UserApiFp.createUser(params, options)(fetch, basePath); }, /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath); + createUsersWithArrayInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithArrayInput(params, options)(fetch, basePath); }, /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithListInput(params)(fetch, basePath); + createUsersWithListInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithListInput(params, options)(fetch, basePath); }, /** * Delete user * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }) { - return UserApiFp.deleteUser(params)(fetch, basePath); + deleteUser(params: { username: string; }, options?: any) { + return UserApiFp.deleteUser(params, options)(fetch, basePath); }, /** * Get user by user name * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }) { - return UserApiFp.getUserByName(params)(fetch, basePath); + getUserByName(params: { username: string; }, options?: any) { + return UserApiFp.getUserByName(params, options)(fetch, basePath); }, /** * Logs user into the system @@ -1310,15 +1310,15 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }) { - return UserApiFp.loginUser(params)(fetch, basePath); + loginUser(params: { username?: string; password?: string; }, options?: any) { + return UserApiFp.loginUser(params, options)(fetch, basePath); }, /** * Logs out current logged in user session * */ - logoutUser() { - return UserApiFp.logoutUser()(fetch, basePath); + logoutUser(options?: any) { + return UserApiFp.logoutUser(options)(fetch, basePath); }, /** * Updated user @@ -1326,8 +1326,8 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }) { - return UserApiFp.updateUser(params)(fetch, basePath); + updateUser(params: { username: string; body?: User; }, options?: any) { + return UserApiFp.updateUser(params, options)(fetch, basePath); }, } }; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts index f37307f73522..020820e1ac23 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts @@ -35,7 +35,7 @@ const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ''); export interface FetchArgs { url: string; - options: any; + options: any; } export class BaseAPI { @@ -109,10 +109,10 @@ export const PetApiFetchParamCreactor = { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }): FetchArgs { + addPet(params: { body?: Pet; }, options?: any): FetchArgs { const baseUrl = `/pet`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -133,7 +133,7 @@ export const PetApiFetchParamCreactor = { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }): FetchArgs { + deletePet(params: { petId: number; apiKey?: string; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling deletePet"); @@ -141,7 +141,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "DELETE" }; + let fetchOptions: RequestInit = assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; fetchOptions.headers = assign({ @@ -157,13 +157,13 @@ export const PetApiFetchParamCreactor = { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }): FetchArgs { + findPetsByStatus(params: { status?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByStatus`; let urlObj = url.parse(baseUrl, true); urlObj.query = assign({}, urlObj.query, { "status": params.status, }); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -179,13 +179,13 @@ export const PetApiFetchParamCreactor = { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }): FetchArgs { + findPetsByTags(params: { tags?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByTags`; let urlObj = url.parse(baseUrl, true); urlObj.query = assign({}, urlObj.query, { "tags": params.tags, }); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -201,7 +201,7 @@ export const PetApiFetchParamCreactor = { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }): FetchArgs { + getPetById(params: { petId: number; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling getPetById"); @@ -209,7 +209,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -225,10 +225,10 @@ export const PetApiFetchParamCreactor = { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }): FetchArgs { + updatePet(params: { body?: Pet; }, options?: any): FetchArgs { const baseUrl = `/pet`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "PUT" }; + let fetchOptions: RequestInit = assign({}, { method: "PUT" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -250,7 +250,7 @@ export const PetApiFetchParamCreactor = { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }): FetchArgs { + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling updatePetWithForm"); @@ -258,7 +258,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" }; @@ -281,7 +281,7 @@ export const PetApiFetchParamCreactor = { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): FetchArgs { + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling uploadFile"); @@ -289,7 +289,7 @@ export const PetApiFetchParamCreactor = { const baseUrl = `/pet/{petId}/uploadImage` .replace(`{${"petId"}}`, `${ params.petId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" }; @@ -316,8 +316,8 @@ export const PetApiFp = { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.addPet(params); + addPet(params: { body?: Pet; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.addPet(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -334,8 +334,8 @@ export const PetApiFp = { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.deletePet(params); + deletePet(params: { petId: number; apiKey?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.deletePet(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -351,8 +351,8 @@ export const PetApiFp = { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise> { - const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params); + findPetsByStatus(params: { status?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise> { + const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -368,8 +368,8 @@ export const PetApiFp = { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise> { - const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params); + findPetsByTags(params: { tags?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise> { + const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -385,8 +385,8 @@ export const PetApiFp = { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.getPetById(params); + getPetById(params: { petId: number; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.getPetById(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -402,8 +402,8 @@ export const PetApiFp = { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.updatePet(params); + updatePet(params: { body?: Pet; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.updatePet(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -421,8 +421,8 @@ export const PetApiFp = { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params); + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -440,8 +440,8 @@ export const PetApiFp = { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreactor.uploadFile(params); + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -463,8 +463,8 @@ export class PetApi extends BaseAPI { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }) { - return PetApiFp.addPet(params)(this.fetch, this.basePath); + addPet(params: { body?: Pet; }, options?: any) { + return PetApiFp.addPet(params, options)(this.fetch, this.basePath); } /** * Deletes a pet @@ -472,40 +472,40 @@ export class PetApi extends BaseAPI { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }) { - return PetApiFp.deletePet(params)(this.fetch, this.basePath); + deletePet(params: { petId: number; apiKey?: string; }, options?: any) { + return PetApiFp.deletePet(params, options)(this.fetch, this.basePath); } /** * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }) { - return PetApiFp.findPetsByStatus(params)(this.fetch, this.basePath); + findPetsByStatus(params: { status?: Array; }, options?: any) { + return PetApiFp.findPetsByStatus(params, options)(this.fetch, this.basePath); } /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }) { - return PetApiFp.findPetsByTags(params)(this.fetch, this.basePath); + findPetsByTags(params: { tags?: Array; }, options?: any) { + return PetApiFp.findPetsByTags(params, options)(this.fetch, this.basePath); } /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }) { - return PetApiFp.getPetById(params)(this.fetch, this.basePath); + getPetById(params: { petId: number; }, options?: any) { + return PetApiFp.getPetById(params, options)(this.fetch, this.basePath); } /** * Update an existing pet * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }) { - return PetApiFp.updatePet(params)(this.fetch, this.basePath); + updatePet(params: { body?: Pet; }, options?: any) { + return PetApiFp.updatePet(params, options)(this.fetch, this.basePath); } /** * Updates a pet in the store with form data @@ -514,8 +514,8 @@ export class PetApi extends BaseAPI { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { - return PetApiFp.updatePetWithForm(params)(this.fetch, this.basePath); + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any) { + return PetApiFp.updatePetWithForm(params, options)(this.fetch, this.basePath); } /** * uploads an image @@ -524,8 +524,8 @@ export class PetApi extends BaseAPI { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { - return PetApiFp.uploadFile(params)(this.fetch, this.basePath); + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any) { + return PetApiFp.uploadFile(params, options)(this.fetch, this.basePath); } }; @@ -539,8 +539,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }) { - return PetApiFp.addPet(params)(fetch, basePath); + addPet(params: { body?: Pet; }, options?: any) { + return PetApiFp.addPet(params, options)(fetch, basePath); }, /** * Deletes a pet @@ -548,40 +548,40 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param petId Pet id to delete * @param apiKey */ - deletePet(params: { petId: number; apiKey?: string; }) { - return PetApiFp.deletePet(params)(fetch, basePath); + deletePet(params: { petId: number; apiKey?: string; }, options?: any) { + return PetApiFp.deletePet(params, options)(fetch, basePath); }, /** * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(params: { status?: Array; }) { - return PetApiFp.findPetsByStatus(params)(fetch, basePath); + findPetsByStatus(params: { status?: Array; }, options?: any) { + return PetApiFp.findPetsByStatus(params, options)(fetch, basePath); }, /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(params: { tags?: Array; }) { - return PetApiFp.findPetsByTags(params)(fetch, basePath); + findPetsByTags(params: { tags?: Array; }, options?: any) { + return PetApiFp.findPetsByTags(params, options)(fetch, basePath); }, /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - getPetById(params: { petId: number; }) { - return PetApiFp.getPetById(params)(fetch, basePath); + getPetById(params: { petId: number; }, options?: any) { + return PetApiFp.getPetById(params, options)(fetch, basePath); }, /** * Update an existing pet * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }) { - return PetApiFp.updatePet(params)(fetch, basePath); + updatePet(params: { body?: Pet; }, options?: any) { + return PetApiFp.updatePet(params, options)(fetch, basePath); }, /** * Updates a pet in the store with form data @@ -590,8 +590,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { - return PetApiFp.updatePetWithForm(params)(fetch, basePath); + updatePetWithForm(params: { petId: string; name?: string; status?: string; }, options?: any) { + return PetApiFp.updatePetWithForm(params, options)(fetch, basePath); }, /** * uploads an image @@ -600,8 +600,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { - return PetApiFp.uploadFile(params)(fetch, basePath); + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, options?: any) { + return PetApiFp.uploadFile(params, options)(fetch, basePath); }, } }; @@ -616,7 +616,7 @@ export const StoreApiFetchParamCreactor = { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }): FetchArgs { + deleteOrder(params: { orderId: string; }, options?: any): FetchArgs { // verify required parameter "orderId" is set if (params["orderId"] == null) { throw new Error("Missing required parameter orderId when calling deleteOrder"); @@ -624,7 +624,7 @@ export const StoreApiFetchParamCreactor = { const baseUrl = `/store/order/{orderId}` .replace(`{${"orderId"}}`, `${ params.orderId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "DELETE" }; + let fetchOptions: RequestInit = assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -639,10 +639,10 @@ export const StoreApiFetchParamCreactor = { * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory(): FetchArgs { + getInventory(options?: any): FetchArgs { const baseUrl = `/store/inventory`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -658,7 +658,7 @@ export const StoreApiFetchParamCreactor = { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }): FetchArgs { + getOrderById(params: { orderId: string; }, options?: any): FetchArgs { // verify required parameter "orderId" is set if (params["orderId"] == null) { throw new Error("Missing required parameter orderId when calling getOrderById"); @@ -666,7 +666,7 @@ export const StoreApiFetchParamCreactor = { const baseUrl = `/store/order/{orderId}` .replace(`{${"orderId"}}`, `${ params.orderId }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -682,10 +682,10 @@ export const StoreApiFetchParamCreactor = { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }): FetchArgs { + placeOrder(params: { body?: Order; }, options?: any): FetchArgs { const baseUrl = `/store/order`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -711,8 +711,8 @@ export const StoreApiFp = { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreactor.deleteOrder(params); + deleteOrder(params: { orderId: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = StoreApiFetchParamCreactor.deleteOrder(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -727,8 +727,8 @@ export const StoreApiFp = { * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory(): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { - const fetchArgs = StoreApiFetchParamCreactor.getInventory(); + getInventory(options?: any): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { + const fetchArgs = StoreApiFetchParamCreactor.getInventory(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -744,8 +744,8 @@ export const StoreApiFp = { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params); + getOrderById(params: { orderId: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -761,8 +761,8 @@ export const StoreApiFp = { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params); + placeOrder(params: { body?: Order; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -784,31 +784,31 @@ export class StoreApi extends BaseAPI { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }) { - return StoreApiFp.deleteOrder(params)(this.fetch, this.basePath); + deleteOrder(params: { orderId: string; }, options?: any) { + return StoreApiFp.deleteOrder(params, options)(this.fetch, this.basePath); } /** * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory() { - return StoreApiFp.getInventory()(this.fetch, this.basePath); + getInventory(options?: any) { + return StoreApiFp.getInventory(options)(this.fetch, this.basePath); } /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }) { - return StoreApiFp.getOrderById(params)(this.fetch, this.basePath); + getOrderById(params: { orderId: string; }, options?: any) { + return StoreApiFp.getOrderById(params, options)(this.fetch, this.basePath); } /** * Place an order for a pet * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }) { - return StoreApiFp.placeOrder(params)(this.fetch, this.basePath); + placeOrder(params: { body?: Order; }, options?: any) { + return StoreApiFp.placeOrder(params, options)(this.fetch, this.basePath); } }; @@ -822,31 +822,31 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - deleteOrder(params: { orderId: string; }) { - return StoreApiFp.deleteOrder(params)(fetch, basePath); + deleteOrder(params: { orderId: string; }, options?: any) { + return StoreApiFp.deleteOrder(params, options)(fetch, basePath); }, /** * Returns pet inventories by status * Returns a map of status codes to quantities */ - getInventory() { - return StoreApiFp.getInventory()(fetch, basePath); + getInventory(options?: any) { + return StoreApiFp.getInventory(options)(fetch, basePath); }, /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(params: { orderId: string; }) { - return StoreApiFp.getOrderById(params)(fetch, basePath); + getOrderById(params: { orderId: string; }, options?: any) { + return StoreApiFp.getOrderById(params, options)(fetch, basePath); }, /** * Place an order for a pet * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }) { - return StoreApiFp.placeOrder(params)(fetch, basePath); + placeOrder(params: { body?: Order; }, options?: any) { + return StoreApiFp.placeOrder(params, options)(fetch, basePath); }, } }; @@ -861,10 +861,10 @@ export const UserApiFetchParamCreactor = { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }): FetchArgs { + createUser(params: { body?: User; }, options?: any): FetchArgs { const baseUrl = `/user`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -884,10 +884,10 @@ export const UserApiFetchParamCreactor = { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }): FetchArgs { + createUsersWithArrayInput(params: { body?: Array; }, options?: any): FetchArgs { const baseUrl = `/user/createWithArray`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -907,10 +907,10 @@ export const UserApiFetchParamCreactor = { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }): FetchArgs { + createUsersWithListInput(params: { body?: Array; }, options?: any): FetchArgs { const baseUrl = `/user/createWithList`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "POST" }; + let fetchOptions: RequestInit = assign({}, { method: "POST" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -930,7 +930,7 @@ export const UserApiFetchParamCreactor = { * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }): FetchArgs { + deleteUser(params: { username: string; }, options?: any): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling deleteUser"); @@ -938,7 +938,7 @@ export const UserApiFetchParamCreactor = { const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "DELETE" }; + let fetchOptions: RequestInit = assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -954,7 +954,7 @@ export const UserApiFetchParamCreactor = { * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }): FetchArgs { + getUserByName(params: { username: string; }, options?: any): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling getUserByName"); @@ -962,7 +962,7 @@ export const UserApiFetchParamCreactor = { const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -979,14 +979,14 @@ export const UserApiFetchParamCreactor = { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }): FetchArgs { + loginUser(params: { username?: string; password?: string; }, options?: any): FetchArgs { const baseUrl = `/user/login`; let urlObj = url.parse(baseUrl, true); urlObj.query = assign({}, urlObj.query, { "username": params.username, "password": params.password, }); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -1001,10 +1001,10 @@ export const UserApiFetchParamCreactor = { * Logs out current logged in user session * */ - logoutUser(): FetchArgs { + logoutUser(options?: any): FetchArgs { const baseUrl = `/user/logout`; let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "GET" }; + let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); let contentTypeHeader: Dictionary; if (contentTypeHeader) { @@ -1021,7 +1021,7 @@ export const UserApiFetchParamCreactor = { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }): FetchArgs { + updateUser(params: { username: string; body?: User; }, options?: any): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling updateUser"); @@ -1029,7 +1029,7 @@ export const UserApiFetchParamCreactor = { const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); - let fetchOptions: RequestInit = { method: "PUT" }; + let fetchOptions: RequestInit = assign({}, { method: "PUT" }, options); let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/json" }; @@ -1055,8 +1055,8 @@ export const UserApiFp = { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.createUser(params); + createUser(params: { body?: User; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.createUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1072,8 +1072,8 @@ export const UserApiFp = { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params); + createUsersWithArrayInput(params: { body?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1089,8 +1089,8 @@ export const UserApiFp = { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params); + createUsersWithListInput(params: { body?: Array; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1106,8 +1106,8 @@ export const UserApiFp = { * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.deleteUser(params); + deleteUser(params: { username: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.deleteUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1123,8 +1123,8 @@ export const UserApiFp = { * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.getUserByName(params); + getUserByName(params: { username: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.getUserByName(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1141,8 +1141,8 @@ export const UserApiFp = { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.loginUser(params); + loginUser(params: { username?: string; password?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.loginUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1157,8 +1157,8 @@ export const UserApiFp = { * Logs out current logged in user session * */ - logoutUser(): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.logoutUser(); + logoutUser(options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.logoutUser(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1175,8 +1175,8 @@ export const UserApiFp = { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreactor.updateUser(params); + updateUser(params: { username: string; body?: User; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + const fetchArgs = UserApiFetchParamCreactor.updateUser(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { @@ -1198,40 +1198,40 @@ export class UserApi extends BaseAPI { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }) { - return UserApiFp.createUser(params)(this.fetch, this.basePath); + createUser(params: { body?: User; }, options?: any) { + return UserApiFp.createUser(params, options)(this.fetch, this.basePath); } /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath); + createUsersWithArrayInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithArrayInput(params, options)(this.fetch, this.basePath); } /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath); + createUsersWithListInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithListInput(params, options)(this.fetch, this.basePath); } /** * Delete user * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }) { - return UserApiFp.deleteUser(params)(this.fetch, this.basePath); + deleteUser(params: { username: string; }, options?: any) { + return UserApiFp.deleteUser(params, options)(this.fetch, this.basePath); } /** * Get user by user name * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }) { - return UserApiFp.getUserByName(params)(this.fetch, this.basePath); + getUserByName(params: { username: string; }, options?: any) { + return UserApiFp.getUserByName(params, options)(this.fetch, this.basePath); } /** * Logs user into the system @@ -1239,15 +1239,15 @@ export class UserApi extends BaseAPI { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }) { - return UserApiFp.loginUser(params)(this.fetch, this.basePath); + loginUser(params: { username?: string; password?: string; }, options?: any) { + return UserApiFp.loginUser(params, options)(this.fetch, this.basePath); } /** * Logs out current logged in user session * */ - logoutUser() { - return UserApiFp.logoutUser()(this.fetch, this.basePath); + logoutUser(options?: any) { + return UserApiFp.logoutUser(options)(this.fetch, this.basePath); } /** * Updated user @@ -1255,8 +1255,8 @@ export class UserApi extends BaseAPI { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }) { - return UserApiFp.updateUser(params)(this.fetch, this.basePath); + updateUser(params: { username: string; body?: User; }, options?: any) { + return UserApiFp.updateUser(params, options)(this.fetch, this.basePath); } }; @@ -1270,40 +1270,40 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }) { - return UserApiFp.createUser(params)(fetch, basePath); + createUser(params: { body?: User; }, options?: any) { + return UserApiFp.createUser(params, options)(fetch, basePath); }, /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath); + createUsersWithArrayInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithArrayInput(params, options)(fetch, basePath); }, /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }) { - return UserApiFp.createUsersWithListInput(params)(fetch, basePath); + createUsersWithListInput(params: { body?: Array; }, options?: any) { + return UserApiFp.createUsersWithListInput(params, options)(fetch, basePath); }, /** * Delete user * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - deleteUser(params: { username: string; }) { - return UserApiFp.deleteUser(params)(fetch, basePath); + deleteUser(params: { username: string; }, options?: any) { + return UserApiFp.deleteUser(params, options)(fetch, basePath); }, /** * Get user by user name * * @param username The name that needs to be fetched. Use user1 for testing. */ - getUserByName(params: { username: string; }) { - return UserApiFp.getUserByName(params)(fetch, basePath); + getUserByName(params: { username: string; }, options?: any) { + return UserApiFp.getUserByName(params, options)(fetch, basePath); }, /** * Logs user into the system @@ -1311,15 +1311,15 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(params: { username?: string; password?: string; }) { - return UserApiFp.loginUser(params)(fetch, basePath); + loginUser(params: { username?: string; password?: string; }, options?: any) { + return UserApiFp.loginUser(params, options)(fetch, basePath); }, /** * Logs out current logged in user session * */ - logoutUser() { - return UserApiFp.logoutUser()(fetch, basePath); + logoutUser(options?: any) { + return UserApiFp.logoutUser(options)(fetch, basePath); }, /** * Updated user @@ -1327,8 +1327,8 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }) { - return UserApiFp.updateUser(params)(fetch, basePath); + updateUser(params: { username: string; body?: User; }, options?: any) { + return UserApiFp.updateUser(params, options)(fetch, basePath); }, } }; diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts index 04b2c032a347..251c3f3a9020 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts @@ -2,46 +2,62 @@ import {expect} from 'chai'; import {PetApi, Pet, Category} from 'typescript-fetch-api'; describe('PetApi', () => { - let api: PetApi; - let fixture: Pet = createTestFixture(); - beforeEach(() => { - api = new PetApi(); - }); + function runSuite(description: string, requestOptions?: any): void { - it('should add and delete Pet', () => { - return api.addPet({ body: fixture }).then(() => { - }); - }); + describe(description, () => { - it('should get Pet by ID', () => { - return api.getPetById({ petId: fixture.id }).then((result) => { - return expect(result).to.deep.equal(fixture); + let api: PetApi; + const fixture: Pet = createTestFixture(); + + beforeEach(() => { + api = new PetApi(); }); - }); - it('should update Pet by ID', () => { - return api.getPetById({ petId: fixture.id }).then( (result) => { - result.name = 'newname'; - return api.updatePet({ body: result }).then(() => { - return api.getPetById({ petId: fixture.id }).then( (result) => { - return expect(result.name).to.deep.equal('newname'); + it('should add and delete Pet', () => { + return api.addPet({ body: fixture }, requestOptions).then(() => { }); }); + + it('should get Pet by ID', () => { + return api.getPetById({ petId: fixture.id }, requestOptions).then((result) => { + return expect(result).to.deep.equal(fixture); + }); + }); + + it('should update Pet by ID', () => { + return api.getPetById({ petId: fixture.id }, requestOptions).then( (result) => { + result.name = 'newname'; + return api.updatePet({ body: result }, requestOptions).then(() => { + return api.getPetById({ petId: fixture.id }, requestOptions).then( (result) => { + return expect(result.name).to.deep.equal('newname'); + }); + }); + }); + }); + + it('should delete Pet', () => { + return api.deletePet({ petId: fixture.id }, requestOptions); + }); + + it('should not contain deleted Pet', () => { + return api.getPetById({ petId: fixture.id }, requestOptions).then((result) => { + return expect(result).to.not.exist; + }, (err) => { + return expect(err).to.exist; + }); + }); + }); - }); - - it('should delete Pet', () => { - return api.deletePet({ petId: fixture.id }); + } + + runSuite('without custom request options'); + + runSuite('with custom request options', { + credentials: 'include', + mode: 'cors' }); - it('should not contain deleted Pet', () => { - return api.getPetById({ petId: fixture.id }).then((result) => { - return expect(result).to.not.exist; - }, (err) => { - return expect(err).to.exist; - }); - }); }); function createTestFixture(ts = Date.now()) { diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts b/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts index 38acc214e21e..be2b802c1e72 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts @@ -2,41 +2,56 @@ import {expect} from 'chai'; import {PetApiFactory, Pet, Category} from 'typescript-fetch-api'; describe('PetApiFactory', () => { - let fixture: Pet = createTestFixture(); - it('should add and delete Pet', () => { - return PetApiFactory().addPet({ body: fixture }).then(() => { - }); - }); + function runSuite(description: string, requestOptions?: any): void { - it('should get Pet by ID', () => { - return PetApiFactory().getPetById({ petId: fixture.id }).then((result) => { - return expect(result).to.deep.equal(fixture); + describe(description, () => { + + const fixture: Pet = createTestFixture(); + + it('should add and delete Pet', () => { + return PetApiFactory().addPet({ body: fixture }, requestOptions).then(() => { + }); }); - }); - it('should update Pet by ID', () => { - return PetApiFactory().getPetById({ petId: fixture.id }).then( (result) => { - result.name = 'newname'; - return PetApiFactory().updatePet({ body: result }).then(() => { - return PetApiFactory().getPetById({ petId: fixture.id }).then( (result) => { - return expect(result.name).to.deep.equal('newname'); + it('should get Pet by ID', () => { + return PetApiFactory().getPetById({ petId: fixture.id }, requestOptions).then((result) => { + return expect(result).to.deep.equal(fixture); + }); + }); + + it('should update Pet by ID', () => { + return PetApiFactory().getPetById({ petId: fixture.id }, requestOptions).then( (result) => { + result.name = 'newname'; + return PetApiFactory().updatePet({ body: result }, requestOptions).then(() => { + return PetApiFactory().getPetById({ petId: fixture.id }, requestOptions).then( (result) => { + return expect(result.name).to.deep.equal('newname'); + }); + }); + }); + }); + + it('should delete Pet', () => { + return PetApiFactory().deletePet({ petId: fixture.id }, requestOptions); + }); + + it('should not contain deleted Pet', () => { + return PetApiFactory().getPetById({ petId: fixture.id }, requestOptions).then((result) => { + return expect(result).to.not.exist; + }, (err) => { + return expect(err).to.exist; }); }); }); - }); - - it('should delete Pet', () => { - return PetApiFactory().deletePet({ petId: fixture.id }); + } + + runSuite('without custom request options'); + + runSuite('with custom request options', { + credentials: 'include', + mode: 'cors' }); - it('should not contain deleted Pet', () => { - return PetApiFactory().getPetById({ petId: fixture.id }).then((result) => { - return expect(result).to.not.exist; - }, (err) => { - return expect(err).to.exist; - }); - }); }); function createTestFixture(ts = Date.now()) { diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts index 420def0ab629..14b26e4f2d04 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApi.ts @@ -2,17 +2,31 @@ import {expect} from 'chai'; import {StoreApi} from 'typescript-fetch-api'; describe('StoreApi', function() { - let api: StoreApi; - - beforeEach(function() { - api = new StoreApi(); - }); - it('should get inventory', function() { - return api.getInventory().then((result) => { - expect(Object.keys(result)).to.not.be.empty; + function runSuite(description: string, requestOptions?: any): void { + + describe(description, () => { + let api: StoreApi; + const requestOptions: any = {credentials: 'include', mode: 'cors'} + + beforeEach(function() { + api = new StoreApi(); + }); + + it('should get inventory', function() { + return api.getInventory(requestOptions).then((result) => { + expect(Object.keys(result)).to.not.be.empty; + }); + }); + }); + } + + runSuite('without custom request options'); + + runSuite('with custom request options', { + credentials: 'include', + mode: 'cors' }); }); - diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts index c1d5560e2af8..bef90b2a5588 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts @@ -2,11 +2,27 @@ import {expect} from 'chai'; import {StoreApiFactory} from 'typescript-fetch-api'; describe('StoreApiFactory', function() { - it('should get inventory', function() { - return StoreApiFactory().getInventory().then((result) => { - expect(Object.keys(result)).to.not.be.empty; + + function runSuite(description: string, requestOptions?: any): void { + + describe(description, () => { + + const requestOptions: any = {credentials: 'include', mode: 'cors'}; + + it('should get inventory', function() { + return StoreApiFactory().getInventory(requestOptions).then((result) => { + expect(Object.keys(result)).to.not.be.empty; + }); + }); + }); + } + + runSuite('without custom request options'); + + runSuite('with custom request options', { + credentials: 'include', + mode: 'cors' }); }); -