Commit 7c452f9 1 parent 9d1030a commit 7c452f9 Copy full SHA for 7c452f9
File tree 1 file changed +12
-2
lines changed
src/resolver/strategies/openapi-3-1-apidom
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -41,14 +41,23 @@ const resolveOpenAPI31Strategy = async (options) => {
41
41
mode = 'non-strict' ,
42
42
} = options ;
43
43
try {
44
+ const { cache } = resolveOpenAPI31Strategy ;
45
+
44
46
// determining BaseURI
45
47
const cwd = url . isHttpUrl ( url . cwd ( ) ) ? url . cwd ( ) : 'https://smartbear.com/' ;
46
48
const retrievalURI = optionsUtil . retrievalURI ( options ) ;
47
49
const baseURI = url . resolve ( cwd , retrievalURI ) ;
48
50
49
51
// prepare spec for dereferencing
50
- const openApiElement = OpenApi3_1Element . refract ( spec ) ;
51
- openApiElement . classes . push ( 'result' ) ;
52
+ let openApiElement ;
53
+ if ( cache . has ( spec ) ) {
54
+ openApiElement = cache . get ( spec ) ;
55
+ } else {
56
+ openApiElement = OpenApi3_1Element . refract ( spec ) ;
57
+ openApiElement . classes . push ( 'result' ) ;
58
+ cache . set ( spec , openApiElement ) ;
59
+ }
60
+
52
61
const openApiParseResultElement = new ParseResultElement ( [ openApiElement ] ) ;
53
62
54
63
// prepare fragment for dereferencing
@@ -125,6 +134,7 @@ const resolveOpenAPI31Strategy = async (options) => {
125
134
throw error ;
126
135
}
127
136
} ;
137
+ resolveOpenAPI31Strategy . cache = new WeakMap ( ) ;
128
138
129
139
export default resolveOpenAPI31Strategy ;
130
140
/* eslint-enable camelcase */
You can’t perform that action at this time.
0 commit comments