INNER CODE UNIT · Go
applyRequiredFieldsFor
stacklok/toolhive · cmd/help/openapi-normalize/main.go:246
func applyRequiredFieldsFor(schemas map[string]any, renames map[string]string, fieldsBySchema map[string][]string) error {
for sourceName, fields := range fieldsBySchema {
normalizedName, exists := renames[sourceName]
if !exists {
normalizedName = publicSchemaName(sourceName)
if _, normalizedExists := schemas[normalizedName]; !normalizedExists {
return fmt.Errorf("required-field override references missing schema %q", sourceName)
}
}
schema, ok := object(schemas[normalizedName])
if !ok {
return fmt.Errorf("required-field override schema %q is not an object", sourceName)
}
properties, ok := object(schema["properties"])
if !ok {
return fmt.Errorf("required-field override schema %q has no properties", sourceName)
}
existing, validRequired := stringsSlice(schema["required"])