From e4d1fd3abc725a05515932c73c139ce08698519a Mon Sep 17 00:00:00 2001 From: Cody Fincher <204685+cofin@users.noreply.github.com> Date: Sat, 24 Aug 2024 21:27:46 -0500 Subject: [PATCH] bug(docs): stale reference to pydantic signature models (#3697) Fixes #3259 --- docs/usage/routing/parameters.rst | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/usage/routing/parameters.rst b/docs/usage/routing/parameters.rst index 4355309fce..657ff7252a 100644 --- a/docs/usage/routing/parameters.rst +++ b/docs/usage/routing/parameters.rst @@ -32,8 +32,8 @@ Currently, the following types are supported: * :class:`int`: Accepts ints and floats. * :class:`path`: Accepts valid POSIX paths. * :class:`str`: Accepts all string values. -* ``time``: Accepts time strings with optional timezone compatible with pydantic formats. -* ``timedelta``: Accepts duration strings compatible with the pydantic formats. +* ``time``: Accepts time strings with optional timezone compatible with standard (Pydantic/Msgspec) datetime formats. +* ``timedelta``: Accepts duration strings compatible with the standard (Pydantic/Msgspec) timedelta formats. * ``uuid``: Accepts all uuid values. The types declared in the path :term:`parameter` and the function do not need to match 1:1 - as long as @@ -47,8 +47,7 @@ The :term:`parameter` defined inside the ``path`` :term:`kwarg ` is ty passed as part of the request will be a timestamp in milliseconds without any decimals. The parameter in the function declaration though is typed as :class:`datetime.datetime`. -This works because the int value will be passed to a pydantic model representing the function signature, which will -coerce the :class:`int` into a :class:`~datetime.datetime`. +This works because the int value will be automatically coerced from an :class:`int` into a :class:`~datetime.datetime`. Thus, when the function is called it will be called with a :class:`~datetime.datetime`-typed parameter. @@ -89,11 +88,11 @@ Every :term:`keyword argument ` that is not otherwise specified (for e .. admonition:: Technical details :class: info - These :term:`parameters ` will be parsed from the function signature and used to generate a Pydantic model. + These :term:`parameters ` will be parsed from the function signature and used to generate an internal data model. This model in turn will be used to validate the parameters and generate the OpenAPI schema. - This means that you can also use any pydantic type in the signature, and it will - follow the same kind of validation and parsing as you would get from pydantic. + This ability allows you to use any number of schema/modelling libraries, including Pydantic, Msgspec, Attrs, and Dataclasses, and it will + follow the same kind of validation and parsing as you would get from these libraries. Query :term:`parameters ` come in three basic types: @@ -133,8 +132,6 @@ Type coercion It is possible to coerce query :term:`parameters ` into different types. A query starts out as a :class:`string `, but its values can be parsed into all kinds of types. -Since this is done by Pydantic, everything that works there will work for query parameters as well. - .. literalinclude:: /examples/parameters/query_params_types.py :caption: Coercing query parameters into different types