MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / JSONSchemaExtend

Method JSONSchemaExtend

cli/internal/specs/v0/spec.go:56–124  ·  view source on GitHub ↗
(sc *jsonschema.Schema)

Source from the content-addressed store, hash-verified

54}
55
56func (Spec) JSONSchemaExtend(sc *jsonschema.Schema) {
57 // delete & obtain the values
58 source, _ := sc.Properties.Delete("Source")
59 destination, _ := sc.Properties.Delete("Destination")
60 transformer, _ := sc.Properties.Delete("Transformer")
61
62 sc.AllOf = []*jsonschema.Schema{
63 {
64 // `kind: source` implies source spec
65 If: &jsonschema.Schema{
66 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
67 properties := jsonschema.NewProperties()
68 kind := *sc.Properties.Value("kind")
69 kind.Const = "source"
70 kind.Enum = nil
71 properties.Set("kind", &kind)
72 return properties
73 }(),
74 },
75 Then: &jsonschema.Schema{
76 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
77 properties := jsonschema.NewProperties()
78 properties.Set("spec", source)
79 return properties
80 }(),
81 },
82 },
83 {
84 // `kind: destination` implies destination spec
85 If: &jsonschema.Schema{
86 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
87 properties := jsonschema.NewProperties()
88 kind := *sc.Properties.Value("kind")
89 kind.Const = "destination"
90 kind.Enum = nil
91 properties.Set("kind", &kind)
92 return properties
93 }(),
94 },
95 Then: &jsonschema.Schema{
96 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
97 properties := jsonschema.NewProperties()
98 properties.Set("spec", destination)
99 return properties
100 }(),
101 },
102 },
103 {
104 // `kind: transformer` implies transformer spec
105 If: &jsonschema.Schema{
106 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
107 properties := jsonschema.NewProperties()
108 kind := *sc.Properties.Value("kind")
109 kind.Const = "transformer"
110 kind.Enum = nil
111 properties.Set("kind", &kind)
112 return properties
113 }(),

Callers

nothing calls this directly

Calls 2

ValueMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected