// 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/capifcore/internal/common29122" externalRef1 "oransc.org/nonrtric/capifcore/internal/common29571" externalRef2 "oransc.org/nonrtric/capifcore/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/6RW0W7buBL9FYL3PuwCimQpcdL4TZs2hbDA1rCMfWkDg5FGNrsSyQ4pp9nAH7S/sV+2", "GFJJnMQ10vgliuzhmTNzznB8xyvdGa1AOcsnd9xWK+iE/7cw69O8rhGsnQm1BPqsBluhNE5qxSd8BgbB", "0lFWTNenTIRohhQe84gb1AbQSfCAoGp6/B+h4RM+L7PzNMsWF7rrtHovnIhvRdf+L3kklAxsknsqfBNx", "6wS6g3E2EUf41kuEmk8+D6CRp3gVcXdrgE+4vv4KlaOkM907qZaFavTeNgjF8mnBMIQzqRqNnaC4l+0Y", "gmZ9G96lg85uFbazgtnjIeLVSVWEY+kDa4Eobl9U+CTbnhI98k+UiH27Q2oBzRR1IwPWllIZKZVPi8vF", "tL9upV0tSsC1rGCRT4sfC5c/4m0iLs36hGT0ttzZu1ea4eSJv/f306c93Z92r+lemeeZbludfKkaBcN3", "B6hE+15X9qVwxx+nUzYvWXYeZ1nG/kzP4nE8YqE/XshLFB3caPyLNRqZj/9Do1td617VFGF5xHts+YSv", "nDN2kiQ3Nzfx8dKYWOMyaZxJSgOVTQRWK7mGJDtfWEAJNglZE9+8naNDBCjtbMfAMPZF/fsPy0ZZFgVe", "n3AplPzbfy1aNhXoFKBlv+Sz4reI5fOijNjFRZlH7MO8LCI2L9/7xzynPxe/esy8bRnK5cpZRp7GNdTx", "F8Uj7qQjv/Lgz4HSgmaezMkjvga0gXcap/GIytIGlDCSOh2P4hENgnArL0Rig7OPhJE2uRveciOLekPf", "L8HtGjSHEtZgmVvBvruEps2/FDWf8I/gygd8W26l8oxIYgdo+eTz84RFDcrJRgIy3TDBTBhLqNlAmIXa", "JQVTbTziSnTUJ/s0zaNrHfYQDauEShxcax1KtSSH7yfhK/9weZ/0Ww94+5hVQHMkD8w316yRrQNkEhFa", "WAvlyAxGKwtki1Y4qJnTrFe2N0YjvTYgXI9gf0CMAo8ohm9z2br7xmfpq7ZUeZ/x8j7hZnNF9Q78CDYb", "jehRaeVAeR8JY1pZeUskXy2VefeSxr6d4pebv1KeNuvT7zE5/Xh09pNb94FwQmc9xLsDIN4RxEmo+00Q", "dNZDpAdApAHi+ACI4wBxcgDESYA4PQDi1EOkB7BIA4vs/O0Q2TlBjA8QdRxEHR+gyDgoUkMj+ta9Geb+", "/Gbjh8hvluHKDevzThg509ptkkoY2RwNN/sR3ezJOqUFI1CK6+H34BAddsRA7WEFw3fRmRbiSnf8+cAO", "B5mwrIZGKqiZVKxqRW+BncVjumOf/i4gzleb/wIAAP//hn2OrAwMAAA=", } // 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 }