// Package routinginfoapi 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 routinginfoapi 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" externalRef0 "oransc.org/nonrtric/sme/internal/common29122" externalRef1 "oransc.org/nonrtric/sme/internal/common29571" externalRef2 "oransc.org/nonrtric/sme/internal/publishserviceapi" ) // ServerInterface represents all server handlers. type ServerInterface interface { // (GET /service-apis/{serviceApiId}) GetServiceApisServiceApiId(ctx echo.Context, serviceApiId string, params GetServiceApisServiceApiIdParams) error } // ServerInterfaceWrapper converts echo contexts to parameters. type ServerInterfaceWrapper struct { Handler ServerInterface } // GetServiceApisServiceApiId converts echo context to params. func (w *ServerInterfaceWrapper) GetServiceApisServiceApiId(ctx echo.Context) error { var err error // ------------- Path parameter "serviceApiId" ------------- var serviceApiId string err = runtime.BindStyledParameterWithLocation("simple", false, "serviceApiId", runtime.ParamLocationPath, ctx.Param("serviceApiId"), &serviceApiId) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter serviceApiId: %s", err)) } // Parameter object where we will unmarshal all parameters from the context var params GetServiceApisServiceApiIdParams // ------------- Required query parameter "aef-id" ------------- err = runtime.BindQueryParameter("form", true, true, "aef-id", ctx.QueryParams(), ¶ms.AefId) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter aef-id: %s", err)) } // ------------- Optional query parameter "supp-feat" ------------- err = runtime.BindQueryParameter("form", true, false, "supp-feat", ctx.QueryParams(), ¶ms.SuppFeat) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter supp-feat: %s", err)) } // Invoke the callback with all the unmarshalled arguments err = w.Handler.GetServiceApisServiceApiId(ctx, serviceApiId, params) 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.GET(baseURL+"/service-apis/:serviceApiId", wrapper.GetServiceApisServiceApiId) } // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ "H4sIAAAAAAAC/6RW0W7buBL9FYL3PuwCsmTJcdL4zZs2hbDA1rCMfWkDg5FGNrsSyQ4pp9nAH7S/sV+2", "GFJJnMQ10vgliuzhOWdmznB8x0vdGq1AOcsnd9yWa2iF/zc3m9NpVSFYOxdqBfRZBbZEaZzUik/4HAyC", "paMsn21OmQjRDCk85hE3qA2gk+ABQVX0+D9CzSd8UWTnaZYtL3TbavVeOBHfirb5X/IoKOnVJPdS+Dbi", "1gl0R+NsI47wrZMIFZ987kEjL/Eq4u7WAJ9wff0VSkekc905qVa5qvXBMgjFprOcYQhnUtUaW0FxL8vR", "B827JrxLB63dSWxvBvPHQ6SrlSoPx9IH1QJR3L7I8AnbgRQ98k+kiF2zp9UC6hnqWgasnU5l1KnpLL9c", "zrrrRtr1sgDcyBKW01n+48ZNH/G2EZdmc0Jt9LbcW7tXmuHkib8P19PTnh6mPWi6V/I869tOJV92jYLh", "uwNUonmvS/uycaOPsxlbFCw7j7MsY3+mZ/EoHrJQH9/ISxQt3Gj8i9UamY//Q6NbX+tOVRRhecQ7bPiE", "r50zkyS5ubmJRytjYo2rpHYmKQyUNhFYruUGkux8aQEl2CSQJr52eyeH+Il1vmdevqh//2HZMEujIOoT", "roSSf/svRcNmAp0CtOyX6Tz/LWLTRV5E7OKimEbsw6LII7Yo3vvHYkp/Ln6Nv6hp0zCUq7WzjOyMG6ji", "L4pH3ElHVuXBmr2cJY07+ZJHfANog+Y0TuPhQDRmLeKMUtMGlDCSih0P4yHNgnBr34vEBnMPhJE2uevf", "pkbm1Za+X4HbN2sOJWzAMreGQ9cJDZx/ySs+4R/BFQ/4ttih8oqoyw7Q8snn54R5BcrJWgIyXTPBTJhM", "qFgvmIUaSAqm3HjElWipXvYpzaNxHXYQ9duEUuyNax1KtSKTHxbhM/9weU/6rQO8fWQVUA/kkXwLzWrZ", "OEAmEaGBjVCOTGG0skD2aISDijnNOmU7YzTSaw3CdQj2B8IocEAxfFfLzvU3PktftaiKe8bLe8Lt9ory", "7fURbDYc0qPUyoHyPhLGNLL0lki+Wkrz7qWMQ2vF7zd/qzwt1qffY3L6aHj2k4v3QXBCZz3EuyMg3hHE", "Scj7TRB01kOkR0CkAWJ0BMQoQJwcAXESIE6PgDj1EOkRKtKgIjt/O0R2ThDjI5o6Dk0dH9GRcehIBbXo", "GvdmmPvz260fIr9h+is3bNA7YeRca7dNSmFkPehv9gHd7MkmpUUjUIrr/idhHx12RC/Nb2E7SRL4LlrT", "QFzqlj8f2P4gE5ZVUEsFFZOK2e66bERngZ3FY7pmn/46INlX2/8CAAD//0fkW+0SDAAA", } // 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 } pathPrefix := path.Dir(pathToFile) for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29122_CommonData.yaml")) { if _, ok := res[rawPath]; ok { // it is not possible to compare functions in golang, so always overwrite the old value } res[rawPath] = rawFunc } for rawPath, rawFunc := range externalRef2.PathToRawSpec(path.Join(pathPrefix, "TS29222_CAPIF_Publish_Service_API.yaml")) { if _, ok := res[rawPath]; ok { // it is not possible to compare functions in golang, so always overwrite the old value } res[rawPath] = rawFunc } for rawPath, rawFunc := range externalRef1.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) { if _, ok := res[rawPath]; ok { // it is not possible to compare functions in golang, so always overwrite the old value } res[rawPath] = rawFunc } 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 }