{"action":"closed","issue":{"url":"https://api.github.com/repos/emicklei/go-restful/issues/251","labels_url":"https://api.github.com/repos/emicklei/go-restful/issues/251/labels{/name}","comments_url":"https://api.github.com/repos/emicklei/go-restful/issues/251/comments","events_url":"https://api.github.com/repos/emicklei/go-restful/issues/251/events","html_url":"https://github.com/emicklei/go-restful/issues/251","id":114942979,"number":251,"title":"swagger validation fails for CurlyRouter paths with regexes","user":{"login":"nikhiljindal","id":10199099,"avatar_url":"https://avatars.githubusercontent.com/u/10199099?v=3","gravatar_id":"","url":"https://api.github.com/users/nikhiljindal","html_url":"https://github.com/nikhiljindal","followers_url":"https://api.github.com/users/nikhiljindal/followers","following_url":"https://api.github.com/users/nikhiljindal/following{/other_user}","gists_url":"https://api.github.com/users/nikhiljindal/gists{/gist_id}","starred_url":"https://api.github.com/users/nikhiljindal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikhiljindal/subscriptions","organizations_url":"https://api.github.com/users/nikhiljindal/orgs","repos_url":"https://api.github.com/users/nikhiljindal/repos","events_url":"https://api.github.com/users/nikhiljindal/events{/privacy}","received_events_url":"https://api.github.com/users/nikhiljindal/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-11-04T00:38:07Z","updated_at":"2015-11-27T14:02:44Z","closed_at":"2015-11-27T14:02:43Z","body":"Swagger validation fails when path contains regex of the form {subpath:*}.\r\n\r\nFor ex: consider an example as explained in https://github.com/emicklei/go-restful/blob/master/examples/restful-serve-static.go.\r\n```\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"net/http\"\r\n\t\"path\"\r\n\r\n\t\"github.com/emicklei/go-restful\"\r\n\t\"github.com/emicklei/go-restful/swagger\"\r\n)\r\n\r\nvar rootdir = \"/tmp\"\r\n\r\nfunc main() {\r\n\trestful.DefaultContainer.Router(restful.CurlyRouter{})\r\n\r\n\tws := new(restful.WebService)\r\n\tws.Path(\"/resources\")\r\n\tpathParam := ws.PathParameter(\"subpath\", \"subpath of the resource\").DataType(\"string\")\r\n\tws.Route(ws.GET(\"/static/{subpath:*}\").To(staticFromPathParam).Param(pathParam))\r\n\trestful.Add(ws)\r\n\r\n\tprintln(\"[go-restful] serving files on http://localhost:8080/static from local /tmp\")\r\n\r\n\tswaggerConfig := swagger.Config{\r\n\t\tWebServicesUrl: \"http://localhost\",\r\n\t\tWebServices:    []*restful.WebService{ws},\r\n\t\tApiPath:        \"/swaggerapi/\",\r\n\t}\r\n\tswagger.RegisterSwaggerService(swaggerConfig, restful.DefaultContainer)\r\n\r\n\thttp.ListenAndServe(\":8080\", nil)\r\n}\r\n\r\nfunc staticFromPathParam(req *restful.Request, resp *restful.Response) {\r\n\tactual := path.Join(rootdir, req.PathParameter(\"subpath\"))\r\n\tfmt.Printf(\"serving %s ... (from %s)\\n\", actual, req.PathParameter(\"subpath\"))\r\n\thttp.ServeFile(\r\n\t\tresp.ResponseWriter,\r\n\t\treq.Request,\r\n\t\tactual)\r\n}\r\n```\r\n\r\nThe generated swagger spec for this is:\r\n\r\n```\r\n{\r\n  \"swaggerVersion\": \"1.2\",\r\n  \"apiVersion\": \"\",\r\n  \"basePath\": \"http://localhost\",\r\n  \"resourcePath\": \"/resources\",\r\n  \"apis\": [\r\n   {\r\n    \"path\": \"/resources/static/{subpath:*}\",\r\n    \"description\": \"\",\r\n    \"operations\": [\r\n     {\r\n      \"type\": \"void\",\r\n      \"method\": \"GET\",\r\n      \"nickname\": \"staticFromPathParam\",\r\n      \"parameters\": [\r\n       {\r\n        \"type\": \"string\",\r\n        \"paramType\": \"path\",\r\n        \"name\": \"subpath\",\r\n        \"description\": \"subpath of the resource\",\r\n        \"required\": true,\r\n        \"allowMultiple\": false\r\n       }\r\n      ]\r\n     }\r\n    ]\r\n   }\r\n  ],\r\n  \"models\": {}\r\n }\r\n```\r\n\r\nRunning swagger-tools validate gives the following error:\r\n```\r\nAPI Declaration (/resources) Errors:\r\n\r\n    #/apis/0/operations/0/parameters/0/name: API path parameter could not be resolved: subpath\r\n    #/apis/0/path: API requires path parameter but it is not defined: subpath:*\r\n\r\n2 errors and 0 warnings\r\n```\r\n\r\nThe validation code expects the path name to be `subpath:*` which is not a valid name (The generated client will have code like: public `String staticFromPathParam(String subpath:*)`)\r\n\r\nI do not know what the correct spec is (asking it here: https://github.com/swagger-api/swagger-spec/issues/502), but wanted to let you know that the currently generated spec is incorrect."}}