@@ -95,6 +95,8 @@ export class SchemaPreprocessor {
95
95
private apiDocRes : OpenAPIV3 . DocumentV3 | OpenAPIV3 . DocumentV3_1 ;
96
96
private serDesMap : SerDesMap ;
97
97
private responseOpts : ValidateResponseOpts ;
98
+ private resolvedSchemaCache = new Map < string , SchemaObject > ( ) ;
99
+
98
100
constructor (
99
101
apiDoc : OpenAPIV3 . DocumentV3 | OpenAPIV3 . DocumentV3_1 ,
100
102
ajvOptions : Options ,
@@ -470,7 +472,7 @@ export class SchemaPreprocessor {
470
472
}
471
473
}
472
474
473
- private handleReadonly (
475
+ private handleReadonly (
474
476
parent : OpenAPIV3 . SchemaObject ,
475
477
schema : OpenAPIV3 . SchemaObject ,
476
478
opts ,
@@ -606,12 +608,18 @@ export class SchemaPreprocessor {
606
608
private resolveSchema < T > ( schema ) : T {
607
609
if ( ! schema ) return null ;
608
610
const ref = schema ?. [ '$ref' ] ;
611
+ if ( ref && this . resolvedSchemaCache . has ( ref ) ) {
612
+ return this . resolvedSchemaCache . get ( ref ) as T ;
613
+ }
609
614
let res = ( ref ? this . ajv . getSchema ( ref ) ?. schema : schema ) as T ;
610
615
if ( ref && ! res ) {
611
616
const path = ref . split ( '/' ) . join ( '.' ) ;
612
617
const p = path . substring ( path . indexOf ( '.' ) + 1 ) ;
613
618
res = _get ( this . apiDoc , p ) ;
614
619
}
620
+ if ( ref ) {
621
+ this . resolvedSchemaCache . set ( ref , res ) ;
622
+ }
615
623
return res ;
616
624
}
617
625
/**
0 commit comments