(specUrl: string)
| 109 | } |
| 110 | |
| 111 | private async loadCustomSpec(specUrl: string): Promise<boolean> { |
| 112 | try { |
| 113 | assertAllowedSpecUrl(specUrl); |
| 114 | output.debug('Fetching OpenAPI spec from ' + specUrl); |
| 115 | const spec = this.fetchSpecUrl |
| 116 | ? await this.fetchSpecUrl(specUrl) |
| 117 | : await this.fetchSpec(specUrl); |
| 118 | if (!spec) { |
| 119 | this.error = `Could not load OpenAPI spec from ${specUrl}.`; |
| 120 | return false; |
| 121 | } |
| 122 | this.validateSpec(spec, specUrl); |
| 123 | this.spec = spec; |
| 124 | return Boolean(this.spec); |
| 125 | } catch (err) { |
| 126 | const message = err instanceof Error ? err.message : String(err); |
| 127 | this.error = message; |
| 128 | output.debug(`Failed to fetch OpenAPI spec from ${specUrl}: ${message}`); |
| 129 | return false; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Load the OpenAPI spec with spinner UI. |
no test coverage detected