This repository was archived by the owner on Nov 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
packages/fury-adapter-swagger/lib Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1530,7 +1530,16 @@ class Parser {
15301530
15311531 pushAssets ( schema , payload , contentType , pushBody ) {
15321532 let jsonSchema ;
1533+
1534+ if ( this . bodyCache === undefined ) {
1535+ this . bodyCache = { } ;
1536+ }
1537+
15331538 const referencedPathValue = this . referencedPathValue ( ) ;
1539+ let cacheKey ;
1540+ if ( referencedPathValue && referencedPathValue . $ref ) {
1541+ cacheKey = `${ referencedPathValue . $ref } ;${ contentType } ` ;
1542+ }
15341543
15351544 try {
15361545 const root = { definitions : this . definitions } ;
@@ -1542,7 +1551,15 @@ class Parser {
15421551 }
15431552
15441553 if ( pushBody ) {
1545- bodyFromSchema ( jsonSchema , payload , this , contentType ) ;
1554+ if ( cacheKey && this . bodyCache [ cacheKey ] ) {
1555+ const asset = this . bodyCache [ cacheKey ] ;
1556+ payload . push ( asset . clone ( ) ) ;
1557+ } else {
1558+ const asset = bodyFromSchema ( jsonSchema , payload , this , contentType ) ;
1559+ if ( cacheKey ) {
1560+ this . bodyCache [ cacheKey ] = asset ;
1561+ }
1562+ }
15461563 }
15471564
15481565 this . pushSchemaAsset ( schema , jsonSchema , payload , this . path ) ;
You can’t perform that action at this time.
0 commit comments