Skip to content

json_schema_to_type silently returns Any for allOf and oneOf schemas #3839

@strawgate

Description

@strawgate

Description

json_schema_to_type() handles anyOf schemas but has no handling for allOf or oneOf. Both silently resolve to typing.Any, effectively disabling all validation.

allOf is the standard way to compose schemas in OpenAPI 3.x and JSON Schema 2020-12 (schema intersection/inheritance). oneOf is used for discriminated unions. Both are extremely common in real-world specs.

Reproduction

from fastmcp.utilities.json_schema_type import json_schema_to_type

# allOf — standard OpenAPI schema composition
schema = {
    "allOf": [
        {"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]},
        {"type": "object", "properties": {"age": {"type": "integer"}}},
    ]
}
T = json_schema_to_type(schema)
print(T)  # typing.Any — no validation at all!

# oneOf — discriminated union
schema2 = {
    "oneOf": [
        {"type": "string"},
        {"type": "integer"},
    ]
}
T2 = json_schema_to_type(schema2)
print(T2)  # typing.Any

Expected behavior

  • allOf should merge sub-schemas and produce a type with all properties
  • oneOf should produce a Union type

Impact

The client's result.data for any tool whose output schema uses allOf or oneOf gets no type validation — any shape of data is silently accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.openapiRelated to OpenAPI integration, parsing, or code generation features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions