Skip to content

Commit 645928a

Browse files
committed
fixes #1034 - allow spec to have empty server array
1 parent 2a0f12a commit 645928a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/templates/endpoint-template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function endpointBodyTemplate(path) {
140140
.request_body = "${path.requestBody}"
141141
.api_keys = "${nonEmptyApiKeys}"
142142
.servers = "${path.servers}"
143-
server-url = "${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer.computedUrl}"
143+
server-url = "${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer?.computedUrl}"
144144
active-schema-tab = "${this.defaultSchemaTab}"
145145
fill-request-fields-with-example = "${this.fillRequestFieldsWithExample}"
146146
allow-try = "${this.allowTry}"

src/templates/expanded-endpoint-template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function expandedEndpointBodyTemplate(path, tagName = '', tagDescription
128128
.request_body = "${path.requestBody}"
129129
.api_keys = "${nonEmptyApiKeys}"
130130
.servers = "${path.servers}"
131-
server-url = "${path.servers?.[0]?.url || this.selectedServer.computedUrl}"
131+
server-url = "${path.servers?.[0]?.url || this.selectedServer?.computedUrl}"
132132
fill-request-fields-with-example = "${this.fillRequestFieldsWithExample}"
133133
allow-try = "${this.allowTry}"
134134
show-curl-before-try = "${this.showCurlBeforeTry}"

src/templates/security-scheme-template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, a
261261
const pkceOnly = authFlow['x-pkce-only'] || false;
262262
const isUrlAbsolute = (url) => (url.indexOf('://') > 0 || url.indexOf('//') === 0);
263263
// Calculcate base URL
264-
const url = new URL(this.selectedServer.computedUrl);
264+
const url = new URL(this.selectedServer?.computedUrl);
265265
const baseUrl = url.origin;
266266

267267
if (refreshUrl && !isUrlAbsolute(refreshUrl)) {

0 commit comments

Comments
 (0)