diff --git a/controller/internal/routes/identity_api_model.go b/controller/internal/routes/identity_api_model.go index 4a2c38af1..d337c1426 100644 --- a/controller/internal/routes/identity_api_model.go +++ b/controller/internal/routes/identity_api_model.go @@ -263,7 +263,7 @@ func MapAdvisorServiceReachabilityToRestEntity(entity *model.AdvisorServiceReach for _, router := range entity.CommonRouters { commonRouters = append(commonRouters, &rest_model.RouterEntityRef{ EntityRef: *ToEntityRef(router.Router.Name, router.Router, EdgeRouterLinkFactory), - IsOnline: router.IsOnline, + IsOnline: &router.IsOnline, }) } diff --git a/rest_model/router_entity_ref.go b/rest_model/router_entity_ref.go index 8d7cf2a6d..7d2cc0bc7 100644 --- a/rest_model/router_entity_ref.go +++ b/rest_model/router_entity_ref.go @@ -33,6 +33,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // RouterEntityRef router entity ref @@ -42,7 +43,8 @@ type RouterEntityRef struct { EntityRef // is online - IsOnline bool `json:"isOnline,omitempty"` + // Required: true + IsOnline *bool `json:"isOnline"` } // UnmarshalJSON unmarshals this object from a JSON structure @@ -56,7 +58,7 @@ func (m *RouterEntityRef) UnmarshalJSON(raw []byte) error { // AO1 var dataAO1 struct { - IsOnline bool `json:"isOnline,omitempty"` + IsOnline *bool `json:"isOnline"` } if err := swag.ReadJSON(raw, &dataAO1); err != nil { return err @@ -77,7 +79,7 @@ func (m RouterEntityRef) MarshalJSON() ([]byte, error) { } _parts = append(_parts, aO0) var dataAO1 struct { - IsOnline bool `json:"isOnline,omitempty"` + IsOnline *bool `json:"isOnline"` } dataAO1.IsOnline = m.IsOnline @@ -99,12 +101,25 @@ func (m *RouterEntityRef) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIsOnline(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } +func (m *RouterEntityRef) validateIsOnline(formats strfmt.Registry) error { + + if err := validate.Required("isOnline", "body", m.IsOnline); err != nil { + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *RouterEntityRef) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/rest_server/embedded_spec.go b/rest_server/embedded_spec.go index b56516d6c..d56a118cb 100644 --- a/rest_server/embedded_spec.go +++ b/rest_server/embedded_spec.go @@ -6818,6 +6818,9 @@ func init() { }, { "type": "object", + "required": [ + "isOnline" + ], "properties": { "isOnline": { "type": "boolean" @@ -22439,6 +22442,9 @@ func init() { }, { "type": "object", + "required": [ + "isOnline" + ], "properties": { "isOnline": { "type": "boolean" diff --git a/specs/swagger.yml b/specs/swagger.yml index ef8d127a6..43aba18ad 100644 --- a/specs/swagger.yml +++ b/specs/swagger.yml @@ -5572,6 +5572,8 @@ definitions: allOf: - $ref: '#/definitions/entityRef' - type: object + required: + - isOnline properties: isOnline: type: boolean