package toolkit import "testing" func TestSchemaNilPropertiesBecomesObject(t *testing.T) { s := Schema(nil, nil) props, ok := s["properties"].(map[string]any) if !ok || props == nil { t.Fatalf("properties = %#v, want non-nil object", s["properties"]) } if _, has := s["required"]; has { t.Error("required must be omitted when empty") } } func TestSchemaRequired(t *testing.T) { s := Schema(map[string]any{"a": StrProps("A", true)}, []string{"a"}) req, ok := s["required"].([]string) if !ok || len(req) != 1 || req[0] != "a" { t.Fatalf("required = %#v", s["required"]) } } func TestStrPropsEnum(t *testing.T) { s := StrProps("mode", true, "a", "b") enum, ok := s["enum"].([]string) if !ok || len(enum) != 2 { t.Fatalf("enum = %#v", s["enum"]) } if StrProps("x", false)["enum"] != nil { t.Error("no enum expected without values") } } func TestObjectProps(t *testing.T) { s := ObjectProps("headers", false) if s["type"] != "object" { t.Errorf("type = %v", s["type"]) } if s["additionalProperties"] == nil { t.Error("additionalProperties must be set") } }