From 48fb6010b3f13fe26e04589a94cd58d9a2fcd673 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Wed, 30 Jul 2025 12:10:56 +0200 Subject: [PATCH] the api parser creates it's output directory if it does not exist --- generator/api.ts | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/generator/api.ts b/generator/api.ts index 902862d8..bf351772 100644 --- a/generator/api.ts +++ b/generator/api.ts @@ -3,28 +3,12 @@ import { slugify, toArrayWithKey, toTitle, writeToDisk } from './helpers' import {OpenAPIV3, OpenAPIV3_1} from 'openapi-types' import * as fs from 'fs' import * as ejs from 'ejs' -import { spawn } from 'child_process'; import * as yaml from 'js-yaml'; import { merge } from 'allof-merge' import RequestBodyObject = OpenAPIV3_1.RequestBodyObject; -const goExecutable = './generator/expandOpenAPIRef' - export default async function gen(inputFileName: string, outputDir: string) { - // const args = [inputFileName]; - // const process = spawn(goExecutable, args); - // process.stdout.on('data', (data) => { - // console.log(`Output: ${data}`); - // }); - // process.stderr.on('data', (data) => { - // console.error(`Error: ${data}`); - // }); - // process.on('close', (code) => { - // console.log(`Process exited with code ${code}`); - // }); - // const specRaw = fs.readFileSync("generator/openapi/expanded.yml", 'utf8') const specRaw = fs.readFileSync(inputFileName, 'utf8') - // const spec = JSON.parse(specRaw) as any const specYaml = yaml.load(specRaw); const onMergeError = (msg) => { throw new Error(msg) @@ -33,6 +17,8 @@ export default async function gen(inputFileName: string, outputDir: string) { const spec = merged as OpenAPIV3.Document + await fs.promises.mkdir(outputDir, { recursive: true }); + switch (spec.openapi) { case '3.0.0': case '3.0.1':