Skip to content

Commit 36e21f6

Browse files
the api parser creates it's output directory if it does not exist (#399)
1 parent 8c057cf commit 36e21f6

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

generator/api.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,12 @@ import { slugify, toArrayWithKey, toTitle, writeToDisk } from './helpers'
33
import {OpenAPIV3, OpenAPIV3_1} from 'openapi-types'
44
import * as fs from 'fs'
55
import * as ejs from 'ejs'
6-
import { spawn } from 'child_process';
76
import * as yaml from 'js-yaml';
87
import { merge } from 'allof-merge'
98
import RequestBodyObject = OpenAPIV3_1.RequestBodyObject;
109

11-
const goExecutable = './generator/expandOpenAPIRef'
12-
1310
export default async function gen(inputFileName: string, outputDir: string) {
14-
// const args = [inputFileName];
15-
// const process = spawn(goExecutable, args);
16-
// process.stdout.on('data', (data) => {
17-
// console.log(`Output: ${data}`);
18-
// });
19-
// process.stderr.on('data', (data) => {
20-
// console.error(`Error: ${data}`);
21-
// });
22-
// process.on('close', (code) => {
23-
// console.log(`Process exited with code ${code}`);
24-
// });
25-
// const specRaw = fs.readFileSync("generator/openapi/expanded.yml", 'utf8')
2611
const specRaw = fs.readFileSync(inputFileName, 'utf8')
27-
// const spec = JSON.parse(specRaw) as any
2812
const specYaml = yaml.load(specRaw);
2913
const onMergeError = (msg) => {
3014
throw new Error(msg)
@@ -33,6 +17,8 @@ export default async function gen(inputFileName: string, outputDir: string) {
3317

3418
const spec = merged as OpenAPIV3.Document
3519

20+
await fs.promises.mkdir(outputDir, { recursive: true });
21+
3622
switch (spec.openapi) {
3723
case '3.0.0':
3824
case '3.0.1':

0 commit comments

Comments
 (0)