File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 5656 "email" : " project@hostname.com"
5757 },
5858 "dependencies" : {
59+ "api-spec-converter" : " ^2.11.2" ,
5960 "case" : " ^1.6.1" ,
6061 "fs-extra" : " ^7.0.1" ,
6162 "fs" : " 0.0.1-security" ,
Original file line number Diff line number Diff line change @@ -72,17 +72,32 @@ export class FileReaderService {
7272 return document ;
7373 case '2' :
7474 console . info ( 'Convertin to OpenAPI V3' ) ;
75- const converter = require ( 'swagger2openapi' ) ;
76- const converted = await converter . convertObj ( document , {
77- patch : true ,
78- warnOnly : true ,
79- } ) ;
80- return converted . openapi ;
75+ return this . convertFile ( 'swagger_2' , document ) ;
76+ case '1' :
77+ return this . convertFile ( 'swagger_1' , document ) ;
8178 default :
8279 throw 'This OpenAPi/Swagger version is not compatible with this tool' ;
8380 }
8481 }
8582
83+ /**
84+ * Convert from file definition to OpenAPI V3
85+ * @param from
86+ * @param document
87+ * @url https://github.com/LucyBot-Inc/api-spec-converter
88+ */
89+ private async convertFile (
90+ from : string ,
91+ document : any ,
92+ ) : Promise < OpenAPIV3 . Document > {
93+ const Converter = require ( 'api-spec-converter' ) ;
94+ return Converter . convert ( {
95+ from,
96+ to : 'openapi_3' ,
97+ source : 'https://api.gettyimages.com/swagger/api-docs' ,
98+ } ) ;
99+ }
100+
86101 private async prepareFile ( ) : Promise < void > {
87102 let extension = fileExtension ( this . path ) ;
88103 if ( ! fileIsJSON ( this . path ) && ! fileIsYAML ( this . path ) ) {
You can’t perform that action at this time.
0 commit comments