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"`
|
||||
}
|
||||
|
||||
// PostUsersJSONRequestBody defines body for PostUsers for application/json ContentType.
|
||||
type PostUsersJSONRequestBody = User
|
||||
|
||||
// Getter for additional properties for Title. Returns the specified
|
||||
// element and whether it was found
|
||||
func (a Title) Get(fieldName string) (value interface{}, found bool) {
|
||||
|
|
@ -344,9 +341,6 @@ type ServerInterface interface {
|
|||
// Get titles
|
||||
// (GET /title)
|
||||
GetTitle(c *gin.Context, params GetTitleParams)
|
||||
// Add new user
|
||||
// (POST /users)
|
||||
PostUsers(c *gin.Context)
|
||||
// Get user info
|
||||
// (GET /users/{user_id})
|
||||
GetUsersUserId(c *gin.Context, userId string, params GetUsersUserIdParams)
|
||||
|
|
@ -443,19 +437,6 @@ func (siw *ServerInterfaceWrapper) GetTitle(c *gin.Context) {
|
|||
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
|
||||
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.POST(options.BaseURL+"/users", wrapper.PostUsers)
|
||||
router.GET(options.BaseURL+"/users/:user_id", wrapper.GetUsersUserId)
|
||||
}
|
||||
|
||||
|
|
@ -564,27 +544,6 @@ func (response GetTitle500Response) VisitGetTitleResponse(w http.ResponseWriter)
|
|||
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 {
|
||||
UserId string `json:"user_id"`
|
||||
Params GetUsersUserIdParams
|
||||
|
|
@ -632,9 +591,6 @@ type StrictServerInterface interface {
|
|||
// Get titles
|
||||
// (GET /title)
|
||||
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 /users/{user_id})
|
||||
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
|
||||
func (sh *strictHandler) GetUsersUserId(ctx *gin.Context, userId string, params GetUsersUserIdParams) {
|
||||
var request GetUsersUserIdRequestObject
|
||||
|
|
|
|||
|
|
@ -243,28 +243,28 @@ paths:
|
|||
# items:
|
||||
# $ref: '#/components/schemas/User'
|
||||
|
||||
post:
|
||||
summary: Add new user
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
responses:
|
||||
'200':
|
||||
description: Add result
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
success:
|
||||
type: boolean
|
||||
error:
|
||||
type: string
|
||||
user_json:
|
||||
$ref: '#/components/schemas/User'
|
||||
# post:
|
||||
# summary: Add new user
|
||||
# requestBody:
|
||||
# required: true
|
||||
# content:
|
||||
# application/json:
|
||||
# schema:
|
||||
# $ref: '#/components/schemas/User'
|
||||
# responses:
|
||||
# '200':
|
||||
# description: Add result
|
||||
# content:
|
||||
# application/json:
|
||||
# schema:
|
||||
# type: object
|
||||
# properties:
|
||||
# success:
|
||||
# type: boolean
|
||||
# error:
|
||||
# type: string
|
||||
# user_json:
|
||||
# $ref: '#/components/schemas/User'
|
||||
|
||||
# /users/{user_id}/titles:
|
||||
# get:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue