@@ -10,7 +10,6 @@ import * as Validator from "./Validator";
1010export { Converter } ;
1111
1212export interface Params {
13- version : "v3" ;
1413 entryPoint : string ;
1514 option ?: Partial < Converter . v3 . Option > ;
1615 /** default: true */
@@ -20,23 +19,17 @@ export interface Params {
2019 } ;
2120}
2221
23- export const generateTypeScriptCode = ( { version , entryPoint, option, enableValidate = true , log } : Params ) : string => {
22+ export const generateTypeScriptCode = ( { entryPoint, option, enableValidate = true , log } : Params ) : string => {
2423 const schema = fileSystem . loadJsonOrYaml ( entryPoint ) ;
2524 const resolvedReferenceDocument = ResolveReference . resolve ( entryPoint , entryPoint , JSON . parse ( JSON . stringify ( schema ) ) ) ;
2625
2726 if ( enableValidate ) {
2827 Validator . v3 . validate ( resolvedReferenceDocument , log && log . validator ) ;
2928 }
3029
31- switch ( version ) {
32- case "v3" : {
33- const convertOption : Converter . v3 . Option = option
34- ? { makeApiClient : option . makeApiClient || DefaultCodeTemplate . makeClientApiClient }
35- : { makeApiClient : DefaultCodeTemplate . makeClientApiClient } ;
36- const { createFunction, generateLeadingComment } = Converter . v3 . create ( entryPoint , schema , resolvedReferenceDocument , convertOption ) ;
37- return [ generateLeadingComment ( ) , TypeScriptCodeGenerator . generate ( createFunction ) ] . join ( EOL + EOL + EOL ) ;
38- }
39- default :
40- return "UnSupport OpenAPI Version" ;
41- }
30+ const convertOption : Converter . v3 . Option = option
31+ ? { makeApiClient : option . makeApiClient || DefaultCodeTemplate . makeClientApiClient }
32+ : { makeApiClient : DefaultCodeTemplate . makeClientApiClient } ;
33+ const { createFunction, generateLeadingComment } = Converter . v3 . create ( entryPoint , schema , resolvedReferenceDocument , convertOption ) ;
34+ return [ generateLeadingComment ( ) , TypeScriptCodeGenerator . generate ( createFunction ) ] . join ( EOL + EOL + EOL ) ;
4235} ;
0 commit comments