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/+xY3W7iOBR+Fcu7F7tSSEgo6pC7DG1XuZlFgPZmOkImOSGeJrbHdmDYigfa19gnW9lO",
90 "2UKhqhpNpZF6U6L4nM/n5/Pnk97jjNeCM2Ba4fgeq6yEmtjHcQnZXdLoEpimGdGUsyl8Mys5qExSYd7g",
91 "GE9BSFAGAJEDa5QZBCThWwNKo5xo4mMPC8kFSE3B7kIETdma34FM86fYySRF1C2j9AoRpeiKQY6WW6RL",
92 "QONkkt6gjEtARcMyu6nmdumx56akFSDOektOZE7Z6tjChKW3AnCMlZaUrfDOw6oRgksN+Q0Q3UgX7q8S",
93 "Chzj+SwaDS/DxZjXNWdXJrMtqatfgv+rGbSlDGZPcHY7D5uqUAk5jj8f1uDUxl/24fHlV8i0Ce9Ue5R4",
94 "TXuU4EzBmf68XRVelvYUTKFM3lzSv1/Myr0xkrDm2cPjc8yUdqeUFfwo5SiKFpZ5ixlkjaR6u0gm6TOp",
95 "t1afuKZFW/y3JdijVLwOdX4Bvc7U+SeimPGB7xokI9UVz9TTlAd/TCZoPkPRyI+iCP0VXvqh30cuRCsr",
96 "N5LUsOHyDhVcImv/iUtdLnnDcmOhsIcbWeEYl1qLOAg2m40/WAnhc7kKCi2CmYBMBURmJV1DEI0WCiQF",
97 "FbhNA9Mi2lLzqWSaXZPrG6Ra5qGaMLKCGpj2b9m//6CoH4WeC+xPuSKsbRqp0IRIzUAq9FsyTT96KJmn",
98 "Mw+Nx7PEQ9fzWeqh+ezK/swT82f8u3/LkqpCkq5KrUyvQa4h92+ZEVWqK1Pc5PrwsGAPr0EqF3HoR36/",
99 "RypREj80iXEBjAhqSu33/b4hDNGl7URgRat3qGRmQXClza8hln1prhM84UqfEErsaAFKf+T51rhlnGlg",
100 "2t1Iomrtgq/KoTuKPeLlSQKeuTF3hzTUsgH7wh0Km1bU7//QKJRwURxSZV7CXgM3RCHVZBkoVTSVb9ow",
101 "6F8encTQKN8zJ3GfU2B8LcSHDhAfDMSFK82rIIyvhQg7QIQOYtABYuAgLjpAXFiIsEMioUsk7JBI6BIJ",
102 "hx0ghhYiGr0eIhoZiGEHXgwdL4Ydmjp0Tc2hIE2lXw3z4L+z80BdE7nFsZvtjsY139oE7irvHdy1z+vf",
103 "iZv8B+nfmdnsjfXvzOTyrn/v+veufz+H/rkjfPhB4bsTbKdLqXD8+b6doO+JoFPO9S4gUPQeRt5gHZoh",
104 "k0hKltX+Xw3Gzo3Mbdh2/lZxEMB3UosK/IzX+FgnWkdEFMqhoAxyRBlSzTKrSKMAXfpDxAt0+F1g4/2y",
105 "+y8AAP//CPXtp2ERAAA=",
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)