add new field in swagger

This commit is contained in:
alteredCoder 2021-10-13 10:21:06 +02:00
parent 21f83b6a0f
commit e96a267144
2 changed files with 46 additions and 1 deletions

View file

@ -6,6 +6,8 @@ package models
// Editing this file might prove futile when you re-run the swagger generate command // Editing this file might prove futile when you re-run the swagger generate command
import ( import (
"context"
"github.com/go-openapi/errors" "github.com/go-openapi/errors"
"github.com/go-openapi/strfmt" "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag" "github.com/go-openapi/swag"
@ -17,7 +19,7 @@ import (
// swagger:model Decision // swagger:model Decision
type Decision struct { type Decision struct {
// duration // the duration of the decisions
// Required: true // Required: true
Duration *string `json:"duration"` Duration *string `json:"duration"`
@ -45,6 +47,9 @@ type Decision struct {
// Required: true // Required: true
Type *string `json:"type"` Type *string `json:"type"`
// the date until the decisions must be active
Until string `json:"until,omitempty"`
// the value of the decision scope : an IP, a range, a username, etc // the value of the decision scope : an IP, a range, a username, etc
// Required: true // Required: true
Value *string `json:"value"` Value *string `json:"value"`
@ -138,6 +143,42 @@ func (m *Decision) validateValue(formats strfmt.Registry) error {
return nil return nil
} }
// ContextValidate validate this decision based on the context it is used
func (m *Decision) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateID(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateSimulated(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Decision) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
return err
}
return nil
}
func (m *Decision) contextValidateSimulated(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "simulated", "body", m.Simulated); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation // MarshalBinary interface implementation
func (m *Decision) MarshalBinary() ([]byte, error) { func (m *Decision) MarshalBinary() ([]byte, error) {
if m == nil { if m == nil {

View file

@ -831,7 +831,11 @@ definitions:
description: 'the value of the decision scope : an IP, a range, a username, etc' description: 'the value of the decision scope : an IP, a range, a username, etc'
type: string type: string
duration: duration:
description: 'the duration of the decisions'
type: string type: string
until:
type: string
description: 'the date until the decisions must be active'
scenario: scenario:
type: string type: string
simulated: simulated: