MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / JSONSchemaExtend

Method JSONSchemaExtend

plugins/destination/gremlin/client/spec.go:119–219  ·  view source on GitHub ↗
(sc *jsonschema.Schema)

Source from the content-addressed store, hash-verified

117}
118
119func (Spec) JSONSchemaExtend(sc *jsonschema.Schema) {
120 forceAuthMode := func(sc *jsonschema.Schema, value authMode) *jsonschema.Schema {
121 authMode := *sc.Properties.Value("auth_mode")
122 authMode.Enum = nil
123 authMode.Const = value
124 return &authMode
125 }
126 forceMinLength := func(sc *jsonschema.Schema, field string) *jsonschema.Schema {
127 one := uint64(1)
128 val := *sc.Properties.Value(field)
129 val.MinLength = &one
130 return &val
131 }
132
133 sc.AllOf = append(sc.AllOf, []*jsonschema.Schema{
134 {
135 Title: "auth_mode:aws requires aws_region to be set",
136 If: &jsonschema.Schema{
137 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
138 properties := jsonschema.NewProperties()
139 properties.Set("auth_mode", forceAuthMode(sc, authModeAWS))
140 return properties
141 }(),
142 Required: []string{"auth_mode"},
143 },
144 Then: &jsonschema.Schema{
145 // require properties not to be empty or null
146 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
147 properties := jsonschema.NewProperties()
148 properties.Set("aws_region", forceMinLength(sc, "aws_region"))
149 return properties
150 }(),
151 Required: []string{"aws_region"},
152 },
153 },
154
155 {
156 Title: "auth_mode:basic requires username and password to be set",
157 If: &jsonschema.Schema{
158 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
159 properties := jsonschema.NewProperties()
160 properties.Set("auth_mode", forceAuthMode(sc, authModeBasic))
161 return properties
162 }(),
163 Required: []string{"auth_mode"},
164 },
165 Then: &jsonschema.Schema{
166 // require properties not to be empty or null
167 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
168 properties := jsonschema.NewProperties()
169 properties.Set("username", forceMinLength(sc, "username"))
170 properties.Set("password", forceMinLength(sc, "password"))
171 return properties
172 }(),
173 Required: []string{"username", "password"},
174 },
175 },
176 {

Callers

nothing calls this directly

Calls 2

ValueMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected