From e0f0f387bd732c99e267d8cc736d645d739229b3 Mon Sep 17 00:00:00 2001 From: quobix Date: Thu, 18 Jan 2024 13:29:52 -0500 Subject: [PATCH] resolved build issues Signed-off-by: quobix --- index/resolver.go | 4 ++-- what-changed/what_changed_test.go | 35 ------------------------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/index/resolver.go b/index/resolver.go index 4124f05..2d72ea5 100644 --- a/index/resolver.go +++ b/index/resolver.go @@ -637,7 +637,7 @@ func (resolver *Resolver) extractRelatives(ref *Reference, node, parent *yaml.No n.Value == "anyOf" { // 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 if _, v := utils.FindKeyNodeTop("items", node.Content[i+1].Content); v != nil { if utils.IsNodeMap(v) { @@ -745,7 +745,7 @@ func (resolver *Resolver) extractRelatives(ref *Reference, node, parent *yaml.No } } // 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 for q := range node.Content[i+1].Content { v := node.Content[i+1].Content[q] diff --git a/what-changed/what_changed_test.go b/what-changed/what_changed_test.go index 5a69a94..a7b575a 100644 --- a/what-changed/what_changed_test.go +++ b/what-changed/what_changed_test.go @@ -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) { original, _ := os.ReadFile("../test_specs/burgershop.openapi.yaml")