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