mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
Wired up callbacks to what-changed for operations.
It was a todo that I needed to loop back on. now operational Signed-off-by: Dave Shanley <dshanley@splunk.com>
This commit is contained in:
@@ -25,8 +25,7 @@ type OperationChanges struct {
|
||||
RequestBodyChanges *RequestBodyChanges
|
||||
ServerChanges []*ServerChanges
|
||||
ExtensionChanges *ExtensionChanges
|
||||
// todo: callbacks need implementing.
|
||||
//CallbackChanges map[string]*CallbackChanges
|
||||
CallbackChanges map[string]*CallbackChanges
|
||||
}
|
||||
|
||||
func (o *OperationChanges) TotalChanges() int {
|
||||
@@ -49,7 +48,9 @@ func (o *OperationChanges) TotalChanges() int {
|
||||
for k := range o.ServerChanges {
|
||||
c += o.ServerChanges[k].TotalChanges()
|
||||
}
|
||||
// todo: add callbacks in here.
|
||||
for k := range o.CallbackChanges {
|
||||
c += o.CallbackChanges[k].TotalChanges()
|
||||
}
|
||||
if o.ExtensionChanges != nil {
|
||||
c += o.ExtensionChanges.TotalChanges()
|
||||
}
|
||||
@@ -70,6 +71,9 @@ func (o *OperationChanges) TotalBreakingChanges() int {
|
||||
for k := range o.SecurityRequirementChanges {
|
||||
c += o.SecurityRequirementChanges[k].TotalBreakingChanges()
|
||||
}
|
||||
for k := range o.CallbackChanges {
|
||||
c += o.CallbackChanges[k].TotalBreakingChanges()
|
||||
}
|
||||
if o.RequestBodyChanges != nil {
|
||||
c += o.RequestBodyChanges.TotalBreakingChanges()
|
||||
}
|
||||
@@ -342,6 +346,22 @@ func CompareOperations(l, r any) *OperationChanges {
|
||||
rOperation.RequestBody.Value)
|
||||
}
|
||||
|
||||
// callbacks
|
||||
if !lOperation.GetCallbacks().IsEmpty() && !rOperation.GetCallbacks().IsEmpty() {
|
||||
oc.CallbackChanges = CheckMapForChanges(lOperation.Callbacks.Value, rOperation.Callbacks.Value, &changes,
|
||||
v3.CallbacksLabel, CompareCallback)
|
||||
}
|
||||
if !lOperation.GetCallbacks().IsEmpty() && rOperation.GetCallbacks().IsEmpty() {
|
||||
CreateChange(&changes, PropertyRemoved, v3.CallbacksLabel,
|
||||
lOperation.Callbacks.ValueNode, nil, true, lOperation.Callbacks.Value,
|
||||
nil)
|
||||
}
|
||||
if lOperation.Callbacks.IsEmpty() && !rOperation.Callbacks.IsEmpty() {
|
||||
CreateChange(&changes, PropertyAdded, v3.CallbacksLabel,
|
||||
nil, rOperation.Callbacks.ValueNode, true, nil,
|
||||
rOperation.Callbacks.Value)
|
||||
}
|
||||
|
||||
// servers
|
||||
oc.ServerChanges = checkServers(lOperation.Servers, rOperation.Servers)
|
||||
oc.ExtensionChanges = CompareExtensions(lOperation.Extensions, rOperation.Extensions)
|
||||
|
||||
Reference in New Issue
Block a user