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 de492936e727..11827d1ddc4d 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache @@ -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 99d6195e8049..52d75f230b76 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -97,10 +97,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" }; @@ -121,7 +121,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"); @@ -129,7 +129,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({ @@ -145,13 +145,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) { @@ -167,13 +167,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) { @@ -189,7 +189,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"); @@ -197,7 +197,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) { @@ -213,10 +213,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" }; @@ -238,7 +238,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"); @@ -246,7 +246,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" }; @@ -269,7 +269,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"); @@ -277,7 +277,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" }; @@ -304,8 +304,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) { @@ -322,8 +322,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) { @@ -339,8 +339,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) { @@ -356,8 +356,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) { @@ -373,8 +373,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) { @@ -390,8 +390,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) { @@ -409,8 +409,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) { @@ -428,8 +428,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) { @@ -451,8 +451,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 @@ -460,40 +460,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 @@ -502,8 +502,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 @@ -512,8 +512,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); } }; @@ -527,8 +527,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 @@ -536,40 +536,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 @@ -578,8 +578,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 @@ -588,8 +588,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); }, }; }; @@ -604,7 +604,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"); @@ -612,7 +612,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) { @@ -627,10 +627,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) { @@ -646,7 +646,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"); @@ -654,7 +654,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) { @@ -670,10 +670,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" }; @@ -699,8 +699,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) { @@ -715,8 +715,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) { @@ -732,8 +732,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) { @@ -749,8 +749,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) { @@ -772,31 +772,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); } }; @@ -810,31 +810,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); }, }; }; @@ -849,10 +849,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" }; @@ -872,10 +872,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" }; @@ -895,10 +895,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" }; @@ -918,7 +918,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"); @@ -926,7 +926,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) { @@ -942,7 +942,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"); @@ -950,7 +950,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) { @@ -967,14 +967,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) { @@ -989,10 +989,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) { @@ -1009,7 +1009,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"); @@ -1017,7 +1017,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" }; @@ -1043,8 +1043,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) { @@ -1060,8 +1060,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) { @@ -1077,8 +1077,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) { @@ -1094,8 +1094,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) { @@ -1111,8 +1111,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) { @@ -1129,8 +1129,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) { @@ -1145,8 +1145,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) { @@ -1163,8 +1163,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) { @@ -1186,40 +1186,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 @@ -1227,15 +1227,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 @@ -1243,8 +1243,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); } }; @@ -1258,40 +1258,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 @@ -1299,15 +1299,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 @@ -1315,8 +1315,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 786141130ce4..fdfa555e86d3 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts @@ -22,7 +22,7 @@ const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ''); export interface FetchArgs { url: string; - options: any; + options: any; } export class BaseAPI { @@ -96,10 +96,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" }; @@ -120,7 +120,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"); @@ -128,7 +128,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({ @@ -144,13 +144,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) { @@ -166,13 +166,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) { @@ -188,7 +188,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"); @@ -196,7 +196,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) { @@ -212,10 +212,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" }; @@ -237,7 +237,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"); @@ -245,7 +245,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" }; @@ -268,7 +268,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"); @@ -276,7 +276,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" }; @@ -303,8 +303,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) { @@ -321,8 +321,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) { @@ -338,8 +338,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) { @@ -355,8 +355,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) { @@ -372,8 +372,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) { @@ -389,8 +389,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) { @@ -408,8 +408,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) { @@ -427,8 +427,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) { @@ -450,8 +450,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 @@ -459,40 +459,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 @@ -501,8 +501,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 @@ -511,8 +511,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); } }; @@ -526,8 +526,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 @@ -535,40 +535,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 @@ -577,8 +577,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 @@ -587,8 +587,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); }, } }; @@ -603,7 +603,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"); @@ -611,7 +611,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) { @@ -626,10 +626,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) { @@ -645,7 +645,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"); @@ -653,7 +653,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) { @@ -669,10 +669,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" }; @@ -698,8 +698,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) { @@ -714,8 +714,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) { @@ -731,8 +731,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) { @@ -748,8 +748,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) { @@ -771,31 +771,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); } }; @@ -809,31 +809,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); }, } }; @@ -848,10 +848,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" }; @@ -871,10 +871,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" }; @@ -894,10 +894,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" }; @@ -917,7 +917,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"); @@ -925,7 +925,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) { @@ -941,7 +941,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"); @@ -949,7 +949,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) { @@ -966,14 +966,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) { @@ -988,10 +988,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) { @@ -1008,7 +1008,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"); @@ -1016,7 +1016,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" }; @@ -1042,8 +1042,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) { @@ -1059,8 +1059,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) { @@ -1076,8 +1076,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) { @@ -1093,8 +1093,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) { @@ -1110,8 +1110,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) { @@ -1128,8 +1128,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) { @@ -1144,8 +1144,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) { @@ -1162,8 +1162,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) { @@ -1185,40 +1185,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 @@ -1226,15 +1226,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 @@ -1242,8 +1242,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); } }; @@ -1257,40 +1257,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 @@ -1298,15 +1298,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 @@ -1314,8 +1314,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 0a699f9f75a9..611766ecd6bd 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 @@ -23,7 +23,7 @@ const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ''); export interface FetchArgs { url: string; - options: any; + options: any; } export class BaseAPI { @@ -97,10 +97,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" }; @@ -121,7 +121,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"); @@ -129,7 +129,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({ @@ -145,13 +145,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) { @@ -167,13 +167,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) { @@ -189,7 +189,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"); @@ -197,7 +197,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) { @@ -213,10 +213,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" }; @@ -238,7 +238,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"); @@ -246,7 +246,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" }; @@ -269,7 +269,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"); @@ -277,7 +277,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" }; @@ -304,8 +304,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) { @@ -322,8 +322,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) { @@ -339,8 +339,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) { @@ -356,8 +356,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) { @@ -373,8 +373,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) { @@ -390,8 +390,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) { @@ -409,8 +409,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) { @@ -428,8 +428,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) { @@ -451,8 +451,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 @@ -460,40 +460,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 @@ -502,8 +502,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 @@ -512,8 +512,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); } }; @@ -527,8 +527,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 @@ -536,40 +536,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 @@ -578,8 +578,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 @@ -588,8 +588,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); }, } }; @@ -604,7 +604,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"); @@ -612,7 +612,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) { @@ -627,10 +627,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) { @@ -646,7 +646,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"); @@ -654,7 +654,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) { @@ -670,10 +670,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" }; @@ -699,8 +699,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) { @@ -715,8 +715,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) { @@ -732,8 +732,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) { @@ -749,8 +749,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) { @@ -772,31 +772,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); } }; @@ -810,31 +810,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); }, } }; @@ -849,10 +849,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" }; @@ -872,10 +872,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" }; @@ -895,10 +895,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" }; @@ -918,7 +918,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"); @@ -926,7 +926,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) { @@ -942,7 +942,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"); @@ -950,7 +950,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) { @@ -967,14 +967,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) { @@ -989,10 +989,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) { @@ -1009,7 +1009,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"); @@ -1017,7 +1017,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" }; @@ -1043,8 +1043,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) { @@ -1060,8 +1060,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) { @@ -1077,8 +1077,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) { @@ -1094,8 +1094,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) { @@ -1111,8 +1111,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) { @@ -1129,8 +1129,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) { @@ -1145,8 +1145,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) { @@ -1163,8 +1163,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) { @@ -1186,40 +1186,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 @@ -1227,15 +1227,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 @@ -1243,8 +1243,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); } }; @@ -1258,40 +1258,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 @@ -1299,15 +1299,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 @@ -1315,8 +1315,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' }); }); -