Skip to content

Commit 090577f

Browse files
committed
BUG/MINOR: discovery: fix interface nil conversion
1 parent 165be83 commit 090577f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

misc/misc.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func HandleContainerGetError(err error) *models.Error {
114114
// DiscoverChildPaths return children models.Endpoints given path
115115
func DiscoverChildPaths(path string, spec json.RawMessage) (models.Endpoints, error) {
116116
var m map[string]interface{}
117-
var json = jsoniter.ConfigCompatibleWithStandardLibrary
117+
json := jsoniter.ConfigCompatibleWithStandardLibrary
118118
err := json.Unmarshal(spec, &m)
119119
if err != nil {
120120
return nil, err
@@ -124,8 +124,14 @@ func DiscoverChildPaths(path string, spec json.RawMessage) (models.Endpoints, er
124124
for key, value := range paths {
125125
v := value.(map[string]interface{})
126126
if g, ok := v["get"].(map[string]interface{}); ok {
127-
title := g["summary"].(string)
128-
description := g["description"].(string)
127+
title := ""
128+
if titleInterface, ok := g["summary"]; ok && titleInterface != nil {
129+
title = titleInterface.(string)
130+
}
131+
description := ""
132+
if descInterface, ok := g["description"]; ok && descInterface != nil {
133+
description = descInterface.(string)
134+
}
129135

130136
if strings.HasPrefix(key, path) && key != path {
131137
resource := key[len(path):]

0 commit comments

Comments
 (0)