From 287c149f923711c46dfa37af4e162c1b0416f899 Mon Sep 17 00:00:00 2001 From: Andrey Kuzmin Date: Sat, 27 Apr 2019 12:44:12 +0200 Subject: [PATCH] Regenerate v2 models Signed-off-by: Andrey Kuzmin --- api/v2/models/alert_group.go | 20 ++++++++++---------- api/v2/restapi/embedded_spec.go | 10 ++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/api/v2/models/alert_group.go b/api/v2/models/alert_group.go index dcb271ca4..92a4b9182 100644 --- a/api/v2/models/alert_group.go +++ b/api/v2/models/alert_group.go @@ -26,6 +26,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // AlertGroup alert group @@ -33,13 +34,16 @@ import ( type AlertGroup struct { // alerts + // Required: true Alerts []*GettableAlert `json:"alerts"` // labels - Labels LabelSet `json:"labels,omitempty"` + // Required: true + Labels LabelSet `json:"labels"` // receiver - Receiver *Receiver `json:"receiver,omitempty"` + // Required: true + Receiver *Receiver `json:"receiver"` } // Validate validates this alert group @@ -66,8 +70,8 @@ func (m *AlertGroup) Validate(formats strfmt.Registry) error { func (m *AlertGroup) validateAlerts(formats strfmt.Registry) error { - if swag.IsZero(m.Alerts) { // not required - return nil + if err := validate.Required("alerts", "body", m.Alerts); err != nil { + return err } for i := 0; i < len(m.Alerts); i++ { @@ -91,10 +95,6 @@ func (m *AlertGroup) validateAlerts(formats strfmt.Registry) error { func (m *AlertGroup) 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") @@ -107,8 +107,8 @@ func (m *AlertGroup) validateLabels(formats strfmt.Registry) error { func (m *AlertGroup) validateReceiver(formats strfmt.Registry) error { - if swag.IsZero(m.Receiver) { // not required - return nil + if err := validate.Required("receiver", "body", m.Receiver); err != nil { + return err } if m.Receiver != nil { diff --git a/api/v2/restapi/embedded_spec.go b/api/v2/restapi/embedded_spec.go index 08201bf4e..c13f93ff5 100644 --- a/api/v2/restapi/embedded_spec.go +++ b/api/v2/restapi/embedded_spec.go @@ -395,6 +395,11 @@ func init() { }, "alertGroup": { "type": "object", + "required": [ + "labels", + "receiver", + "alerts" + ], "properties": { "alerts": { "type": "array", @@ -1199,6 +1204,11 @@ func init() { }, "alertGroup": { "type": "object", + "required": [ + "labels", + "receiver", + "alerts" + ], "properties": { "alerts": { "type": "array",