Skip to content

Commit

Permalink
Make sure empty Swagger base paths is keyed by / (#1287)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael committed Jun 28, 2017
1 parent 4786baf commit 4c3d4d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions goagen/gen_swagger/swagger.go
Expand Up @@ -958,9 +958,6 @@ func buildPathFromDefinition(s *Swagger, api *design.APIDefinition, route *desig
return fmt.Sprintf("/{%s}", w[2:])
},
)
if key == "" {
key = "/"
}
bp := design.WildcardRegex.ReplaceAllStringFunc(
basePath,
func(w string) string {
Expand All @@ -970,6 +967,9 @@ func buildPathFromDefinition(s *Swagger, api *design.APIDefinition, route *desig
if bp != "/" {
key = strings.TrimPrefix(key, bp)
}
if key == "" {
key = "/"
}
var path interface{}
var ok bool
if path, ok = s.Paths[key]; !ok {
Expand Down
4 changes: 2 additions & 2 deletions goagen/gen_swagger/swagger_test.go
Expand Up @@ -655,7 +655,7 @@ var _ = Describe("New", func() {
})

It("should set the action tags", func() {
p := swagger.Paths[""].(*genswagger.Path)
p := swagger.Paths["/"].(*genswagger.Path)
Ω(p.Put.Tags).Should(HaveLen(2))
tags := []string{"res", "Update"}
Ω(p.Put.Tags).Should(Equal(tags))
Expand All @@ -664,7 +664,7 @@ var _ = Describe("New", func() {
It("should set the swagger extensions", func() {
Ω(swagger.Info.Extensions).Should(HaveLen(1))
Ω(swagger.Info.Extensions["x-api"]).Should(Equal(unmarshaled))
p := swagger.Paths[""].(*genswagger.Path)
p := swagger.Paths["/"].(*genswagger.Path)
Ω(p.Extensions).Should(HaveLen(1))
Ω(p.Extensions["x-action"]).Should(Equal(unmarshaled))
Ω(p.Put.Extensions).Should(HaveLen(1))
Expand Down

0 comments on commit 4c3d4d9

Please sign in to comment.