1 // Package eventsapi provides primitives to interact with the openapi HTTP API.
3 // Code generated by github.com/deepmap/oapi-codegen version v1.10.1 DO NOT EDIT.
16 "github.com/deepmap/oapi-codegen/pkg/runtime"
17 "github.com/getkin/kin-openapi/openapi3"
18 "github.com/labstack/echo/v4"
21 // ServerInterface represents all server handlers.
22 type ServerInterface interface {
24 // (POST /{subscriberId}/subscriptions)
25 PostSubscriberIdSubscriptions(ctx echo.Context, subscriberId string) error
27 // (DELETE /{subscriberId}/subscriptions/{subscriptionId})
28 DeleteSubscriberIdSubscriptionsSubscriptionId(ctx echo.Context, subscriberId string, subscriptionId string) error
31 // ServerInterfaceWrapper converts echo contexts to parameters.
32 type ServerInterfaceWrapper struct {
33 Handler ServerInterface
36 // PostSubscriberIdSubscriptions converts echo context to params.
37 func (w *ServerInterfaceWrapper) PostSubscriberIdSubscriptions(ctx echo.Context) error {
39 // ------------- Path parameter "subscriberId" -------------
40 var subscriberId string
42 err = runtime.BindStyledParameterWithLocation("simple", false, "subscriberId", runtime.ParamLocationPath, ctx.Param("subscriberId"), &subscriberId)
44 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter subscriberId: %s", err))
47 // Invoke the callback with all the unmarshalled arguments
48 err = w.Handler.PostSubscriberIdSubscriptions(ctx, subscriberId)
52 // DeleteSubscriberIdSubscriptionsSubscriptionId converts echo context to params.
53 func (w *ServerInterfaceWrapper) DeleteSubscriberIdSubscriptionsSubscriptionId(ctx echo.Context) error {
55 // ------------- Path parameter "subscriberId" -------------
56 var subscriberId string
58 err = runtime.BindStyledParameterWithLocation("simple", false, "subscriberId", runtime.ParamLocationPath, ctx.Param("subscriberId"), &subscriberId)
60 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter subscriberId: %s", err))
63 // ------------- Path parameter "subscriptionId" -------------
64 var subscriptionId string
66 err = runtime.BindStyledParameterWithLocation("simple", false, "subscriptionId", runtime.ParamLocationPath, ctx.Param("subscriptionId"), &subscriptionId)
68 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter subscriptionId: %s", err))
71 // Invoke the callback with all the unmarshalled arguments
72 err = w.Handler.DeleteSubscriberIdSubscriptionsSubscriptionId(ctx, subscriberId, subscriptionId)
76 // This is a simple interface which specifies echo.Route addition functions which
77 // are present on both echo.Echo and echo.Group, since we want to allow using
78 // either of them for path registration
79 type EchoRouter interface {
80 CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
81 DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
82 GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
83 HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
84 OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
85 PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
86 POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
87 PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
88 TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
91 // RegisterHandlers adds each server route to the EchoRouter.
92 func RegisterHandlers(router EchoRouter, si ServerInterface) {
93 RegisterHandlersWithBaseURL(router, si, "")
96 // Registers handlers, and prepends BaseURL to the paths, so that the paths
97 // can be served under a prefix.
98 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
100 wrapper := ServerInterfaceWrapper{
104 router.POST(baseURL+"/:subscriberId/subscriptions", wrapper.PostSubscriberIdSubscriptions)
105 router.DELETE(baseURL+"/:subscriberId/subscriptions/:subscriptionId", wrapper.DeleteSubscriberIdSubscriptionsSubscriptionId)
109 // Base64 encoded, gzipped, json marshaled Swagger object
110 var swaggerSpec = []string{
112 "H4sIAAAAAAAC/+xZ4Y7iOPJ/Fcv7/zAjZZKGnv7PDt8YoGeiQw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"gbtX7pVOPaLmJh7ek9wykB+tvaKXZkPK7Y0rJEkyJeE3s3iEQp9yDnOnPFr95NXsXBehc4kPPFoZTZyp",
139 "/JmWpGmSC3u/SqvAZu+pfnA4Xa33s1gTsFmQKWfSFlbz6u1hFtxx1LEWoVeF18CiY6/1IV9fvXsheW11",
140 "e1rWQPx8AcTPGuLt1dXZEFrWQDQugGhYiOsLIK4txNsLIN4aiMYFjjSsI40LHGlYRxo3F0DcGIjm+/Mh",
141 "mu81xM0FeXFj8+LmgqDe2KBGEJMsUWfDbOTX5r/yD0YdAUSBvu0yeHzO+K2bsG7BZHNVwUMuVVAgxGCP",
142 "DjVv6n5kZ/Ivpy82Oyg9x+o9mnj1DEIWpscXVOEyOzkFqitfYx6c34819+44z2LNxu9tQFWcI/Qq2NHx",
143 "7nk83uvUr7GD50Ci/BbV53VzueZ4Qpmd4+5H/iaEDB6TlYWHaHtfcxAJQy7MU/bmlwslslBPti30RFI6",
144 "4lytvZCkNH5jR09v2Tjabbcf8+vo+kUZsf5B/j/I/3+G/B38wlIy9Z6AgqpnYb3+3Cebw55h5Wu7RlB+",
145 "Y/qj9BDnuO7948h/69uj5mPm7Nx9YVM7NY6P51ATpn3r0IKocG74ufTC6EeISmSzIXJ/jO5/SPb+QXoV",
146 "E6/9qWtDHPbVo3bWwA5eEkHJNNm+L+l9tqJyo8ybiWx5HnwnizQBN+QLXB63csHSA2PxdfFG88X+W442",
147 "+GH97wAAAP//6q1GObMmAAA=",
150 // GetSwagger returns the content of the embedded swagger specification file
151 // or error if failed to decode
152 func decodeSpec() ([]byte, error) {
153 zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
155 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
157 zr, err := gzip.NewReader(bytes.NewReader(zipped))
159 return nil, fmt.Errorf("error decompressing spec: %s", err)
162 _, err = buf.ReadFrom(zr)
164 return nil, fmt.Errorf("error decompressing spec: %s", err)
167 return buf.Bytes(), nil
170 var rawSpec = decodeSpecCached()
172 // a naive cached of a decoded swagger spec
173 func decodeSpecCached() func() ([]byte, error) {
174 data, err := decodeSpec()
175 return func() ([]byte, error) {
180 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
181 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
182 var res = make(map[string]func() ([]byte, error))
183 if len(pathToFile) > 0 {
184 res[pathToFile] = rawSpec
190 // GetSwagger returns the Swagger specification corresponding to the generated code
191 // in this file. The external references of Swagger specification are resolved.
192 // The logic of resolving external references is tightly connected to "import-mapping" feature.
193 // Externally referenced files must be embedded in the corresponding golang packages.
194 // Urls can be supported but this task was out of the scope.
195 func GetSwagger() (swagger *openapi3.T, err error) {
196 var resolvePath = PathToRawSpec("")
198 loader := openapi3.NewLoader()
199 loader.IsExternalRefsAllowed = true
200 loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
201 var pathToFile = url.String()
202 pathToFile = path.Clean(pathToFile)
203 getSpec, ok := resolvePath[pathToFile]
205 err1 := fmt.Errorf("path not found: %s", pathToFile)
211 specData, err = rawSpec()
215 swagger, err = loader.LoadFromData(specData)