File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ export default [
1212 'assert' ,
1313 'aws-cdk-lib' ,
1414 'constructs' ,
15- 'fs' ,
15+ 'node:fs' ,
16+ 'node:path' ,
1617 'openapi3-ts'
1718 ] ,
1819 plugins : [ typescript ( ) ] ,
Original file line number Diff line number Diff line change 11import * as assert from 'assert' ;
2- import * as fs from 'fs' ;
2+ import * as fs from 'node:fs' ;
3+ import * as path from 'node:path' ;
34import { Stack , aws_apigateway as apigateway } from 'aws-cdk-lib' ;
45import { Construct , Node } from 'constructs' ;
56import {
@@ -127,6 +128,11 @@ export class RestApiWithSpec extends apigateway.RestApi implements IRestApiWithS
127128
128129 /** Synthesizes the OpenAPI definition. */
129130 private synthesizeOpenApi ( ) : string [ ] {
131+ // makes sure that the output folder exists. if not, creates it.
132+ const outputDir = path . dirname ( this . props . openApiOutputPath ) ;
133+ if ( ! fs . existsSync ( outputDir ) ) {
134+ fs . mkdirSync ( outputDir , { recursive : true } ) ;
135+ }
130136 fs . writeFileSync (
131137 this . props . openApiOutputPath ,
132138 this . builder . getSpecAsJson ( undefined , 2 ) ,
You can’t perform that action at this time.
0 commit comments