MCPcopy Create free account
hub / github.com/goadesign/goa / Merge

Method Merge

http/codegen/openapi/merge.go:12–37  ·  view source on GitHub ↗

Merge does a two level deep merge of other into s.

(other *Schema)

Source from the content-addressed store, hash-verified

10
11// Merge does a two level deep merge of other into s.
12func (s *Schema) Merge(other *Schema) {
13 items := s.createMergeItems(other)
14 for _, v := range items {
15 if v.needed && v.b != nil {
16 reflect.Indirect(reflect.ValueOf(v.a)).Set(reflect.ValueOf(v.b))
17 }
18 }
19
20 for n, p := range other.Properties {
21 if _, ok := s.Properties[n]; !ok {
22 if s.Properties == nil {
23 s.Properties = make(map[string]*Schema)
24 }
25 s.Properties[n] = p
26 }
27 }
28
29 for n, d := range other.Defs {
30 if _, ok := s.Defs[n]; !ok {
31 s.Defs[n] = d
32 }
33 }
34
35 s.Links = append(s.Links, other.Links...)
36 s.Required = append(s.Required, other.Required...)
37}
38
39func (s *Schema) createMergeItems(other *Schema) mergeItems {
40 minInt := func(a, b *int) bool { return (a == nil && b != nil) || (a != nil && b != nil && *a > *b) }

Callers 2

makeHTTPTypeRecursiveFunction · 0.45
buildAttributeSchemaFunction · 0.45

Calls 2

createMergeItemsMethod · 0.95
SetMethod · 0.80

Tested by

no test coverage detected