| 125 | } |
| 126 | |
| 127 | private async askForUrl(): Promise<UrlOptions> { |
| 128 | return { |
| 129 | source: "url", |
| 130 | url: await prompt |
| 131 | .text({ |
| 132 | message: "Url", |
| 133 | placeholder: "https://.../openapi.json", |
| 134 | validate(value) { |
| 135 | if (!value.startsWith("https://") && !value.startsWith("http://")) { |
| 136 | return "Url must starts with http or https protocol"; |
| 137 | } |
| 138 | if ( |
| 139 | !value.endsWith(".json") && |
| 140 | !value.endsWith(".yaml") && |
| 141 | !value.endsWith(".yml") |
| 142 | ) { |
| 143 | return "Url must ends with `.json` or `.yaml` or `.yml`"; |
| 144 | } |
| 145 | }, |
| 146 | }) |
| 147 | .then(handlePromptCancel), |
| 148 | }; |
| 149 | } |
| 150 | |
| 151 | async execute() { |
| 152 | const userConfigPath = path.join( |