github.com/circl-dev/go-swagger@v0.31.0/examples/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package pet 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/go-openapi/swag" 14 "github.com/circl-dev/runtime/middleware" 15 ) 16 17 // NewPetDeleteParams creates a new PetDeleteParams object 18 // 19 // There are no default values defined in the spec. 20 func NewPetDeleteParams() PetDeleteParams { 21 22 return PetDeleteParams{} 23 } 24 25 // PetDeleteParams contains all the bound params for the pet delete operation 26 // typically these are obtained from a http.Request 27 // 28 // swagger:parameters PetDelete 29 type PetDeleteParams struct { 30 31 // HTTP Request Object 32 HTTPRequest *http.Request `json:"-"` 33 34 /* 35 In: header 36 */ 37 APIKey *string 38 /*Pet id to delete 39 Required: true 40 In: path 41 */ 42 PetID int64 43 } 44 45 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 46 // for simple values it will use straight method calls. 47 // 48 // To ensure default values, the struct must have been initialized with NewPetDeleteParams() beforehand. 49 func (o *PetDeleteParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 50 var res []error 51 52 o.HTTPRequest = r 53 54 if err := o.bindAPIKey(r.Header[http.CanonicalHeaderKey("api_key")], true, route.Formats); err != nil { 55 res = append(res, err) 56 } 57 58 rPetID, rhkPetID, _ := route.Params.GetOK("petId") 59 if err := o.bindPetID(rPetID, rhkPetID, route.Formats); err != nil { 60 res = append(res, err) 61 } 62 if len(res) > 0 { 63 return errors.CompositeValidationError(res...) 64 } 65 return nil 66 } 67 68 // bindAPIKey binds and validates parameter APIKey from header. 69 func (o *PetDeleteParams) bindAPIKey(rawData []string, hasKey bool, formats strfmt.Registry) error { 70 var raw string 71 if len(rawData) > 0 { 72 raw = rawData[len(rawData)-1] 73 } 74 75 // Required: false 76 77 if raw == "" { // empty values pass all other validations 78 return nil 79 } 80 o.APIKey = &raw 81 82 return nil 83 } 84 85 // bindPetID binds and validates parameter PetID from path. 86 func (o *PetDeleteParams) bindPetID(rawData []string, hasKey bool, formats strfmt.Registry) error { 87 var raw string 88 if len(rawData) > 0 { 89 raw = rawData[len(rawData)-1] 90 } 91 92 // Required: true 93 // Parameter is provided by construction from the route 94 95 value, err := swag.ConvertInt64(raw) 96 if err != nil { 97 return errors.InvalidType("petId", "path", "int64", raw) 98 } 99 o.PetID = value 100 101 return nil 102 }