mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
fix: panic thrown when paths is wrapped in an array #4
When paths are wrapped in an array, the index throws an error because it's expecting them to be supplied as a map. Now paths can be wrapped or unwrapped, the index won't care.
This commit is contained in:
@@ -1279,7 +1279,12 @@ func (index *SpecIndex) GetOperationCount() int {
|
||||
for x, p := range index.pathsNode.Content {
|
||||
if x%2 == 0 {
|
||||
|
||||
method := index.pathsNode.Content[x+1]
|
||||
var method *yaml.Node
|
||||
if utils.IsNodeArray(index.pathsNode) {
|
||||
method = index.pathsNode.Content[x]
|
||||
} else {
|
||||
method = index.pathsNode.Content[x+1]
|
||||
}
|
||||
|
||||
// extract methods for later use.
|
||||
for y, m := range method.Content {
|
||||
@@ -1339,7 +1344,12 @@ func (index *SpecIndex) GetOperationsParameterCount() int {
|
||||
for x, pathItemNode := range index.pathsNode.Content {
|
||||
if x%2 == 0 {
|
||||
|
||||
pathPropertyNode := index.pathsNode.Content[x+1]
|
||||
var pathPropertyNode *yaml.Node
|
||||
if utils.IsNodeArray(index.pathsNode) {
|
||||
pathPropertyNode = index.pathsNode.Content[x]
|
||||
} else {
|
||||
pathPropertyNode = index.pathsNode.Content[x+1]
|
||||
}
|
||||
|
||||
// extract methods for later use.
|
||||
for y, prop := range pathPropertyNode.Content {
|
||||
|
||||
Reference in New Issue
Block a user