mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 12:37:48 +00:00
Every `Build()` method now requires a `context.Context`. This is so the rolodex knows where to resolve from when locating relative links. Without knowing where we are, there is no way to resolve anything. This new mechanism allows the model to recurse across as many files as required to locate references, without loosing track of where we are in the process. Signed-off-by: quobix <dave@quobix.com>
24 lines
556 B
Go
24 lines
556 B
Go
// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package index
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"gopkg.in/yaml.v3"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestSpecIndex_SearchIndexForReference(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.SearchIndexForReference("#/components/schemas/Pet")
|
|
assert.NotNil(t, ref)
|
|
}
|