mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
Fixed resolving bug with polymorphic schemas.
Multiple polymorphic, deeply embedded schemas cause resolving issues as a channel waits forever due to a counting issue. This has been resolved. Signed-off-by: Dave Shanley <dshanley@splunk.com>
This commit is contained in:
@@ -242,38 +242,43 @@ func NewSchema(schema *base.Schema) *Schema {
|
|||||||
var not []*SchemaProxy
|
var not []*SchemaProxy
|
||||||
var items []*SchemaProxy
|
var items []*SchemaProxy
|
||||||
|
|
||||||
|
children := 0
|
||||||
if !schema.AllOf.IsEmpty() {
|
if !schema.AllOf.IsEmpty() {
|
||||||
|
children++
|
||||||
go buildOutSchema(schema.AllOf.Value, &allOf, polyCompletedChan, errChan)
|
go buildOutSchema(schema.AllOf.Value, &allOf, polyCompletedChan, errChan)
|
||||||
}
|
}
|
||||||
if !schema.AnyOf.IsEmpty() {
|
if !schema.AnyOf.IsEmpty() {
|
||||||
|
children++
|
||||||
go buildOutSchema(schema.AnyOf.Value, &anyOf, polyCompletedChan, errChan)
|
go buildOutSchema(schema.AnyOf.Value, &anyOf, polyCompletedChan, errChan)
|
||||||
}
|
}
|
||||||
if !schema.OneOf.IsEmpty() {
|
if !schema.OneOf.IsEmpty() {
|
||||||
|
children++
|
||||||
go buildOutSchema(schema.OneOf.Value, &oneOf, polyCompletedChan, errChan)
|
go buildOutSchema(schema.OneOf.Value, &oneOf, polyCompletedChan, errChan)
|
||||||
}
|
}
|
||||||
if !schema.Not.IsEmpty() {
|
if !schema.Not.IsEmpty() {
|
||||||
|
children++
|
||||||
go buildOutSchema(schema.Not.Value, ¬, polyCompletedChan, errChan)
|
go buildOutSchema(schema.Not.Value, ¬, polyCompletedChan, errChan)
|
||||||
}
|
}
|
||||||
if !schema.Items.IsEmpty() {
|
if !schema.Items.IsEmpty() {
|
||||||
|
children++
|
||||||
go buildOutSchema(schema.Items.Value, &items, polyCompletedChan, errChan)
|
go buildOutSchema(schema.Items.Value, &items, polyCompletedChan, errChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
completeChildren := 0
|
completeChildren := 0
|
||||||
completedProps := 0
|
completedProps := 0
|
||||||
totalProps := len(schema.Properties.Value)
|
totalProps := len(schema.Properties.Value)
|
||||||
totalChildren := len(schema.AllOf.Value) + len(schema.OneOf.Value) + len(schema.AnyOf.Value) + len(schema.Items.Value) + len(schema.Not.Value)
|
if totalProps+children > 0 {
|
||||||
if totalProps+totalChildren > 0 {
|
|
||||||
allDone:
|
allDone:
|
||||||
for true {
|
for true {
|
||||||
select {
|
select {
|
||||||
case <-polyCompletedChan:
|
case <-polyCompletedChan:
|
||||||
completeChildren++
|
completeChildren++
|
||||||
if totalProps == completedProps && totalChildren == completeChildren {
|
if totalProps == completedProps && children == completeChildren {
|
||||||
break allDone
|
break allDone
|
||||||
}
|
}
|
||||||
case <-propsChan:
|
case <-propsChan:
|
||||||
completedProps++
|
completedProps++
|
||||||
if totalProps == completedProps && totalChildren == completeChildren {
|
if totalProps == completedProps && children == completeChildren {
|
||||||
break allDone
|
break allDone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ func TestSpecIndex_TestEmptyBrokenReferences(t *testing.T) {
|
|||||||
assert.Equal(t, 2, index.GetOperationsParameterCount())
|
assert.Equal(t, 2, index.GetOperationsParameterCount())
|
||||||
assert.Equal(t, 1, index.GetInlineDuplicateParamCount())
|
assert.Equal(t, 1, index.GetInlineDuplicateParamCount())
|
||||||
assert.Equal(t, 1, index.GetInlineUniqueParamCount())
|
assert.Equal(t, 1, index.GetInlineUniqueParamCount())
|
||||||
assert.Len(t, index.refErrors, 7)
|
assert.Len(t, index.refErrors, 6)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user