0% found this document useful (0 votes)
20 views1 page

25

FastAPI takes advantage of type hints to provide editor support, type checks, define requirements, convert and validate request data, and generate OpenAPI documentation.

Uploaded by

Andres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

25

FastAPI takes advantage of type hints to provide editor support, type checks, define requirements, convert and validate request data, and generate OpenAPI documentation.

Uploaded by

Andres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

FastAPI is all based on Pydantic.

You will see a lot more of all this in practice in the Tutorial - User Guide.

Type hints in FastAPI¶


FastAPI takes advantage of these type hints to do several things.

With FastAPI you declare parameters with type hints and you get:

Editor support.
Type checks.
...and FastAPI uses the same declarations to:

Define requirements: from request path parameters, query parameters, headers,


bodies, dependencies, etc.
Convert data: from the request to the required type.
Validate data: coming from each request:
Generating automatic errors returned to the client when the data is invalid.
Document the API using OpenAPI:
which is then used by the automatic interactive documentation user interfaces.
This might all sound abstract. Don't worry. You'll see all this in action in the
Tutorial - User Guide.

The important thing is that by using standard Python types, in a single place
(instead of adding more classes, decorators, etc), FastAPI will do a lot of the
work for you.

Info

If you already went through all the tutorial and came back to see more about types,
a good resource is the "cheat sheet" from mypy.

You might also like