Skip to content

Commit

Permalink
fixes #1034 - allow spec to have empty server array
Browse files Browse the repository at this point in the history
  • Loading branch information
mrin9 committed Sep 27, 2024
1 parent 2a0f12a commit 645928a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/templates/endpoint-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion src/templates/expanded-endpoint-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion src/templates/security-scheme-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 645928a

Please sign in to comment.