(ctx: Context)
| 108 | |
| 109 | @Get('/main.js') |
| 110 | async main(ctx: Context) { |
| 111 | const template = await readFile(join(__dirname, 'main.tpl.js'), 'utf8'); |
| 112 | let body = ''; |
| 113 | |
| 114 | if (!Array.isArray(this.options)) { |
| 115 | const url = isUrlOption(this.options) ? this.options.url : 'openapi.json'; |
| 116 | body = template |
| 117 | .replace('{{ urls }}', `url: "${url}"`) |
| 118 | .replace('{{ primaryName }}', ''); |
| 119 | } else { |
| 120 | let primaryName: string = ''; |
| 121 | const options = this.options |
| 122 | .map(option => { |
| 123 | if (option.primary) { |
| 124 | primaryName = `\n \'urls.primaryName\': "${option.name}",`; |
| 125 | } |
| 126 | return { |
| 127 | name: option.name, |
| 128 | url: isUrlOption(option) ? option.url : `openapi.json?name=${option.name}` |
| 129 | }; |
| 130 | }); |
| 131 | body = template |
| 132 | .replace('{{ urls }}', `urls: ${JSON.stringify(options)}`) |
| 133 | .replace('{{ primaryName }}', primaryName); |
| 134 | } |
| 135 | body = body.replace('{{ uiOptions }}', JSON.stringify(this.uiOptions)); |
| 136 | return new HttpResponseOK(body) |
| 137 | .setHeader('Content-Type', 'application/javascript'); |
| 138 | } |
| 139 | |
| 140 | @Get('/swagger-ui.css') |
| 141 | swaggerUi() { |
nothing calls this directly
no test coverage detected