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 8d91b7268bf..44c69c31d65 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache @@ -121,16 +121,16 @@ export const {{classname}}FetchParamCreactor = { // authentication ({{name}}) required {{#isApiKey}} {{#isKeyInHeader}} - if (configuration.apiKey) { + if (configuration.apiKey && configuration.apiKey.{{keyParamName}}) { fetchOptions.headers = {{#supportsES6}}Object.{{/supportsES6}}assign({ - '{{keyParamName}}': configuration.apiKey, + '{{keyParamName}}': configuration.apiKey.{{keyParamName}}, }, contentTypeHeader); } {{/isKeyInHeader}} {{#isKeyInQuery}} - if (configuration.apiKey) { + if (configuration.apiKey && configuration.apiKey.{{keyParamName}}) { urlObj.query = {{#supportsES6}}Object.{{/supportsES6}}assign({}, urlObj.query, { - '{{keyParamName}}': configuration.apiKey, + '{{keyParamName}}': configuration.apiKey.{{keyParamName}}, }); } {{/isKeyInQuery}} diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/configuration.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/configuration.mustache index 94989933b63..f9ef24d8266 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/configuration.mustache @@ -1,5 +1,11 @@ export class Configuration { - apiKey: string; + apiKey: { +{{#authMethods}} +{{#isApiKey}} + {{keyParamName}}: string; +{{/isApiKey}} +{{/authMethods}} + }; username: string; password: string; accessToken: string; diff --git a/samples/client/petstore/typescript-fetch/builds/default/api.ts b/samples/client/petstore/typescript-fetch/builds/default/api.ts index a2954e79640..7a03eb902ca 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -53,11 +53,26 @@ export class BaseAPI { } +/** + * Describes the result of uploading an image resource + */ +export interface ApiResponse { + "code"?: number; + "type"?: string; + "message"?: string; +} + +/** + * A category for a pet + */ export interface Category { "id"?: number; "name"?: string; } +/** + * An order for a pets from the pet store + */ export interface Order { "id"?: number; "petId"?: number; @@ -71,6 +86,9 @@ export interface Order { } export type OrderStatusEnum = "placed" | "approved" | "delivered"; +/** + * A pet for sale in the pet store + */ export interface Pet { "id"?: number; "category"?: Category; @@ -84,11 +102,17 @@ export interface Pet { } export type PetStatusEnum = "available" | "pending" | "sold"; +/** + * A tag for a pet + */ export interface Tag { "id"?: number; "name"?: string; } +/** + * A User who is purchasing from the pet store + */ export interface User { "id"?: number; "username"?: string; @@ -114,7 +138,11 @@ export const PetApiFetchParamCreactor = { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }, configuration: Configuration): FetchArgs { + addPet(params: { body: Pet; }, configuration: Configuration): FetchArgs { + // verify required parameter "body" is set + if (params["body"] == null) { + throw new Error("Missing required parameter body when calling addPet"); + } const baseUrl = `/pet`; let urlObj = url.parse(baseUrl, true); let fetchOptions: RequestInit = { method: "POST" }; @@ -178,7 +206,11 @@ 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; }, configuration: Configuration): FetchArgs { + findPetsByStatus(params: { status: Array; }, configuration: Configuration): FetchArgs { + // verify required parameter "status" is set + if (params["status"] == null) { + throw new Error("Missing required parameter status when calling findPetsByStatus"); + } const baseUrl = `/pet/findByStatus`; let urlObj = url.parse(baseUrl, true); urlObj.query = assign({}, urlObj.query, { @@ -208,7 +240,11 @@ 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; }, configuration: Configuration): FetchArgs { + findPetsByTags(params: { tags: Array; }, configuration: Configuration): FetchArgs { + // verify required parameter "tags" is set + if (params["tags"] == null) { + throw new Error("Missing required parameter tags when calling findPetsByTags"); + } const baseUrl = `/pet/findByTags`; let urlObj = url.parse(baseUrl, true); urlObj.query = assign({}, urlObj.query, { @@ -235,8 +271,8 @@ export const PetApiFetchParamCreactor = { }, /** * 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 + * Returns a single pet + * @param petId ID of pet to return */ getPetById(params: { petId: number; }, configuration: Configuration): FetchArgs { // verify required parameter "petId" is set @@ -253,16 +289,9 @@ export const PetApiFetchParamCreactor = { fetchOptions.headers = contentTypeHeader; } // authentication (api_key) required - if (configuration.apiKey) { - fetchOptions.headers = assign({ - 'api_key': configuration.apiKey, - }, contentTypeHeader); - } - // authentication (petstore_auth) required - // oauth required - if (configuration.accessToken) { + if (configuration.apiKey && configuration.apiKey.api_key) { fetchOptions.headers = assign({ - 'Authorization': 'Bearer ' + configuration.accessToken, + 'api_key': configuration.apiKey.api_key, }, contentTypeHeader); } @@ -276,7 +305,11 @@ export const PetApiFetchParamCreactor = { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }, configuration: Configuration): FetchArgs { + updatePet(params: { body: Pet; }, configuration: Configuration): FetchArgs { + // verify required parameter "body" is set + if (params["body"] == null) { + throw new Error("Missing required parameter body when calling updatePet"); + } const baseUrl = `/pet`; let urlObj = url.parse(baseUrl, true); let fetchOptions: RequestInit = { method: "PUT" }; @@ -309,7 +342,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; }, configuration: Configuration): FetchArgs { + updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): FetchArgs { // verify required parameter "petId" is set if (params["petId"] == null) { throw new Error("Missing required parameter petId when calling updatePetWithForm"); @@ -391,7 +424,7 @@ export const PetApiFp = { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise { + addPet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = PetApiFetchParamCreactor.addPet(params, configuration); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -426,7 +459,7 @@ 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; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise> { + findPetsByStatus(params: { status: Array; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise> { const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, configuration); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -443,7 +476,7 @@ 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; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise> { + findPetsByTags(params: { tags: Array; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise> { const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, configuration); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -457,8 +490,8 @@ export const PetApiFp = { }, /** * 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 + * Returns a single pet + * @param petId ID of pet to return */ getPetById(params: { petId: number; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = PetApiFetchParamCreactor.getPetById(params, configuration); @@ -477,7 +510,7 @@ export const PetApiFp = { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise { + updatePet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = PetApiFetchParamCreactor.updatePet(params, configuration); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -496,7 +529,7 @@ 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; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise { + updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, configuration); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -515,12 +548,12 @@ export const PetApiFp = { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise { + uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, configuration); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { - return response; + return response.json(); } else { throw response; } @@ -538,7 +571,7 @@ export class PetApi extends BaseAPI { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }) { + addPet(params: { body: Pet; }) { return PetApiFp.addPet(params, this.configuration)(this.fetch, this.basePath); } /** @@ -555,7 +588,7 @@ export class PetApi extends BaseAPI { * 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; }) { + findPetsByStatus(params: { status: Array; }) { return PetApiFp.findPetsByStatus(params, this.configuration)(this.fetch, this.basePath); } /** @@ -563,13 +596,13 @@ export class PetApi extends BaseAPI { * 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; }) { + findPetsByTags(params: { tags: Array; }) { return PetApiFp.findPetsByTags(params, this.configuration)(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 + * Returns a single pet + * @param petId ID of pet to return */ getPetById(params: { petId: number; }) { return PetApiFp.getPetById(params, this.configuration)(this.fetch, this.basePath); @@ -579,7 +612,7 @@ export class PetApi extends BaseAPI { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }) { + updatePet(params: { body: Pet; }) { return PetApiFp.updatePet(params, this.configuration)(this.fetch, this.basePath); } /** @@ -589,7 +622,7 @@ 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; }) { + updatePetWithForm(params: { petId: number; name?: string; status?: string; }) { return PetApiFp.updatePetWithForm(params, this.configuration)(this.fetch, this.basePath); } /** @@ -614,7 +647,7 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * * @param body Pet object that needs to be added to the store */ - addPet(params: { body?: Pet; }, configuration: Configuration) { + addPet(params: { body: Pet; }, configuration: Configuration) { return PetApiFp.addPet(params, configuration)(fetch, basePath); }, /** @@ -631,7 +664,7 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * 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; }, configuration: Configuration) { + findPetsByStatus(params: { status: Array; }, configuration: Configuration) { return PetApiFp.findPetsByStatus(params, configuration)(fetch, basePath); }, /** @@ -639,13 +672,13 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * 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; }, configuration: Configuration) { + findPetsByTags(params: { tags: Array; }, configuration: Configuration) { return PetApiFp.findPetsByTags(params, configuration)(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 + * Returns a single pet + * @param petId ID of pet to return */ getPetById(params: { petId: number; }, configuration: Configuration) { return PetApiFp.getPetById(params, configuration)(fetch, basePath); @@ -655,7 +688,7 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) { * * @param body Pet object that needs to be added to the store */ - updatePet(params: { body?: Pet; }, configuration: Configuration) { + updatePet(params: { body: Pet; }, configuration: Configuration) { return PetApiFp.updatePet(params, configuration)(fetch, basePath); }, /** @@ -665,7 +698,7 @@ 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; }, configuration: Configuration) { + updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration) { return PetApiFp.updatePetWithForm(params, configuration)(fetch, basePath); }, /** @@ -725,9 +758,9 @@ export const StoreApiFetchParamCreactor = { fetchOptions.headers = contentTypeHeader; } // authentication (api_key) required - if (configuration.apiKey) { + if (configuration.apiKey && configuration.apiKey.api_key) { fetchOptions.headers = assign({ - 'api_key': configuration.apiKey, + 'api_key': configuration.apiKey.api_key, }, contentTypeHeader); } @@ -741,7 +774,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: number; }): FetchArgs { // verify required parameter "orderId" is set if (params["orderId"] == null) { throw new Error("Missing required parameter orderId when calling getOrderById"); @@ -766,7 +799,11 @@ export const StoreApiFetchParamCreactor = { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }): FetchArgs { + placeOrder(params: { body: Order; }): FetchArgs { + // verify required parameter "body" is set + if (params["body"] == null) { + throw new Error("Missing required parameter body when calling placeOrder"); + } const baseUrl = `/store/order`; let urlObj = url.parse(baseUrl, true); let fetchOptions: RequestInit = { method: "POST" }; @@ -829,7 +866,7 @@ 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 { + getOrderById(params: { orderId: number; }): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -846,7 +883,7 @@ export const StoreApiFp = { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }): (fetch: FetchAPI, basePath?: string) => Promise { + placeOrder(params: { body: Order; }): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -884,7 +921,7 @@ export class StoreApi extends BaseAPI { * 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; }) { + getOrderById(params: { orderId: number; }) { return StoreApiFp.getOrderById(params)(this.fetch, this.basePath); } /** @@ -892,7 +929,7 @@ export class StoreApi extends BaseAPI { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }) { + placeOrder(params: { body: Order; }) { return StoreApiFp.placeOrder(params)(this.fetch, this.basePath); } }; @@ -922,7 +959,7 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) { * 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; }) { + getOrderById(params: { orderId: number; }) { return StoreApiFp.getOrderById(params)(fetch, basePath); }, /** @@ -930,7 +967,7 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) { * * @param body order placed for purchasing the pet */ - placeOrder(params: { body?: Order; }) { + placeOrder(params: { body: Order; }) { return StoreApiFp.placeOrder(params)(fetch, basePath); }, } @@ -946,7 +983,11 @@ 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; }): FetchArgs { + // verify required parameter "body" is set + if (params["body"] == null) { + throw new Error("Missing required parameter body when calling createUser"); + } const baseUrl = `/user`; let urlObj = url.parse(baseUrl, true); let fetchOptions: RequestInit = { method: "POST" }; @@ -970,7 +1011,11 @@ export const UserApiFetchParamCreactor = { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }): FetchArgs { + createUsersWithArrayInput(params: { body: Array; }): FetchArgs { + // verify required parameter "body" is set + if (params["body"] == null) { + throw new Error("Missing required parameter body when calling createUsersWithArrayInput"); + } const baseUrl = `/user/createWithArray`; let urlObj = url.parse(baseUrl, true); let fetchOptions: RequestInit = { method: "POST" }; @@ -994,7 +1039,11 @@ export const UserApiFetchParamCreactor = { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }): FetchArgs { + createUsersWithListInput(params: { body: Array; }): FetchArgs { + // verify required parameter "body" is set + if (params["body"] == null) { + throw new Error("Missing required parameter body when calling createUsersWithListInput"); + } const baseUrl = `/user/createWithList`; let urlObj = url.parse(baseUrl, true); let fetchOptions: RequestInit = { method: "POST" }; @@ -1069,7 +1118,15 @@ 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; }): FetchArgs { + // verify required parameter "username" is set + if (params["username"] == null) { + throw new Error("Missing required parameter username when calling loginUser"); + } + // verify required parameter "password" is set + if (params["password"] == null) { + throw new Error("Missing required parameter password when calling loginUser"); + } const baseUrl = `/user/login`; let urlObj = url.parse(baseUrl, true); urlObj.query = assign({}, urlObj.query, { @@ -1113,11 +1170,15 @@ 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; }): FetchArgs { // verify required parameter "username" is set if (params["username"] == null) { throw new Error("Missing required parameter username when calling updateUser"); } + // verify required parameter "body" is set + if (params["body"] == null) { + throw new Error("Missing required parameter body when calling updateUser"); + } const baseUrl = `/user/{username}` .replace(`{${"username"}}`, `${ params.username }`); let urlObj = url.parse(baseUrl, true); @@ -1148,7 +1209,7 @@ 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 { + createUser(params: { body: User; }): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = UserApiFetchParamCreactor.createUser(params); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -1165,7 +1226,7 @@ export const UserApiFp = { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { + createUsersWithArrayInput(params: { body: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -1182,7 +1243,7 @@ export const UserApiFp = { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { + createUsersWithListInput(params: { body: Array; }): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -1234,7 +1295,7 @@ 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 { + loginUser(params: { username: string; password: string; }): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = UserApiFetchParamCreactor.loginUser(params); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -1268,7 +1329,7 @@ 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 { + updateUser(params: { username: string; body: User; }): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = UserApiFetchParamCreactor.updateUser(params); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -1291,7 +1352,7 @@ export class UserApi extends BaseAPI { * This can only be done by the logged in user. * @param body Created user object */ - createUser(params: { body?: User; }) { + createUser(params: { body: User; }) { return UserApiFp.createUser(params)(this.fetch, this.basePath); } /** @@ -1299,7 +1360,7 @@ export class UserApi extends BaseAPI { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }) { + createUsersWithArrayInput(params: { body: Array; }) { return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath); } /** @@ -1307,7 +1368,7 @@ export class UserApi extends BaseAPI { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }) { + createUsersWithListInput(params: { body: Array; }) { return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath); } /** @@ -1332,7 +1393,7 @@ 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; }) { + loginUser(params: { username: string; password: string; }) { return UserApiFp.loginUser(params)(this.fetch, this.basePath); } /** @@ -1348,7 +1409,7 @@ export class UserApi extends BaseAPI { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(params: { username: string; body?: User; }) { + updateUser(params: { username: string; body: User; }) { return UserApiFp.updateUser(params)(this.fetch, this.basePath); } }; @@ -1363,7 +1424,7 @@ 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; }) { + createUser(params: { body: User; }) { return UserApiFp.createUser(params)(fetch, basePath); }, /** @@ -1371,7 +1432,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * * @param body List of user object */ - createUsersWithArrayInput(params: { body?: Array; }) { + createUsersWithArrayInput(params: { body: Array; }) { return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath); }, /** @@ -1379,7 +1440,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) { * * @param body List of user object */ - createUsersWithListInput(params: { body?: Array; }) { + createUsersWithListInput(params: { body: Array; }) { return UserApiFp.createUsersWithListInput(params)(fetch, basePath); }, /** @@ -1404,7 +1465,7 @@ 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; }) { + loginUser(params: { username: string; password: string; }) { return UserApiFp.loginUser(params)(fetch, basePath); }, /** @@ -1420,7 +1481,7 @@ 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; }) { + updateUser(params: { username: string; body: User; }) { return UserApiFp.updateUser(params)(fetch, basePath); }, } diff --git a/samples/client/petstore/typescript-fetch/builds/default/configuration.ts b/samples/client/petstore/typescript-fetch/builds/default/configuration.ts index 94989933b63..ba410680e28 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/configuration.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/configuration.ts @@ -1,5 +1,7 @@ export class Configuration { - apiKey: string; + apiKey: { + api_key: string; + }; username: string; password: string; accessToken: string; 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 da6dfe0c024..1f6063d7192 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts @@ -7,7 +7,9 @@ let config: Configuration; before(function() { config = new Configuration(); config.accessToken = "foobar"; - config.apiKey = "foobar"; + config.apiKey = { + api_key: "foobar" + }; config.username = "foo"; config.password = "bar"; }); 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 4c33bd64814..aa163dbb60d 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts @@ -7,7 +7,9 @@ let config: Configuration; before(function() { config = new Configuration(); config.accessToken = "foobar"; - config.apiKey = "foobar"; + config.apiKey = { + api_key: "foobar" + }; config.username = "foo"; config.password = "bar"; });