@@ -193,27 +193,45 @@ export class LocalRegistry implements IRegistry {
193193 packageId : string ,
194194 filterByOperationGroup : string ,
195195 ) : Promise < ResolvedDocuments | null > {
196- const { documents } = await this . getVersion ( packageId || this . packageId , version ) ?? { }
196+ const { config : { refs = [ ] } = { } , documents } = await this . getVersion ( packageId || this . packageId , version ) ?? { }
197197
198- const filterOperationIdsByGroup = ( id : string ) : boolean => this . groupToOperationIdsMap [ filterByOperationGroup ] ?. includes ( id )
199- const versionDocuments : ResolvedDocument [ ] = [ ...documents ?. values ( ) ?? [ ] ]
200- . filter ( versionDocument => versionDocument . operationIds . some ( filterOperationIdsByGroup ) )
201- . map ( versionDocument => {
202- return {
203- version : versionDocument . version ,
204- fileId : versionDocument . fileId ,
205- slug : versionDocument . slug ,
206- type : versionDocument . type ,
207- format : versionDocument . format ,
208- filename : versionDocument . filename ,
209- labels : [ ] ,
210- title : versionDocument . title ,
211- includedOperationIds : versionDocument . operationIds . filter ( filterOperationIdsByGroup ) ,
212- data : toBase64 ( JSON . stringify ( versionDocument . data ) ) ,
213- }
214- } )
198+ const documentsFromVersion = Array . from ( documents ?. values ( ) ?? [ ] )
199+
200+ if ( isNotEmpty ( documentsFromVersion ) ) {
201+ return { documents : this . resolveDocuments ( documentsFromVersion , this . filterOperationIdsByGroup ( filterByOperationGroup ) ) }
202+ }
203+
204+ const documentsFromRefs = (
205+ await Promise . all ( refs . map ( async ( { refId, version } ) => {
206+ const versionCache = await this . getVersion ( refId , version )
207+ if ( ! versionCache ) return [ ]
208+ const { documents } = versionCache
209+ return Array . from ( documents . values ( ) )
210+ } ) )
211+ ) . flat ( )
215212
216- return { documents : versionDocuments }
213+ return { documents : this . resolveDocuments ( documentsFromRefs , this . filterOperationIdsByGroup ( filterByOperationGroup ) ) }
214+ }
215+
216+ private filterOperationIdsByGroup ( filterByOperationGroup : string ) : ( id : string ) => boolean {
217+ return ( id : string ) : boolean => this . groupToOperationIdsMap [ filterByOperationGroup ] ?. includes ( id )
218+ }
219+
220+ private resolveDocuments ( documents : VersionDocument [ ] , filterOperationIdsByGroup : ( id : string ) => boolean ) : ResolvedDocument [ ] {
221+ return documents
222+ . filter ( versionDocument => versionDocument . operationIds . some ( filterOperationIdsByGroup ) )
223+ . map ( document => ( {
224+ version : document . version ,
225+ fileId : document . fileId ,
226+ slug : document . slug ,
227+ type : document . type ,
228+ format : document . format ,
229+ filename : document . filename ,
230+ labels : [ ] ,
231+ title : document . title ,
232+ includedOperationIds : document . operationIds . filter ( filterOperationIdsByGroup ) ,
233+ data : toBase64 ( JSON . stringify ( document . data ) ) ,
234+ } ) )
217235 }
218236
219237 async versionDeprecatedResolver (
0 commit comments