fix: regen oapi for auth
This commit is contained in:
parent
e316617175
commit
b03f9c9704
2 changed files with 60 additions and 60 deletions
108
auth/auth.gen.go
108
auth/auth.gen.go
|
|
@ -13,32 +13,32 @@ import (
|
|||
strictgin "github.com/oapi-codegen/runtime/strictmiddleware/gin"
|
||||
)
|
||||
|
||||
// PostAuthSignInJSONBody defines parameters for PostAuthSignIn.
|
||||
type PostAuthSignInJSONBody struct {
|
||||
// PostSignInJSONBody defines parameters for PostSignIn.
|
||||
type PostSignInJSONBody struct {
|
||||
Nickname string `json:"nickname"`
|
||||
Pass string `json:"pass"`
|
||||
}
|
||||
|
||||
// PostAuthSignUpJSONBody defines parameters for PostAuthSignUp.
|
||||
type PostAuthSignUpJSONBody struct {
|
||||
// PostSignUpJSONBody defines parameters for PostSignUp.
|
||||
type PostSignUpJSONBody struct {
|
||||
Nickname string `json:"nickname"`
|
||||
Pass string `json:"pass"`
|
||||
}
|
||||
|
||||
// PostAuthSignInJSONRequestBody defines body for PostAuthSignIn for application/json ContentType.
|
||||
type PostAuthSignInJSONRequestBody PostAuthSignInJSONBody
|
||||
// PostSignInJSONRequestBody defines body for PostSignIn for application/json ContentType.
|
||||
type PostSignInJSONRequestBody PostSignInJSONBody
|
||||
|
||||
// PostAuthSignUpJSONRequestBody defines body for PostAuthSignUp for application/json ContentType.
|
||||
type PostAuthSignUpJSONRequestBody PostAuthSignUpJSONBody
|
||||
// PostSignUpJSONRequestBody defines body for PostSignUp for application/json ContentType.
|
||||
type PostSignUpJSONRequestBody PostSignUpJSONBody
|
||||
|
||||
// ServerInterface represents all server handlers.
|
||||
type ServerInterface interface {
|
||||
// Sign in a user and return JWT
|
||||
// (POST /auth/sign-in)
|
||||
PostAuthSignIn(c *gin.Context)
|
||||
// (POST /sign-in)
|
||||
PostSignIn(c *gin.Context)
|
||||
// Sign up a new user
|
||||
// (POST /auth/sign-up)
|
||||
PostAuthSignUp(c *gin.Context)
|
||||
// (POST /sign-up)
|
||||
PostSignUp(c *gin.Context)
|
||||
}
|
||||
|
||||
// ServerInterfaceWrapper converts contexts to parameters.
|
||||
|
|
@ -50,8 +50,8 @@ type ServerInterfaceWrapper struct {
|
|||
|
||||
type MiddlewareFunc func(c *gin.Context)
|
||||
|
||||
// PostAuthSignIn operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostAuthSignIn(c *gin.Context) {
|
||||
// PostSignIn operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostSignIn(c *gin.Context) {
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
middleware(c)
|
||||
|
|
@ -60,11 +60,11 @@ func (siw *ServerInterfaceWrapper) PostAuthSignIn(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
siw.Handler.PostAuthSignIn(c)
|
||||
siw.Handler.PostSignIn(c)
|
||||
}
|
||||
|
||||
// PostAuthSignUp operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostAuthSignUp(c *gin.Context) {
|
||||
// PostSignUp operation middleware
|
||||
func (siw *ServerInterfaceWrapper) PostSignUp(c *gin.Context) {
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
middleware(c)
|
||||
|
|
@ -73,7 +73,7 @@ func (siw *ServerInterfaceWrapper) PostAuthSignUp(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
siw.Handler.PostAuthSignUp(c)
|
||||
siw.Handler.PostSignUp(c)
|
||||
}
|
||||
|
||||
// GinServerOptions provides options for the Gin server.
|
||||
|
|
@ -103,54 +103,54 @@ func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options
|
|||
ErrorHandler: errorHandler,
|
||||
}
|
||||
|
||||
router.POST(options.BaseURL+"/auth/sign-in", wrapper.PostAuthSignIn)
|
||||
router.POST(options.BaseURL+"/auth/sign-up", wrapper.PostAuthSignUp)
|
||||
router.POST(options.BaseURL+"/sign-in", wrapper.PostSignIn)
|
||||
router.POST(options.BaseURL+"/sign-up", wrapper.PostSignUp)
|
||||
}
|
||||
|
||||
type PostAuthSignInRequestObject struct {
|
||||
Body *PostAuthSignInJSONRequestBody
|
||||
type PostSignInRequestObject struct {
|
||||
Body *PostSignInJSONRequestBody
|
||||
}
|
||||
|
||||
type PostAuthSignInResponseObject interface {
|
||||
VisitPostAuthSignInResponse(w http.ResponseWriter) error
|
||||
type PostSignInResponseObject interface {
|
||||
VisitPostSignInResponse(w http.ResponseWriter) error
|
||||
}
|
||||
|
||||
type PostAuthSignIn200JSONResponse struct {
|
||||
type PostSignIn200JSONResponse struct {
|
||||
UserId int64 `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
}
|
||||
|
||||
func (response PostAuthSignIn200JSONResponse) VisitPostAuthSignInResponse(w http.ResponseWriter) error {
|
||||
func (response PostSignIn200JSONResponse) VisitPostSignInResponse(w http.ResponseWriter) error {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
|
||||
return json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
type PostAuthSignIn401JSONResponse struct {
|
||||
type PostSignIn401JSONResponse struct {
|
||||
Error *string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func (response PostAuthSignIn401JSONResponse) VisitPostAuthSignInResponse(w http.ResponseWriter) error {
|
||||
func (response PostSignIn401JSONResponse) VisitPostSignInResponse(w http.ResponseWriter) error {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
return json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
type PostAuthSignUpRequestObject struct {
|
||||
Body *PostAuthSignUpJSONRequestBody
|
||||
type PostSignUpRequestObject struct {
|
||||
Body *PostSignUpJSONRequestBody
|
||||
}
|
||||
|
||||
type PostAuthSignUpResponseObject interface {
|
||||
VisitPostAuthSignUpResponse(w http.ResponseWriter) error
|
||||
type PostSignUpResponseObject interface {
|
||||
VisitPostSignUpResponse(w http.ResponseWriter) error
|
||||
}
|
||||
|
||||
type PostAuthSignUp200JSONResponse struct {
|
||||
type PostSignUp200JSONResponse struct {
|
||||
UserId int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
func (response PostAuthSignUp200JSONResponse) VisitPostAuthSignUpResponse(w http.ResponseWriter) error {
|
||||
func (response PostSignUp200JSONResponse) VisitPostSignUpResponse(w http.ResponseWriter) error {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
|
||||
|
|
@ -160,11 +160,11 @@ func (response PostAuthSignUp200JSONResponse) VisitPostAuthSignUpResponse(w http
|
|||
// StrictServerInterface represents all server handlers.
|
||||
type StrictServerInterface interface {
|
||||
// Sign in a user and return JWT
|
||||
// (POST /auth/sign-in)
|
||||
PostAuthSignIn(ctx context.Context, request PostAuthSignInRequestObject) (PostAuthSignInResponseObject, error)
|
||||
// (POST /sign-in)
|
||||
PostSignIn(ctx context.Context, request PostSignInRequestObject) (PostSignInResponseObject, error)
|
||||
// Sign up a new user
|
||||
// (POST /auth/sign-up)
|
||||
PostAuthSignUp(ctx context.Context, request PostAuthSignUpRequestObject) (PostAuthSignUpResponseObject, error)
|
||||
// (POST /sign-up)
|
||||
PostSignUp(ctx context.Context, request PostSignUpRequestObject) (PostSignUpResponseObject, error)
|
||||
}
|
||||
|
||||
type StrictHandlerFunc = strictgin.StrictGinHandlerFunc
|
||||
|
|
@ -179,11 +179,11 @@ type strictHandler struct {
|
|||
middlewares []StrictMiddlewareFunc
|
||||
}
|
||||
|
||||
// PostAuthSignIn operation middleware
|
||||
func (sh *strictHandler) PostAuthSignIn(ctx *gin.Context) {
|
||||
var request PostAuthSignInRequestObject
|
||||
// PostSignIn operation middleware
|
||||
func (sh *strictHandler) PostSignIn(ctx *gin.Context) {
|
||||
var request PostSignInRequestObject
|
||||
|
||||
var body PostAuthSignInJSONRequestBody
|
||||
var body PostSignInJSONRequestBody
|
||||
if err := ctx.ShouldBindJSON(&body); err != nil {
|
||||
ctx.Status(http.StatusBadRequest)
|
||||
ctx.Error(err)
|
||||
|
|
@ -192,10 +192,10 @@ func (sh *strictHandler) PostAuthSignIn(ctx *gin.Context) {
|
|||
request.Body = &body
|
||||
|
||||
handler := func(ctx *gin.Context, request interface{}) (interface{}, error) {
|
||||
return sh.ssi.PostAuthSignIn(ctx, request.(PostAuthSignInRequestObject))
|
||||
return sh.ssi.PostSignIn(ctx, request.(PostSignInRequestObject))
|
||||
}
|
||||
for _, middleware := range sh.middlewares {
|
||||
handler = middleware(handler, "PostAuthSignIn")
|
||||
handler = middleware(handler, "PostSignIn")
|
||||
}
|
||||
|
||||
response, err := handler(ctx, request)
|
||||
|
|
@ -203,8 +203,8 @@ func (sh *strictHandler) PostAuthSignIn(ctx *gin.Context) {
|
|||
if err != nil {
|
||||
ctx.Error(err)
|
||||
ctx.Status(http.StatusInternalServerError)
|
||||
} else if validResponse, ok := response.(PostAuthSignInResponseObject); ok {
|
||||
if err := validResponse.VisitPostAuthSignInResponse(ctx.Writer); err != nil {
|
||||
} else if validResponse, ok := response.(PostSignInResponseObject); ok {
|
||||
if err := validResponse.VisitPostSignInResponse(ctx.Writer); err != nil {
|
||||
ctx.Error(err)
|
||||
}
|
||||
} else if response != nil {
|
||||
|
|
@ -212,11 +212,11 @@ func (sh *strictHandler) PostAuthSignIn(ctx *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
// PostAuthSignUp operation middleware
|
||||
func (sh *strictHandler) PostAuthSignUp(ctx *gin.Context) {
|
||||
var request PostAuthSignUpRequestObject
|
||||
// PostSignUp operation middleware
|
||||
func (sh *strictHandler) PostSignUp(ctx *gin.Context) {
|
||||
var request PostSignUpRequestObject
|
||||
|
||||
var body PostAuthSignUpJSONRequestBody
|
||||
var body PostSignUpJSONRequestBody
|
||||
if err := ctx.ShouldBindJSON(&body); err != nil {
|
||||
ctx.Status(http.StatusBadRequest)
|
||||
ctx.Error(err)
|
||||
|
|
@ -225,10 +225,10 @@ func (sh *strictHandler) PostAuthSignUp(ctx *gin.Context) {
|
|||
request.Body = &body
|
||||
|
||||
handler := func(ctx *gin.Context, request interface{}) (interface{}, error) {
|
||||
return sh.ssi.PostAuthSignUp(ctx, request.(PostAuthSignUpRequestObject))
|
||||
return sh.ssi.PostSignUp(ctx, request.(PostSignUpRequestObject))
|
||||
}
|
||||
for _, middleware := range sh.middlewares {
|
||||
handler = middleware(handler, "PostAuthSignUp")
|
||||
handler = middleware(handler, "PostSignUp")
|
||||
}
|
||||
|
||||
response, err := handler(ctx, request)
|
||||
|
|
@ -236,8 +236,8 @@ func (sh *strictHandler) PostAuthSignUp(ctx *gin.Context) {
|
|||
if err != nil {
|
||||
ctx.Error(err)
|
||||
ctx.Status(http.StatusInternalServerError)
|
||||
} else if validResponse, ok := response.(PostAuthSignUpResponseObject); ok {
|
||||
if err := validResponse.VisitPostAuthSignUpResponse(ctx.Writer); err != nil {
|
||||
} else if validResponse, ok := response.(PostSignUpResponseObject); ok {
|
||||
if err := validResponse.VisitPostSignUpResponse(ctx.Writer); err != nil {
|
||||
ctx.Error(err)
|
||||
}
|
||||
} else if response != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue