// Package discoverserviceapi 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 discoverserviceapi import ( "bytes" "compress/gzip" "encoding/base64" "encoding/json" "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 /allServiceAPIs) GetAllServiceAPIs(ctx echo.Context, params GetAllServiceAPIsParams) error } // ServerInterfaceWrapper converts echo contexts to parameters. type ServerInterfaceWrapper struct { Handler ServerInterface } // GetAllServiceAPIs converts echo context to params. func (w *ServerInterfaceWrapper) GetAllServiceAPIs(ctx echo.Context) error { var err error // Parameter object where we will unmarshal all parameters from the context var params GetAllServiceAPIsParams // ------------- Required query parameter "api-invoker-id" ------------- err = runtime.BindQueryParameter("form", true, true, "api-invoker-id", ctx.QueryParams(), ¶ms.ApiInvokerId) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-invoker-id: %s", err)) } // ------------- Optional query parameter "api-name" ------------- err = runtime.BindQueryParameter("form", true, false, "api-name", ctx.QueryParams(), ¶ms.ApiName) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-name: %s", err)) } // ------------- Optional query parameter "api-version" ------------- err = runtime.BindQueryParameter("form", true, false, "api-version", ctx.QueryParams(), ¶ms.ApiVersion) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-version: %s", err)) } // ------------- Optional query parameter "comm-type" ------------- err = runtime.BindQueryParameter("form", true, false, "comm-type", ctx.QueryParams(), ¶ms.CommType) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter comm-type: %s", err)) } // ------------- Optional query parameter "protocol" ------------- err = runtime.BindQueryParameter("form", true, false, "protocol", ctx.QueryParams(), ¶ms.Protocol) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter protocol: %s", err)) } // ------------- Optional query parameter "aef-id" ------------- err = runtime.BindQueryParameter("form", true, false, "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 "data-format" ------------- err = runtime.BindQueryParameter("form", true, false, "data-format", ctx.QueryParams(), ¶ms.DataFormat) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter data-format: %s", err)) } // ------------- Optional query parameter "preferred-aef-loc" ------------- if paramValue := ctx.QueryParam("preferred-aef-loc"); paramValue != "" { var value externalRef2.AefLocation err = json.Unmarshal([]byte(paramValue), &value) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, "Error unmarshaling parameter 'preferred-aef-loc' as JSON") } params.PreferredAefLoc = &value } // ------------- Optional query parameter "supported-features" ------------- err = runtime.BindQueryParameter("form", true, false, "supported-features", ctx.QueryParams(), ¶ms.SupportedFeatures) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter supported-features: %s", err)) } // ------------- Optional query parameter "api-supported-features" ------------- err = runtime.BindQueryParameter("form", true, false, "api-supported-features", ctx.QueryParams(), ¶ms.ApiSupportedFeatures) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-supported-features: %s", err)) } // Invoke the callback with all the unmarshalled arguments err = w.Handler.GetAllServiceAPIs(ctx, 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+"/allServiceAPIs", wrapper.GetAllServiceAPIs) } // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ "H4sIAAAAAAAC/7xX224bNxD9lQHbhwSQdq31LdabasuBisJRLaUvTWBQ3FmJCZfckFw5qqEP6m/0y4oh", "Vxc7kgtHQV9iZz08c2bOzHD4wIQpK6NRe8e6D8yJGZY8/HolnTBztJj3hoPwJUcnrKy8NJp12S1WFh0d", "BA5KOg+mADIFUVuL2qsFWJxK5wkDpAY/Q7jsDQfXIIxFKGotCAu4zsFxL12xkHoKHHRdTtASXiGVRwvC", "So9Wcqismcscc5gsAlxvOABhtKtLtMkHzVqssqZC6yXGeNDOpcDecHC1Ib8jmK2/kluCbo4GF9xBVU+U", "dLON6+bvCfS5mD2y3oIGN+NKgdRC1TlCr39NIRRSoYOSezGjgAntSaAxFumxDGR/tliwLhuPsossy+5C", "Eu+GkdHdKLq+6w0HyYKX6qd0o2naCJqOdiWCLVuslHoQ3XRazC8qZF3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uMdnEfzo6O", "6MdLS3ynvycPhD31u3IPE5MvqLxoR4i3rkVXK7/Zt2mfg1Bl9P/Vk2LrDRE2tA9hbT0+On+Spg614DNp", "WuchpbMB4s0BEG8I4iSm87sg6GyA6BwA0YkQxwdAHEeIkwMgTiLE2QEQZwGicwCLTmSRXXw/RHZBEKcH", "iHoaRT09QJHTqEiOBa+V/26Y1fnlMjRmeHI0q3V8XNEyeWuMX6bNUGzzSrp03qH3BreST1ScGY1dfD80", "pNZPM/zKy0phIkzJnrZ/c3D3SnqenD5ZSLMsS4jux+W/AQAA//8zY8i1lhAAAA==", } // 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 }