// Package eventsapi provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/deepmap/oapi-codegen version v1.10.1 DO NOT EDIT. package eventsapi import ( "bytes" "compress/gzip" "encoding/base64" "fmt" "net/http" "net/url" "path" "strings" "github.com/deepmap/oapi-codegen/pkg/runtime" "github.com/getkin/kin-openapi/openapi3" "github.com/labstack/echo/v4" ) // ServerInterface represents all server handlers. type ServerInterface interface { // (POST /{subscriberId}/subscriptions) PostSubscriberIdSubscriptions(ctx echo.Context, subscriberId string) error // (DELETE /{subscriberId}/subscriptions/{subscriptionId}) DeleteSubscriberIdSubscriptionsSubscriptionId(ctx echo.Context, subscriberId string, subscriptionId string) error } // ServerInterfaceWrapper converts echo contexts to parameters. type ServerInterfaceWrapper struct { Handler ServerInterface } // PostSubscriberIdSubscriptions converts echo context to params. func (w *ServerInterfaceWrapper) PostSubscriberIdSubscriptions(ctx echo.Context) error { var err error // ------------- Path parameter "subscriberId" ------------- var subscriberId string err = runtime.BindStyledParameterWithLocation("simple", false, "subscriberId", runtime.ParamLocationPath, ctx.Param("subscriberId"), &subscriberId) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter subscriberId: %s", err)) } // Invoke the callback with all the unmarshalled arguments err = w.Handler.PostSubscriberIdSubscriptions(ctx, subscriberId) return err } // DeleteSubscriberIdSubscriptionsSubscriptionId converts echo context to params. func (w *ServerInterfaceWrapper) DeleteSubscriberIdSubscriptionsSubscriptionId(ctx echo.Context) error { var err error // ------------- Path parameter "subscriberId" ------------- var subscriberId string err = runtime.BindStyledParameterWithLocation("simple", false, "subscriberId", runtime.ParamLocationPath, ctx.Param("subscriberId"), &subscriberId) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter subscriberId: %s", err)) } // ------------- Path parameter "subscriptionId" ------------- var subscriptionId string err = runtime.BindStyledParameterWithLocation("simple", false, "subscriptionId", runtime.ParamLocationPath, ctx.Param("subscriptionId"), &subscriptionId) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter subscriptionId: %s", err)) } // Invoke the callback with all the unmarshalled arguments err = w.Handler.DeleteSubscriberIdSubscriptionsSubscriptionId(ctx, subscriberId, subscriptionId) return err } // This is a simple interface which specifies echo.Route addition functions which // are present on both echo.Echo and echo.Group, since we want to allow using // either of them for path registration type EchoRouter interface { CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route } // RegisterHandlers adds each server route to the EchoRouter. func RegisterHandlers(router EchoRouter, si ServerInterface) { RegisterHandlersWithBaseURL(router, si, "") } // Registers handlers, and prepends BaseURL to the paths, so that the paths // can be served under a prefix. func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) { wrapper := ServerInterfaceWrapper{ Handler: si, } router.POST(baseURL+"/:subscriberId/subscriptions", wrapper.PostSubscriberIdSubscriptions) router.DELETE(baseURL+"/:subscriberId/subscriptions/:subscriptionId", wrapper.DeleteSubscriberIdSubscriptionsSubscriptionId) } // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ "H4sIAAAAAAAC/+xZ4Y7iOPJ/Fcv7/zAjZaFhpv+zzbcM0DPRoQYRek57sy1kkgp4J9hZ26GbayHdO9xT", "3Gvco9yTnGyHEEICdHMrre5mtdptOa5fVbmqflU2zz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dXV6+G0LIGonUBRMtCvLsA4p2FeH8BxHsD0brAkZZ1pHWBIy3rSOv6AohrA9G+eT1E+0ZDXF+Q", "F9c2L64vCOq1DWoIEUlj9WqYrfzG/FP+8agrgCjQd10Gj+eM3roD6/5LthcVPOJS+QVC9PfoUPOmbkZ2", "Hv96+lqzg9IzrN6jiVcPIGRpGnxBFS6zk1OguvIV5sH5/Vhz735zFmu2fm8DquIcojf+jo53r+PRXpd+", "ix28ABJmN6gBr5vJNccTyuwQdz/2tiFk8BivLTyE+V3NQSQIuDAP2dvfLpRIAz3WomeS0DHnatMMSEKj", "H+3Y2Vy1jjbb/GN2E92YRn9+Smy+s/939v+fYX8Hv6yYbMHHoKDqVVivn/tec9g0rHxt2/DLD0x/lCbi", "HNe9fxzZT3173HzMnJ27L+xqp+bxyQJqwrRvHVoSFSwMQZceGL0QUYlsNpj71Pfp/Y/I399pr2Lotb91", "banDvnrUzhvYwSsiKJnF+fuS3mdrKjMqfzOBJ7JMYmgEfInLE1cmWHpfzB8XrzVd7D/kaGsfNv8OAAD/", "//oDEyW/JgAA", } // GetSwagger returns the content of the embedded swagger specification file // or error if failed to decode func decodeSpec() ([]byte, error) { zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) if err != nil { return nil, fmt.Errorf("error base64 decoding spec: %s", err) } zr, err := gzip.NewReader(bytes.NewReader(zipped)) if err != nil { return nil, fmt.Errorf("error decompressing spec: %s", err) } var buf bytes.Buffer _, err = buf.ReadFrom(zr) if err != nil { return nil, fmt.Errorf("error decompressing spec: %s", err) } return buf.Bytes(), nil } var rawSpec = decodeSpecCached() // a naive cached of a decoded swagger spec func decodeSpecCached() func() ([]byte, error) { data, err := decodeSpec() return func() ([]byte, error) { return data, err } } // Constructs a synthetic filesystem for resolving external references when loading openapi specifications. func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { var res = make(map[string]func() ([]byte, error)) if len(pathToFile) > 0 { res[pathToFile] = rawSpec } return res } // GetSwagger returns the Swagger specification corresponding to the generated code // in this file. The external references of Swagger specification are resolved. // The logic of resolving external references is tightly connected to "import-mapping" feature. // Externally referenced files must be embedded in the corresponding golang packages. // Urls can be supported but this task was out of the scope. func GetSwagger() (swagger *openapi3.T, err error) { var resolvePath = PathToRawSpec("") loader := openapi3.NewLoader() loader.IsExternalRefsAllowed = true loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { var pathToFile = url.String() pathToFile = path.Clean(pathToFile) getSpec, ok := resolvePath[pathToFile] if !ok { err1 := fmt.Errorf("path not found: %s", pathToFile) return nil, err1 } return getSpec() } var specData []byte specData, err = rawSpec() if err != nil { return } swagger, err = loader.LoadFromData(specData) if err != nil { return } return }