Files
Marc Carré ded7717c94 Switch from emicklei/go-restful-openapi to marccarre/go-restful-openapi
In order to remove dependencies on `Sirupsen/logrus` while emicklei/go-restful-openapi/pull/49 is getting reviewed and, hopefully, merged:
```
$ gvt delete github.com/emicklei/go-restful-openapi
$ gvt fetch --branch lowercase-sirupsen --revision 129557de7d9f2d2ca4a90cd31c379db90a561ad8 github.com/marccarre/go-restful-openapi
2018/07/23 15:50:36 Fetching: github.com/marccarre/go-restful-openapi
2018/07/23 15:50:38 · Skipping (existing): github.com/emicklei/go-restful
2018/07/23 15:50:38 · Skipping (existing): github.com/sirupsen/logrus
2018/07/23 15:50:38 · Skipping (existing): github.com/go-openapi/spec
2018/07/23 15:50:38 · Fetching recursive dependency: github.com/emicklei/go-restful-openapi
2018/07/23 15:50:40 ·· Skipping (existing): github.com/emicklei/go-restful
2018/07/23 15:50:40 ·· Fetching recursive dependency: github.com/Sirupsen/logrus
2018/07/23 15:50:43 ··· Skipping (existing): golang.org/x/sys/unix
2018/07/23 15:50:43 ··· Skipping (existing): golang.org/x/crypto/ssh/terminal
2018/07/23 15:50:43 ··· Skipping (existing): github.com/sirupsen/logrus
2018/07/23 15:50:43 ·· Skipping (existing): github.com/go-openapi/spec
```
2018-07-23 20:10:15 +02:00

34 lines
890 B
Go

package main
import restful "github.com/emicklei/go-restful"
import restfulspec "github.com/emicklei/go-restful-openapi"
type ExampleService struct{}
type ExampleReq struct{}
type ExampleResp struct{}
type ResponseMsg struct{}
func (s ExampleService) WebService() *restful.WebService {
ws := new(restful.WebService)
ws.
Path("/example").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
tags := []string{"example"}
ws.Route(ws.POST("/example").To(s.create).
Doc("create example thing").
Metadata(restfulspec.KeyOpenAPITags, tags).
Metadata(SecurityDefinitionKey, OAISecurity{Name: "jwt"}).
Writes(ExampleResp{}).
Reads(ExampleReq{}).
Returns(200, "OK", &ExampleResp{}).
Returns(404, "NotFound", &ResponseMsg{}).
Returns(500, "InternalServerError", &ResponseMsg{}))
return ws
}
func (s ExampleService) create(*restful.Request, *restful.Response) {}