# fastapi.exceptions.FastAPIError: Invalid args for response field! Hint: check that typing.Union[str, NoneType] is a valid Pydantic field type.

- **ID:** `python/fastapi-openapi-schema-generation-error`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A return annotation used a construct FastAPI cannot convert to a Pydantic field (e.g., a custom class without validation, or an unsupported generic).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 0.100+ | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   class Out(BaseModel):
    name: str
@app.get('/x', response_model=Out)
def x(): ...
   ```
2. **** (85% success)
   ```
   from typing import Any
@app.get('/x')
def x() -> Any: ...
   ```

## Dead Ends

- **** — Loses schema and docs; underlying type issue remains. (70% fail)
- **** — Bypasses OpenAPI generation but not validation. (85% fail)
