MCPcopy Index your code
hub / github.com/docker/docker-agent / ensurePropertyTypes

Function ensurePropertyTypes

pkg/tools/schema.go:138–162  ·  view source on GitHub ↗

ensurePropertyTypes recursively walks a JSON Schema map and ensures every property has a "type" set, defaulting to "object" if missing. It descends into nested "properties" and array "items".

(schema map[string]any)

Source from the content-addressed store, hash-verified

136// every property has a "type" set, defaulting to "object" if missing.
137// It descends into nested "properties" and array "items".
138func ensurePropertyTypes(schema map[string]any) {
139 props, ok := schema["properties"].(map[string]any)
140 if !ok {
141 return
142 }
143
144 for _, v := range props {
145 prop, ok := v.(map[string]any)
146 if !ok {
147 continue
148 }
149
150 if prop["type"] == nil {
151 prop["type"] = "object"
152 }
153
154 // Recurse into nested object properties.
155 ensurePropertyTypes(prop)
156
157 // Recurse into array items.
158 if items, ok := prop["items"].(map[string]any); ok {
159 ensurePropertyTypes(items)
160 }
161 }
162}
163
164func ConvertSchema(params, v any) error {
165 // First unmarshal to a map to check we have a type and non-nil properties

Callers 1

SchemaToMapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected