Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7c8c30c
➕ Add mkdocstrings and griffe-typingdoc to dependencies
tiangolo Oct 5, 2023
2efbf3b
🔧 Add mkdocstrings configs to MkDocs
tiangolo Oct 5, 2023
8bf900c
📝 Add first WIP reference page
tiangolo Oct 5, 2023
77ae8a4
⬆️ Upgrade typing-extensions to the minimum version including Doc()
tiangolo Oct 5, 2023
df4c501
📝 Add docs to FastAPI parameters
tiangolo Oct 5, 2023
92573b3
📝 Add docstrings for OpenAPI docs utils
tiangolo Oct 15, 2023
0cae830
📝 Add docstrings for security utils
tiangolo Oct 15, 2023
9830055
📝 Add docstrings for UploadFile
tiangolo Oct 15, 2023
d5518fb
📝 Update docstrings in FastAPI class
tiangolo Oct 15, 2023
da98d29
📝 Add docstrings for path operation methods
tiangolo Oct 15, 2023
3e2a049
📝 Add docstring for jsonable_encoder
tiangolo Oct 15, 2023
8a672af
📝 Add docstrings for exceptions
tiangolo Oct 15, 2023
9341871
📝 Add docstsrings for parameter functions
tiangolo Oct 15, 2023
f77ee85
📝 Add docstrings for responses
tiangolo Oct 15, 2023
a03b4c3
📝 Add docstrings for APIRouter
tiangolo Oct 15, 2023
e06f01f
♻️ Sub-class BackgroundTasks to document it with docstrings
tiangolo Oct 15, 2023
222f6ac
📝 Update usage of background tasks in dependencies
tiangolo Oct 15, 2023
496cf7d
✅ Update tests with new deprecation warnings
tiangolo Oct 15, 2023
6882e9c
📝 Add new reference docs
tiangolo Oct 15, 2023
8d224ed
🔧 Update MkDocs with new reference docs
tiangolo Oct 15, 2023
f55ce13
✅ Update pytest fixture, deprecation is raised only once
tiangolo Oct 15, 2023
864c8eb
🎨 Update format for types in exceptions.py
tiangolo Oct 15, 2023
c9a2fb3
♻️ Update annotations in BackgroundTask, `Annotated` can't take Param…
tiangolo Oct 15, 2023
5ca7caa
✏️ Fix typos caught by @pawamoy
tiangolo Oct 16, 2023
3b11811
🔧 Update and fix MkDocstrings configs from @pawamoy tips
tiangolo Oct 16, 2023
2867297
📝 Update reference docs
tiangolo Oct 17, 2023
136aef8
✏️ Fix typos found by @pawamoy
tiangolo Oct 17, 2023
5fc219b
➕ Add HTTPX as a dependency for docs, for the TestClient
tiangolo Oct 17, 2023
79718d8
🔧 Update MkDocs config, rename websockets reference
tiangolo Oct 17, 2023
d7b1e1b
Merge branch 'master' into ref-docs
tiangolo Oct 17, 2023
b8e9e02
🔇 Add type-ignores for Doc as the stubs haven't been released for mypy
tiangolo Oct 17, 2023
2dc2f80
🔥 Remove duplicated deprecated notice
tiangolo Oct 17, 2023
912a3ec
🔇 Remove typing error for unreleased stub in openapi/docs.py
tiangolo Oct 17, 2023
ed277ea
✅ Add tests for UploadFile for coverage
tiangolo Oct 17, 2023
5b02bc0
⬆️ Upgrade griffe-typingdoc==0.2.2
tiangolo Oct 17, 2023
b7e59f9
📝 Refactor docs structure
tiangolo Oct 17, 2023
a6b92ea
🔨 Update README generation with new index frontmatter and style
tiangolo Oct 17, 2023
0003519
🔨 Update generation of languages, remove from top menu, keep in lang …
tiangolo Oct 17, 2023
ba112c3
Merge branch 'master' into ref-docs
tiangolo Oct 17, 2023
9176a99
📝 Add OpenAPI Pydantic models
tiangolo Oct 18, 2023
eba928c
🔨 Update docs script to not translate Reference and Release Notes
tiangolo Oct 18, 2023
9a8e04b
🔧 Add reference for OpenAPI models
tiangolo Oct 18, 2023
61defbd
🔧 Update MkDocs config for mkdocstrings insiders
tiangolo Oct 18, 2023
f1ec8ac
👷 Install mkdocstring insiders in CI for docs
tiangolo Oct 18, 2023
e2c3672
🐛 Fix MkDocstrings insiders install URL
tiangolo Oct 18, 2023
5b99948
➕ Move dependencies shared by docs and tests to its own requirements …
tiangolo Oct 18, 2023
c34b8c9
👷 Update cache keys for test and docs dependencies
tiangolo Oct 18, 2023
de4c24e
📝 Remove no longer needed __init__ placeholder docstrings
tiangolo Oct 18, 2023
77cb0c7
📝 Move docstring for APIRouter to the class level (not __init__ level)
tiangolo Oct 18, 2023
ac82b9e
🔥 Remove no longer needed dummy placeholder __init__ docstring
tiangolo Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ jobs:
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v06
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt', 'requirements-docs-tests.txt') }}-v06
- name: Install docs extras
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-docs.txt
# Install MkDocs Material Insiders here just to put it in the cache for the rest of the steps
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true'
run: pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
run: |
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
- name: Export Language Codes
id: show-langs
run: |
Expand Down Expand Up @@ -80,13 +83,16 @@ jobs:
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v06
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt', 'requirements-docs-tests.txt') }}-v06
- name: Install docs extras
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-docs.txt
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true'
run: pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
run: |
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
- name: Update Languages
run: python ./scripts/docs.py update-languages
- uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v06
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt', 'requirements-docs-tests.txt') }}-test-v06
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-tests.txt
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v06
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt', 'requirements-docs-tests.txt') }}-test-v06
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-tests.txt
Expand Down
3 changes: 3 additions & 0 deletions docs/en/docs/about/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# About

