diff --git a/src/templates/endpoint-template.js b/src/templates/endpoint-template.js index 908975be..67063944 100644 --- a/src/templates/endpoint-template.js +++ b/src/templates/endpoint-template.js @@ -140,7 +140,7 @@ function endpointBodyTemplate(path) { .request_body = "${path.requestBody}" .api_keys = "${nonEmptyApiKeys}" .servers = "${path.servers}" - server-url = "${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer.computedUrl}" + server-url = "${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer?.computedUrl}" active-schema-tab = "${this.defaultSchemaTab}" fill-request-fields-with-example = "${this.fillRequestFieldsWithExample}" allow-try = "${this.allowTry}" diff --git a/src/templates/expanded-endpoint-template.js b/src/templates/expanded-endpoint-template.js index 3ff98b94..51a4d7ca 100644 --- a/src/templates/expanded-endpoint-template.js +++ b/src/templates/expanded-endpoint-template.js @@ -128,7 +128,7 @@ export function expandedEndpointBodyTemplate(path, tagName = '', tagDescription .request_body = "${path.requestBody}" .api_keys = "${nonEmptyApiKeys}" .servers = "${path.servers}" - server-url = "${path.servers?.[0]?.url || this.selectedServer.computedUrl}" + server-url = "${path.servers?.[0]?.url || this.selectedServer?.computedUrl}" fill-request-fields-with-example = "${this.fillRequestFieldsWithExample}" allow-try = "${this.allowTry}" show-curl-before-try = "${this.showCurlBeforeTry}" diff --git a/src/templates/security-scheme-template.js b/src/templates/security-scheme-template.js index 6727e387..5e96efa3 100644 --- a/src/templates/security-scheme-template.js +++ b/src/templates/security-scheme-template.js @@ -261,7 +261,7 @@ function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, a const pkceOnly = authFlow['x-pkce-only'] || false; const isUrlAbsolute = (url) => (url.indexOf('://') > 0 || url.indexOf('//') === 0); // Calculcate base URL - const url = new URL(this.selectedServer.computedUrl); + const url = new URL(this.selectedServer?.computedUrl); const baseUrl = url.origin; if (refreshUrl && !isUrlAbsolute(refreshUrl)) {