resolved build issues

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2024-01-18 13:29:52 -05:00
parent c8d4f72be5
commit e0f0f387bd
2 changed files with 2 additions and 37 deletions

View File

@@ -637,7 +637,7 @@ func (resolver *Resolver) extractRelatives(ref *Reference, node, parent *yaml.No
n.Value == "anyOf" { n.Value == "anyOf" {
// if this is a polymorphic link, we want to follow it and see if it becomes circular // if this is a polymorphic link, we want to follow it and see if it becomes circular
if len(node.Content) < i+1 && utils.IsNodeMap(node.Content[i+1]) { // check for nested items if i+1 <= len(node.Content) && utils.IsNodeMap(node.Content[i+1]) { // check for nested items
// check if items is present, to indicate an array // check if items is present, to indicate an array
if _, v := utils.FindKeyNodeTop("items", node.Content[i+1].Content); v != nil { if _, v := utils.FindKeyNodeTop("items", node.Content[i+1].Content); v != nil {
if utils.IsNodeMap(v) { if utils.IsNodeMap(v) {
@@ -745,7 +745,7 @@ func (resolver *Resolver) extractRelatives(ref *Reference, node, parent *yaml.No
} }
} }
// for array based polymorphic items // for array based polymorphic items
if utils.IsNodeArray(node.Content[i+1]) { // check for nested items if i+1 <= len(node.Content) && utils.IsNodeArray(node.Content[i+1]) { // check for nested items
// check if items is present, to indicate an array // check if items is present, to indicate an array
for q := range node.Content[i+1].Content { for q := range node.Content[i+1].Content {
v := node.Content[i+1].Content[q] v := node.Content[i+1].Content[q]

View File

@@ -46,41 +46,6 @@ func TestCompareSwaggerDocuments(t *testing.T) {
} }
func TestCompareRefs(t *testing.T) {
original := []byte(`openapi: 3.0
components:
schemas:
Yo:
type: int
OK:
$ref: '#/components/schemas/Yo'
`)
modified := []byte(`openapi: 3.0
components:
schemas:
Yo:
type: int
OK:
type: int
`)
infoOrig, _ := datamodel.ExtractSpecInfo(original)
infoMod, _ := datamodel.ExtractSpecInfo(modified)
origDoc, _ := v3.CreateDocumentFromConfig(infoOrig, datamodel.NewDocumentConfiguration())
modDoc, _ := v3.CreateDocumentFromConfig(infoMod, datamodel.NewDocumentConfiguration())
changes := CompareOpenAPIDocuments(origDoc, modDoc)
assert.Equal(t, 52, changes.TotalChanges())
assert.Equal(t, 27, changes.TotalBreakingChanges())
//out, _ := json.MarshalIndent(changes, "", " ")
//_ = os.WriteFile("output.json", out, 0776)
}
func Benchmark_CompareOpenAPIDocuments(b *testing.B) { func Benchmark_CompareOpenAPIDocuments(b *testing.B) {
original, _ := os.ReadFile("../test_specs/burgershop.openapi.yaml") original, _ := os.ReadFile("../test_specs/burgershop.openapi.yaml")