About FastAPI, its design, inspiration and more. 🤓
5 changes: 5 additions & 0 deletions docs/en/docs/fastapi-people.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
hide:
- navigation
---

# FastAPI People

FastAPI has an amazing community that welcomes people from all backgrounds.
Expand Down
5 changes: 5 additions & 0 deletions docs/en/docs/features.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
hide:
- navigation
---

# Features

## FastAPI features
Expand Down
3 changes: 3 additions & 0 deletions docs/en/docs/help/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Help

Help and get help, contribute, get involved. 🤝
9 changes: 9 additions & 0 deletions docs/en/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
---
hide:
- navigation
---

<style>
.md-content .md-typeset h1 { display: none; }
</style>

<p align="center">
<a href="https://fastapi.tiangolo.com"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" alt="FastAPI"></a>
</p>
Expand Down
5 changes: 5 additions & 0 deletions docs/en/docs/learn/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Learn

Here are the introductory sections and the tutorials to learn **FastAPI**.

You could consider this a **book**, a **course**, the **official** and recommended way to learn FastAPI. 😎
25 changes: 25 additions & 0 deletions docs/en/docs/reference/apirouter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# `APIRouter` class

Here's the reference information for the `APIRouter` class, with all its parameters,
attributes and methods.

You can import the `APIRouter` class directly from `fastapi`:

```python
from fastapi import APIRouter
```

::: fastapi.APIRouter
options:
members:
- websocket
- include_router
- get
- put
- post
- delete
- options
- head
- patch
- trace
- on_event
13 changes: 13 additions & 0 deletions docs/en/docs/reference/background.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Background Tasks - `BackgroundTasks`

You can declare a parameter in a *path operation function* or dependency function
with the type `BackgroundTasks`, and then you can use it to schedule the execution
of background tasks after the response is sent.

You can import it directly from `fastapi`:

```python
from fastapi import BackgroundTasks
```

::: fastapi.BackgroundTasks
32 changes: 32 additions & 0 deletions docs/en/docs/reference/dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Dependencies - `Depends()` and `Security()`

## `Depends()`

Dependencies are handled mainly with the special function `Depends()` that takes a
callable.

Here is the reference for it and its parameters.

You can import it directly from `fastapi`:

```python
from fastapi import Depends
```

::: fastapi.Depends

## `Security()`

For many scenarios, you can handle security (authorization, authentication, etc.) with
dependendencies, using `Depends()`.

But when you want to also declare OAuth2 scopes, you can use `Security()` instead of
`Depends()`.

You can import `Security()` directly from `fastapi`:

```python
from fastapi import Security
```

::: fastapi.Security
3 changes: 3 additions & 0 deletions docs/en/docs/reference/encoders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Encoders - `jsonable_encoder`

::: fastapi.encoders.jsonable_encoder
22 changes: 22 additions & 0 deletions docs/en/docs/reference/exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Exceptions - `HTTPException` and `WebSocketException`

These are the exceptions that you can raise to show errors to the client.

When you raise an exception, as would happen with normal Python, the rest of the
excecution is aborted. This way you can raise these exceptions from anywhere in the
code to abort a request and show the error to the client.

You can use:

* `HTTPException`
* `WebSocketException`

These exceptions can be imported directly from `fastapi`:

```python
from fastapi import HTTPException, WebSocketException
```

::: fastapi.HTTPException

::: fastapi.WebSocketException
32 changes: 32 additions & 0 deletions docs/en/docs/reference/fastapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# `FastAPI` class

Here's the reference information for the `FastAPI` class, with all its parameters,
attributes and methods.

