mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 20:47:44 +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 items []*SchemaProxy
|
||||
|
||||
children := 0
|
||||
if !schema.AllOf.IsEmpty() {
|
||||
children++
|
||||
go buildOutSchema(schema.AllOf.Value, &allOf, polyCompletedChan, errChan)
|
||||
}
|
||||
if !schema.AnyOf.IsEmpty() {
|
||||
children++
|
||||
go buildOutSchema(schema.AnyOf.Value, &anyOf, polyCompletedChan, errChan)
|
||||
}
|
||||
if !schema.OneOf.IsEmpty() {
|
||||
children++
|
||||
go buildOutSchema(schema.OneOf.Value, &oneOf, polyCompletedChan, errChan)
|
||||
}
|
||||
if !schema.Not.IsEmpty() {
|
||||
children++
|
||||
go buildOutSchema(schema.Not.Value, ¬, polyCompletedChan, errChan)
|
||||
}
|
||||
if !schema.Items.IsEmpty() {
|
||||
children++
|
||||
go buildOutSchema(schema.Items.Value, &items, polyCompletedChan, errChan)
|
||||
}
|
||||
|
||||
completeChildren := 0
|
||||
completedProps := 0
|
||||
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+totalChildren > 0 {
|
||||
if totalProps+children > 0 {
|
||||
allDone:
|
||||
for true {
|
||||
select {
|
||||
case <-polyCompletedChan:
|
||||
completeChildren++
|
||||
if totalProps == completedProps && totalChildren == completeChildren {
|
||||
if totalProps == completedProps && children == completeChildren {
|
||||
break allDone
|
||||
}
|
||||
case <-propsChan:
|
||||
completedProps++
|
||||
if totalProps == completedProps && totalChildren == completeChildren {
|
||||
if totalProps == completedProps && children == completeChildren {
|
||||
break allDone
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ func TestSpecIndex_TestEmptyBrokenReferences(t *testing.T) {
|
||||
assert.Equal(t, 2, index.GetOperationsParameterCount())
|
||||
assert.Equal(t, 1, index.GetInlineDuplicateParamCount())
|
||||
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