github.com/circl-dev/go-swagger@v0.31.0/examples/todo-list-strict/restapi/operations/todos/update_one_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package todos 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "net/http" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/circl-dev/runtime" 14 "github.com/circl-dev/runtime/middleware" 15 16 "github.com/circl-dev/go-swagger/examples/todo-list-strict/models" 17 ) 18 19 // NewUpdateOneParams creates a new UpdateOneParams object 20 // no default values defined in spec. 21 func NewUpdateOneParams() UpdateOneParams { 22 23 return UpdateOneParams{} 24 } 25 26 // UpdateOneParams contains all the bound params for the update one operation 27 // typically these are obtained from a http.Request 28 // 29 // swagger:parameters updateOne 30 type UpdateOneParams struct { 31 32 // HTTP Request Object 33 HTTPRequest *http.Request `json:"-"` 34 35 /* 36 In: body 37 */ 38 Body *models.Item 39 /* 40 Required: true 41 In: path 42 */ 43 ID string 44 } 45 46 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 47 // for simple values it will use straight method calls. 48 // 49 // To ensure default values, the struct must have been initialized with NewUpdateOneParams() beforehand. 50 func (o *UpdateOneParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 51 var res []error 52 53 o.HTTPRequest = r 54 55 if runtime.HasBody(r) { 56 defer r.Body.Close() 57 var body models.Item 58 if err := route.Consumer.Consume(r.Body, &body); err != nil { 59 res = append(res, errors.NewParseError("body", "body", "", err)) 60 } else { 61 // validate body object 62 if err := body.Validate(route.Formats); err != nil { 63 res = append(res, err) 64 } 65 66 if len(res) == 0 { 67 o.Body = &body 68 } 69 } 70 } 71 rID, rhkID, _ := route.Params.GetOK("id") 72 if err := o.bindID(rID, rhkID, route.Formats); err != nil { 73 res = append(res, err) 74 } 75 76 if len(res) > 0 { 77 return errors.CompositeValidationError(res...) 78 } 79 return nil 80 } 81 82 // bindID binds and validates parameter ID from path. 83 func (o *UpdateOneParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { 84 var raw string 85 if len(rawData) > 0 { 86 raw = rawData[len(rawData)-1] 87 } 88 89 // Required: true 90 // Parameter is provided by construction from the route 91 92 o.ID = raw 93 94 return nil 95 }