| 101 | } |
| 102 | |
| 103 | private async askForFile(): Promise<FileOptions> { |
| 104 | return { |
| 105 | relativePath: await prompt |
| 106 | .text({ |
| 107 | message: "Relative path", |
| 108 | placeholder: "./openapi.json", |
| 109 | validate(value) { |
| 110 | if (!value.startsWith("./") && !value.startsWith("../")) |
| 111 | return "The path should be relative"; |
| 112 | |
| 113 | if ( |
| 114 | !value.endsWith(".json") && |
| 115 | !value.endsWith(".yaml") && |
| 116 | !value.endsWith(".yml") |
| 117 | ) { |
| 118 | return "The file must be a json or yaml"; |
| 119 | } |
| 120 | }, |
| 121 | }) |
| 122 | .then(handlePromptCancel), |
| 123 | source: "file", |
| 124 | }; |
| 125 | } |
| 126 | |
| 127 | private async askForUrl(): Promise<UrlOptions> { |
| 128 | return { |