From 4319b341e79641ecafd649236430a427c779693b Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Tue, 15 Apr 2025 16:17:12 -0700 Subject: [PATCH] fix(openapi): ensure output folder created fixes #2080 --- packages/plugins/openapi/src/rest-generator.ts | 3 +++ packages/plugins/openapi/src/rpc-generator.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/plugins/openapi/src/rest-generator.ts b/packages/plugins/openapi/src/rest-generator.ts index 98c6abcb6..046983a2c 100644 --- a/packages/plugins/openapi/src/rest-generator.ts +++ b/packages/plugins/openapi/src/rest-generator.ts @@ -79,6 +79,9 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase { security, }; + // ensure output folder exists + fs.mkdirSync(path.dirname(output), { recursive: true }); + const ext = path.extname(output); if (ext && (ext.toLowerCase() === '.yaml' || ext.toLowerCase() === '.yml')) { fs.writeFileSync(output, YAML.stringify(openapi)); diff --git a/packages/plugins/openapi/src/rpc-generator.ts b/packages/plugins/openapi/src/rpc-generator.ts index edd4bc9a6..cb3b9ead1 100644 --- a/packages/plugins/openapi/src/rpc-generator.ts +++ b/packages/plugins/openapi/src/rpc-generator.ts @@ -94,6 +94,9 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase { security, }; + // ensure output folder exists + fs.mkdirSync(path.dirname(output), { recursive: true }); + const ext = path.extname(output); if (ext && (ext.toLowerCase() === '.yaml' || ext.toLowerCase() === '.yml')) { fs.writeFileSync(output, YAML.stringify(openapi));