Parameters & Converters¶
The declarations that bind a handler's arguments to parts of the request, and the path converters behind them.
Path
¶
Bases: ParamBase
Path parameter declaration.
from_field_info
classmethod
¶
Build this marker from a pydantic Field carried in Annotated metadata.
Folding it into a marker is what makes it enforced and published: the
slot, the OpenAPI document and the MCP tool schema all read the marker
and none of them knows about FieldInfo. default is the parameter's
own, adopted only when the Field declares none.
with_default
¶
Return a copy of this marker carrying default as its own.
A copy, because one marker can be shared between parameters -
SHARED = Query() used twice must not take the first one's default.
resolve_default
¶
Return a fresh default - calling default_factory when one is set.
Query
¶
Bases: ParamBase
Query parameter declaration.
from_field_info
classmethod
¶
Build this marker from a pydantic Field carried in Annotated metadata.
Folding it into a marker is what makes it enforced and published: the
slot, the OpenAPI document and the MCP tool schema all read the marker
and none of them knows about FieldInfo. default is the parameter's
own, adopted only when the Field declares none.
with_default
¶
Return a copy of this marker carrying default as its own.
A copy, because one marker can be shared between parameters -
SHARED = Query() used twice must not take the first one's default.
resolve_default
¶
Return a fresh default - calling default_factory when one is set.
Header
¶
Bases: ParamBase
HTTP header parameter declaration.
from_field_info
classmethod
¶
Build this marker from a pydantic Field carried in Annotated metadata.
Folding it into a marker is what makes it enforced and published: the
slot, the OpenAPI document and the MCP tool schema all read the marker
and none of them knows about FieldInfo. default is the parameter's
own, adopted only when the Field declares none.
with_default
¶
Return a copy of this marker carrying default as its own.
A copy, because one marker can be shared between parameters -
SHARED = Query() used twice must not take the first one's default.
resolve_default
¶
Return a fresh default - calling default_factory when one is set.
Cookie
¶
Bases: ParamBase
Cookie parameter declaration.
from_field_info
classmethod
¶
Build this marker from a pydantic Field carried in Annotated metadata.
Folding it into a marker is what makes it enforced and published: the
slot, the OpenAPI document and the MCP tool schema all read the marker
and none of them knows about FieldInfo. default is the parameter's
own, adopted only when the Field declares none.
with_default
¶
Return a copy of this marker carrying default as its own.
A copy, because one marker can be shared between parameters -
SHARED = Query() used twice must not take the first one's default.
resolve_default
¶
Return a fresh default - calling default_factory when one is set.
Body
¶
Bases: ParamBase
Request body parameter declaration.
from_field_info
classmethod
¶
Build this marker from a pydantic Field carried in Annotated metadata.
Folding it into a marker is what makes it enforced and published: the
slot, the OpenAPI document and the MCP tool schema all read the marker
and none of them knows about FieldInfo. default is the parameter's
own, adopted only when the Field declares none.
with_default
¶
Return a copy of this marker carrying default as its own.
A copy, because one marker can be shared between parameters -
SHARED = Query() used twice must not take the first one's default.
resolve_default
¶
Return a fresh default - calling default_factory when one is set.
Form
¶
Bases: ParamBase
Form field parameter declaration.
from_field_info
classmethod
¶
Build this marker from a pydantic Field carried in Annotated metadata.
Folding it into a marker is what makes it enforced and published: the
slot, the OpenAPI document and the MCP tool schema all read the marker
and none of them knows about FieldInfo. default is the parameter's
own, adopted only when the Field declares none.
with_default
¶
Return a copy of this marker carrying default as its own.
A copy, because one marker can be shared between parameters -
SHARED = Query() used twice must not take the first one's default.
resolve_default
¶
Return a fresh default - calling default_factory when one is set.
File
¶
Bases: ParamBase
File upload parameter declaration.
from_field_info
classmethod
¶
Build this marker from a pydantic Field carried in Annotated metadata.
Folding it into a marker is what makes it enforced and published: the
slot, the OpenAPI document and the MCP tool schema all read the marker
and none of them knows about FieldInfo. default is the parameter's
own, adopted only when the Field declares none.
with_default
¶
Return a copy of this marker carrying default as its own.
A copy, because one marker can be shared between parameters -
SHARED = Query() used twice must not take the first one's default.
resolve_default
¶
Return a fresh default - calling default_factory when one is set.
Converter
¶
Base class - subclasses override match and may set greedy.
register_converter
¶
register_converter(name: str, converter_cls: type[Converter]) -> None
Register a custom path converter.
After register_converter("slug", SlugConverter), routes may use
{post:slug} and the radix tree coerces the segment through
SlugConverter().match(...). Shadowing a built-in name raises ValueError.
unregister_converter
¶
Remove a converter registered with register_converter.
No-op when name was never registered; a built-in name raises ValueError
as in register_converter. Routes already registered keep the instance they
were built with, so this affects only later registrations.
RouteInfo
¶
Stored route metadata.
RouteMatch
¶
Result of matching a path against the tree.