diff --git a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache index dcea1e0da57..6fb2e025160 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache @@ -137,6 +137,7 @@ } var url = this.basePath + path; + // use API (operation, path) base path if defined if (apiBasePath !== null && apiBasePath !== undefined) { url = apiBasePath + path; @@ -664,7 +665,8 @@ // go through variable and assign a value for (var variable_name in server['variables']) { if (variable_name in variables) { - if (server['variables'][variable_name]['enum_values'].includes(variables[variable_name])) { + let variable = server['variables'][variable_name]; + if ( !('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name]) ) { url = url.replace("{" + variable_name + "}", variables[variable_name]); } else { throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server['variables'][variable_name]['enum_values'] + "."); 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 1bc2b93cc1a..15cc588f06b 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache @@ -645,7 +645,8 @@ class ApiClient { // go through variable and assign a value for (var variable_name in server['variables']) { if (variable_name in variables) { - if (server['variables'][variable_name]['enum_values'].includes(variables[variable_name])) { + let variable = server['variables'][variable_name]; + if ( !('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name]) ) { url = url.replace("{" + variable_name + "}", variables[variable_name]); } else { throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server['variables'][variable_name]['enum_values'] + "."); diff --git a/samples/client/petstore/javascript-es6/src/ApiClient.js b/samples/client/petstore/javascript-es6/src/ApiClient.js index 2f3db709d0f..d7f02559669 100644 --- a/samples/client/petstore/javascript-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-es6/src/ApiClient.js @@ -576,7 +576,8 @@ class ApiClient { // go through variable and assign a value for (var variable_name in server['variables']) { if (variable_name in variables) { - if (server['variables'][variable_name]['enum_values'].includes(variables[variable_name])) { + let variable = server['variables'][variable_name]; + if ( !('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name]) ) { url = url.replace("{" + variable_name + "}", variables[variable_name]); } else { throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server['variables'][variable_name]['enum_values'] + "."); diff --git a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js index 1a8705972db..592ca85f397 100644 --- a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js @@ -575,7 +575,8 @@ class ApiClient { // go through variable and assign a value for (var variable_name in server['variables']) { if (variable_name in variables) { - if (server['variables'][variable_name]['enum_values'].includes(variables[variable_name])) { + let variable = server['variables'][variable_name]; + if ( !('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name]) ) { url = url.replace("{" + variable_name + "}", variables[variable_name]); } else { throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server['variables'][variable_name]['enum_values'] + "."); diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 3416af28c95..0e979efba3f 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -136,6 +136,7 @@ } var url = this.basePath + path; + // use API (operation, path) base path if defined if (apiBasePath !== null && apiBasePath !== undefined) { url = apiBasePath + path; @@ -611,7 +612,8 @@ // go through variable and assign a value for (var variable_name in server['variables']) { if (variable_name in variables) { - if (server['variables'][variable_name]['enum_values'].includes(variables[variable_name])) { + let variable = server['variables'][variable_name]; + if ( !('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name]) ) { url = url.replace("{" + variable_name + "}", variables[variable_name]); } else { throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server['variables'][variable_name]['enum_values'] + "."); diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index ed27f48fde1..7aa1c8ce42f 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -136,6 +136,7 @@ } var url = this.basePath + path; + // use API (operation, path) base path if defined if (apiBasePath !== null && apiBasePath !== undefined) { url = apiBasePath + path; @@ -622,7 +623,8 @@ // go through variable and assign a value for (var variable_name in server['variables']) { if (variable_name in variables) { - if (server['variables'][variable_name]['enum_values'].includes(variables[variable_name])) { + let variable = server['variables'][variable_name]; + if ( !('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name]) ) { url = url.replace("{" + variable_name + "}", variables[variable_name]); } else { throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server['variables'][variable_name]['enum_values'] + ".");