feat: Adding openapi generated without server just models
This commit is contained in:
@@ -3,10 +3,6 @@
|
||||
// Code generated by github.com/deepmap/oapi-codegen version v1.16.3 DO NOT EDIT.
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
BearerAuthScopes = "bearerAuth.Scopes"
|
||||
)
|
||||
@@ -63,85 +59,3 @@ type PostAuthLogoutJSONRequestBody = RevokeRequest
|
||||
|
||||
// PostAuthRefreshJSONRequestBody defines body for PostAuthRefresh for application/json ContentType.
|
||||
type PostAuthRefreshJSONRequestBody = RefreshRequest
|
||||
|
||||
// ServerInterface represents all server handlers.
|
||||
type ServerInterface interface {
|
||||
// Obtain access and refresh tokens
|
||||
// (POST /auth/login)
|
||||
PostAuthLogin(c *fiber.Ctx) error
|
||||
// Revoke refresh token / logout
|
||||
// (POST /auth/logout)
|
||||
PostAuthLogout(c *fiber.Ctx) error
|
||||
// Get current authenticated user
|
||||
// (GET /auth/me)
|
||||
GetAuthMe(c *fiber.Ctx) error
|
||||
// Refresh access token using a refresh token
|
||||
// (POST /auth/refresh)
|
||||
PostAuthRefresh(c *fiber.Ctx) error
|
||||
}
|
||||
|
||||
// ServerInterfaceWrapper converts contexts to parameters.
|
||||
type ServerInterfaceWrapper struct {
|
||||
Handler ServerInterface
|
||||
}
|
||||
|
||||
type MiddlewareFunc fiber.Handler
|
||||
|
||||
// PostAuthLogin operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostAuthLogin(c *fiber.Ctx) error {
|
||||
|
||||
return siw.Handler.PostAuthLogin(c)
|
||||
}
|
||||
|
||||
// PostAuthLogout operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostAuthLogout(c *fiber.Ctx) error {
|
||||
|
||||
c.Context().SetUserValue(BearerAuthScopes, []string{})
|
||||
|
||||
return siw.Handler.PostAuthLogout(c)
|
||||
}
|
||||
|
||||
// GetAuthMe operation middleware
|
||||
func (siw *ServerInterfaceWrapper) GetAuthMe(c *fiber.Ctx) error {
|
||||
|
||||
c.Context().SetUserValue(BearerAuthScopes, []string{})
|
||||
|
||||
return siw.Handler.GetAuthMe(c)
|
||||
}
|
||||
|
||||
// PostAuthRefresh operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostAuthRefresh(c *fiber.Ctx) error {
|
||||
|
||||
return siw.Handler.PostAuthRefresh(c)
|
||||
}
|
||||
|
||||
// FiberServerOptions provides options for the Fiber server.
|
||||
type FiberServerOptions struct {
|
||||
BaseURL string
|
||||
Middlewares []MiddlewareFunc
|
||||
}
|
||||
|
||||
// RegisterHandlers creates http.Handler with routing matching OpenAPI spec.
|
||||
func RegisterHandlers(router fiber.Router, si ServerInterface) {
|
||||
RegisterHandlersWithOptions(router, si, FiberServerOptions{})
|
||||
}
|
||||
|
||||
// RegisterHandlersWithOptions creates http.Handler with additional options
|
||||
func RegisterHandlersWithOptions(router fiber.Router, si ServerInterface, options FiberServerOptions) {
|
||||
wrapper := ServerInterfaceWrapper{
|
||||
Handler: si,
|
||||
}
|
||||
|
||||
for _, m := range options.Middlewares {
|
||||
router.Use(m)
|
||||
}
|
||||
|
||||
router.Post(options.BaseURL+"/auth/login", wrapper.PostAuthLogin)
|
||||
|
||||
router.Post(options.BaseURL+"/auth/logout", wrapper.PostAuthLogout)
|
||||
|
||||
router.Get(options.BaseURL+"/auth/me", wrapper.GetAuthMe)
|
||||
|
||||
router.Post(options.BaseURL+"/auth/refresh", wrapper.PostAuthRefresh)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user