Merged in jb/openapi (pull request #22)
add openapi infra * add openapi infra Includes generated stubs and all deps * generatetolocation * basesetupoffunctionsandclient * round1controllertests * passintegrationtests * cleanupfromfullsuite * storedjson * fixjsonyaml * fixtests Approved-by: Michael McGuinness
This commit is contained in:
committed by
Michael McGuinness
parent
5ca36b0502
commit
174644b63c
+34
@@ -0,0 +1,34 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/apapsch/go-jsonmerge/v2"
|
||||
)
|
||||
|
||||
// JsonMerge merges two JSON representation into a single object. `data` is the
|
||||
// existing representation and `patch` is the new data to be merged in
|
||||
//
|
||||
// Deprecated: Use JSONMerge instead.
|
||||
func JsonMerge(data, patch json.RawMessage) (json.RawMessage, error) {
|
||||
return JSONMerge(data, patch)
|
||||
}
|
||||
|
||||
// JSONMerge merges two JSON representation into a single object. `data` is the
|
||||
// existing representation and `patch` is the new data to be merged in
|
||||
func JSONMerge(data, patch json.RawMessage) (json.RawMessage, error) {
|
||||
merger := jsonmerge.Merger{
|
||||
CopyNonexistent: true,
|
||||
}
|
||||
if data == nil {
|
||||
data = []byte(`{}`)
|
||||
}
|
||||
if patch == nil {
|
||||
patch = []byte(`{}`)
|
||||
}
|
||||
merged, err := merger.MergeBytes(data, patch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return merged, nil
|
||||
}
|
||||
Reference in New Issue
Block a user