From 552e2b14ac509407598ab988592c452ccb75a60b Mon Sep 17 00:00:00 2001 From: Ernest Micklei Date: Mon, 16 Nov 2015 09:50:27 +0100 Subject: [PATCH] hide use of wildcard in apidocs --- swagger/CHANGES.md | 4 ++++ swagger/swagger_webservice.go | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/swagger/CHANGES.md b/swagger/CHANGES.md index c9b49044..736f6f37 100644 --- a/swagger/CHANGES.md +++ b/swagger/CHANGES.md @@ -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 diff --git a/swagger/swagger_webservice.go b/swagger/swagger_webservice.go index c6e76aba..8dc3d5f9 100644 --- a/swagger/swagger_webservice.go +++ b/swagger/swagger_webservice.go @@ -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{ @@ -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 {