mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
Fix issue with non-working IgnorePoly flag.
This commit is contained in:
@@ -369,7 +369,9 @@ func (resolver *Resolver) VisitReference(ref *Reference, seen map[string]bool, j
|
|||||||
IsInfiniteLoop: isInfiniteLoop,
|
IsInfiniteLoop: isInfiniteLoop,
|
||||||
}
|
}
|
||||||
|
|
||||||
if resolver.IgnoreArray && isArray {
|
if resolver.IgnorePoly && !isArray {
|
||||||
|
resolver.ignoredPolyReferences = append(resolver.ignoredPolyReferences, circRef)
|
||||||
|
} else if resolver.IgnoreArray && isArray {
|
||||||
resolver.ignoredArrayReferences = append(resolver.ignoredArrayReferences, circRef)
|
resolver.ignoredArrayReferences = append(resolver.ignoredArrayReferences, circRef)
|
||||||
} else {
|
} else {
|
||||||
if !resolver.circChecked {
|
if !resolver.circChecked {
|
||||||
|
|||||||
@@ -217,22 +217,36 @@ components:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestResolver_CheckForCircularReferences_IgnorePoly_Any(t *testing.T) {
|
func TestResolver_CheckForCircularReferences_IgnorePoly_Any(t *testing.T) {
|
||||||
circular := []byte(`openapi: 3.0.0
|
circular := []byte(`openapi: 3.1.0
|
||||||
|
paths:
|
||||||
|
/one:
|
||||||
|
get:
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/One'
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
ProductCategory:
|
One:
|
||||||
type: "object"
|
|
||||||
properties:
|
properties:
|
||||||
name:
|
thing:
|
||||||
type: "string"
|
oneOf:
|
||||||
children:
|
- "$ref": "#/components/schemas/Two"
|
||||||
type: "object"
|
- "$ref": "#/components/schemas/Three"
|
||||||
anyOf:
|
|
||||||
- $ref: "#/components/schemas/ProductCategory"
|
|
||||||
description: "Array of sub-categories in the same format."
|
|
||||||
required:
|
required:
|
||||||
- "name"
|
- thing
|
||||||
- "children"`)
|
Two:
|
||||||
|
description: "test two"
|
||||||
|
properties:
|
||||||
|
testThing:
|
||||||
|
"$ref": "#/components/schemas/One"
|
||||||
|
Three:
|
||||||
|
description: "test three"
|
||||||
|
properties:
|
||||||
|
testThing:
|
||||||
|
"$ref": "#/components/schemas/One"`)
|
||||||
var rootNode yaml.Node
|
var rootNode yaml.Node
|
||||||
_ = yaml.Unmarshal(circular, &rootNode)
|
_ = yaml.Unmarshal(circular, &rootNode)
|
||||||
|
|
||||||
|
|||||||
@@ -1441,8 +1441,8 @@ components:
|
|||||||
rolodex.SetRootNode(&rootNode)
|
rolodex.SetRootNode(&rootNode)
|
||||||
|
|
||||||
err := rolodex.IndexTheRolodex()
|
err := rolodex.IndexTheRolodex()
|
||||||
assert.Error(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, rolodex.GetCaughtErrors(), 1)
|
assert.Len(t, rolodex.GetCaughtErrors(), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRolodex_IndexCircularLookup_ignorePoly(t *testing.T) {
|
func TestRolodex_IndexCircularLookup_ignorePoly(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user