fix: tmp commeneted method
This commit is contained in:
parent
5cc6757900
commit
f49fad2307
3 changed files with 23 additions and 100 deletions
|
|
@ -103,9 +103,6 @@ type GetUsersUserIdParams struct {
|
||||||
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostUsersJSONRequestBody defines body for PostUsers for application/json ContentType.
|
|
||||||
type PostUsersJSONRequestBody = User
|
|
||||||
|
|
||||||
// Getter for additional properties for Title. Returns the specified
|
// Getter for additional properties for Title. Returns the specified
|
||||||
// element and whether it was found
|
// element and whether it was found
|
||||||
func (a Title) Get(fieldName string) (value interface{}, found bool) {
|
func (a Title) Get(fieldName string) (value interface{}, found bool) {
|
||||||
|
|
@ -344,9 +341,6 @@ type ServerInterface interface {
|
||||||
// Get titles
|
// Get titles
|
||||||
// (GET /title)
|
// (GET /title)
|
||||||
GetTitle(c *gin.Context, params GetTitleParams)
|
GetTitle(c *gin.Context, params GetTitleParams)
|
||||||
// Add new user
|
|
||||||
// (POST /users)
|
|
||||||
PostUsers(c *gin.Context)
|
|
||||||
// Get user info
|
// Get user info
|
||||||
// (GET /users/{user_id})
|
// (GET /users/{user_id})
|
||||||
GetUsersUserId(c *gin.Context, userId string, params GetUsersUserIdParams)
|
GetUsersUserId(c *gin.Context, userId string, params GetUsersUserIdParams)
|
||||||
|
|
@ -443,19 +437,6 @@ func (siw *ServerInterfaceWrapper) GetTitle(c *gin.Context) {
|
||||||
siw.Handler.GetTitle(c, params)
|
siw.Handler.GetTitle(c, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostUsers operation middleware
|
|
||||||
func (siw *ServerInterfaceWrapper) PostUsers(c *gin.Context) {
|
|
||||||
|
|
||||||
for _, middleware := range siw.HandlerMiddlewares {
|
|
||||||
middleware(c)
|
|
||||||
if c.IsAborted() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
siw.Handler.PostUsers(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUsersUserId operation middleware
|
// GetUsersUserId operation middleware
|
||||||
func (siw *ServerInterfaceWrapper) GetUsersUserId(c *gin.Context) {
|
func (siw *ServerInterfaceWrapper) GetUsersUserId(c *gin.Context) {
|
||||||
|
|
||||||
|
|
@ -519,7 +500,6 @@ func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options
|
||||||
}
|
}
|
||||||
|
|
||||||
router.GET(options.BaseURL+"/title", wrapper.GetTitle)
|
router.GET(options.BaseURL+"/title", wrapper.GetTitle)
|
||||||
router.POST(options.BaseURL+"/users", wrapper.PostUsers)
|
|
||||||
router.GET(options.BaseURL+"/users/:user_id", wrapper.GetUsersUserId)
|
router.GET(options.BaseURL+"/users/:user_id", wrapper.GetUsersUserId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -564,27 +544,6 @@ func (response GetTitle500Response) VisitGetTitleResponse(w http.ResponseWriter)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostUsersRequestObject struct {
|
|
||||||
Body *PostUsersJSONRequestBody
|
|
||||||
}
|
|
||||||
|
|
||||||
type PostUsersResponseObject interface {
|
|
||||||
VisitPostUsersResponse(w http.ResponseWriter) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type PostUsers200JSONResponse struct {
|
|
||||||
Error *string `json:"error,omitempty"`
|
|
||||||
Success *bool `json:"success,omitempty"`
|
|
||||||
UserJson *User `json:"user_json,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (response PostUsers200JSONResponse) VisitPostUsersResponse(w http.ResponseWriter) error {
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
w.WriteHeader(200)
|
|
||||||
|
|
||||||
return json.NewEncoder(w).Encode(response)
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUsersUserIdRequestObject struct {
|
type GetUsersUserIdRequestObject struct {
|
||||||
UserId string `json:"user_id"`
|
UserId string `json:"user_id"`
|
||||||
Params GetUsersUserIdParams
|
Params GetUsersUserIdParams
|
||||||
|
|
@ -632,9 +591,6 @@ type StrictServerInterface interface {
|
||||||
// Get titles
|
// Get titles
|
||||||
// (GET /title)
|
// (GET /title)
|
||||||
GetTitle(ctx context.Context, request GetTitleRequestObject) (GetTitleResponseObject, error)
|
GetTitle(ctx context.Context, request GetTitleRequestObject) (GetTitleResponseObject, error)
|
||||||
// Add new user
|
|
||||||
// (POST /users)
|
|
||||||
PostUsers(ctx context.Context, request PostUsersRequestObject) (PostUsersResponseObject, error)
|
|
||||||
// Get user info
|
// Get user info
|
||||||
// (GET /users/{user_id})
|
// (GET /users/{user_id})
|
||||||
GetUsersUserId(ctx context.Context, request GetUsersUserIdRequestObject) (GetUsersUserIdResponseObject, error)
|
GetUsersUserId(ctx context.Context, request GetUsersUserIdRequestObject) (GetUsersUserIdResponseObject, error)
|
||||||
|
|
@ -679,39 +635,6 @@ func (sh *strictHandler) GetTitle(ctx *gin.Context, params GetTitleParams) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostUsers operation middleware
|
|
||||||
func (sh *strictHandler) PostUsers(ctx *gin.Context) {
|
|
||||||
var request PostUsersRequestObject
|
|
||||||
|
|
||||||
var body PostUsersJSONRequestBody
|
|
||||||
if err := ctx.ShouldBindJSON(&body); err != nil {
|
|
||||||
ctx.Status(http.StatusBadRequest)
|
|
||||||
ctx.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
request.Body = &body
|
|
||||||
|
|
||||||
handler := func(ctx *gin.Context, request interface{}) (interface{}, error) {
|
|
||||||
return sh.ssi.PostUsers(ctx, request.(PostUsersRequestObject))
|
|
||||||
}
|
|
||||||
for _, middleware := range sh.middlewares {
|
|
||||||
handler = middleware(handler, "PostUsers")
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ctx.Error(err)
|
|
||||||
ctx.Status(http.StatusInternalServerError)
|
|
||||||
} else if validResponse, ok := response.(PostUsersResponseObject); ok {
|
|
||||||
if err := validResponse.VisitPostUsersResponse(ctx.Writer); err != nil {
|
|
||||||
ctx.Error(err)
|
|
||||||
}
|
|
||||||
} else if response != nil {
|
|
||||||
ctx.Error(fmt.Errorf("unexpected response type: %T", response))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUsersUserId operation middleware
|
// GetUsersUserId operation middleware
|
||||||
func (sh *strictHandler) GetUsersUserId(ctx *gin.Context, userId string, params GetUsersUserIdParams) {
|
func (sh *strictHandler) GetUsersUserId(ctx *gin.Context, userId string, params GetUsersUserIdParams) {
|
||||||
var request GetUsersUserIdRequestObject
|
var request GetUsersUserIdRequestObject
|
||||||
|
|
|
||||||
|
|
@ -243,28 +243,28 @@ paths:
|
||||||
# items:
|
# items:
|
||||||
# $ref: '#/components/schemas/User'
|
# $ref: '#/components/schemas/User'
|
||||||
|
|
||||||
post:
|
# post:
|
||||||
summary: Add new user
|
# summary: Add new user
|
||||||
requestBody:
|
# requestBody:
|
||||||
required: true
|
# required: true
|
||||||
content:
|
# content:
|
||||||
application/json:
|
# application/json:
|
||||||
schema:
|
# schema:
|
||||||
$ref: '#/components/schemas/User'
|
# $ref: '#/components/schemas/User'
|
||||||
responses:
|
# responses:
|
||||||
'200':
|
# '200':
|
||||||
description: Add result
|
# description: Add result
|
||||||
content:
|
# content:
|
||||||
application/json:
|
# application/json:
|
||||||
schema:
|
# schema:
|
||||||
type: object
|
# type: object
|
||||||
properties:
|
# properties:
|
||||||
success:
|
# success:
|
||||||
type: boolean
|
# type: boolean
|
||||||
error:
|
# error:
|
||||||
type: string
|
# type: string
|
||||||
user_json:
|
# user_json:
|
||||||
$ref: '#/components/schemas/User'
|
# $ref: '#/components/schemas/User'
|
||||||
|
|
||||||
# /users/{user_id}/titles:
|
# /users/{user_id}/titles:
|
||||||
# get:
|
# get:
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
func mapUser(u sqlc.GetUserByIDRow) oapi.User {
|
func mapUser(u sqlc.GetUserByIDRow) oapi.User {
|
||||||
return oapi.User{
|
return oapi.User{
|
||||||
AvatarId: u.AvatarID,
|
AvatarId: u.AvatarID,
|
||||||
CreationDate: u.CreationDate,
|
CreationDate: &u.CreationDate,
|
||||||
DispName: u.DispName,
|
DispName: u.DispName,
|
||||||
Id: &u.ID,
|
Id: &u.ID,
|
||||||
Mail: (*types.Email)(u.Mail),
|
Mail: (*types.Email)(u.Mail),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue