From 538f12c36df8f01c1728c6e0608d3cb79d2c8260 Mon Sep 17 00:00:00 2001 From: Himanshu Pant Date: Thu, 23 Sep 2021 11:53:56 +0530 Subject: [PATCH] fix: :bug: Added ability to override basePath while creating ApiClient instance (#10327) Solves #9179 --- .../src/main/resources/Javascript/es6/ApiClient.mustache | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache index de2134ade06..d0f55eb3126 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache @@ -16,13 +16,18 @@ import querystring from "querystring"; * @class */{{/emitJSDoc}} class ApiClient { - constructor() { + /** + * The base URL against which to resolve every API call's (relative) path. + * Overrides the default value set in spec file if present + * @param {String} basePath + */ + constructor(basePath = '{{{basePath}}}') { {{#emitJSDoc}}/** * The base URL against which to resolve every API call's (relative) path. * @type {String} * @default {{{basePath}}} */{{/emitJSDoc}} - this.basePath = '{{{basePath}}}'.replace(/\/+$/, ''); + this.basePath = basePath.replace(/\/+$/, ''); {{#emitJSDoc}}/** * The authentication methods to be included for all API calls.