1 // Package routinginfoapi 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.
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 /service-apis/{serviceApiId})
28 GetServiceApisServiceApiId(ctx echo.Context, serviceApiId string, params GetServiceApisServiceApiIdParams) error
31 // ServerInterfaceWrapper converts echo contexts to parameters.
32 type ServerInterfaceWrapper struct {
33 Handler ServerInterface
36 // GetServiceApisServiceApiId converts echo context to params.
37 func (w *ServerInterfaceWrapper) GetServiceApisServiceApiId(ctx echo.Context) error {
39 // ------------- Path parameter "serviceApiId" -------------
40 var serviceApiId string
42 err = runtime.BindStyledParameterWithLocation("simple", false, "serviceApiId", runtime.ParamLocationPath, ctx.Param("serviceApiId"), &serviceApiId)
44 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter serviceApiId: %s", err))
47 // Parameter object where we will unmarshal all parameters from the context
48 var params GetServiceApisServiceApiIdParams
49 // ------------- Required query parameter "aef-id" -------------
51 err = runtime.BindQueryParameter("form", true, true, "aef-id", ctx.QueryParams(), ¶ms.AefId)
53 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter aef-id: %s", err))
56 // ------------- Optional query parameter "supp-feat" -------------
58 err = runtime.BindQueryParameter("form", true, false, "supp-feat", ctx.QueryParams(), ¶ms.SuppFeat)
60 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter supp-feat: %s", err))
63 // Invoke the callback with all the unmarshalled arguments
64 err = w.Handler.GetServiceApisServiceApiId(ctx, serviceApiId, params)
68 // This is a simple interface which specifies echo.Route addition functions which
69 // are present on both echo.Echo and echo.Group, since we want to allow using
70 // either of them for path registration
71 type EchoRouter interface {
72 CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
73 DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
74 GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
75 HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
76 OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
77 PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
78 POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
79 PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
80 TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
83 // RegisterHandlers adds each server route to the EchoRouter.
84 func RegisterHandlers(router EchoRouter, si ServerInterface) {
85 RegisterHandlersWithBaseURL(router, si, "")
88 // Registers handlers, and prepends BaseURL to the paths, so that the paths
89 // can be served under a prefix.
90 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
92 wrapper := ServerInterfaceWrapper{
96 router.GET(baseURL+"/service-apis/:serviceApiId", wrapper.GetServiceApisServiceApiId)
100 // Base64 encoded, gzipped, json marshaled Swagger object
101 var swaggerSpec = []string{
103 "H4sIAAAAAAAC/6RW0W7buBL9FYL3PuwCimQpcdL4TZs2hbDA1rCMfWkDg5FGNrsSyQ4pp9nAH7S/sV+2",
104 "GFJJnMQ10vgliuzhmTNzznB8xyvdGa1AOcsnd9xWK+iE/7cw69O8rhGsnQm1BPqsBluhNE5qxSd8BgbB",
105 "0lFWTNenTIRohhQe84gb1AbQSfCAoGp6/B+h4RM+L7PzNMsWF7rrtHovnIhvRdf+L3kklAxsknsqfBNx",
106 "6wS6g3E2EUf41kuEmk8+D6CR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O",
119 "B5mwrIZGKqiZVKxqRW+BncVjumOf/i4gzleb/wIAAP//hn2OrAwMAAA=",
122 // GetSwagger returns the content of the embedded swagger specification file
123 // or error if failed to decode
124 func decodeSpec() ([]byte, error) {
125 zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
127 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
129 zr, err := gzip.NewReader(bytes.NewReader(zipped))
131 return nil, fmt.Errorf("error decompressing spec: %s", err)
134 _, err = buf.ReadFrom(zr)
136 return nil, fmt.Errorf("error decompressing spec: %s", err)
139 return buf.Bytes(), nil
142 var rawSpec = decodeSpecCached()
144 // a naive cached of a decoded swagger spec
145 func decodeSpecCached() func() ([]byte, error) {
146 data, err := decodeSpec()
147 return func() ([]byte, error) {
152 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
153 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
154 var res = make(map[string]func() ([]byte, error))
155 if len(pathToFile) > 0 {
156 res[pathToFile] = rawSpec
159 pathPrefix := path.Dir(pathToFile)
161 for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29122_CommonData.yaml")) {
162 if _, ok := res[rawPath]; ok {
163 // it is not possible to compare functions in golang, so always overwrite the old value
165 res[rawPath] = rawFunc
167 for rawPath, rawFunc := range externalRef2.PathToRawSpec(path.Join(pathPrefix, "TS29222_CAPIF_Publish_Service_API.yaml")) {
168 if _, ok := res[rawPath]; ok {
169 // it is not possible to compare functions in golang, so always overwrite the old value
171 res[rawPath] = rawFunc
173 for rawPath, rawFunc := range externalRef1.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) {
174 if _, ok := res[rawPath]; ok {
175 // it is not possible to compare functions in golang, so always overwrite the old value
177 res[rawPath] = rawFunc
182 // GetSwagger returns the Swagger specification corresponding to the generated code
183 // in this file. The external references of Swagger specification are resolved.
184 // The logic of resolving external references is tightly connected to "import-mapping" feature.
185 // Externally referenced files must be embedded in the corresponding golang packages.
186 // Urls can be supported but this task was out of the scope.
187 func GetSwagger() (swagger *openapi3.T, err error) {
188 var resolvePath = PathToRawSpec("")
190 loader := openapi3.NewLoader()
191 loader.IsExternalRefsAllowed = true
192 loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
193 var pathToFile = url.String()
194 pathToFile = path.Clean(pathToFile)
195 getSpec, ok := resolvePath[pathToFile]
197 err1 := fmt.Errorf("path not found: %s", pathToFile)
203 specData, err = rawSpec()
207 swagger, err = loader.LoadFromData(specData)