1 // Package discoverserviceapi 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.
4 package discoverserviceapi
16 "github.com/deepmap/oapi-codegen/pkg/runtime"
17 "github.com/getkin/kin-openapi/openapi3"
18 "github.com/labstack/echo/v4"
19 externalRef0 "oransc.org/nonrtric/capifcore/internal/common29122"
20 externalRef1 "oransc.org/nonrtric/capifcore/internal/common29571"
21 externalRef2 "oransc.org/nonrtric/capifcore/internal/publishserviceapi"
24 // ServerInterface represents all server handlers.
25 type ServerInterface interface {
27 // (GET /allServiceAPIs)
28 GetAllServiceAPIs(ctx echo.Context, params GetAllServiceAPIsParams) error
31 // ServerInterfaceWrapper converts echo contexts to parameters.
32 type ServerInterfaceWrapper struct {
33 Handler ServerInterface
36 // GetAllServiceAPIs converts echo context to params.
37 func (w *ServerInterfaceWrapper) GetAllServiceAPIs(ctx echo.Context) error {
40 // Parameter object where we will unmarshal all parameters from the context
41 var params GetAllServiceAPIsParams
42 // ------------- Required query parameter "api-invoker-id" -------------
44 err = runtime.BindQueryParameter("form", true, true, "api-invoker-id", ctx.QueryParams(), ¶ms.ApiInvokerId)
46 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-invoker-id: %s", err))
49 // ------------- Optional query parameter "api-name" -------------
51 err = runtime.BindQueryParameter("form", true, false, "api-name", ctx.QueryParams(), ¶ms.ApiName)
53 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-name: %s", err))
56 // ------------- Optional query parameter "api-version" -------------
58 err = runtime.BindQueryParameter("form", true, false, "api-version", ctx.QueryParams(), ¶ms.ApiVersion)
60 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-version: %s", err))
63 // ------------- Optional query parameter "comm-type" -------------
65 err = runtime.BindQueryParameter("form", true, false, "comm-type", ctx.QueryParams(), ¶ms.CommType)
67 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter comm-type: %s", err))
70 // ------------- Optional query parameter "protocol" -------------
72 err = runtime.BindQueryParameter("form", true, false, "protocol", ctx.QueryParams(), ¶ms.Protocol)
74 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter protocol: %s", err))
77 // ------------- Optional query parameter "aef-id" -------------
79 err = runtime.BindQueryParameter("form", true, false, "aef-id", ctx.QueryParams(), ¶ms.AefId)
81 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter aef-id: %s", err))
84 // ------------- Optional query parameter "data-format" -------------
86 err = runtime.BindQueryParameter("form", true, false, "data-format", ctx.QueryParams(), ¶ms.DataFormat)
88 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter data-format: %s", err))
91 // ------------- Optional query parameter "api-cat" -------------
93 err = runtime.BindQueryParameter("form", true, false, "api-cat", ctx.QueryParams(), ¶ms.ApiCat)
95 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-cat: %s", err))
98 // ------------- Optional query parameter "supported-features" -------------
100 err = runtime.BindQueryParameter("form", true, false, "supported-features", ctx.QueryParams(), ¶ms.SupportedFeatures)
102 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter supported-features: %s", err))
105 // ------------- Optional query parameter "api-supported-features" -------------
107 err = runtime.BindQueryParameter("form", true, false, "api-supported-features", ctx.QueryParams(), ¶ms.ApiSupportedFeatures)
109 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-supported-features: %s", err))
112 // Invoke the callback with all the unmarshalled arguments
113 err = w.Handler.GetAllServiceAPIs(ctx, params)
117 // This is a simple interface which specifies echo.Route addition functions which
118 // are present on both echo.Echo and echo.Group, since we want to allow using
119 // either of them for path registration
120 type EchoRouter interface {
121 CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
122 DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
123 GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
124 HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
125 OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
126 PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
127 POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
128 PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
129 TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
132 // RegisterHandlers adds each server route to the EchoRouter.
133 func RegisterHandlers(router EchoRouter, si ServerInterface) {
134 RegisterHandlersWithBaseURL(router, si, "")
137 // Registers handlers, and prepends BaseURL to the paths, so that the paths
138 // can be served under a prefix.
139 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
141 wrapper := ServerInterfaceWrapper{
145 router.GET(baseURL+"/allServiceAPIs", wrapper.GetAllServiceAPIs)
149 // Base64 encoded, gzipped, json marshaled Swagger object
150 var swaggerSpec = []string{
152 "H4sIAAAAAAAC/7xX23IaPRJ+lS7tXiRVMAPjU8wda+MUe+GwhuzNJuUSmoZRopEmkgaHdfFA+xr7ZH+1",
153 "NByMsf9ySP03Bovur78+qvXIhCkro1F7x3qPzIkCSx6+XksnzAIt5v3RMJzk6ISVlZdGsx67w8qiI0Xg",
154 "oKTzYGZAoiBqa1F7tQSLc+k8YYDU4AuEq/5oeAPCWIRZrQVhAdc5OO6lmy2lngMHXZdTtIQ3k8qjBWGl",
155 "Rys5VNYsZI45TJcBrj8agjDa1SXahLVYZU2F1kuM3qBdSIH90fB6S/2AKzu/klECblSDAe6gqqdKumJr",
156 "uPk9gQEXxRPpHWhwBVcKpBaqzhH6gxtyYCYVOii5FwW5S2h7bpIn0mMZqP7d4oz12GScXWZZdh8CeD+K",
157 "fO7H0fB9fz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aPc",
170 "eszB5uZJYFJI2suWYLRawhShuSZAzrbywfmtFo3oRuy1pP01MfpKN4+rjHZx/806HfoQRnvUYQPgVaWa",
171 "OZR+cxTHx+c0Dhf70+dAWAefF/zaPExNvqTiopUgXrMWXa38dr+mFQ5CjdH/6wfEzoshLGW065x0LvaC",
172 "1KWGfSVImyikpBsgPhwB8YEgTmMwfwmCdANE9wiIboQ4OQLiJEKcHgFxGiHOj4A4DxDdI1h0I4vs8tch",
173 "skuCODsiqWcxqWdHZOQsZiTHGa+V/2WYtf5qFdoyvDOaTTo+pmh7vDPGr9JmILZ5JV266NIjg1vJpypO",
174 "jEYuPhYaUuEp5nppij95WSlMhCnZfvM3ii/uoBfJ2d4OmmVZQoy/rv4IAAD//37ZMOyFEAAA",
177 // GetSwagger returns the content of the embedded swagger specification file
178 // or error if failed to decode
179 func decodeSpec() ([]byte, error) {
180 zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
182 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
184 zr, err := gzip.NewReader(bytes.NewReader(zipped))
186 return nil, fmt.Errorf("error decompressing spec: %s", err)
189 _, err = buf.ReadFrom(zr)
191 return nil, fmt.Errorf("error decompressing spec: %s", err)
194 return buf.Bytes(), nil
197 var rawSpec = decodeSpecCached()
199 // a naive cached of a decoded swagger spec
200 func decodeSpecCached() func() ([]byte, error) {
201 data, err := decodeSpec()
202 return func() ([]byte, error) {
207 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
208 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
209 var res = make(map[string]func() ([]byte, error))
210 if len(pathToFile) > 0 {
211 res[pathToFile] = rawSpec
214 pathPrefix := path.Dir(pathToFile)
216 for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29122_CommonData.yaml")) {
217 if _, ok := res[rawPath]; ok {
218 // it is not possible to compare functions in golang, so always overwrite the old value
220 res[rawPath] = rawFunc
222 for rawPath, rawFunc := range externalRef2.PathToRawSpec(path.Join(pathPrefix, "TS29222_CAPIF_Publish_Service_API.yaml")) {
223 if _, ok := res[rawPath]; ok {
224 // it is not possible to compare functions in golang, so always overwrite the old value
226 res[rawPath] = rawFunc
228 for rawPath, rawFunc := range externalRef1.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) {
229 if _, ok := res[rawPath]; ok {
230 // it is not possible to compare functions in golang, so always overwrite the old value
232 res[rawPath] = rawFunc
237 // GetSwagger returns the Swagger specification corresponding to the generated code
238 // in this file. The external references of Swagger specification are resolved.
239 // The logic of resolving external references is tightly connected to "import-mapping" feature.
240 // Externally referenced files must be embedded in the corresponding golang packages.
241 // Urls can be supported but this task was out of the scope.
242 func GetSwagger() (swagger *openapi3.T, err error) {
243 var resolvePath = PathToRawSpec("")
245 loader := openapi3.NewLoader()
246 loader.IsExternalRefsAllowed = true
247 loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
248 var pathToFile = url.String()
249 pathToFile = path.Clean(pathToFile)
250 getSpec, ok := resolvePath[pathToFile]
252 err1 := fmt.Errorf("path not found: %s", pathToFile)
258 specData, err = rawSpec()
262 swagger, err = loader.LoadFromData(specData)