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
17 "github.com/deepmap/oapi-codegen/pkg/runtime"
18 "github.com/getkin/kin-openapi/openapi3"
19 "github.com/labstack/echo/v4"
20 externalRef0 "oransc.org/nonrtric/capifcore/internal/common29122"
21 externalRef1 "oransc.org/nonrtric/capifcore/internal/common29571"
22 externalRef2 "oransc.org/nonrtric/capifcore/internal/publishserviceapi"
25 // ServerInterface represents all server handlers.
26 type ServerInterface interface {
28 // (GET /allServiceAPIs)
29 GetAllServiceAPIs(ctx echo.Context, params GetAllServiceAPIsParams) error
32 // ServerInterfaceWrapper converts echo contexts to parameters.
33 type ServerInterfaceWrapper struct {
34 Handler ServerInterface
37 // GetAllServiceAPIs converts echo context to params.
38 func (w *ServerInterfaceWrapper) GetAllServiceAPIs(ctx echo.Context) error {
41 // Parameter object where we will unmarshal all parameters from the context
42 var params GetAllServiceAPIsParams
43 // ------------- Required query parameter "api-invoker-id" -------------
45 err = runtime.BindQueryParameter("form", true, true, "api-invoker-id", ctx.QueryParams(), ¶ms.ApiInvokerId)
47 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-invoker-id: %s", err))
50 // ------------- Optional query parameter "api-name" -------------
52 err = runtime.BindQueryParameter("form", true, false, "api-name", ctx.QueryParams(), ¶ms.ApiName)
54 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-name: %s", err))
57 // ------------- Optional query parameter "api-version" -------------
59 err = runtime.BindQueryParameter("form", true, false, "api-version", ctx.QueryParams(), ¶ms.ApiVersion)
61 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-version: %s", err))
64 // ------------- Optional query parameter "comm-type" -------------
66 err = runtime.BindQueryParameter("form", true, false, "comm-type", ctx.QueryParams(), ¶ms.CommType)
68 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter comm-type: %s", err))
71 // ------------- Optional query parameter "protocol" -------------
73 err = runtime.BindQueryParameter("form", true, false, "protocol", ctx.QueryParams(), ¶ms.Protocol)
75 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter protocol: %s", err))
78 // ------------- Optional query parameter "aef-id" -------------
80 err = runtime.BindQueryParameter("form", true, false, "aef-id", ctx.QueryParams(), ¶ms.AefId)
82 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter aef-id: %s", err))
85 // ------------- Optional query parameter "data-format" -------------
87 err = runtime.BindQueryParameter("form", true, false, "data-format", ctx.QueryParams(), ¶ms.DataFormat)
89 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter data-format: %s", err))
92 // ------------- Optional query parameter "preferred-aef-loc" -------------
94 if paramValue := ctx.QueryParam("preferred-aef-loc"); paramValue != "" {
96 var value externalRef2.AefLocation
97 err = json.Unmarshal([]byte(paramValue), &value)
99 return echo.NewHTTPError(http.StatusBadRequest, "Error unmarshaling parameter 'preferred-aef-loc' as JSON")
101 params.PreferredAefLoc = &value
105 // ------------- Optional query parameter "supported-features" -------------
107 err = runtime.BindQueryParameter("form", true, false, "supported-features", ctx.QueryParams(), ¶ms.SupportedFeatures)
109 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter supported-features: %s", err))
112 // ------------- Optional query parameter "api-supported-features" -------------
114 err = runtime.BindQueryParameter("form", true, false, "api-supported-features", ctx.QueryParams(), ¶ms.ApiSupportedFeatures)
116 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-supported-features: %s", err))
119 // Invoke the callback with all the unmarshalled arguments
120 err = w.Handler.GetAllServiceAPIs(ctx, params)
124 // This is a simple interface which specifies echo.Route addition functions which
125 // are present on both echo.Echo and echo.Group, since we want to allow using
126 // either of them for path registration
127 type EchoRouter interface {
128 CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
129 DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
130 GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
131 HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
132 OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
133 PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
134 POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
135 PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
136 TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
139 // RegisterHandlers adds each server route to the EchoRouter.
140 func RegisterHandlers(router EchoRouter, si ServerInterface) {
141 RegisterHandlersWithBaseURL(router, si, "")
144 // Registers handlers, and prepends BaseURL to the paths, so that the paths
145 // can be served under a prefix.
146 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
148 wrapper := ServerInterfaceWrapper{
152 router.GET(baseURL+"/allServiceAPIs", wrapper.GetAllServiceAPIs)
156 // Base64 encoded, gzipped, json marshaled Swagger object
157 var swaggerSpec = []string{
159 "H4sIAAAAAAAC/7xX224bNxD9lQHbhwSQdq31LdabasuBisJRLaUvTWBQ3FmJCZfckFw5qqEP6m/0y4oh",
160 "Vxc7kgtHQV9iZz08c2bOzHD4wIQpK6NRe8e6D8yJGZY8/HolnTBztJj3hoPwJUcnrKy8NJp12S1WFh0d",
161 "BA5KOg+mADIFUVuL2qsFWJxK5wkDpAY/Q7jsDQfXIIxFKGotCAu4zsFxL12xkHoKHHRdTtASXiGVRwvC",
162 "So9Wcqismcscc5gsAlxvOABhtKtLtMkHzVqssqZC6yXGeNDOpcDecHC1Ib8jmK2/kluCbo4GF9xBVU+U",
163 "dLON6+bvCfS5mD2y3oIGN+NKgdRC1TlCr39NIRRSoYOSezGjg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M0fVVMdpcEPs4rGHbReNpX3Gennfu4mZA0j+zvKwQV9R3Vc/+sPL1",
177 "JvtoTZM6J22j3WrgwfoaSmA8k7SlLcBotYBJ0ILuDJDFxj4EvzlF07oxe366/j9Z+kjXkKuMdnEfzo6O",
178 "6MdLS3ynvycPhD31u3IPE5MvqLxoR4i3rkVXK7/Zt2mfg1Bl9P/Vk2LrDRE2tA9hbT0+On+Spg614DNp",
179 "WuchpbMB4s0BEG8I4iSm87sg6GyA6BwA0YkQxwdAHEeIkwMgTiLE2QEQZwGicwCLTmSRXXw/RHZBEKcH",
180 "iHoaRT09QJHTqEiOBa+V/26Y1fnlMjRmeHI0q3V8XNEyeWuMX6bNUGzzSrp03qH3BreST1ScGY1dfD80",
181 "pNZPM/zKy0phIkzJnrZ/c3D3SnqenD5ZSLMsS4jux+W/AQAA//8zY8i1lhAAAA==",
184 // GetSwagger returns the content of the embedded swagger specification file
185 // or error if failed to decode
186 func decodeSpec() ([]byte, error) {
187 zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
189 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
191 zr, err := gzip.NewReader(bytes.NewReader(zipped))
193 return nil, fmt.Errorf("error decompressing spec: %s", err)
196 _, err = buf.ReadFrom(zr)
198 return nil, fmt.Errorf("error decompressing spec: %s", err)
201 return buf.Bytes(), nil
204 var rawSpec = decodeSpecCached()
206 // a naive cached of a decoded swagger spec
207 func decodeSpecCached() func() ([]byte, error) {
208 data, err := decodeSpec()
209 return func() ([]byte, error) {
214 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
215 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
216 var res = make(map[string]func() ([]byte, error))
217 if len(pathToFile) > 0 {
218 res[pathToFile] = rawSpec
221 pathPrefix := path.Dir(pathToFile)
223 for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29122_CommonData.yaml")) {
224 if _, ok := res[rawPath]; ok {
225 // it is not possible to compare functions in golang, so always overwrite the old value
227 res[rawPath] = rawFunc
229 for rawPath, rawFunc := range externalRef2.PathToRawSpec(path.Join(pathPrefix, "TS29222_CAPIF_Publish_Service_API.yaml")) {
230 if _, ok := res[rawPath]; ok {
231 // it is not possible to compare functions in golang, so always overwrite the old value
233 res[rawPath] = rawFunc
235 for rawPath, rawFunc := range externalRef1.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) {
236 if _, ok := res[rawPath]; ok {
237 // it is not possible to compare functions in golang, so always overwrite the old value
239 res[rawPath] = rawFunc
244 // GetSwagger returns the Swagger specification corresponding to the generated code
245 // in this file. The external references of Swagger specification are resolved.
246 // The logic of resolving external references is tightly connected to "import-mapping" feature.
247 // Externally referenced files must be embedded in the corresponding golang packages.
248 // Urls can be supported but this task was out of the scope.
249 func GetSwagger() (swagger *openapi3.T, err error) {
250 var resolvePath = PathToRawSpec("")
252 loader := openapi3.NewLoader()
253 loader.IsExternalRefsAllowed = true
254 loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
255 var pathToFile = url.String()
256 pathToFile = path.Clean(pathToFile)
257 getSpec, ok := resolvePath[pathToFile]
259 err1 := fmt.Errorf("path not found: %s", pathToFile)
265 specData, err = rawSpec()
269 swagger, err = loader.LoadFromData(specData)