@@ -12,14 +12,20 @@ export class CodeGenerator {
12
12
private rootSchema : Types . OpenApi . Document ;
13
13
private resolvedReferenceDocument : Types . OpenApi . Document ;
14
14
private parser : Api . OpenApiTools . Parser ;
15
- constructor ( private readonly entryPoint : string , private option ?: Option ) {
16
- this . rootSchema = Api . FileSystem . loadJsonOrYaml ( entryPoint ) ;
17
- this . resolvedReferenceDocument = Api . ResolveReference . resolve ( entryPoint , entryPoint , JSON . parse ( JSON . stringify ( this . rootSchema ) ) ) ;
15
+ constructor ( private readonly entryPointOrDocument : string | Types . OpenApi . Document , private option ?: Option ) {
16
+ if ( typeof entryPointOrDocument === 'string' ) {
17
+ this . rootSchema = Api . FileSystem . loadJsonOrYaml ( entryPointOrDocument ) ;
18
+ this . resolvedReferenceDocument = Api . ResolveReference . resolve ( entryPointOrDocument , entryPointOrDocument , JSON . parse ( JSON . stringify ( this . rootSchema ) ) ) ;
19
+ } else {
20
+ this . rootSchema = entryPointOrDocument
21
+ this . resolvedReferenceDocument = entryPointOrDocument
22
+ }
18
23
this . parser = this . createParser ( ) ;
19
24
}
20
25
21
26
private createParser ( ) : Api . OpenApiTools . Parser {
22
- return new Api . OpenApiTools . Parser ( this . entryPoint , this . rootSchema , this . resolvedReferenceDocument , this . option ?. convertOption ) ;
27
+ const entryPoint = typeof this . entryPointOrDocument === 'string' ? this . entryPointOrDocument : '.'
28
+ return new Api . OpenApiTools . Parser ( entryPoint , this . rootSchema , this . resolvedReferenceDocument , this . option ?. convertOption ) ;
23
29
}
24
30
25
31
/**
0 commit comments