resolveSchemaWithOneOf resolves a schema that may contain oneOf, choosing the object variant for suggestions
(schema map[string]any)
| 153 | |
| 154 | // resolveSchemaWithOneOf resolves a schema that may contain oneOf, choosing the object variant for suggestions |
| 155 | func 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 |
| 180 | func generateFieldSuggestions(invalidProps, acceptedFields []string) string { |
no outgoing calls
no test coverage detected