autogits/bots-common/gitea-generated/models/issue_template.go
Adam Majer 598ecbbd5a .
2024-07-07 21:12:40 +02:00

182 lines
4.0 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"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// IssueTemplate IssueTemplate represents an issue template for a repository
//
// swagger:model IssueTemplate
type IssueTemplate struct {
// about
About string `json:"about,omitempty"`
// content
Content string `json:"content,omitempty"`
// fields
Fields []*IssueFormField `json:"body"`
// file name
FileName string `json:"file_name,omitempty"`
// name
Name string `json:"name,omitempty"`
// ref
Ref string `json:"ref,omitempty"`
// title
Title string `json:"title,omitempty"`
// labels
Labels IssueTemplateLabels `json:"labels,omitempty"`
}
// Validate validates this issue template
func (m *IssueTemplate) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateFields(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabels(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *IssueTemplate) validateFields(formats strfmt.Registry) error {
if swag.IsZero(m.Fields) { // not required
return nil
}
for i := 0; i < len(m.Fields); i++ {
if swag.IsZero(m.Fields[i]) { // not required
continue
}
if m.Fields[i] != nil {
if err := m.Fields[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("body" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("body" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *IssueTemplate) validateLabels(formats strfmt.Registry) error {
if swag.IsZero(m.Labels) { // not required
return nil
}
if err := m.Labels.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("labels")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("labels")
}
return err
}
return nil
}
// ContextValidate validate this issue template based on the context it is used
func (m *IssueTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateFields(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateLabels(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *IssueTemplate) contextValidateFields(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Fields); i++ {
if m.Fields[i] != nil {
if swag.IsZero(m.Fields[i]) { // not required
return nil
}
if err := m.Fields[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("body" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("body" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *IssueTemplate) contextValidateLabels(ctx context.Context, formats strfmt.Registry) error {
if err := m.Labels.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("labels")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("labels")
}
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *IssueTemplate) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *IssueTemplate) UnmarshalBinary(b []byte) error {
var res IssueTemplate
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}