This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/direktiv/apps/go/pkg/apps"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
@@ -21,34 +20,23 @@ import (
|
||||
// swagger:model postParamsBody
|
||||
type PostParamsBody struct {
|
||||
|
||||
// File to create before running commands.
|
||||
Files []apps.DirektivFile `json:"files"`
|
||||
|
||||
// Name of the json input file to utilise
|
||||
Infile string `json:"infile,omitempty"`
|
||||
|
||||
// the filename of the output spreadsheet
|
||||
// Required: true
|
||||
OutFilename *string `json:"out-filename"`
|
||||
|
||||
// Label for the worksheet created in the spreadsheet
|
||||
// Required: true
|
||||
WorksheetName *string `json:"worksheet-name"`
|
||||
// Array of worksheets to create in spreadsheet
|
||||
Sheets []*PostParamsBodySheetsItems `json:"sheets"`
|
||||
}
|
||||
|
||||
// Validate validates this post params body
|
||||
func (m *PostParamsBody) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateFiles(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateOutFilename(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateWorksheetName(formats); err != nil {
|
||||
if err := m.validateSheets(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
@@ -58,27 +46,6 @@ func (m *PostParamsBody) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostParamsBody) validateFiles(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Files) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Files); i++ {
|
||||
|
||||
if err := m.Files[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("files" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("files" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostParamsBody) validateOutFilename(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("out-filename", "body", m.OutFilename); err != nil {
|
||||
@@ -88,10 +55,27 @@ func (m *PostParamsBody) validateOutFilename(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostParamsBody) validateWorksheetName(formats strfmt.Registry) error {
|
||||
func (m *PostParamsBody) validateSheets(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Sheets) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Sheets); i++ {
|
||||
if swag.IsZero(m.Sheets[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Sheets[i] != nil {
|
||||
if err := m.Sheets[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("sheets" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("sheets" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := validate.Required("worksheet-name", "body", m.WorksheetName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -101,7 +85,7 @@ func (m *PostParamsBody) validateWorksheetName(formats strfmt.Registry) error {
|
||||
func (m *PostParamsBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateFiles(ctx, formats); err != nil {
|
||||
if err := m.contextValidateSheets(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
@@ -111,17 +95,19 @@ func (m *PostParamsBody) ContextValidate(ctx context.Context, formats strfmt.Reg
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostParamsBody) contextValidateFiles(ctx context.Context, formats strfmt.Registry) error {
|
||||
func (m *PostParamsBody) contextValidateSheets(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Files); i++ {
|
||||
for i := 0; i < len(m.Sheets); i++ {
|
||||
|
||||
if err := m.Files[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("files" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("files" + "." + strconv.Itoa(i))
|
||||
if m.Sheets[i] != nil {
|
||||
if err := m.Sheets[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("sheets" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("sheets" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
116
build/app/models/post_params_body_sheets_items.go
Normal file
116
build/app/models/post_params_body_sheets_items.go
Normal file
@@ -0,0 +1,116 @@
|
||||
// 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/direktiv/apps/go/pkg/apps"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// PostParamsBodySheetsItems post params body sheets items
|
||||
//
|
||||
// swagger:model postParamsBodySheetsItems
|
||||
type PostParamsBodySheetsItems struct {
|
||||
|
||||
// Name of the json input file to utilise
|
||||
Infile string `json:"infile,omitempty"`
|
||||
|
||||
// File to create before running commands
|
||||
InputFile []apps.DirektivFile `json:"input-file"`
|
||||
|
||||
// Label for the worksheet created in the spreadsheet
|
||||
WorksheetName *string `json:"worksheet-name,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this post params body sheets items
|
||||
func (m *PostParamsBodySheetsItems) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateInputFile(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostParamsBodySheetsItems) validateInputFile(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.InputFile) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.InputFile); i++ {
|
||||
|
||||
if err := m.InputFile[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("input-file" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("input-file" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this post params body sheets items based on the context it is used
|
||||
func (m *PostParamsBodySheetsItems) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateInputFile(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostParamsBodySheetsItems) contextValidateInputFile(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.InputFile); i++ {
|
||||
|
||||
if err := m.InputFile[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("input-file" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("input-file" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *PostParamsBodySheetsItems) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *PostParamsBodySheetsItems) UnmarshalBinary(b []byte) error {
|
||||
var res PostParamsBodySheetsItems
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user