MCPcopy Create free account
hub / github.com/fabien0102/openapi-codegen / askForFile

Method askForFile

cli/src/commands/InitCommand.ts:103–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 {

Callers 1

executeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected