mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
Added GetAllReferences() and GetAllMappedReferences() methods to Rolodex
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"maps"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -425,6 +426,26 @@ func (r *Rolodex) BuildIndexes() {
|
|||||||
r.manualBuilt = true
|
r.manualBuilt = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAllReferences returns all references found in the root and all other indices
|
||||||
|
func (r *Rolodex) GetAllReferences() map[string]*Reference {
|
||||||
|
allRefs := make(map[string]*Reference)
|
||||||
|
for _, idx := range append(r.GetIndexes(), r.GetRootIndex()) {
|
||||||
|
refs := idx.GetAllReferences()
|
||||||
|
maps.Copy(allRefs, refs)
|
||||||
|
}
|
||||||
|
return allRefs
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllMappedReferences returns all mapped references found in the root and all other indices
|
||||||
|
func (r *Rolodex) GetAllMappedReferences() map[string]*Reference {
|
||||||
|
mappedRefs := make(map[string]*Reference)
|
||||||
|
for _, idx := range append(r.GetIndexes(), r.GetRootIndex()) {
|
||||||
|
refs := idx.GetMappedReferences()
|
||||||
|
maps.Copy(mappedRefs, refs)
|
||||||
|
}
|
||||||
|
return mappedRefs
|
||||||
|
}
|
||||||
|
|
||||||
// Open opens a file in the rolodex, and returns a RolodexFile.
|
// Open opens a file in the rolodex, and returns a RolodexFile.
|
||||||
func (r *Rolodex) Open(location string) (RolodexFile, error) {
|
func (r *Rolodex) Open(location string) (RolodexFile, error) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user