Skip to content

Commit

Permalink
Merge branch 'tiangolo:master' into de/docs/tutorial/response-model.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslindemann committed Oct 18, 2023
2 parents 81497cc + 38f191d commit ed7c563
Show file tree
Hide file tree
Showing 61 changed files with 11,825 additions and 1,010 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/build-docs.yml
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
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
@@ -0,0 +1,3 @@
# About

About FastAPI, its design, inspiration and more. 🤓
5 changes: 5 additions & 0 deletions docs/en/docs/fastapi-people.md
@@ -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
@@ -1,3 +1,8 @@
---
hide:
- navigation
---

# Features

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

Help and get help, contribute, get involved. 🤝
9 changes: 9 additions & 0 deletions docs/en/docs/index.md
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,3 @@
# Encoders - `jsonable_encoder`

::: fastapi.encoders.jsonable_encoder
22 changes: 22 additions & 0 deletions docs/en/docs/reference/exceptions.md
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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

0 comments on commit ed7c563

Please sign in to comment.