Move capifcore code to separate folder
[nonrtric/plt/sme.git] / capifcore / internal / routinginfoapi / routinginfoapi-server.gen.go
1 // Package routinginfoapi provides primitives to interact with the openapi HTTP API.
2 //
3 // Code generated by github.com/deepmap/oapi-codegen version v1.10.1 DO NOT EDIT.
4 package routinginfoapi
5
6 import (
7         "bytes"
8         "compress/gzip"
9         "encoding/base64"
10         "fmt"
11         "net/http"
12         "net/url"
13         "path"
14         "strings"
15
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"
22 )
23
24 // ServerInterface represents all server handlers.
25 type ServerInterface interface {
26
27         // (GET /service-apis/{serviceApiId})
28         GetServiceApisServiceApiId(ctx echo.Context, serviceApiId string, params GetServiceApisServiceApiIdParams) error
29 }
30
31 // ServerInterfaceWrapper converts echo contexts to parameters.
32 type ServerInterfaceWrapper struct {
33         Handler ServerInterface
34 }
35
36 // GetServiceApisServiceApiId converts echo context to params.
37 func (w *ServerInterfaceWrapper) GetServiceApisServiceApiId(ctx echo.Context) error {
38         var err error
39         // ------------- Path parameter "serviceApiId" -------------
40         var serviceApiId string
41
42         err = runtime.BindStyledParameterWithLocation("simple", false, "serviceApiId", runtime.ParamLocationPath, ctx.Param("serviceApiId"), &serviceApiId)
43         if err != nil {
44                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter serviceApiId: %s", err))
45         }
46
47         // Parameter object where we will unmarshal all parameters from the context
48         var params GetServiceApisServiceApiIdParams
49         // ------------- Required query parameter "aef-id" -------------
50
51         err = runtime.BindQueryParameter("form", true, true, "aef-id", ctx.QueryParams(), &params.AefId)
52         if err != nil {
53                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter aef-id: %s", err))
54         }
55
56         // ------------- Optional query parameter "supp-feat" -------------
57
58         err = runtime.BindQueryParameter("form", true, false, "supp-feat", ctx.QueryParams(), &params.SuppFeat)
59         if err != nil {
60                 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter supp-feat: %s", err))
61         }
62
63         // Invoke the callback with all the unmarshalled arguments
64         err = w.Handler.GetServiceApisServiceApiId(ctx, serviceApiId, params)
65         return err
66 }
67
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
81 }
82
83 // RegisterHandlers adds each server route to the EchoRouter.
84 func RegisterHandlers(router EchoRouter, si ServerInterface) {
85         RegisterHandlersWithBaseURL(router, si, "")
86 }
87
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) {
91
92         wrapper := ServerInterfaceWrapper{
93                 Handler: si,
94         }
95
96         router.GET(baseURL+"/service-apis/:serviceApiId", wrapper.GetServiceApisServiceApiId)
97
98 }
99
100 // Base64 encoded, gzipped, json marshaled Swagger object
101 var swaggerSpec = []string{
102
103         "H4sIAAAAAAAC/6RW0W7buBL9FYL3PuwCsmTJcdL4zZs2hbDA1rCMfWkDg5FGNrsSyQ4pp9nAH7S/sV+2",
104         "GFJJnMQ10vgliuzhOWdmznB8x0vdGq1AOcsnd9yWa2iF/zc3m9NpVSFYOxdqBfRZBbZEaZzUik/4HAyC",
105         "paMsn21OmQjRDCk85hE3qA2gk+ABQVX0+D9CzSd8UWTnaZYtL3TbavVeOBHfirb5X/IoKOnVJPdS+Dbi",
106         "1gl0R+NsI47wrZMIFZ987kEjL/Eq4u7WAJ9wff0VSkekc905qVa5qvXBMgjFprOcYQhnUtUaW0FxL8vR",
107         "B827JrxLB63dSWxvBvPHQ6SrlSoPx9IH1QJR3L7I8AnbgRQ98k+kiF2zp9UC6hnqWgasnU5l1KnpLL9c",
108         "zrrrRtr1sgDcyBKW01n+48ZNH/G2EZdmc0Jt9LbcW7tXmuHkib8P19PTnh6mPWi6V/I869tOJV92jYLh",
109         "uwNUonmvS/uycaOPsxlbFCw7j7MsY3+mZ/EoHrJQH9/ISxQt3Gj8i9UamY//Q6NbX+tOVRRhecQ7bPiE",
110         "r50zkyS5ubmJRytjYo2rpHYmKQyUNhFYruUGkux8aQEl2CSQJr52eyeH+Il1vmdevqh//2HZMEujIOoT",
111         "roSSf/svRcNmAp0CtOyX6Tz/LWLTRV5E7OKimEbsw6LII7Yo3vvHYkp/Ln6Nv6hp0zCUq7WzjOyMG6ji",
112         "L4pH3ElHVuXBmr2cJY07+ZJHfANog+Y0TuPhQDRmLeKMUtMGlDCSih0P4yHNgnBr34vEBnMPhJE2uevf",
113         "pkbm1Za+X4HbN2sOJWzAMreGQ9cJDZx/ySs+4R/BFQ/4ttih8oqoyw7Q8snn54R5BcrJWgIyXTPBTJhM",
114         "qFgvmIUaSAqm3HjElWipXvYpzaNxHXYQ9duEUuyNax1KtSKTHxbhM/9weU/6rQO8fWQVUA/kkXwLzWrZ",
115         "OEAmEaGBjVCOTGG0skD2aISDijnNOmU7YzTSaw3CdQj2B8IocEAxfFfLzvU3PktftaiKe8bLe8Lt9ory",
116         "7fURbDYc0qPUyoHyPhLGNLL0lki+Wkrz7qWMQ2vF7zd/qzwt1qffY3L6aHj2k4v3QXBCZz3EuyMg3hHE",
117         "Scj7TRB01kOkR0CkAWJ0BMQoQJwcAXESIE6PgDj1EOkRKtKgIjt/O0R2ThDjI5o6Dk0dH9GRcehIBbXo",
118         "GvdmmPvz260fIr9h+is3bNA7YeRca7dNSmFkPehv9gHd7MkmpUUjUIrr/idhHx12RC/Nb2E7SRL4LlrT",
119         "QFzqlj8f2P4gE5ZVUEsFFZOK2e66bERngZ3FY7pmn/46INlX2/8CAAD//0fkW+0SDAAA",
120 }
121
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, ""))
126         if err != nil {
127                 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
128         }
129         zr, err := gzip.NewReader(bytes.NewReader(zipped))
130         if err != nil {
131                 return nil, fmt.Errorf("error decompressing spec: %s", err)
132         }
133         var buf bytes.Buffer
134         _, err = buf.ReadFrom(zr)
135         if err != nil {
136                 return nil, fmt.Errorf("error decompressing spec: %s", err)
137         }
138
139         return buf.Bytes(), nil
140 }
141
142 var rawSpec = decodeSpecCached()
143
144 // a naive cached of a decoded swagger spec
145 func decodeSpecCached() func() ([]byte, error) {
146         data, err := decodeSpec()
147         return func() ([]byte, error) {
148                 return data, err
149         }
150 }
151
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
157         }
158
159         pathPrefix := path.Dir(pathToFile)
160
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
164                 }
165                 res[rawPath] = rawFunc
166         }
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
170                 }
171                 res[rawPath] = rawFunc
172         }
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
176                 }
177                 res[rawPath] = rawFunc
178         }
179         return res
180 }
181
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("")
189
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]
196                 if !ok {
197                         err1 := fmt.Errorf("path not found: %s", pathToFile)
198                         return nil, err1
199                 }
200                 return getSpec()
201         }
202         var specData []byte
203         specData, err = rawSpec()
204         if err != nil {
205                 return
206         }
207         swagger, err = loader.LoadFromData(specData)
208         if err != nil {
209                 return
210         }
211         return
212 }