Class AbstractPythonCodegen.PydanticCoercibleType

  • Enclosing class:
    AbstractPythonCodegen

    protected class AbstractPythonCodegen.PydanticCoercibleType
    extends AbstractPythonCodegen.PydanticType
    Pydantic type generator for values that arrive over the wire as strings — server-bound request parameters in path, query, header, and cookie position. These rely on Pydantic's automatic coercion (e.g. "3" -> 3); the strict types emitted by the base AbstractPythonCodegen.PydanticType (StrictInt/StrictStr/StrictFloat, strict=True) disable that coercion and make FastAPI reject otherwise-valid requests with a 422. See issue #21905.

    Request bodies and models are not wire-string values — they carry real JSON types — so they keep the strict base behaviour.