mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +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,
|
||||
}
|
||||
|
||||
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)
|
||||
} else {
|
||||
if !resolver.circChecked {
|
||||
|
||||
@@ -217,22 +217,36 @@ components:
|
||||
}
|
||||
|
||||
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:
|
||||
schemas:
|
||||
ProductCategory:
|
||||
type: "object"
|
||||
One:
|
||||
properties:
|
||||
name:
|
||||
type: "string"
|
||||
children:
|
||||
type: "object"
|
||||
anyOf:
|
||||
- $ref: "#/components/schemas/ProductCategory"
|
||||
description: "Array of sub-categories in the same format."
|
||||
thing:
|
||||
oneOf:
|
||||
- "$ref": "#/components/schemas/Two"
|
||||
- "$ref": "#/components/schemas/Three"
|
||||
required:
|
||||
- "name"
|
||||
- "children"`)
|
||||
- thing
|
||||
Two:
|
||||
description: "test two"
|
||||
properties:
|
||||
testThing:
|
||||
"$ref": "#/components/schemas/One"
|
||||
Three:
|
||||
description: "test three"
|
||||
properties:
|
||||
testThing:
|
||||
"$ref": "#/components/schemas/One"`)
|
||||
var rootNode yaml.Node
|
||||
_ = yaml.Unmarshal(circular, &rootNode)
|
||||
|
||||
|
||||
@@ -1441,8 +1441,8 @@ components:
|
||||
rolodex.SetRootNode(&rootNode)
|
||||
|
||||
err := rolodex.IndexTheRolodex()
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, rolodex.GetCaughtErrors(), 1)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, rolodex.GetCaughtErrors(), 0)
|
||||
}
|
||||
|
||||
func TestRolodex_IndexCircularLookup_ignorePoly(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user