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

Method execute

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

Source from the content-addressed store, hash-verified

149 }
150
151 async execute() {
152 const userConfigPath = path.join(
153 process.cwd(),
154 this.config || "openapi-codegen.config.ts"
155 );
156
157 const config = await this.getConfigSourceFile(userConfigPath);
158
159 const source = await prompt
160 .select({
161 options: [
162 { label: "File", value: "file" },
163 { label: "Url", value: "url" },
164 // { label: "Github", value: "github" },
165 ],
166 message: "Select the source of your OpenAPI",
167 })
168 .then(handlePromptCancel);
169
170 const from: FromOptions =
171 source === "file" ? await this.askForFile() : await this.askForUrl();
172
173 const namespace = format.camel(
174 await prompt
175 .text({
176 message: "What namespace do you want for your API?",
177 })
178 .then(handlePromptCancel)
179 );
180
181 const plugin = await prompt
182 .select<Plugin>({
183 message: "What do you want to generate?",
184 options: [
185 { label: "Types only", value: "typescript/types-only" },
186 { label: "Generic Fetchers", value: "typescript/fetch" },
187 { label: "React Query components", value: "typescript/react-query" },
188 ],
189 })
190 .then(handlePromptCancel);
191
192 const outputDir = await prompt
193 .text({
194 message: "Which folder do you want to generate?",
195 })
196 .then(handlePromptCancel);
197
198 const configProperty = generateConfigProperty({
199 namespace,
200 options: {
201 from,
202 outputDir,
203 plugin,
204 },
205 });
206
207 const importsToInsert = getImports(plugin);
208

Callers

nothing calls this directly

Calls 8

getConfigSourceFileMethod · 0.95
askForFileMethod · 0.95
askForUrlMethod · 0.95
generateConfigPropertyFunction · 0.85
getImportsFunction · 0.85
updateConfigFunction · 0.85
writeFileMethod · 0.80

Tested by

no test coverage detected