1 // Package aefsecurityapi 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.
15 "github.com/getkin/kin-openapi/openapi3"
16 "github.com/labstack/echo/v4"
17 externalRef0 "oransc.org/nonrtric/capifcore/internal/common29571"
20 // ServerInterface represents all server handlers.
21 type ServerInterface interface {
22 // Check authentication.
23 // (POST /check-authentication)
24 PostCheckAuthentication(ctx echo.Context) error
25 // Revoke authorization.
26 // (POST /revoke-authorization)
27 PostRevokeAuthorization(ctx echo.Context) error
30 // ServerInterfaceWrapper converts echo contexts to parameters.
31 type ServerInterfaceWrapper struct {
32 Handler ServerInterface
35 // PostCheckAuthentication converts echo context to params.
36 func (w *ServerInterfaceWrapper) PostCheckAuthentication(ctx echo.Context) error {
39 // Invoke the callback with all the unmarshalled arguments
40 err = w.Handler.PostCheckAuthentication(ctx)
44 // PostRevokeAuthorization converts echo context to params.
45 func (w *ServerInterfaceWrapper) PostRevokeAuthorization(ctx echo.Context) error {
48 // Invoke the callback with all the unmarshalled arguments
49 err = w.Handler.PostRevokeAuthorization(ctx)
53 // This is a simple interface which specifies echo.Route addition functions which
54 // are present on both echo.Echo and echo.Group, since we want to allow using
55 // either of them for path registration
56 type EchoRouter interface {
57 CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
58 DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
59 GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
60 HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
61 OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
62 PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
63 POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
64 PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
65 TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
68 // RegisterHandlers adds each server route to the EchoRouter.
69 func RegisterHandlers(router EchoRouter, si ServerInterface) {
70 RegisterHandlersWithBaseURL(router, si, "")
73 // Registers handlers, and prepends BaseURL to the paths, so that the paths
74 // can be served under a prefix.
75 func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
77 wrapper := ServerInterfaceWrapper{
81 router.POST(baseURL+"/check-authentication", wrapper.PostCheckAuthentication)
82 router.POST(baseURL+"/revoke-authorization", wrapper.PostRevokeAuthorization)
86 // Base64 encoded, gzipped, json marshaled Swagger object
87 var swaggerSpec = []string{
89 "H4sIAAAAAAAC/+xY3W7bNhR+lQNuFxugSJZSI43vVCcZdNMZsbGbtgho6chiI5EsSdn1Aj/QXmNPNpBU",
90 "vNixgyBCAxTITSyI53w8Px8/HuWO5KKRgiM3mozuiM4rbKh7HFeY36atqZAbllPDBL/Gb3alQJ0rJu0b",
91 "MiLXKBVqCwB0xxpyiwAKv7WoDRTU0JAERCohURmGbhcqWcaX4hZVVjzGTicZML8M2QVQrdmCYwHzNZgK",
92 "YZxOsivIhUIoW567TY1wSw89VxWrEQQ/mQuqCsYX+xbhZ04CYtYSyYhooxhfkE1AdCulUAaLK6SmVT7g",
93 "XxWWZERm0+R8eBbfjEXTCH5hc1vTpv4l+r+eUVfMaPoIZ7MJiK0LU1iQ0afdKhza+Ms2PDH/irmx4R1q",
94 "kJYvaZCWgms80qHXq8Lz0r5GWyibt1Ds72fzcmsMCpciv398ipvK7ZTxUuylnCTJjePezRTzVjGzvkkn",
95 "2ROpd1YfhWFlV/zXJdiDVIIedX4GvY7U+SeimPXB7wYVp/WFyPXjlE//mExgNoXkPEySBP6Kz8JhOAAf",
96 "ohOWK0UbXAl1C6VQ4Ow/CmWquWh5YS00CUirajIilTFSj6JotVqFpwspQ6EWUWlkNJWY64iqvGJLjJLz",
97 "G42KoY78rpHtEeu4+Vg17bbp5RXojnrQUE4X2CA3IcBn/u8/kAySJPCx/akWlHd9ozVMqDIclYbf0uvs",
98 "QwDpLJsGMB5P0wAuZ9MsgNn0wv3MUvtn/LvDTOsaFFtURtuGo1pi0SkrM7WtcHq5e2JIQJaotI86DpNw",
99 "YJMSEjmVzNY5HIQDyxZqKteGyCnWya6M2QUptLG/llXupb1NyERoc0AliecEavNBFGvrlgtukBt/Icm6",
100 "s4u+ao/u+fWAlAfZd+TC3Oxy0KgW3Qt/IlxayWDwQ6PQ0kexS5NZhVsBXFENus1z1Lps69C24XRwtncM",
101 "Yyt7TxzDbU6R9XUQ73tAvLcQ73xpXgRhfR1E3AMi9hCnPSBOPcS7HhDvHETcI5HYJxL3SCT2icTDHhBD",
102 "B5GcvxwiObcQwx68GHpeDHs0deibWmBJ29q8GObef+OGgaahak1GfrDbm9VCZxP5e/xk56J9Wv8OXOM/",
103 "SP+ODGavrH9HxpY3/XvTvzf9+zn0zx/h3a+J0J9gN1UqTUaf7rrx+Y5Kdi2E2UQUy5P7cTdaxna4pIrR",
104 "eb39T4O18+NyF/Z2+MbvtJE1hrloyL5OdI5ANRRYMo4FMA55TVuNcBYOQZSw+0Xggv2y+S8AAP//WFej",
108 // GetSwagger returns the content of the embedded swagger specification file
109 // or error if failed to decode
110 func decodeSpec() ([]byte, error) {
111 zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
113 return nil, fmt.Errorf("error base64 decoding spec: %s", err)
115 zr, err := gzip.NewReader(bytes.NewReader(zipped))
117 return nil, fmt.Errorf("error decompressing spec: %s", err)
120 _, err = buf.ReadFrom(zr)
122 return nil, fmt.Errorf("error decompressing spec: %s", err)
125 return buf.Bytes(), nil
128 var rawSpec = decodeSpecCached()
130 // a naive cached of a decoded swagger spec
131 func decodeSpecCached() func() ([]byte, error) {
132 data, err := decodeSpec()
133 return func() ([]byte, error) {
138 // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
139 func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
140 var res = make(map[string]func() ([]byte, error))
141 if len(pathToFile) > 0 {
142 res[pathToFile] = rawSpec
145 pathPrefix := path.Dir(pathToFile)
147 for rawPath, rawFunc := range externalRef0.PathToRawSpec(path.Join(pathPrefix, "TS29571_CommonData.yaml")) {
148 if _, ok := res[rawPath]; ok {
149 // it is not possible to compare functions in golang, so always overwrite the old value
151 res[rawPath] = rawFunc
156 // GetSwagger returns the Swagger specification corresponding to the generated code
157 // in this file. The external references of Swagger specification are resolved.
158 // The logic of resolving external references is tightly connected to "import-mapping" feature.
159 // Externally referenced files must be embedded in the corresponding golang packages.
160 // Urls can be supported but this task was out of the scope.
161 func GetSwagger() (swagger *openapi3.T, err error) {
162 var resolvePath = PathToRawSpec("")
164 loader := openapi3.NewLoader()
165 loader.IsExternalRefsAllowed = true
166 loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
167 var pathToFile = url.String()
168 pathToFile = path.Clean(pathToFile)
169 getSpec, ok := resolvePath[pathToFile]
171 err1 := fmt.Errorf("path not found: %s", pathToFile)
177 specData, err = rawSpec()
181 swagger, err = loader.LoadFromData(specData)