Skip to content

Commit

Permalink
del GetJsonOrigValue and GetJsonNewValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven committed Apr 7, 2024
1 parent 94fcebb commit 08e6402
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func RequestParameterXExtensibleEnumValueRemovedCheck(diffReport *diff.Diff, ope
if paramItem.SchemaDiff.ExtensionsDiff.Modified[diff.XExtensibleEnumExtension] == nil {
continue
}
from, ok := diff.GetJsonOrigValue(paramItem.SchemaDiff.ExtensionsDiff.Modified[diff.XExtensibleEnumExtension])
from, ok := paramItem.SchemaDiff.Base.Extensions[diff.XExtensibleEnumExtension].(json.RawMessage)
if !ok {
continue
}
to, ok := diff.GetJsonNewValue(paramItem.SchemaDiff.ExtensionsDiff.Modified[diff.XExtensibleEnumExtension])
to, ok := paramItem.SchemaDiff.Revision.Extensions[diff.XExtensibleEnumExtension].(json.RawMessage)
if !ok {
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func RequestPropertyXExtensibleEnumValueRemovedCheck(diffReport *diff.Diff, oper
if propertyDiff.ExtensionsDiff.Modified[diff.XExtensibleEnumExtension] == nil {
return
}
from, ok := diff.GetJsonOrigValue(propertyDiff.ExtensionsDiff.Modified[diff.XExtensibleEnumExtension])
from, ok := propertyDiff.Base.Extensions[diff.XExtensibleEnumExtension].(json.RawMessage)
if !ok {
return
}
to, ok := diff.GetJsonOrigValue(propertyDiff.ExtensionsDiff.Modified[diff.XExtensibleEnumExtension])
to, ok := propertyDiff.Base.Extensions[diff.XExtensibleEnumExtension].(json.RawMessage)
if !ok {
return
}
Expand Down
26 changes: 0 additions & 26 deletions diff/json_diff.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package diff

import (
"encoding/json"

"github.com/wI2L/jsondiff"
)

Expand Down Expand Up @@ -43,27 +41,3 @@ func compareJson(source, target interface{}, opts ...jsondiff.Option) (jsonPatch
}
return toJsonPatch(patch), nil
}

// GetJsonOrigValue returns the original value of the diff, only if there is exactly one diff
func GetJsonOrigValue(patch jsonPatch) (json.RawMessage, bool) {
if len(patch) != 1 {
return nil, false
}
result, ok := patch[0].OldValue.(json.RawMessage)
if !ok {
return nil, false
}
return result, true
}

// GetJsonOrigValue returns the new value of the diff, only if there is exactly one diff
func GetJsonNewValue(patch jsonPatch) (json.RawMessage, bool) {
if len(patch) != 1 {
return nil, false
}
result, ok := patch[0].Value.(json.RawMessage)
if !ok {
return nil, false
}
return result, true
}

0 comments on commit 08e6402

Please sign in to comment.