Ai
3 Star 2 Fork 0

Gitee 极速下载/go-swagger

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/go-swagger/go-swagger
Clone or Download
update_pet_parameters.go 1.46 KB
Copy Edit Raw Blame History
Ivan Porto Carrero authored 2015-12-25 13:01 +08:00 . fixes #132 use pointers for nullables
package pet
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-swagger/go-swagger/errors"
"github.com/go-swagger/go-swagger/httpkit/middleware"
"github.com/go-swagger/go-swagger/examples/generated/models"
)
// NewUpdatePetParams creates a new UpdatePetParams object
// with the default values initialized.
func NewUpdatePetParams() UpdatePetParams {
return UpdatePetParams{}
}
// UpdatePetParams contains all the bound params for the update pet operation
// typically these are obtained from a http.Request
//
// swagger:parameters updatePet
type UpdatePetParams struct {
/*Pet object that needs to be added to the store
Required: true
In: body
*/
Body *models.Pet
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdatePetParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
var body models.Pet
if err := route.Consumer.Consume(r.Body, &body); err != nil {
res = append(res, errors.NewParseError("body", "body", "", err))
} else {
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mirrors/go-swagger.git
git@gitee.com:mirrors/go-swagger.git
mirrors
go-swagger
go-swagger
v0.2.0

Search