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 "api-cat" -------------
94 err = runtime.BindQueryParameter("form", true, false, "api-cat", ctx.QueryParams(), ¶ms.ApiCat)
96 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-cat: %s", err))
99 // ------------- Optional query parameter "preferred-aef-loc" -------------
101 if paramValue := ctx.QueryParam("preferred-aef-loc"); paramValue != "" {
103 var value externalRef2.AefLocation
104 err = json.Unmarshal([]byte(paramValue), &value)
106 return echo.NewHTTPError(http.StatusBadRequest, "Error unmarshaling parameter 'preferred-aef-loc' as JSON")
108 params.PreferredAefLoc = &value
112 // ------------- Optional query parameter "supported-features" -------------
114 err = runtime.BindQueryParameter("form", true, false, "supported-features", ctx.QueryParams(), ¶ms.SupportedFeatures)
116 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter supported-features: %s", err))
119 // ------------- Optional query parameter "api-supported-features" -------------
121 err = runtime.BindQueryParameter("form", true, false, "api-supported-features", ctx.QueryParams(), ¶ms.ApiSupportedFeatures)
123 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter api-supported-features: %s", err))
126 // Invoke the callback with all the unmarshalled arguments
127 err = w.Handler.GetAllServiceAPIs(ctx, params)
131 // This is a simple interface which specifies echo.Route addition functions which
132 // are present on both echo.Echo and echo.Group, since we want to allow using
133 // either of them for path registration
134 type EchoRouter interface {
135 CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
136 DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
137 GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
138 HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
139 OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
140 PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
141 POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
142 PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
143 TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
146 // RegisterHandlers adds each server route to the EchoRouter.
147 func RegisterHandlers(router EchoRouter, si ServerInterface) {
148 RegisterHandlersWithBaseURL(router, si, "")
151 // Registers handlers, and prepends BaseURL to the paths, so that the paths
152 // can be served under a prefix.
153 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
155 wrapper := ServerInterfaceWrapper{
159 router.GET(baseURL+"/allServiceAPIs", wrapper.GetAllServiceAPIs)
163 // Base64 encoded, gzipped, json marshaled Swagger object
164 var swaggerSpec = []string{
166 "H4sIAAAAAAAC/7xX3W4bOw5+FUK7Fy1gz8STv8Z33sQpvFik3tjdm20RyBqOrVYjTSWNU2/gB9rXOE92",
167 "QGn8E8cOkLo4N006oT5+JD9S1BMTpqyMRu0d6z4xJ2ZY8vDrjXTCzNFi3hsOwpccnbCy8tJo1mX3WFl0",
168 "dBA4KOk8mALIFERtLWqvFmBxKp0nDJAa/Azhujcc3IIwFqGotSAs4DoHx710xULqKXDQdTlBS3iFV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wz2n6Vxy7w4UkeY8V800hlXw8M/Rp7tw4mBR",
182 "c+55O2L/5lQR69sIvCem8c4mIbjHqbELGpiPMylmL3aNCSqjpw68ea1XxE4ce5IrjPaow9znVaUa4aXf",
183 "HBF7+q056GHxLxPx45LwMgmVxQItbYKkH9VYH5Z1Y90mISkj2MvU3iKniefA1VVlrN/o5e52vRSG235z",
184 "HayvvNEm44c4rGHbRePpkHLOLzsPccMhMbyyhK0QV9T3KeZwWPl6I38mGKlzqm20Ww1uWF+nCYxnkrbN",
185 "BRitFjAJtaC7D2SxsQ/Bb07RrdOYvX5L/DVZ+krXqauMdnGvz05O6MdbJb6/gZ8/dA7od+UeJiZfkLxo",
186 "14nbg0VXK795N9BeCkFl9P/V02jrLRQ2zS9h/T49udxJU4da8JU0rfOQ0tkA8eEIiA8EcRbT+UsQdDZA",
187 "dI6A6ESI0yMgTiPE2REQZxHi4giIiwDROYJFJ7LIrn4dIrsiiPMjinoei3p+REXOY0VyLHit/C/DrM4v",
188 "l6Exw9OpeSLERyItxffG+GXaDMU2r6RL5x16N3Er+UTFmdHYxXdQQ2r9xMSfvKwUJsKUbLf9m4P7V+vL",
189 "5Hxnsc6yLCG6X5d/BgAA//+yTjhGXhEAAA==",
192 // GetSwagger returns the content of the embedded swagger specification file
193 // or error if failed to decode
194 func decodeSpec() ([]byte, error) {
195 zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
197 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
199 zr, err := gzip.NewReader(bytes.NewReader(zipped))
201 return nil, fmt.Errorf("error decompressing spec: %s", err)
204 _, err = buf.ReadFrom(zr)
206 return nil, fmt.Errorf("error decompressing spec: %s", err)
209 return buf.Bytes(), nil
212 var rawSpec = decodeSpecCached()
214 // a naive cached of a decoded swagger spec
215 func decodeSpecCached() func() ([]byte, error) {
216 data, err := decodeSpec()
217 return func() ([]byte, error) {
222 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
223 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
224 var res = make(map[string]func() ([]byte, error))
225 if len(pathToFile) > 0 {
226 res[pathToFile] = rawSpec
229 pathPrefix := path.Dir(pathToFile)
231 for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29122_CommonData.yaml")) {
232 if _, ok := res[rawPath]; ok {
233 // it is not possible to compare functions in golang, so always overwrite the old value
235 res[rawPath] = rawFunc
237 for rawPath, rawFunc := range externalRef2.PathToRawSpec(path.Join(pathPrefix, "TS29222_CAPIF_Publish_Service_API.yaml")) {
238 if _, ok := res[rawPath]; ok {
239 // it is not possible to compare functions in golang, so always overwrite the old value
241 res[rawPath] = rawFunc
243 for rawPath, rawFunc := range externalRef1.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) {
244 if _, ok := res[rawPath]; ok {
245 // it is not possible to compare functions in golang, so always overwrite the old value
247 res[rawPath] = rawFunc
252 // GetSwagger returns the Swagger specification corresponding to the generated code
253 // in this file. The external references of Swagger specification are resolved.
254 // The logic of resolving external references is tightly connected to "import-mapping" feature.
255 // Externally referenced files must be embedded in the corresponding golang packages.
256 // Urls can be supported but this task was out of the scope.
257 func GetSwagger() (swagger *openapi3.T, err error) {
258 var resolvePath = PathToRawSpec("")
260 loader := openapi3.NewLoader()
261 loader.IsExternalRefsAllowed = true
262 loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
263 var pathToFile = url.String()
264 pathToFile = path.Clean(pathToFile)
265 getSpec, ok := resolvePath[pathToFile]
267 err1 := fmt.Errorf("path not found: %s", pathToFile)
273 specData, err = rawSpec()
277 swagger, err = loader.LoadFromData(specData)