mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
removed golang x package in favour of the std lib
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"golang.org/x/sync/syncmap"
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/pb33f/libopenapi/index"
|
"github.com/pb33f/libopenapi/index"
|
||||||
@@ -22,6 +21,7 @@ import (
|
|||||||
"github.com/pb33f/libopenapi/utils"
|
"github.com/pb33f/libopenapi/utils"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFindItemInOrderedMap(t *testing.T) {
|
func TestFindItemInOrderedMap(t *testing.T) {
|
||||||
@@ -1901,7 +1901,7 @@ func TestLocateRefNode_DoARealLookup(t *testing.T) {
|
|||||||
idx := index.NewSpecIndexWithConfig(&rootNode, cf)
|
idx := index.NewSpecIndexWithConfig(&rootNode, cf)
|
||||||
|
|
||||||
// fake cache to a lookup for a file that does not exist will work.
|
// fake cache to a lookup for a file that does not exist will work.
|
||||||
fakeCache := new(syncmap.Map)
|
fakeCache := new(sync.Map)
|
||||||
fakeCache.Store(lookup, &index.Reference{Node: &no, Index: idx})
|
fakeCache.Store(lookup, &index.Reference{Node: &no, Index: idx})
|
||||||
idx.SetCache(fakeCache)
|
idx.SetCache(fakeCache)
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
|
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
|
||||||
"github.com/pb33f/libopenapi/orderedmap"
|
"github.com/pb33f/libopenapi/orderedmap"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"golang.org/x/exp/slices"
|
"slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
type loopFrame struct {
|
type loopFrame struct {
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -7,8 +7,6 @@ require (
|
|||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
github.com/vmware-labs/yaml-jsonpath v0.3.2
|
github.com/vmware-labs/yaml-jsonpath v0.3.2
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8
|
github.com/wk8/go-ordered-map/v2 v2.1.8
|
||||||
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
|
|
||||||
golang.org/x/sync v0.6.0
|
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -73,8 +73,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE=
|
|
||||||
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
|
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
@@ -87,8 +85,6 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su
|
|||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
|
||||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pb33f/libopenapi/utils"
|
"github.com/pb33f/libopenapi/utils"
|
||||||
"golang.org/x/exp/slices"
|
"slices"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/pb33f/libopenapi/datamodel"
|
"github.com/pb33f/libopenapi/datamodel"
|
||||||
"golang.org/x/sync/syncmap"
|
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@@ -236,7 +235,7 @@ type SpecIndex struct {
|
|||||||
allRefSchemaDefinitions []*Reference // all schemas found that are references.
|
allRefSchemaDefinitions []*Reference // all schemas found that are references.
|
||||||
allInlineSchemaDefinitions []*Reference // all schemas found in document outside of components (openapi) or definitions (swagger).
|
allInlineSchemaDefinitions []*Reference // all schemas found in document outside of components (openapi) or definitions (swagger).
|
||||||
allInlineSchemaObjectDefinitions []*Reference // all schemas that are objects found in document outside of components (openapi) or definitions (swagger).
|
allInlineSchemaObjectDefinitions []*Reference // all schemas that are objects found in document outside of components (openapi) or definitions (swagger).
|
||||||
allComponentSchemaDefinitions *syncmap.Map // all schemas found in components (openapi) or definitions (swagger).
|
allComponentSchemaDefinitions *sync.Map // all schemas found in components (openapi) or definitions (swagger).
|
||||||
securitySchemesNode *yaml.Node // components/securitySchemes node
|
securitySchemesNode *yaml.Node // components/securitySchemes node
|
||||||
allSecuritySchemes map[string]*Reference // all security schemes / definitions.
|
allSecuritySchemes map[string]*Reference // all security schemes / definitions.
|
||||||
requestBodiesNode *yaml.Node // components/requestBodies node
|
requestBodiesNode *yaml.Node // components/requestBodies node
|
||||||
@@ -273,7 +272,7 @@ type SpecIndex struct {
|
|||||||
componentIndexChan chan bool
|
componentIndexChan chan bool
|
||||||
polyComponentIndexChan chan bool
|
polyComponentIndexChan chan bool
|
||||||
resolver *Resolver
|
resolver *Resolver
|
||||||
cache *syncmap.Map
|
cache *sync.Map
|
||||||
built bool
|
built bool
|
||||||
uri []string
|
uri []string
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
@@ -292,7 +291,7 @@ func (index *SpecIndex) GetConfig() *SpecIndexConfig {
|
|||||||
return index.config
|
return index.config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (index *SpecIndex) SetCache(sync *syncmap.Map) {
|
func (index *SpecIndex) SetCache(sync *sync.Map) {
|
||||||
index.cache = sync
|
index.cache = sync
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +299,7 @@ func (index *SpecIndex) GetNodeMap() map[int]map[int]*yaml.Node {
|
|||||||
return index.nodeMap
|
return index.nodeMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (index *SpecIndex) GetCache() *syncmap.Map {
|
func (index *SpecIndex) GetCache() *sync.Map {
|
||||||
return index.cache
|
return index.cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pb33f/libopenapi/utils"
|
"github.com/pb33f/libopenapi/utils"
|
||||||
"golang.org/x/exp/slices"
|
"slices"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pb33f/libopenapi/datamodel"
|
"github.com/pb33f/libopenapi/datamodel"
|
||||||
"golang.org/x/sync/syncmap"
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LocalFS is a file system that indexes local files.
|
// LocalFS is a file system that indexes local files.
|
||||||
@@ -25,12 +25,12 @@ type LocalFS struct {
|
|||||||
indexConfig *SpecIndexConfig
|
indexConfig *SpecIndexConfig
|
||||||
entryPointDirectory string
|
entryPointDirectory string
|
||||||
baseDirectory string
|
baseDirectory string
|
||||||
Files syncmap.Map
|
Files sync.Map
|
||||||
extractedFiles map[string]RolodexFile
|
extractedFiles map[string]RolodexFile
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
readingErrors []error
|
readingErrors []error
|
||||||
rolodex *Rolodex
|
rolodex *Rolodex
|
||||||
processingFiles syncmap.Map
|
processingFiles sync.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFiles returns the files that have been indexed. A map of RolodexFile objects keyed by the full path of the file.
|
// GetFiles returns the files that have been indexed. A map of RolodexFile objects keyed by the full path of the file.
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import (
|
|||||||
|
|
||||||
"github.com/pb33f/libopenapi/datamodel"
|
"github.com/pb33f/libopenapi/datamodel"
|
||||||
"github.com/pb33f/libopenapi/utils"
|
"github.com/pb33f/libopenapi/utils"
|
||||||
"golang.org/x/sync/syncmap"
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -38,8 +38,8 @@ type RemoteFS struct {
|
|||||||
rootURL string
|
rootURL string
|
||||||
rootURLParsed *url.URL
|
rootURLParsed *url.URL
|
||||||
RemoteHandlerFunc utils.RemoteURLHandler
|
RemoteHandlerFunc utils.RemoteURLHandler
|
||||||
Files syncmap.Map
|
Files sync.Map
|
||||||
ProcessingFiles syncmap.Map
|
ProcessingFiles sync.Map
|
||||||
FetchTime int64
|
FetchTime int64
|
||||||
FetchChannel chan *RemoteFile
|
FetchChannel chan *RemoteFile
|
||||||
remoteErrors []error
|
remoteErrors []error
|
||||||
@@ -344,10 +344,10 @@ func (i *RemoteFS) Open(remoteURL string) (fs.File, error) {
|
|||||||
remoteParsedURL.Host = i.rootURLParsed.Host
|
remoteParsedURL.Host = i.rootURLParsed.Host
|
||||||
remoteParsedURL.Scheme = i.rootURLParsed.Scheme
|
remoteParsedURL.Scheme = i.rootURLParsed.Scheme
|
||||||
// this has been disabled, because I don't think it has value, it causes more problems than it solves currently.
|
// this has been disabled, because I don't think it has value, it causes more problems than it solves currently.
|
||||||
//if !strings.HasPrefix(remoteParsedURL.Path, "/") {
|
// if !strings.HasPrefix(remoteParsedURL.Path, "/") {
|
||||||
// remoteParsedURL.Path = filepath.Join(i.rootURLParsed.Path, remoteParsedURL.Path)
|
// remoteParsedURL.Path = filepath.Join(i.rootURLParsed.Path, remoteParsedURL.Path)
|
||||||
// remoteParsedURL.Path = strings.ReplaceAll(remoteParsedURL.Path, "\\", "/")
|
// remoteParsedURL.Path = strings.ReplaceAll(remoteParsedURL.Path, "\\", "/")
|
||||||
//}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if remoteParsedURL.Scheme == "" {
|
if remoteParsedURL.Scheme == "" {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
"github.com/pb33f/libopenapi/utils"
|
"github.com/pb33f/libopenapi/utils"
|
||||||
"github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath"
|
"github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath"
|
||||||
"golang.org/x/sync/syncmap"
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -73,7 +72,7 @@ func createNewIndex(rootNode *yaml.Node, index *SpecIndex, avoidBuildOut bool) *
|
|||||||
index.nodeMap = make(map[int]map[int]*yaml.Node)
|
index.nodeMap = make(map[int]map[int]*yaml.Node)
|
||||||
go index.MapNodes(rootNode) // this can run async.
|
go index.MapNodes(rootNode) // this can run async.
|
||||||
|
|
||||||
index.cache = new(syncmap.Map)
|
index.cache = new(sync.Map)
|
||||||
|
|
||||||
// boot index.
|
// boot index.
|
||||||
results := index.ExtractRefs(index.root.Content[0], index.root, []string{}, 0, false, "")
|
results := index.ExtractRefs(index.root.Content[0], index.root, []string{}, 0, false, "")
|
||||||
|
|||||||
@@ -19,10 +19,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pb33f/libopenapi/utils"
|
"github.com/pb33f/libopenapi/utils"
|
||||||
"golang.org/x/sync/syncmap"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -44,7 +43,7 @@ func TestSpecIndex_GetCache(t *testing.T) {
|
|||||||
assert.True(t, ok)
|
assert.True(t, ok)
|
||||||
|
|
||||||
// create a new cache
|
// create a new cache
|
||||||
newCache := new(syncmap.Map)
|
newCache := new(sync.Map)
|
||||||
index.SetCache(newCache)
|
index.SetCache(newCache)
|
||||||
|
|
||||||
// check that the cache has been set.
|
// check that the cache has been set.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/lucasjones/reggen"
|
"github.com/lucasjones/reggen"
|
||||||
"github.com/pb33f/libopenapi/datamodel/high/base"
|
"github.com/pb33f/libopenapi/datamodel/high/base"
|
||||||
"github.com/pb33f/libopenapi/orderedmap"
|
"github.com/pb33f/libopenapi/orderedmap"
|
||||||
"golang.org/x/exp/slices"
|
"slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"golang.org/x/exp/slices"
|
"slices"
|
||||||
|
|
||||||
"github.com/pb33f/libopenapi/datamodel/low"
|
"github.com/pb33f/libopenapi/datamodel/low"
|
||||||
"github.com/pb33f/libopenapi/datamodel/low/base"
|
"github.com/pb33f/libopenapi/datamodel/low/base"
|
||||||
|
|||||||
Reference in New Issue
Block a user