mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 12:37:48 +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
|
RequestBodyChanges *RequestBodyChanges
|
||||||
ServerChanges []*ServerChanges
|
ServerChanges []*ServerChanges
|
||||||
ExtensionChanges *ExtensionChanges
|
ExtensionChanges *ExtensionChanges
|
||||||
// todo: callbacks need implementing.
|
CallbackChanges map[string]*CallbackChanges
|
||||||
//CallbackChanges map[string]*CallbackChanges
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OperationChanges) TotalChanges() int {
|
func (o *OperationChanges) TotalChanges() int {
|
||||||
@@ -49,7 +48,9 @@ func (o *OperationChanges) TotalChanges() int {
|
|||||||
for k := range o.ServerChanges {
|
for k := range o.ServerChanges {
|
||||||
c += o.ServerChanges[k].TotalChanges()
|
c += o.ServerChanges[k].TotalChanges()
|
||||||
}
|
}
|
||||||
// todo: add callbacks in here.
|
for k := range o.CallbackChanges {
|
||||||
|
c += o.CallbackChanges[k].TotalChanges()
|
||||||
|
}
|
||||||
if o.ExtensionChanges != nil {
|
if o.ExtensionChanges != nil {
|
||||||
c += o.ExtensionChanges.TotalChanges()
|
c += o.ExtensionChanges.TotalChanges()
|
||||||
}
|
}
|
||||||
@@ -70,6 +71,9 @@ func (o *OperationChanges) TotalBreakingChanges() int {
|
|||||||
for k := range o.SecurityRequirementChanges {
|
for k := range o.SecurityRequirementChanges {
|
||||||
c += o.SecurityRequirementChanges[k].TotalBreakingChanges()
|
c += o.SecurityRequirementChanges[k].TotalBreakingChanges()
|
||||||
}
|
}
|
||||||
|
for k := range o.CallbackChanges {
|
||||||
|
c += o.CallbackChanges[k].TotalBreakingChanges()
|
||||||
|
}
|
||||||
if o.RequestBodyChanges != nil {
|
if o.RequestBodyChanges != nil {
|
||||||
c += o.RequestBodyChanges.TotalBreakingChanges()
|
c += o.RequestBodyChanges.TotalBreakingChanges()
|
||||||
}
|
}
|
||||||
@@ -342,6 +346,22 @@ func CompareOperations(l, r any) *OperationChanges {
|
|||||||
rOperation.RequestBody.Value)
|
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
|
// servers
|
||||||
oc.ServerChanges = checkServers(lOperation.Servers, rOperation.Servers)
|
oc.ServerChanges = checkServers(lOperation.Servers, rOperation.Servers)
|
||||||
oc.ExtensionChanges = CompareExtensions(lOperation.Extensions, rOperation.Extensions)
|
oc.ExtensionChanges = CompareExtensions(lOperation.Extensions, rOperation.Extensions)
|
||||||
|
|||||||
Reference in New Issue
Block a user