github.com/Bio-core/jtree@v0.0.0-20190705165106-1d7a7e7d6272/restapi/operations/add_patient_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package operations 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/runtime" 13 "github.com/go-openapi/runtime/middleware" 14 15 "github.com/Bio-core/jtree/models" 16 ) 17 18 // NewAddPatientParams creates a new AddPatientParams object 19 // with the default values initialized. 20 func NewAddPatientParams() AddPatientParams { 21 var () 22 return AddPatientParams{} 23 } 24 25 // AddPatientParams contains all the bound params for the add patient operation 26 // typically these are obtained from a http.Request 27 // 28 // swagger:parameters addPatient 29 type AddPatientParams struct { 30 31 // HTTP Request Object 32 HTTPRequest *http.Request `json:"-"` 33 34 /*Patient 35 In: body 36 */ 37 Patient *models.Patient 38 } 39 40 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 // for simple values it will use straight method calls 42 func (o *AddPatientParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 43 var res []error 44 o.HTTPRequest = r 45 46 if runtime.HasBody(r) { 47 defer r.Body.Close() 48 var body models.Patient 49 if err := route.Consumer.Consume(r.Body, &body); err != nil { 50 res = append(res, errors.NewParseError("patient", "body", "", err)) 51 } else { 52 if err := body.Validate(route.Formats); err != nil { 53 res = append(res, err) 54 } 55 56 if len(res) == 0 { 57 o.Patient = &body 58 } 59 } 60 61 } 62 63 if len(res) > 0 { 64 return errors.CompositeValidationError(res...) 65 } 66 return nil 67 }