Skip to content

Commit 777bb3f

Browse files
committed
Merge remote-tracking branch 'origin/issue251'
2 parents 7b748ee + 552e2b1 commit 777bb3f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

swagger/CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Change history of swagger
22
=
3+
2015-10-16
4+
- add type override mechanism for swagger models (MR 254, nathanejohnson)
5+
- replace uses of wildcard in generated apidocs (issue 251)
6+
37
2015-05-25
48
- (api break) changed the type of Properties in Model
59
- (api break) changed the type of Models in ApiDeclaration

swagger/swagger_webservice.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (sws SwaggerService) composeDeclaration(ws *restful.WebService, pathPrefix
230230
}
231231
}
232232
pathToRoutes.Do(func(path string, routes []restful.Route) {
233-
api := Api{Path: strings.TrimSuffix(path, "/"), Description: ws.Documentation()}
233+
api := Api{Path: strings.TrimSuffix(withoutWildcard(path), "/"), Description: ws.Documentation()}
234234
voidString := "void"
235235
for _, route := range routes {
236236
operation := Operation{
@@ -263,6 +263,13 @@ func (sws SwaggerService) composeDeclaration(ws *restful.WebService, pathPrefix
263263
return decl
264264
}
265265

266+
func withoutWildcard(path string) string {
267+
if strings.HasSuffix(path, ":*}") {
268+
return path[0:len(path)-3] + "}"
269+
}
270+
return path
271+
}
272+
266273
// composeResponseMessages takes the ResponseErrors (if any) and creates ResponseMessages from them.
267274
func composeResponseMessages(route restful.Route, decl *ApiDeclaration) (messages []ResponseMessage) {
268275
if route.ResponseErrors == nil {

0 commit comments

Comments
 (0)