mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
@@ -44,7 +44,6 @@ func (index *SpecIndex) FindComponent(componentId string) *Reference {
|
|||||||
// root search
|
// root search
|
||||||
return index.FindComponentInRoot(componentId)
|
return index.FindComponentInRoot(componentId)
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindComponent(root *yaml.Node, componentId, absoluteFilePath string, index *SpecIndex) *Reference {
|
func FindComponent(root *yaml.Node, componentId, absoluteFilePath string, index *SpecIndex) *Reference {
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ func TestRolodexLocalFile_TestFilters(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRolodexLocalFile_TestBasFS(t *testing.T) {
|
func TestRolodexLocalFile_TestBadFS(t *testing.T) {
|
||||||
|
|
||||||
testFS := test_badfs{}
|
testFS := test_badfs{}
|
||||||
|
|
||||||
@@ -176,3 +176,11 @@ func TestRolodexLocalFile_TestBasFS(t *testing.T) {
|
|||||||
assert.Nil(t, fileFS)
|
assert.Nil(t, fileFS)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewRolodexLocalFile_BadOffset(t *testing.T) {
|
||||||
|
|
||||||
|
lf := &LocalFile{offset: -1}
|
||||||
|
z, y := io.ReadAll(lf)
|
||||||
|
assert.Len(t, z, 0)
|
||||||
|
assert.Error(t, y)
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
package index
|
package index
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"os"
|
"os"
|
||||||
@@ -21,3 +22,15 @@ func TestSpecIndex_SearchIndexForReference(t *testing.T) {
|
|||||||
ref, _ := idx.SearchIndexForReference("#/components/schemas/Pet")
|
ref, _ := idx.SearchIndexForReference("#/components/schemas/Pet")
|
||||||
assert.NotNil(t, ref)
|
assert.NotNil(t, ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSpecIndex_SearchIndexForReferenceWithContext(t *testing.T) {
|
||||||
|
petstore, _ := os.ReadFile("../test_specs/petstorev3.json")
|
||||||
|
var rootNode yaml.Node
|
||||||
|
_ = yaml.Unmarshal(petstore, &rootNode)
|
||||||
|
|
||||||
|
c := CreateOpenAPIIndexConfig()
|
||||||
|
idx := NewSpecIndexWithConfig(&rootNode, c)
|
||||||
|
|
||||||
|
ref, _, _ := idx.SearchIndexForReferenceWithContext(context.Background(), "#/components/schemas/Pet")
|
||||||
|
assert.NotNil(t, ref)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user