anyof-objects
Category: Semantic — schema semantics trigger this rule
Error Codes
| Profile | Code | Severity |
|---|---|---|
| openai.so.2026-04-30 | OAI-S-anyof-objects | Warn |
| anthropic.so.2026-04-30 | ANT-S-anyof-objects | Warn |
Description
anyOf with only object-typed branches may not be fully supported
Provider Evidence
| Profile | Status | Source | Basis |
|---|---|---|---|
| anthropic.so.2026-04-30 | inferred | Anthropic JSON Schema limitations | Each anyOf branch must remain within Anthropic's supported subset. |
| openai.so.2026-04-30 | documented | OpenAI anyOf requirements | — |
Rationale
When all anyOf branches are object-typed, some providers may not correctly resolve the union. Merging branches into a single object schema when appropriate improves compatibility across providers.
Bad Example
{
"type": "object",
"anyOf": [
{ "type": "object", "properties": { "x": { "type": "string" } } },
{ "type": "object", "properties": { "y": { "type": "number" } } }
]
}
Good Example
{
"type": "object",
"properties": {
"x": { "type": "string" },
"y": { "type": "number" }
}
}