github.com/circl-dev/go-swagger@v0.31.0/examples/contributed-templates/stratoscale/restapi/operations/store/order_delete_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package store
     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  	"github.com/circl-dev/validate"
    16  )
    17  
    18  // NewOrderDeleteParams creates a new OrderDeleteParams object
    19  //
    20  // There are no default values defined in the spec.
    21  func NewOrderDeleteParams() OrderDeleteParams {
    22  
    23  	return OrderDeleteParams{}
    24  }
    25  
    26  // OrderDeleteParams contains all the bound params for the order delete operation
    27  // typically these are obtained from a http.Request
    28  //
    29  // swagger:parameters OrderDelete
    30  type OrderDeleteParams struct {
    31  
    32  	// HTTP Request Object
    33  	HTTPRequest *http.Request `json:"-"`
    34  
    35  	/*ID of the order that needs to be deleted
    36  	  Required: true
    37  	  Minimum: 1
    38  	  In: path
    39  	*/
    40  	OrderID int64
    41  }
    42  
    43  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    44  // for simple values it will use straight method calls.
    45  //
    46  // To ensure default values, the struct must have been initialized with NewOrderDeleteParams() beforehand.
    47  func (o *OrderDeleteParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    48  	var res []error
    49  
    50  	o.HTTPRequest = r
    51  
    52  	rOrderID, rhkOrderID, _ := route.Params.GetOK("orderId")
    53  	if err := o.bindOrderID(rOrderID, rhkOrderID, route.Formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  	if len(res) > 0 {
    57  		return errors.CompositeValidationError(res...)
    58  	}
    59  	return nil
    60  }
    61  
    62  // bindOrderID binds and validates parameter OrderID from path.
    63  func (o *OrderDeleteParams) bindOrderID(rawData []string, hasKey bool, formats strfmt.Registry) error {
    64  	var raw string
    65  	if len(rawData) > 0 {
    66  		raw = rawData[len(rawData)-1]
    67  	}
    68  
    69  	// Required: true
    70  	// Parameter is provided by construction from the route
    71  
    72  	value, err := swag.ConvertInt64(raw)
    73  	if err != nil {
    74  		return errors.InvalidType("orderId", "path", "int64", raw)
    75  	}
    76  	o.OrderID = value
    77  
    78  	if err := o.validateOrderID(formats); err != nil {
    79  		return err
    80  	}
    81  
    82  	return nil
    83  }
    84  
    85  // validateOrderID carries on validations for parameter OrderID
    86  func (o *OrderDeleteParams) validateOrderID(formats strfmt.Registry) error {
    87  
    88  	if err := validate.MinimumInt("orderId", "path", o.OrderID, 1, false); err != nil {
    89  		return err
    90  	}
    91  
    92  	return nil
    93  }