MCPcopy Create free account
hub / github.com/github/gh-aw / resolveSchemaWithOneOf

Function resolveSchemaWithOneOf

pkg/parser/schema_suggestions.go:155–177  ·  view source on GitHub ↗

resolveSchemaWithOneOf resolves a schema that may contain oneOf, choosing the object variant for suggestions

(schema map[string]any)

Source from the content-addressed store, hash-verified

153
154// resolveSchemaWithOneOf resolves a schema that may contain oneOf, choosing the object variant for suggestions
155func resolveSchemaWithOneOf(schema map[string]any) map[string]any {
156 // Check if this schema has oneOf
157 if oneOf, ok := schema["oneOf"].([]any); ok {
158 // Look for the first object type in oneOf that has properties
159 for _, variant := range oneOf {
160 if variantMap, ok := variant.(map[string]any); ok {
161 if schemaType, ok := variantMap["type"].(string); ok && schemaType == "object" {
162 if _, hasProperties := variantMap["properties"]; hasProperties {
163 return variantMap
164 }
165 }
166 }
167 }
168 // If no object with properties found, return the first variant
169 if len(oneOf) > 0 {
170 if firstVariant, ok := oneOf[0].(map[string]any); ok {
171 return firstVariant
172 }
173 }
174 }
175
176 return schema
177}
178
179// generateFieldSuggestions creates a helpful suggestion message for invalid field names
180func generateFieldSuggestions(invalidProps, acceptedFields []string) string {

Callers 1

navigateToSchemaPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected