Skip to content

Commit

Permalink
Fix panic when swagger has no paths (#2092)
Browse files Browse the repository at this point in the history
Fixes #2059

Fix a panic in linkerd profile --open-api when the swagger spec has no Paths field.

Signed-off-by: Alex Leong <alex@buoyant.io>
  • Loading branch information
adleong authored Jan 16, 2019
1 parent af47232 commit 3398e93
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cli/cmd/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ func renderOpenAPI(options *profileOptions, w io.Writer) error {
routes := make([]*sp.RouteSpec, 0)

paths := make([]string, 0)
for path := range swagger.Paths.Paths {
paths = append(paths, path)
if swagger.Paths != nil {
for path := range swagger.Paths.Paths {
paths = append(paths, path)
}
sort.Strings(paths)
}
sort.Strings(paths)

for _, path := range paths {
item := swagger.Paths.Paths[path]
Expand Down

0 comments on commit 3398e93

Please sign in to comment.