You can import the `FastAPI` class directly from `fastapi`:

```python
from fastapi import FastAPI
```

::: fastapi.FastAPI
options:
members:
- openapi_version
- webhooks
- state
- dependency_overrides
- openapi
- websocket
- include_router
- get
- put
- post
- delete
- options
- head
- patch
- trace
- on_event
- middleware
- exception_handler
13 changes: 13 additions & 0 deletions docs/en/docs/reference/httpconnection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# `HTTPConnection` class

When you want to define dependencies that should be compatible with both HTTP and
WebSockets, you can define a parameter that takes an `HTTPConnection` instead of a
`Request` or a `WebSocket`.

You can import it from `fastapi.requests`:

```python
from fastapi.requests import HTTPConnection
```

::: fastapi.requests.HTTPConnection
7 changes: 7 additions & 0 deletions docs/en/docs/reference/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Reference - Code API

Here's the reference or code API, the classes, functions, parameters, attributes, and
all the FastAPI parts you can use in you applications.

If you want to **learn FastAPI** you are much better off reading the
[FastAPI Tutorial](https://fastapi.tiangolo.com/tutorial/).
46 changes: 46 additions & 0 deletions docs/en/docs/reference/middleware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Middleware

There are several middlewares available provided by Starlette directly.

Read more about them in the
[FastAPI docs for Middleware](https://fastapi.tiangolo.com/advanced/middleware/).

::: fastapi.middleware.cors.CORSMiddleware

It can be imported from `fastapi`:

```python
from fastapi.middleware.cors import CORSMiddleware
```

::: fastapi.middleware.gzip.GZipMiddleware

It can be imported from `fastapi`:

```python
from fastapi.middleware.gzip import GZipMiddleware
```

::: fastapi.middleware.httpsredirect.HTTPSRedirectMiddleware

It can be imported from `fastapi`:

```python
from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware
```

::: fastapi.middleware.trustedhost.TrustedHostMiddleware

It can be imported from `fastapi`:

```python
from fastapi.middleware.trustedhost import TrustedHostMiddleware
```

::: fastapi.middleware.wsgi.WSGIMiddleware

It can be imported from `fastapi`:

```python
from fastapi.middleware.wsgi import WSGIMiddleware
```
11 changes: 11 additions & 0 deletions docs/en/docs/reference/openapi/docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# OpenAPI `docs`

Utilities to handle OpenAPI automatic UI documentation, including Swagger UI (by default at `/docs`) and ReDoc (by default at `/redoc`).

::: fastapi.openapi.docs.get_swagger_ui_html

::: fastapi.openapi.docs.get_redoc_html

::: fastapi.openapi.docs.get_swagger_ui_oauth2_redirect_html

::: fastapi.openapi.docs.swagger_ui_default_parameters
5 changes: 5 additions & 0 deletions docs/en/docs/reference/openapi/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OpenAPI

There are several utilities to handle OpenAPI.

You normally don't need to use them unless you have a specific advanced use case that requires it.
5 changes: 5 additions & 0 deletions docs/en/docs/reference/openapi/models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OpenAPI `models`

OpenAPI Pydantic models used to generate and validate the generated OpenAPI.

::: fastapi.openapi.models
36 changes: 36 additions & 0 deletions docs/en/docs/reference/parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Request Parameters

Here's the reference information for the request parameters.

These are the special functions that you can put in *path operation function*
parameters or dependency functions with `Annotated` to get data from the request.

It includes:

* `Query()`
* `Path()`
* `Body()`
* `Cookie()`
* `Header()`
* `Form()`
* `File()`

You can import them all directly from `fastapi`:

```python
from fastapi import Body, Cookie, File, Form, Header, Path, Query
```

::: fastapi.Query

::: fastapi.Path

::: fastapi.Body

::: fastapi.Cookie

::: fastapi.Header

::: fastapi.Form

::: fastapi.File
18 changes: 18 additions & 0 deletions docs/en/docs/reference/request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# `Request` class

You can declare a parameter in a *path operation function* or dependency to be of type
`Request` and then you can access the raw request object directly, without any
validation, etc.

You can import it directly from `fastapi`:

```python
from fastapi import Request
```

!!! tip
When you want to define dependencies that should be compatible with both HTTP and
WebSockets, you can define a parameter that takes an `HTTPConnection` instead of a
`Request` or a `WebSocket`.

::: fastapi.Request
15 changes: 15 additions & 0 deletions docs/en/docs/reference/response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `Response` class

You can declare a parameter in a *path operation function* or dependency to be of type
`Response` and then you can set data for the response like headers or cookies.

You can also use it directly to create an instance of it and return it from your *path
operations*.

You can import it directly from `fastapi`:

```python
from fastapi import Response
```

::: fastapi.Response
Loading