@@ -26,28 +26,29 @@ export class SpecGenerator {
2626 }
2727 return new Promise < void > ( ( resolve , reject ) => {
2828 const swaggerDirs = _ . castArray ( this . config . outputDirectory ) ;
29- this . debugger ( 'Saving specs to files : %j' , swaggerDirs ) ;
29+ this . debugger ( 'Saving specs to folders : %j' , swaggerDirs ) ;
3030 swaggerDirs . forEach ( swaggerDir => {
31- mkdirp ( swaggerDir , ( dirErr : any ) => {
32- if ( dirErr ) {
33- throw dirErr ;
34- }
31+ mkdirp ( swaggerDir ) . then ( ( ) => {
32+ this . debugger ( 'Saving specs json file to folder: %j' , swaggerDir ) ;
3533 fs . writeFile ( `${ swaggerDir } /swagger.json` , JSON . stringify ( spec , null , '\t' ) , ( err : any ) => {
3634 if ( err ) {
37- reject ( err ) ;
35+ return reject ( err ) ;
3836 }
3937 if ( this . config . yaml ) {
38+ this . debugger ( 'Saving specs yaml file to folder: %j' , swaggerDir ) ;
4039 fs . writeFile ( `${ swaggerDir } /swagger.yaml` , YAML . stringify ( spec , 1000 ) , ( errYaml : any ) => {
4140 if ( errYaml ) {
42- reject ( errYaml ) ;
41+ return reject ( errYaml ) ;
4342 }
43+ this . debugger ( 'Generated files saved to folder: %j' , swaggerDir ) ;
4444 resolve ( ) ;
4545 } ) ;
4646 } else {
47+ this . debugger ( 'Generated files saved to folder: %j' , swaggerDir ) ;
4748 resolve ( ) ;
4849 }
4950 } ) ;
50- } ) ;
51+ } ) . catch ( reject ) ;
5152 } ) ;
5253 } ) ;
5354 }
@@ -383,18 +384,18 @@ export class SpecGenerator {
383384 }
384385
385386 private getSwaggerTypeForEnumType ( enumType : EnumerateType ) : Swagger . Schema {
386- function getDerivedTypeFromValues ( values : Array < any > ) : string {
387- return values . reduce ( ( derivedType : string , item : any ) => {
388- const currentType = typeof item ;
389- derivedType = derivedType && derivedType !== currentType ? 'string' : currentType ;
390- return derivedType ;
391- } , null ) ;
387+ function getDerivedTypeFromValues ( values : Array < any > ) : string {
388+ return values . reduce ( ( derivedType : string , item : any ) => {
389+ const currentType = typeof item ;
390+ derivedType = derivedType && derivedType !== currentType ? 'string' : currentType ;
391+ return derivedType ;
392+ } , null ) ;
392393 }
393394
394395 const enumValues = enumType . enumMembers . map ( member => member as string ) as [ string ] ;
395396 return {
396- enum : enumType . enumMembers . map ( member => member as string ) as [ string ] ,
397- type : getDerivedTypeFromValues ( enumValues ) ,
397+ enum : enumType . enumMembers . map ( member => member as string ) as [ string ] ,
398+ type : getDerivedTypeFromValues ( enumValues ) ,
398399 } ;
399400 }
400401
0 commit comments