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));