mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
@@ -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]
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user