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

Function removeNullFromType

pkg/tools/schema.go:107–133  ·  view source on GitHub ↗
(prop map[string]any)

Source from the content-addressed store, hash-verified

105}
106
107func removeNullFromType(prop map[string]any) {
108 typeVal, exists := prop["type"]
109 if !exists {
110 return
111 }
112 arr, ok := typeVal.([]any)
113 if !ok {
114 return
115 }
116
117 filtered := arr[:0]
118 for _, t := range arr {
119 if s, ok := t.(string); ok && s == "null" {
120 continue
121 }
122 filtered = append(filtered, t)
123 }
124
125 switch len(filtered) {
126 case 0:
127 // All entries were "null"; leave the schema alone.
128 case 1:
129 prop["type"] = filtered[0]
130 default:
131 prop["type"] = filtered
132 }
133}
134
135// ensurePropertyTypes recursively walks a JSON Schema map and ensures
136// every property has a "type" set, defaulting to "object" if missing.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected