Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/issue251'
Browse files Browse the repository at this point in the history
  • Loading branch information
emicklei committed Nov 26, 2015
2 parents 7b748ee + 552e2b1 commit 777bb3f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions swagger/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Change history of swagger
=
2015-10-16
- add type override mechanism for swagger models (MR 254, nathanejohnson)
- replace uses of wildcard in generated apidocs (issue 251)

2015-05-25
- (api break) changed the type of Properties in Model
- (api break) changed the type of Models in ApiDeclaration
Expand Down
9 changes: 8 additions & 1 deletion swagger/swagger_webservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (sws SwaggerService) composeDeclaration(ws *restful.WebService, pathPrefix
}
}
pathToRoutes.Do(func(path string, routes []restful.Route) {
api := Api{Path: strings.TrimSuffix(path, "/"), Description: ws.Documentation()}
api := Api{Path: strings.TrimSuffix(withoutWildcard(path), "/"), Description: ws.Documentation()}
voidString := "void"
for _, route := range routes {
operation := Operation{
Expand Down Expand Up @@ -263,6 +263,13 @@ func (sws SwaggerService) composeDeclaration(ws *restful.WebService, pathPrefix
return decl
}

func withoutWildcard(path string) string {
if strings.HasSuffix(path, ":*}") {
return path[0:len(path)-3] + "}"
}
return path
}

// composeResponseMessages takes the ResponseErrors (if any) and creates ResponseMessages from them.
func composeResponseMessages(route restful.Route, decl *ApiDeclaration) (messages []ResponseMessage) {
if route.ResponseErrors == nil {
Expand Down

0 comments on commit 777bb3f

Please sign in to comment.