@@ -3,28 +3,12 @@ import { slugify, toArrayWithKey, toTitle, writeToDisk } from './helpers'
3
3
import { OpenAPIV3 , OpenAPIV3_1 } from 'openapi-types'
4
4
import * as fs from 'fs'
5
5
import * as ejs from 'ejs'
6
- import { spawn } from 'child_process' ;
7
6
import * as yaml from 'js-yaml' ;
8
7
import { merge } from 'allof-merge'
9
8
import RequestBodyObject = OpenAPIV3_1 . RequestBodyObject ;
10
9
11
- const goExecutable = './generator/expandOpenAPIRef'
12
-
13
10
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')
26
11
const specRaw = fs . readFileSync ( inputFileName , 'utf8' )
27
- // const spec = JSON.parse(specRaw) as any
28
12
const specYaml = yaml . load ( specRaw ) ;
29
13
const onMergeError = ( msg ) => {
30
14
throw new Error ( msg )
@@ -33,6 +17,8 @@ export default async function gen(inputFileName: string, outputDir: string) {
33
17
34
18
const spec = merged as OpenAPIV3 . Document
35
19
20
+ await fs . promises . mkdir ( outputDir , { recursive : true } ) ;
21
+
36
22
switch ( spec . openapi ) {
37
23
case '3.0.0' :
38
24
case '3.0.1' :
0 commit comments