201 lines
4.3 KiB
Go
201 lines
4.3 KiB
Go
|
// Code generated by go-swagger; DO NOT EDIT.
|
||
|
|
||
|
package models
|
||
|
|
||
|
// This file was generated by the swagger tool.
|
||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/go-openapi/errors"
|
||
|
"github.com/go-openapi/strfmt"
|
||
|
"github.com/go-openapi/swag"
|
||
|
"github.com/go-openapi/validate"
|
||
|
)
|
||
|
|
||
|
// Milestone Milestone milestone is a collection of issues on one repository
|
||
|
//
|
||
|
// swagger:model Milestone
|
||
|
type Milestone struct {
|
||
|
|
||
|
// closed
|
||
|
// Format: date-time
|
||
|
Closed strfmt.DateTime `json:"closed_at,omitempty"`
|
||
|
|
||
|
// closed issues
|
||
|
ClosedIssues int64 `json:"closed_issues,omitempty"`
|
||
|
|
||
|
// created
|
||
|
// Format: date-time
|
||
|
Created strfmt.DateTime `json:"created_at,omitempty"`
|
||
|
|
||
|
// deadline
|
||
|
// Format: date-time
|
||
|
Deadline strfmt.DateTime `json:"due_on,omitempty"`
|
||
|
|
||
|
// description
|
||
|
Description string `json:"description,omitempty"`
|
||
|
|
||
|
// ID
|
||
|
ID int64 `json:"id,omitempty"`
|
||
|
|
||
|
// open issues
|
||
|
OpenIssues int64 `json:"open_issues,omitempty"`
|
||
|
|
||
|
// title
|
||
|
Title string `json:"title,omitempty"`
|
||
|
|
||
|
// updated
|
||
|
// Format: date-time
|
||
|
Updated strfmt.DateTime `json:"updated_at,omitempty"`
|
||
|
|
||
|
// state
|
||
|
State StateType `json:"state,omitempty"`
|
||
|
}
|
||
|
|
||
|
// Validate validates this milestone
|
||
|
func (m *Milestone) Validate(formats strfmt.Registry) error {
|
||
|
var res []error
|
||
|
|
||
|
if err := m.validateClosed(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.validateCreated(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.validateDeadline(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.validateUpdated(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.validateState(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if len(res) > 0 {
|
||
|
return errors.CompositeValidationError(res...)
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *Milestone) validateClosed(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Closed) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := validate.FormatOf("closed_at", "body", "date-time", m.Closed.String(), formats); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *Milestone) validateCreated(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Created) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := validate.FormatOf("created_at", "body", "date-time", m.Created.String(), formats); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *Milestone) validateDeadline(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Deadline) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := validate.FormatOf("due_on", "body", "date-time", m.Deadline.String(), formats); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *Milestone) validateUpdated(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Updated) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := validate.FormatOf("updated_at", "body", "date-time", m.Updated.String(), formats); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *Milestone) validateState(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.State) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := m.State.Validate(formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("state")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("state")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// ContextValidate validate this milestone based on the context it is used
|
||
|
func (m *Milestone) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||
|
var res []error
|
||
|
|
||
|
if err := m.contextValidateState(ctx, formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if len(res) > 0 {
|
||
|
return errors.CompositeValidationError(res...)
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *Milestone) contextValidateState(ctx context.Context, formats strfmt.Registry) error {
|
||
|
|
||
|
if swag.IsZero(m.State) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := m.State.ContextValidate(ctx, formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("state")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("state")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// MarshalBinary interface implementation
|
||
|
func (m *Milestone) MarshalBinary() ([]byte, error) {
|
||
|
if m == nil {
|
||
|
return nil, nil
|
||
|
}
|
||
|
return swag.WriteJSON(m)
|
||
|
}
|
||
|
|
||
|
// UnmarshalBinary interface implementation
|
||
|
func (m *Milestone) UnmarshalBinary(b []byte) error {
|
||
|
var res Milestone
|
||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
*m = res
|
||
|
return nil
|
||
|
}
|