github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/generated/models/order.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     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  	"context"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/strfmt"
    13  	"github.com/go-openapi/swag"
    14  	"github.com/go-openapi/validate"
    15  )
    16  
    17  // Order order
    18  //
    19  // swagger:model Order
    20  type Order struct {
    21  
    22  	// complete
    23  	Complete bool `json:"complete,omitempty"`
    24  
    25  	// id
    26  	ID int64 `json:"id,omitempty"`
    27  
    28  	// pet Id
    29  	PetID int64 `json:"petId,omitempty"`
    30  
    31  	// quantity
    32  	Quantity int32 `json:"quantity,omitempty"`
    33  
    34  	// ship date
    35  	// Format: date-time
    36  	ShipDate strfmt.DateTime `json:"shipDate,omitempty"`
    37  
    38  	// Order Status
    39  	Status string `json:"status,omitempty"`
    40  }
    41  
    42  // Validate validates this order
    43  func (m *Order) Validate(formats strfmt.Registry) error {
    44  	var res []error
    45  
    46  	if err := m.validateShipDate(formats); err != nil {
    47  		res = append(res, err)
    48  	}
    49  
    50  	if len(res) > 0 {
    51  		return errors.CompositeValidationError(res...)
    52  	}
    53  	return nil
    54  }
    55  
    56  func (m *Order) validateShipDate(formats strfmt.Registry) error {
    57  	if swag.IsZero(m.ShipDate) { // not required
    58  		return nil
    59  	}
    60  
    61  	if err := validate.FormatOf("shipDate", "body", "date-time", m.ShipDate.String(), formats); err != nil {
    62  		return err
    63  	}
    64  
    65  	return nil
    66  }
    67  
    68  // ContextValidate validates this order based on context it is used
    69  func (m *Order) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    70  	return nil
    71  }
    72  
    73  // MarshalBinary interface implementation
    74  func (m *Order) MarshalBinary() ([]byte, error) {
    75  	if m == nil {
    76  		return nil, nil
    77  	}
    78  	return swag.WriteJSON(m)
    79  }
    80  
    81  // UnmarshalBinary interface implementation
    82  func (m *Order) UnmarshalBinary(b []byte) error {
    83  	var res Order
    84  	if err := swag.ReadJSON(b, &res); err != nil {
    85  		return err
    86  	}
    87  	*m = res
    88  	return nil
    89  }