mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
This commit is contained in:
@@ -216,7 +216,7 @@ func (index *SpecIndex) ExtractRefs(node, parent *yaml.Node, seenPath []string,
|
||||
continue
|
||||
}
|
||||
// issue #481, don't look at refs in arrays, the next node isn't the value.
|
||||
if utils.IsNodeArray(node) {
|
||||
if utils.IsNodeArray(node) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -444,6 +444,9 @@ func (index *SpecIndex) ExtractRefs(node, parent *yaml.Node, seenPath []string,
|
||||
if utils.IsNodeArray(node) {
|
||||
continue
|
||||
}
|
||||
if slices.Contains(seenPath, "example") || slices.Contains(seenPath, "examples") {
|
||||
continue
|
||||
}
|
||||
|
||||
ref := &DescriptionReference{
|
||||
ParentNode: parent,
|
||||
@@ -462,6 +465,10 @@ func (index *SpecIndex) ExtractRefs(node, parent *yaml.Node, seenPath []string,
|
||||
|
||||
if n.Value == "summary" {
|
||||
|
||||
if slices.Contains(seenPath, "example") || slices.Contains(seenPath, "examples") {
|
||||
continue
|
||||
}
|
||||
|
||||
var b *yaml.Node
|
||||
if len(node.Content) == i+1 {
|
||||
b = node.Content[i]
|
||||
|
||||
@@ -1701,3 +1701,18 @@ components:
|
||||
schemas := index.GetAllSchemas()
|
||||
assert.Equal(t, 6, len(schemas))
|
||||
}
|
||||
|
||||
func TestSpecIndex_CheckIgnoreDescriptionsInExamples(t *testing.T) {
|
||||
yml := `openapi: 3.1.0
|
||||
components:
|
||||
examples:
|
||||
example1:
|
||||
description: this should be ignored`
|
||||
|
||||
var rootNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &rootNode)
|
||||
|
||||
index := NewSpecIndexWithConfig(&rootNode, CreateOpenAPIIndexConfig())
|
||||
schemas := index.GetAllDescriptions()
|
||||
assert.Equal(t, 0, len(schemas))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user