Compare commits

..

42 Commits

Author SHA1 Message Date
github-actions[bot]
6cbdde2315 📝 Update release notes
[skip ci]
2026-05-24 13:03:53 +00:00
dependabot[bot]
1464678ba6 ⬆ Bump the python-packages group with 15 updates (#15594)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-24 15:03:23 +02:00
github-actions[bot]
1a84bbc00b 📝 Update release notes
[skip ci]
2026-05-24 11:07:04 +00:00
Yurii Motov
3fdc54edab 👷 Configure Dependabot to group updates and update weekly (#15560) 2026-05-24 13:06:37 +02:00
github-actions[bot]
09ba2cec98 📝 Update release notes
[skip ci]
2026-05-24 11:01:06 +00:00
Alexander Li
3e3d38930e ✏️ Use Annotated in inline example in docs/en/docs/tutorial/body-multiple-params.md (#15591) 2026-05-24 13:00:37 +02:00
github-actions[bot]
84f205c8f7 📝 Update release notes
[skip ci]
2026-05-24 10:57:12 +00:00
Ömer 🇹🇷
7baefe7144 📝 Remove "NGINX Unit" from the list of ASGI-servers in docs (#15475) 2026-05-24 12:56:40 +02:00
github-actions[bot]
2895c51ba8 📝 Update release notes
[skip ci]
2026-05-24 10:29:48 +00:00
zadevhub
21c46919fc 📝 Update docs/en/docs/tutorial/security/oauth2-jwt.md (#14781)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: Yurii Motov <109919500+YuriiMotov@users.noreply.github.com>
2026-05-24 10:29:22 +00:00
Sebastián Ramírez
8206485753 🔖 Release version 0.136.3 2026-05-23 20:51:45 +02:00
github-actions[bot]
c910e0139f 📝 Update release notes
[skip ci]
2026-05-23 18:40:42 +00:00
Sebastián Ramírez
063b5bf582 ♻️ Do not accept underscore headers when using convert_underscores=True (the default) (#15589) 2026-05-23 18:35:05 +00:00
Sebastián Ramírez
22b02e26f9 🔖 Release version 0.136.2 2026-05-23 19:24:08 +02:00
github-actions[bot]
3b252a2a22 📝 Update release notes
[skip ci]
2026-05-23 17:23:30 +00:00
Sebastián Ramírez
c7fb7851b3 ♻️ Validate Server Sent Event fields to avoid applications from sending broken data (#15588) 2026-05-23 17:23:05 +00:00
github-actions[bot]
cb83b83dcf 📝 Update release notes
[skip ci]
2026-05-23 17:02:38 +00:00
Sebastián Ramírez
00f805cec9 Update tests, don't double dispose the engine (#15587) 2026-05-23 17:02:16 +00:00
github-actions[bot]
3675137523 📝 Update release notes
[skip ci]
2026-05-23 16:36:21 +00:00
Yurii Motov
7b57e42986 📝 Document --entrypoint CLI option (#15464) 2026-05-23 18:35:54 +02:00
github-actions[bot]
e16894ec5b 📝 Update release notes
[skip ci]
2026-05-23 15:33:10 +00:00
Roman Postnov
8b647e3405 ️ Speed up test suite via caching and fixture scopes to make it ~24% faster (#13583)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2026-05-23 17:32:48 +02:00
github-actions[bot]
4f37a43d32 📝 Update release notes
[skip ci]
2026-05-22 17:16:06 +00:00
Sebastián Ramírez
973230c782 🔥 Remove config files now in central GitHub repo (#15585) 2026-05-22 19:15:08 +02:00
github-actions[bot]
ecd70826eb 📝 Update release notes
[skip ci]
2026-05-22 09:11:29 +00:00
Sebastián Ramírez
c347875c9c 📝 Update and simplify docs about help and management (#15583) 2026-05-22 11:10:53 +02:00
github-actions[bot]
0b9863020d 📝 Update release notes
[skip ci]
2026-05-21 20:03:55 +00:00
Sebastián Ramírez
55a9ff2e5e 📝 Add docs references to central contributing docs (#15580) 2026-05-21 20:03:25 +00:00
github-actions[bot]
b95681eb5b 📝 Update release notes
[skip ci]
2026-05-21 06:55:49 +00:00
dependabot[bot]
c99e215ed8 ⬆ Bump urllib3 from 2.6.3 to 2.7.0 (#15502)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-21 08:55:21 +02:00
github-actions[bot]
4232d80e84 📝 Update release notes
[skip ci]
2026-05-21 06:49:11 +00:00
dependabot[bot]
87d1daeeea ⬆ Bump idna from 3.11 to 3.15 (#15565)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-21 08:48:48 +02:00
github-actions[bot]
60571d7ada 📝 Update release notes
[skip ci]
2026-05-21 06:39:04 +00:00
dependabot[bot]
a314e3be3b ⬆ Bump cloudflare/wrangler-action from 3.15.0 to 4.0.0 (#15571)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-21 08:38:39 +02:00
github-actions[bot]
b11805add7 📝 Update release notes
[skip ci]
2026-05-21 05:29:09 +00:00
Francisco Silva
74d735d518 🌐 Improve translation consistency in ‎docs/pt/docs/advanced/generate-clients.md‎ (#15456)
Co-authored-by: uilton <uilton@meta4chain.com>
Co-authored-by: Yurii Motov <109919500+YuriiMotov@users.noreply.github.com>
2026-05-21 07:28:41 +02:00
github-actions[bot]
ed7f49ed69 📝 Update release notes
[skip ci]
2026-05-20 16:12:24 +00:00
Sebastián Ramírez
3969ae8f38 📝 Update security policy (#15577) 2026-05-20 16:11:48 +00:00
github-actions[bot]
f4cafbc467 📝 Update release notes
[skip ci]
2026-05-19 17:41:11 +00:00
Sebastián Ramírez
31ced9d49e 🔧 Migrate docs from MkDocs to Zensical (#15563) 2026-05-19 19:40:41 +02:00
github-actions[bot]
6f9dcdf61a 📝 Update release notes
[skip ci]
2026-05-19 13:42:52 +00:00
Sebastián Ramírez
2b5cd26248 🍱 Update sponsors: TalorData image (#15562) 2026-05-19 15:42:23 +02:00
67 changed files with 1053 additions and 2662 deletions

1
.github/FUNDING.yml vendored
View File

@@ -1 +0,0 @@
github: [tiangolo]

View File

@@ -4,26 +4,47 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
cooldown:
default-days: 7
commit-message:
prefix:
labels:
- "internal"
- "dependencies"
- "github_actions"
groups:
github-actions:
patterns:
- "*"
# Python
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
cooldown:
default-days: 7
commit-message:
prefix:
groups:
python-packages:
dependency-type: "development"
patterns:
- "*"
# pre-commit
- package-ecosystem: "pre-commit"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
cooldown:
default-days: 7
commit-message:
prefix:
labels:
- "internal"
- "dependencies"
- "pre-commit"
groups:
pre-commit:
patterns:
- "*"

View File

@@ -34,14 +34,13 @@ jobs:
- docs_src/**
- pyproject.toml
- uv.lock
- mkdocs.yml
- mkdocs.env.yml
- .github/workflows/build-docs.yml
- .github/workflows/deploy-docs.yml
- scripts/mkdocs_hooks.py
- scripts/docs.py
langs:
needs:
- changes
if: ${{ needs.changes.outputs.docs == 'true' }}
runs-on: ubuntu-latest
outputs:
langs: ${{ steps.show-langs.outputs.langs }}
@@ -103,21 +102,28 @@ jobs:
run: uv run ./scripts/docs.py update-languages
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: mkdocs-cards-${{ matrix.lang }}-${{ github.ref }}
path: docs/${{ matrix.lang }}/.cache
key: zensical-${{ matrix.lang }}-${{ github.ref }}
path: site_zensical_src/${{ matrix.lang }}/.cache
- name: Build Docs
run: | # zizmor: ignore[template-injection] - comes from trusted source
uv run ./scripts/docs.py build-lang ${{ matrix.lang }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: docs-site-${{ matrix.lang }}
path: ./site/**
# English owns root static assets. Translated pages reference /img, /css,
# and /js, so omit duplicated language-local copies from artifacts.
path: |
./site/**
!./site/${{ matrix.lang }}/img/**
!./site/${{ matrix.lang }}/css/**
!./site/${{ matrix.lang }}/js/**
include-hidden-files: true
# https://github.com/marketplace/actions/alls-green#why
docs-all-green: # This job does nothing and is only used for the branch protection
if: always()
needs:
- langs
- build-docs
runs-on: ubuntu-latest
steps:
@@ -125,4 +131,4 @@ jobs:
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}
allowed-skips: build-docs
allowed-skips: langs, build-docs

View File

@@ -60,7 +60,7 @@ jobs:
env:
PROJECT_NAME: fastapitiangolo
BRANCH: ${{ ( github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'master' && 'main' ) || ( github.event.workflow_run.head_sha ) }}
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3.15.0
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} # zizmor: ignore[secrets-outside-env]
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} # zizmor: ignore[secrets-outside-env]

1
.gitignore vendored
View File

@@ -7,6 +7,7 @@ __pycache__
htmlcov
dist
site
site_zensical_src
.coverage*
coverage.xml
.netlify

View File

@@ -1 +0,0 @@
Please read the [Development - Contributing](https://fastapi.tiangolo.com/contributing/) guidelines in the documentation site.

View File

@@ -1,31 +0,0 @@
# Security Policy
Security is very important for FastAPI and its community. 🔒
Learn more about it below. 👇
## Versions
The latest version of FastAPI is supported.
You are encouraged to [write tests](https://fastapi.tiangolo.com/tutorial/testing/) for your application and update your FastAPI version frequently after ensuring that your tests are passing. This way you will benefit from the latest features, bug fixes, and **security fixes**.
You can learn more about [FastAPI versions and how to pin and upgrade them](https://fastapi.tiangolo.com/deployment/versions/) for your project in the docs.
## Reporting a Vulnerability
If you think you found a vulnerability, and even if you are not sure about it, please report it right away by sending an email to: security@tiangolo.com. Please try to be as explicit as possible, describing all the steps and example code to reproduce the security issue.
I (the author, [@tiangolo](https://x.com/tiangolo)) will review it thoroughly and get back to you.
## Public Discussions
Please restrain from publicly discussing a potential security vulnerability. 🙊
It's better to discuss privately and try to find a solution first, to limit the potential impact as much as possible.
---
Thanks for your help!
The FastAPI community and I thank you for that. 🙇

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,267 +1,7 @@
# Development - Contributing
# Contributing
First, you might want to see the basic ways to [help FastAPI and get help](help-fastapi.md).
## Developing
If you already cloned the [fastapi repository](https://github.com/fastapi/fastapi) and you want to deep dive in the code, here are some guidelines to set up your environment.
### Install requirements
Create a virtual environment and install the required packages with [`uv`](https://github.com/astral-sh/uv):
<div class="termy">
```console
$ uv sync --extra all
---> 100%
```
</div>
It will install all the dependencies and your local FastAPI in your local environment.
### Using your local FastAPI
If you create a Python file that imports and uses FastAPI, and run it with the Python from your local environment, it will use your cloned local FastAPI source code.
And if you update that local FastAPI source code when you run that Python file again, it will use the fresh version of FastAPI you just edited.
That way, you don't have to "install" your local version to be able to test every change.
/// note | Technical Details
This only happens when you install using `uv sync --extra all` instead of running `pip install fastapi` directly.
That is because `uv sync --extra all` will install the local version of FastAPI in "editable" mode by default.
///
### Format the code
There is a script that you can run that will format and clean all your code:
<div class="termy">
```console
$ bash scripts/format.sh
```
</div>
It will also auto-sort all your imports.
## Tests
There is a script that you can run locally to test all the code and generate coverage reports in HTML:
<div class="termy">
```console
$ bash scripts/test-cov-html.sh
```
</div>
This command generates a directory `./htmlcov/`, if you open the file `./htmlcov/index.html` in your browser, you can explore interactively the regions of code that are covered by the tests, and notice if there is any region missing.
## Docs
First, make sure you set up your environment as described above, that will install all the requirements.
### Docs live
During local development, there is a script that builds the site and checks for any changes, live-reloading:
<div class="termy">
```console
$ python ./scripts/docs.py live
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
<span style="color: green;">[INFO]</span> Start watching changes
<span style="color: green;">[INFO]</span> Start detecting changes
```
</div>
It will serve the documentation on `http://127.0.0.1:8008`.
That way, you can edit the documentation/source files and see the changes live.
/// tip
Alternatively, you can perform the same steps that scripts does manually.
Go into the language directory, for the main docs in English it's at `docs/en/`:
```console
$ cd docs/en/
```
Then run `mkdocs` in that directory:
```console
$ mkdocs serve --dev-addr 127.0.0.1:8008
```
///
#### Typer CLI (optional)
The instructions here show you how to use the script at `./scripts/docs.py` with the `python` program directly.
But you can also use [Typer CLI](https://typer.tiangolo.com/typer-cli/), and you will get autocompletion in your terminal for the commands after installing completion.
If you install Typer CLI, you can install completion with:
<div class="termy">
```console
$ typer --install-completion
zsh completion installed in /home/user/.bashrc.
Completion will take effect once you restart the terminal.
```
</div>
### Docs Structure
The documentation uses [MkDocs](https://www.mkdocs.org/).
And there are extra tools/scripts in place to handle translations in `./scripts/docs.py`.
/// tip
You don't need to see the code in `./scripts/docs.py`, you just use it in the command line.
///
All the documentation is in Markdown format in the directory `./docs/en/`.
Many of the tutorials have blocks of code.
In most of the cases, these blocks of code are actual complete applications that can be run as is.
In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs_src/` directory.
And those Python files are included/injected in the documentation when generating the site.
### Docs for tests
Most of the tests actually run against the example source files in the documentation.
This helps to make sure that:
* The documentation is up-to-date.
* The documentation examples can be run as is.
* Most of the features are covered by the documentation, ensured by test coverage.
#### Apps and docs at the same time
If you run the examples with, e.g.:
<div class="termy">
```console
$ fastapi dev tutorial001.py
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
as Uvicorn by default will use the port `8000`, the documentation on port `8008` won't clash.
### Translations
Help with translations is VERY MUCH appreciated! And it can't be done without the help from the community. 🌎 🚀
Translation pull requests are made by LLMs guided with prompts designed by the FastAPI team together with the community of native speakers for each supported language.
#### LLM Prompt per Language
Each language has a directory: [https://github.com/fastapi/fastapi/tree/master/docs](https://github.com/fastapi/fastapi/tree/master/docs), in it you can see a file `llm-prompt.md` with the prompt specific for that language.
For example, for Spanish, the prompt is at: [`docs/es/llm-prompt.md`](https://github.com/fastapi/fastapi/blob/master/docs/es/llm-prompt.md).
If you see mistakes in your language, you can make suggestions to the prompt in that file for your language, and request the specific pages you would like to re-generate after the changes.
#### Reviewing Translation PRs
We dont require approval from native speakers for translation PRs generated automatically by our translation workflow. However, you can still review them and suggest improvements to the LLM prompt for that language to make the future translations better.
You can check the currently [existing pull requests](https://github.com/fastapi/fastapi/pulls) for your language. You can filter the pull requests by the ones with the label for your language. For example, for Spanish, the label is [`lang-es`](https://github.com/fastapi/fastapi/pulls?q=is%3Aopen+sort%3Aupdated-desc+label%3Alang-es+label%3Aawaiting-review).
You can also review already merged translation PRs. To do this, go to the [closed pull requests](https://github.com/fastapi/fastapi/pulls?q=is%3Apr+is%3Aclosed) and filter by your language label. For example, for Spanish, you can use [`lang-es`](https://github.com/fastapi/fastapi/pulls?q=is%3Apr+is%3Aclosed+label%3Alang-es).
When reviewing a pull request, it's better not to suggest changes in the same pull request, because it is LLM generated, and it won't be possible to make sure that small individual changes are replicated in other similar sections, or that they are preserved when translating the same content again.
Instead of adding suggestions to the translation PR, make the suggestions to the LLM prompt file for that language, in a new PR. For example, for Spanish, the LLM prompt file is at: [`docs/es/llm-prompt.md`](https://github.com/fastapi/fastapi/blob/master/docs/es/llm-prompt.md).
/// tip
Check the docs about [adding a pull request review](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-reviews) to approve it or request changes.
///
PRs with suggestions to the language-specific LLM prompt require approval from at least one native speaker. Your help here is very much appreciated!
#### Subscribe to Notifications for Your Language
Check if there's a [GitHub Discussion](https://github.com/fastapi/fastapi/discussions/categories/translations) to coordinate translations for your language. You can subscribe to it, and when there's a new pull request to review, an automatic comment will be added to the discussion.
To check the 2-letter code for the language you want to translate, you can use the table [List of ISO 639-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
#### Request a New Language
Let's say that you want to request translations for a language that is not yet translated, not even some pages. For example, Latin.
* The first step would be for you to find other 2 people that would be willing to be reviewing translation PRs for that language with you.
* Once there are at least 3 people that would be willing to commit to help maintain that language, you can continue the next steps.
* Create a new discussion following the template.
* Tag the other 2 people that will help with the language, and ask them to confirm there they will help.
Once there are several people in the discussion, the FastAPI team can evaluate it and can make it an official translation.
Then the docs will be automatically translated using LLMs, and the team of native speakers can review the translation, and help tweak the LLM prompts.
Once there's a new translation, for example if docs are updated or there's a new section, there will be a comment in the same discussion with the link to the new translation to review.
## Automated Code and AI
You are encouraged to use all the tools you want to do your work and contribute as efficiently as possible, this includes AI (LLM) tools, etc. Nevertheless, contributions should have meaningful human intervention, judgement, context, etc.
If the **human effort** put in a PR, e.g. writing LLM prompts, is **less** than the **effort we would need to put** to **review it**, please **don't** submit the PR.
Think of it this way: we can already write LLM prompts or run automated tools ourselves, and that would be faster than reviewing external PRs.
### Closing Automated and AI PRs
If we see PRs that seem AI generated or automated in similar ways, we'll flag them and close them.
The same applies to comments and descriptions, please don't copy paste the content generated by an LLM.
### Human Effort Denial of Service
Using automated tools and AI to submit PRs or comments that we have to carefully review and handle would be the equivalent of a [Denial-of-service attack](https://en.wikipedia.org/wiki/Denial-of-service_attack) on our human effort.
It would be very little effort from the person submitting the PR (an LLM prompt) that generates a large amount of effort on our side (carefully reviewing code).
Please don't do that.
We'll need to block accounts that spam us with repeated automated PRs or comments.
### Use Tools Wisely
As Uncle Ben said:
<blockquote>
With great <strike>power</strike> <strong>tools</strong> comes great responsibility.
</blockquote>
Avoid inadvertently doing harm.
You have amazing tools at hand, use them wisely to help effectively.
To contribute code to the project, please follow the guidelines in [tiangolo.com - Contributing](https://tiangolo.com/open-source/contributing/).

View File

@@ -56,7 +56,6 @@ There are several alternatives, including:
* [Hypercorn](https://hypercorn.readthedocs.io/): an ASGI server compatible with HTTP/2 and Trio among other features.
* [Daphne](https://github.com/django/daphne): the ASGI server built for Django Channels.
* [Granian](https://github.com/emmett-framework/granian): A Rust HTTP server for Python applications.
* [NGINX Unit](https://unit.nginx.org/howto/fastapi/): NGINX Unit is a lightweight and versatile web application runtime.
## Server Machine and Server Program { #server-machine-and-server-program }

View File

@@ -1,3 +1,8 @@
---
include_yaml:
topic_repos: data/topic_repos.yml
---
# External Links
**FastAPI** has a great community constantly growing.

View File

@@ -95,7 +95,7 @@ which would be equivalent to:
from backend.main import app
```
### `fastapi dev` with path { #fastapi-dev-with-path }
### `fastapi dev` with path or with `--entrypoint` CLI option { #fastapi-dev-with-path-or-with-entrypoint-cli-option }
You can also pass the file path to the `fastapi dev` command, and it will guess the FastAPI app object to use:
@@ -103,7 +103,13 @@ You can also pass the file path to the `fastapi dev` command, and it will guess
$ fastapi dev main.py
```
But you would have to remember to pass the correct path every time you call the `fastapi` command.
Or, you can also pass the `--entrypoint` option to the `fastapi dev` command:
```console
$ fastapi dev --entrypoint main:app
```
But you would have to remember to pass the correct path\entrypoint every time you call the `fastapi` command.
Additionally, other tools might not be able to find it, for example the [VS Code Extension](editor-support.md) or [FastAPI Cloud](https://fastapicloud.com), so it is recommended to use the `entrypoint` in `pyproject.toml`.

View File

@@ -1,6 +1,16 @@
---
hide:
- navigation
include_yaml:
github_sponsors: data/github_sponsors.yml
people: data/people.yml
contributors: data/contributors.yml
translation_reviewers: data/translation_reviewers.yml
skip_users: data/skip_users.yml
members: data/members.yml
sponsors_badge: data/sponsors_badge.yml
sponsors: data/sponsors.yml
---
# FastAPI People

View File

@@ -1,14 +1,8 @@
# Help FastAPI - Get Help { #help-fastapi-get-help }
# Help { #help }
Do you like **FastAPI**?
Would you like to help FastAPI or get help about FastAPI?
Would you like to help FastAPI, other users, and the author?
Or would you like to get help with **FastAPI**?
There are very simple ways to help (several involve just one or two clicks).
And there are several ways to get help too.
There are very simple ways to help and get help.
## Subscribe to the newsletter { #subscribe-to-the-newsletter }
@@ -20,9 +14,13 @@ You can subscribe to the (infrequent) [**FastAPI and friends** newsletter](newsl
* Breaking changes 🚨
* Tips and tricks ✅
## Follow FastAPI on X (Twitter) { #follow-fastapi-on-x-twitter }
## Follow FastAPI online { #follow-fastapi-online }
[Follow @fastapi on **X (Twitter)**](https://x.com/fastapi) to get the latest news about **FastAPI**. 🐦
You can follow **FastAPI** online in several places:
* [@fastapi on **X / Twitter**](https://x.com/fastapi)
* [@fastapi.tiangolo.com on **Bluesky**](https://bsky.app/profile/fastapi.tiangolo.com)
* [FastAPI on **LinkedIn**](https://www.linkedin.com/company/fastapi/)
## Star **FastAPI** in GitHub { #star-fastapi-in-github }
@@ -38,98 +36,28 @@ There you can select "Releases only".
By doing it, you will receive notifications (in your email) whenever there's a new release (a new version) of **FastAPI** with bug fixes and new features.
## Connect with the author { #connect-with-the-author }
## Follow the author { #follow-the-author }
You can connect with [me (Sebastián Ramírez / `tiangolo`)](https://tiangolo.com), the author.
You can follow [me (Sebastián Ramírez / `tiangolo`)](https://tiangolo.com), the author in a few places, to hear when I have news to share about FastAPI and friends:
You can:
* [Follow me on **GitHub**](https://github.com/tiangolo).
* See other Open Source projects I have created that could help you.
* Follow me to see when I create a new Open Source project.
* [Follow me on **X (Twitter)**](https://x.com/tiangolo) or [Mastodon](https://fosstodon.org/@tiangolo).
* Tell me how you use FastAPI (I love to hear that).
* Hear when I make announcements or release new tools.
* You can also [follow @fastapi on X (Twitter)](https://x.com/fastapi) (a separate account).
* [Follow me on **LinkedIn**](https://www.linkedin.com/in/tiangolo/).
* Hear when I make announcements or release new tools (although I use X (Twitter) more often 🤷‍♂).
* Read what I write (or follow me) on [**Dev.to**](https://dev.to/tiangolo) or [**Medium**](https://medium.com/@tiangolo).
* Read other ideas, articles, and read about tools I have created.
* Follow me to read when I publish something new.
## Tweet about **FastAPI** { #tweet-about-fastapi }
[Tweet about **FastAPI**](https://x.com/compose/tweet?text=I'm loving @fastapi because... https://github.com/fastapi/fastapi) and let me and others know why you like it. 🎉
I love to hear about how **FastAPI** is being used, what you have liked in it, in which project/company are you using it, etc.
## Vote for FastAPI { #vote-for-fastapi }
* [Vote for **FastAPI** in Slant](https://www.slant.co/options/34241/~fastapi-review).
* [Vote for **FastAPI** in AlternativeTo](https://alternativeto.net/software/fastapi/about/).
* [Say you use **FastAPI** on StackShare](https://stackshare.io/pypi-fastapi).
* [@tiangolo on **GitHub**](https://github.com/tiangolo).
* [@tiangolo on **X (Twitter)**](https://x.com/tiangolo)
* [@tiangolo.com on **Bluesky**](https://bsky.app/profile/tiangolo.com)
* [@tiangolo on **LinkedIn**](https://www.linkedin.com/in/tiangolo/).
## Help others with questions in GitHub { #help-others-with-questions-in-github }
You can try and help others with their questions in:
* [GitHub Discussions](https://github.com/fastapi/fastapi/discussions/categories/questions?discussions_q=category%3AQuestions+is%3Aunanswered)
* [GitHub Issues](https://github.com/fastapi/fastapi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Aquestion+-label%3Aanswered+)
You can try and help others with their questions in [GitHub Discussions](https://github.com/fastapi/fastapi/discussions/categories/questions?discussions_q=category%3AQuestions+is%3Aunanswered).
In many cases you might already know the answer for those questions. 🤓
If you are helping a lot of people with their questions, you will become an official [FastAPI Expert](fastapi-people.md#fastapi-experts). 🎉
Just remember, the most important point is: try to be kind. People come with their frustrations and in many cases don't ask in the best way, but try as best as you can to be kind. 🤗
Just remember, the most important point is: try to be kind. 🤗
The idea is for the **FastAPI** community to be kind and welcoming. At the same time, don't accept bullying or disrespectful behavior towards others. We have to take care of each other.
### How to Help { #how-to-help }
---
Here's how to help others with questions (in discussions or issues):
### Understand the question { #understand-the-question }
* Check if you can understand what is the **purpose** and use case of the person asking.
* Then check if the question (the vast majority are questions) is **clear**.
* In many cases the question asked is about an imaginary solution from the user, but there might be a **better** one. If you can understand the problem and use case better, you might be able to suggest a better **alternative solution**.
* If you can't understand the question, ask for more **details**.
### Reproduce the problem { #reproduce-the-problem }
For most of the cases and most of the questions there's something related to the person's **original code**.
In many cases they will only copy a fragment of the code, but that's not enough to **reproduce the problem**.
* You can ask them to provide a [minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example), that you can **copy-paste** and run locally to see the same error or behavior they are seeing, or to understand their use case better.
* If you are feeling too generous, you can try to **create an example** like that yourself, just based on the description of the problem. Just keep in mind that this might take a lot of time and it might be better to ask them to clarify the problem first.
### Suggest solutions { #suggest-solutions }
* After being able to understand the question, you can give them a possible **answer**.
* In many cases, it's better to understand their **underlying problem or use case**, because there might be a better way to solve it than what they are trying to do.
### Ask to close { #ask-to-close }
If they reply, there's a high chance you would have solved their problem, congrats, **you're a hero**! 🦸
* Now, if that solved their problem, you can ask them to:
* In GitHub Discussions: mark the comment as the **answer**.
* In GitHub Issues: **close** the issue.
## Watch the GitHub repository { #watch-the-github-repository }
You can "watch" FastAPI in GitHub (clicking the "watch" button at the top right): [https://github.com/fastapi/fastapi](https://github.com/fastapi/fastapi). 👀
If you select "Watching" instead of "Releases only" you will receive notifications when someone creates a new issue or question. You can also specify that you only want to be notified about new issues, or discussions, or PRs, etc.
Then you can try and help them solve those questions.
Follow the [guide on how to help](https://tiangolo.com/open-source/help/#help-others-with-questions-in-github) here.
## Ask Questions { #ask-questions }
@@ -138,122 +66,22 @@ You can [create a new question](https://github.com/fastapi/fastapi/discussions/n
* Ask a **question** or ask about a **problem**.
* Suggest a new **feature**.
**Note**: if you do it, then I'm going to ask you to also help others. 😉
## Review Pull Requests { #review-pull-requests }
You can help me review pull requests from others.
Again, please try your best to be kind. 🤗
---
Here's what to keep in mind and how to review a pull request:
### Understand the problem { #understand-the-problem }
* First, make sure you **understand the problem** that the pull request is trying to solve. It might have a longer discussion in a GitHub Discussion or issue.
* There's also a good chance that the pull request is not actually needed because the problem can be solved in a **different way**. Then you can suggest or ask about that.
### Don't worry about style { #dont-worry-about-style }
* Don't worry too much about things like commit message styles, I will squash and merge customizing the commit manually.
* Also don't worry about style rules, there are already automatized tools checking that.
And if there's any other style or consistency need, I'll ask directly for that, or I'll add commits on top with the needed changes.
### Check the code { #check-the-code }
* Check and read the code, see if it makes sense, **run it locally** and see if it actually solves the problem.
* Then **comment** saying that you did that, that's how I will know you really checked it.
/// note
Unfortunately, I can't simply trust PRs that just have several approvals.
Several times it has happened that there are PRs with 3, 5 or more approvals, probably because the description is appealing, but when I check the PRs, they are actually broken, have a bug, or don't solve the problem they claim to solve. 😅
So, it's really important that you actually read and run the code, and let me know in the comments that you did. 🤓
///
* If the PR can be simplified in a way, you can ask for that, but there's no need to be too picky, there might be a lot of subjective points of view (and I will have my own as well 🙈), so it's better if you can focus on the fundamental things.
### Tests { #tests }
* Help me check that the PR has **tests**.
* Check that the tests **fail** before the PR. 🚨
* Then check that the tests **pass** after the PR. ✅
* Many PRs don't have tests, you can **remind** them to add tests, or you can even **suggest** some tests yourself. That's one of the things that consume most time and you can help a lot with that.
* Then also comment what you tried, that way I'll know that you checked it. 🤓
## Create a Pull Request { #create-a-pull-request }
You can [contribute](contributing.md) to the source code with Pull Requests, for example:
* To fix a typo you found on the documentation.
* To share an article, video, or podcast you created or found about FastAPI by [editing this file](https://github.com/fastapi/fastapi/edit/master/docs/en/data/external_links.yml).
* Make sure you add your link to the start of the corresponding section.
* To help [translate the documentation](contributing.md#translations) to your language.
* You can also help to review the translations created by others.
* To propose new documentation sections.
* To fix an existing issue/bug.
* Make sure to add tests.
* To add a new feature.
* Make sure to add tests.
* Make sure to add documentation if it's relevant.
Note that PRs from non-team members are not allowed to modify `pyproject.toml` or `uv.lock`, to prevent supply chain risk.
If you would like to add a new dependency, create a new [Discussion](https://github.com/fastapi/fastapi/discussions/categories/questions) to explain why.
## Help Maintain FastAPI { #help-maintain-fastapi }
Help me maintain **FastAPI**! 🤓
There's a lot of work to do, and for most of it, **YOU** can do it.
The main tasks that you can do right now are:
* [Help others with questions in GitHub](#help-others-with-questions-in-github) (see the section above).
* [Review Pull Requests](#review-pull-requests) (see the section above).
Those two tasks are what **consume time the most**. That's the main work of maintaining FastAPI.
If you can help me with that, **you are helping me maintain FastAPI** and making sure it keeps **advancing faster and better**. 🚀
## Join the chat { #join-the-chat }
## Join the Chat { #join-the-chat }
Join the 👥 [Discord chat server](https://discord.gg/VQjSZaeJmf) 👥 and hang out with others in the FastAPI community.
/// tip
For questions, ask them in [GitHub Discussions](https://github.com/fastapi/fastapi/discussions/new?category=questions), there's a much better chance you will receive help by the [FastAPI Experts](fastapi-people.md#fastapi-experts).
For questions, ask them in GitHub Discussions, there's a much better chance you will receive help.
Use the chat only for other general conversations.
///
### Don't use the chat for questions { #dont-use-the-chat-for-questions }
### Don't use the Chat for Questions { #dont-use-the-chat-for-questions }
Keep in mind that as chats allow more "free conversation", it's easy to ask questions that are too general and more difficult to answer, so, you might not receive answers.
In GitHub, the template will guide you to write the right question so that you can more easily get a good answer, or even solve the problem yourself even before asking. And in GitHub I can make sure I always answer everything, even if it takes some time. I can't personally do that with the chat systems. 😅
In GitHub, the template will guide you to write the right question so that you can more easily get a good answer, or even solve the problem yourself even before asking.
Conversations in the chat systems are also not as easily searchable as in GitHub, so questions and answers might get lost in the conversation. And only the ones in GitHub count to become a [FastAPI Expert](fastapi-people.md#fastapi-experts), so you will most probably receive more attention in GitHub.
On the other side, there are thousands of users in the chat systems, so there's a high chance you'll find someone to talk to there, almost all the time. 😄
## Sponsor the author { #sponsor-the-author }
If your **product/company** depends on or is related to **FastAPI** and you want to reach its users, you can sponsor the author (me) through [GitHub sponsors](https://github.com/sponsors/tiangolo). Depending on the tier, you could get some extra benefits, like a badge in the docs. 🎁
---
Thanks! 🚀
Conversations in the chat systems are also not as easily searchable as in GitHub, they get lost.

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1,165 +0,0 @@
# Repository Management Tasks
These are the tasks that can be performed to manage the FastAPI repository by [team members](./fastapi-people.md#team).
/// tip
This section is useful only to a handful of people, team members with permissions to manage the repository. You can probably skip it. 😉
///
...so, you are a [team member of FastAPI](./fastapi-people.md#team)? Wow, you are so cool! 😎
You can help with everything on [Help FastAPI - Get Help](./help-fastapi.md) the same ways as external contributors. But additionally, there are some tasks that only you (as part of the team) can perform.
Here are the general instructions for the tasks you can perform.
Thanks a lot for your help. 🙇
## Be Nice
First of all, be nice. 😊
You probably are super nice if you were added to the team, but it's worth mentioning it. 🤓
### When Things are Difficult
When things are great, everything is easier, so that doesn't need much instructions. But when things are difficult, here are some guidelines.
Try to find the good side. In general, if people are not being unfriendly, try to thank their effort and interest, even if you disagree with the main subject (discussion, PR), just thank them for being interested in the project, or for having dedicated some time to try to do something.
It's difficult to convey emotion in text, use emojis to help. 😅
In discussions and PRs, in many cases, people bring their frustration and show it without filter, in many cases exaggerating, complaining, being entitled, etc. That's really not nice, and when it happens, it lowers our priority to solve their problems. But still, try to breath, and be gentle with your answers.
Try to avoid using bitter sarcasm or potentially passive-aggressive comments. If something is wrong, it's better to be direct (try to be gentle) than sarcastic.
Try to be as specific and objective as possible, avoid generalizations.
For conversations that are more difficult, for example to reject a PR, you can ask me (@tiangolo) to handle it directly.
## Edit PR Titles
* Edit the PR title to start with an emoji from [gitmoji](https://gitmoji.dev/).
* Use the emoji character, not the GitHub code. So, use `🐛` instead of `:bug:`. This is so that it shows up correctly outside of GitHub, for example in the release notes.
* For translations use the `🌐` emoji ("globe with meridians").
* Start the title with a verb. For example `Add`, `Refactor`, `Fix`, etc. This way the title will say the action that the PR does. Like `Add support for teleporting`, instead of `Teleporting wasn't working, so this PR fixes it`.
* Edit the text of the PR title to start in "imperative", like giving an order. So, instead of `Adding support for teleporting` use `Add support for teleporting`.
* Try to make the title descriptive about what it achieves. If it's a feature, try to describe it, for example `Add support for teleporting` instead of `Create TeleportAdapter class`.
* Do not finish the title with a period (`.`).
* When the PR is for a translation, start with the `🌐` and then `Add {language} translation for` and then the translated file path. For example:
```Markdown
🌐 Add Spanish translation for `docs/es/docs/teleporting.md`
```
Once the PR is merged, a GitHub Action ([latest-changes](https://github.com/tiangolo/latest-changes)) will use the PR title to update the latest changes automatically.
So, having a nice PR title will not only look nice in GitHub, but also in the release notes. 📝
## Add Labels to PRs
The same GitHub Action [latest-changes](https://github.com/tiangolo/latest-changes) uses one label in the PR to decide the section in the release notes to put this PR in.
Make sure you use a supported label from the [latest-changes list of labels](https://github.com/tiangolo/latest-changes#using-labels):
* `breaking`: Breaking Changes
* Existing code will break if they update the version without changing their code. This rarely happens, so this label is not frequently used.
* `security`: Security Fixes
* This is for security fixes, like vulnerabilities. It would almost never be used.
* `feature`: Features
* New features, adding support for things that didn't exist before.
* `bug`: Fixes
* Something that was supported didn't work, and this fixes it. There are many PRs that claim to be bug fixes because the user is doing something in an unexpected way that is not supported, but they considered it what should be supported by default. Many of these are actually features or refactors. But in some cases there's an actual bug.
* `refactor`: Refactors
* This is normally for changes to the internal code that don't change the behavior. Normally it improves maintainability, or enables future features, etc.
* `upgrade`: Upgrades
* This is for upgrades to direct dependencies from the project, or extra optional dependencies, normally in `pyproject.toml`. So, things that would affect final users, they would end up receiving the upgrade in their code base once they update. But this is not for upgrades to internal dependencies used for development, testing, docs, etc. Those internal dependencies or GitHub Action versions should be marked as `internal`, not `upgrade`.
* `docs`: Docs
* Changes in docs. This includes updating the docs, fixing typos. But it doesn't include changes to translations.
* You can normally quickly detect it by going to the "Files changed" tab in the PR and checking if the updated file(s) starts with `docs/en/docs`. The original version of the docs is always in English, so in `docs/en/docs`.
* `lang-all`: Translations
* Use this for translations. You can normally quickly detect it by going to the "Files changed" tab in the PR and checking if the updated file(s) starts with `docs/{some lang}/docs` but not `docs/en/docs`. For example, `docs/es/docs`.
* `internal`: Internal
* Use this for changes that only affect how the repo is managed. For example upgrades to internal dependencies, changes in GitHub Actions or scripts, etc.
/// tip
Some tools like Dependabot, will add some labels, like `dependencies`, but have in mind that this label is not used by the `latest-changes` GitHub Action, so it won't be used in the release notes. Please make sure one of the labels above is added.
///
## Add Labels to Translation PRs
When there's a PR for a translation, apart from adding the `lang-all` label, also add a label for the language.
There will be a label for each language using the language code, like `lang-{lang code}`, for example, `lang-es` for Spanish, `lang-fr` for French, etc.
* Add the specific language label.
* Add the label `awaiting-review`.
The label `awaiting-review` is special, only used for translations. A GitHub Action will detect it, then it will read the language label, and it will update the GitHub Discussions managing the translations for that language to notify people that there's a new translation to review.
Once a native speaker comes, reviews the PR, and approves it, the GitHub Action will come and remove the `awaiting-review` label, and add the `approved-1` label.
This way, we can notice when there are new translations ready, because they have the `approved-1` label.
## Merge Translation PRs
Translations are generated automatically with LLMs and scripts.
There's one GitHub Action that can be manually run to add or update translations for a language: [`translate.yml`](https://github.com/fastapi/fastapi/actions/workflows/translate.yml).
For these language translation PRs, confirm that:
* The PR was automated (authored by @tiangolo), not made by another user.
* It has the labels `lang-all` and `lang-{lang code}`.
For PRs that update language-specific LLM prompts, confirm that:
* The PR has the labels `lang-all` and `lang-{lang code}`.
* It is approved by at least one native speaker.
* In some cases you might need to translate several pages with new prompt to make sure it works as expected.
If the PR meets the above conditions, you can merge it. 😎
## Review PRs
* If a PR doesn't explain what it does or why, if it seems like it could be useful, ask for more information. Otherwise, feel free to close it.
* If a PR seems to be spam, meaningless, only to change statistics (to appear as "contributor") or similar, you can simply mark it as `invalid`, and it will be automatically closed.
* If a PR seems to be AI generated, and seems like reviewing it would take more time from you than the time it took to write the prompt, mark it as `maybe-ai`, and it will be automatically closed.
* A PR should have a specific use case that it is solving.
* If the PR is for a feature, it should have docs.
* Unless it's a feature we want to discourage, like support for a corner case that we don't want users to use.
* The docs should include a source example file, not write Python directly in Markdown.
* If the source example(s) file can have different syntax for different Python versions, there should be different versions of the file, and they should be shown in tabs in the docs.
* There should be tests testing the source example.
* Before the PR is applied, the new tests should fail.
* After applying the PR, the new tests should pass.
* Coverage should stay at 100%.
* If you see the PR makes sense, or we discussed it and considered it should be accepted, you can add commits on top of the PR to tweak it, to add docs, tests, format, refactor, remove extra files, etc.
* Feel free to comment in the PR to ask for more information, to suggest changes, etc.
* Once you think the PR is ready, move it in the internal GitHub project for me to review it.
## FastAPI People PRs
Every month, a GitHub Action updates the FastAPI People data. Those PRs look like this one: [👥 Update FastAPI People](https://github.com/fastapi/fastapi/pull/11669).
If the tests are passing, you can merge it right away.
## Dependabot PRs
Dependabot will create PRs to update dependencies for several things, and those PRs all look similar, but some are way more delicate than others.
* If the PR is for a direct dependency, so, Dependabot is modifying `pyproject.toml` in the main dependencies, **don't merge it**. 😱 Let me check it first. There's a good chance that some additional tweaks or updates are needed.
* If the PR updates one of the internal dependencies, for example the group `dev` in `pyproject.toml`, or GitHub Action versions, if the tests are passing, the release notes (shown in a summary in the PR) don't show any obvious potential breaking change, you can merge it. 😎
## Mark GitHub Discussions Answers
When a question in GitHub Discussions has been answered, mark the answer by clicking "Mark as answer".
You can filter discussions by [`Questions` that are `Unanswered`](https://github.com/tiangolo/fastapi/discussions/categories/questions?discussions_q=category:Questions+is:open+is:unanswered).

View File

@@ -12,19 +12,7 @@ I normally give the final review to each PR before merging them. I make the fina
There's a team of people that help manage and maintain the project. 😎
They have different levels of permissions and [specific instructions](./management-tasks.md).
Some of the tasks they can perform include:
* Adding labels to PRs.
* Editing PR titles.
* Adding commits on top of PRs to tweak them.
* Mark answers in GitHub Discussions questions, etc.
* Merge some specific types of PRs.
You can see the current team members in [FastAPI People - Team](./fastapi-people.md#team).
Joining the team is by invitation only, and I could update or remove permissions, instructions, or membership.
Learn more about it in [tiangolo.com - GitHub FastAPI](https://tiangolo.com/github-fastapi/).
## FastAPI Experts
@@ -32,8 +20,6 @@ The people that help others the most in GitHub Discussions can become [**FastAPI
This is normally the best way to contribute to the project.
## External Contributions
## External Help
External contributions are very welcome and appreciated, including answering questions, submitting PRs, etc. 🙇‍♂
There are many ways to [help maintain FastAPI](./help-fastapi.md#help-maintain-fastapi).
External help is very much appreciated. There are many ways to [help](./help-fastapi.md). ☕

View File

@@ -9,6 +9,34 @@ hide:
### Docs
* ✏️ Use `Annotated` in inline example in `docs/en/docs/tutorial/body-multiple-params.md`. PR [#15591](https://github.com/fastapi/fastapi/pull/15591) by [@TheArchons](https://github.com/TheArchons).
* 📝 Remove "NGINX Unit" from the list of ASGI-servers in docs. PR [#15475](https://github.com/fastapi/fastapi/pull/15475) by [@angryfoxx](https://github.com/angryfoxx).
* 📝 Update `docs/en/docs/tutorial/security/oauth2-jwt.md`. PR [#14781](https://github.com/fastapi/fastapi/pull/14781) by [@zadevhub](https://github.com/zadevhub).
### Internal
* ⬆ Bump the python-packages group with 15 updates. PR [#15594](https://github.com/fastapi/fastapi/pull/15594) by [@dependabot[bot]](https://github.com/apps/dependabot).
* 👷 Configure Dependabot to group updates and update weekly. PR [#15560](https://github.com/fastapi/fastapi/pull/15560) by [@YuriiMotov](https://github.com/YuriiMotov).
## 0.136.3 (2026-05-23)
### Refactors
* ♻️ Do not accept underscore headers when using `convert_underscores=True` (the default). PR [#15589](https://github.com/fastapi/fastapi/pull/15589) by [@tiangolo](https://github.com/tiangolo).
## 0.136.2 (2026-05-23)
### Refactors
* ♻️ Validate Server Sent Event fields to avoid applications from sending broken data. PR [#15588](https://github.com/fastapi/fastapi/pull/15588) by [@tiangolo](https://github.com/tiangolo).
### Docs
* 📝 Document `--entrypoint` CLI option. PR [#15464](https://github.com/fastapi/fastapi/pull/15464) by [@YuriiMotov](https://github.com/YuriiMotov).
* 📝 Update and simplify docs about help and management. PR [#15583](https://github.com/fastapi/fastapi/pull/15583) by [@tiangolo](https://github.com/tiangolo).
* 📝 Add docs references to central contributing docs. PR [#15580](https://github.com/fastapi/fastapi/pull/15580) by [@tiangolo](https://github.com/tiangolo).
* 📝 Update security policy. PR [#15577](https://github.com/fastapi/fastapi/pull/15577) by [@tiangolo](https://github.com/tiangolo).
* 🍱 Update sponsors: TalorData image. PR [#15562](https://github.com/fastapi/fastapi/pull/15562) by [@tiangolo](https://github.com/tiangolo).
* 📝 Update docs, simplify usage of admonitions, only default ones. PR [#15553](https://github.com/fastapi/fastapi/pull/15553) by [@tiangolo](https://github.com/tiangolo).
* 📝 Fix image URLs in `index.md`. PR [#15534](https://github.com/fastapi/fastapi/pull/15534) by [@YuriiMotov](https://github.com/YuriiMotov).
* ✏️ Fix Azkaban spelling typo in `virtual-environments.md`. PR [#15463](https://github.com/fastapi/fastapi/pull/15463) by [@isaacbernat](https://github.com/isaacbernat).
@@ -18,6 +46,7 @@ hide:
### Translations
* 🌐 Improve translation consistency in `docs/pt/docs/advanced/generate-clients.md`. PR [#15456](https://github.com/fastapi/fastapi/pull/15456) by [@Will-thom](https://github.com/Will-thom).
* 🌐 Update translations for ja (update-outdated). PR [#15530](https://github.com/fastapi/fastapi/pull/15530) by [@tiangolo](https://github.com/tiangolo).
* 🌐 Update translations for uk (update-outdated). PR [#15529](https://github.com/fastapi/fastapi/pull/15529) by [@tiangolo](https://github.com/tiangolo).
* 🌐 Update translations for pt (update-outdated). PR [#15528](https://github.com/fastapi/fastapi/pull/15528) by [@tiangolo](https://github.com/tiangolo).
@@ -33,6 +62,13 @@ hide:
### Internal
* ✅ Update tests, don't double dispose the engine. PR [#15587](https://github.com/fastapi/fastapi/pull/15587) by [@tiangolo](https://github.com/tiangolo).
* ⚡️ Speed up test suite via caching and fixture scopes to make it ~24% faster. PR [#13583](https://github.com/fastapi/fastapi/pull/13583) by [@dikos1337](https://github.com/dikos1337).
* 🔥 Remove config files now in central GitHub repo. PR [#15585](https://github.com/fastapi/fastapi/pull/15585) by [@tiangolo](https://github.com/tiangolo).
* ⬆ Bump urllib3 from 2.6.3 to 2.7.0. PR [#15502](https://github.com/fastapi/fastapi/pull/15502) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump idna from 3.11 to 3.15. PR [#15565](https://github.com/fastapi/fastapi/pull/15565) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump cloudflare/wrangler-action from 3.15.0 to 4.0.0. PR [#15571](https://github.com/fastapi/fastapi/pull/15571) by [@dependabot[bot]](https://github.com/apps/dependabot).
* 🔧 Migrate docs from MkDocs to Zensical. PR [#15563](https://github.com/fastapi/fastapi/pull/15563) by [@tiangolo](https://github.com/tiangolo).
* 🔒️ Only allow team members to modify dependencies. PR [#15548](https://github.com/fastapi/fastapi/pull/15548) by [@svlandeg](https://github.com/svlandeg).
* ⬆ Bump actions/add-to-project from 1.0.2 to 2.0.0. PR [#15490](https://github.com/fastapi/fastapi/pull/15490) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump actions/labeler from 6.0.1 to 6.1.0. PR [#15507](https://github.com/fastapi/fastapi/pull/15507) by [@dependabot[bot]](https://github.com/apps/dependabot).

View File

@@ -0,0 +1,28 @@
# Translations
Translation pull requests are made by LLMs guided with prompts designed by the FastAPI team together with the community of native speakers for each supported language.
## LLM Prompt per Language
Each language has a directory: [https://github.com/fastapi/fastapi/tree/master/docs](https://github.com/fastapi/fastapi/tree/master/docs), in it you can see a file `llm-prompt.md` with the prompt specific for that language.
For example, for Spanish, the prompt is at: [`docs/es/llm-prompt.md`](https://github.com/fastapi/fastapi/blob/master/docs/es/llm-prompt.md).
If you see mistakes in your language, you can make suggestions to the prompt in that file for your language, and request the specific pages you would like to re-generate after the changes.
PRs with suggestions to the language-specific LLM prompt require approval from at least one native speaker. Your help here is very much appreciated!
## Request a New Language
Let's say that you want to request translations for a language that is not yet translated, not even some pages. For example, Latin.
* The first step would be for you to find other 2 people that would be willing to be reviewing translation PRs for that language with you.
* Once there are at least 3 people that would be willing to commit to help maintain that language, you can continue the next steps.
* Create a new discussion following the template.
* Tag the other 2 people that will help with the language, and ask them to confirm there they will help.
Once there are several people in the discussion, the FastAPI team can evaluate it and can make it an official translation.
Then the docs will be automatically translated using LLMs, and the team of native speakers can review the translation, and help tweak the LLM prompts.
Once there's a new translation, for example if docs are updated or there's a new section, there will be a comment in the same discussion with the link to the new translation to review.

View File

@@ -126,7 +126,7 @@ By default, **FastAPI** will then expect its body directly.
But if you want it to expect a JSON with a key `item` and inside of it the model contents, as it does when you declare extra body parameters, you can use the special `Body` parameter `embed`:
```Python
item: Item = Body(embed=True)
item: Annotated[Item, Body(embed=True)]
```
as in:

View File

@@ -180,7 +180,7 @@ which would be equivalent to:
from backend.main import app
```
### `fastapi dev` with path { #fastapi-dev-with-path }
### `fastapi dev` with path or with `--entrypoint` CLI option { #fastapi-dev-with-path-or-with-entrypoint-cli-option }
You can also pass the file path to the `fastapi dev` command, and it will guess the FastAPI app object to use:
@@ -188,7 +188,13 @@ You can also pass the file path to the `fastapi dev` command, and it will guess
$ fastapi dev main.py
```
But you would have to remember to pass the correct path every time you call the `fastapi` command.
Or, you can also pass the `--entrypoint` option to the `fastapi dev` command:
```console
$ fastapi dev --entrypoint main:app
```
But you would have to remember to pass the correct path\entrypoint every time you call the `fastapi` command.
Additionally, other tools might not be able to find it, for example the [VS Code Extension](../editor-support.md) or [FastAPI Cloud](https://fastapicloud.com), so it is recommended to use the `entrypoint` in `pyproject.toml`.

View File

@@ -18,7 +18,7 @@ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4
It is not encrypted, so, anyone could recover the information from the contents.
But it's signed. So, when you receive a token that you emitted, you can verify that you actually emitted it.
But it's signed. So, when you receive a token that you issued, you can verify that it was you who issued it.
That way, you can create a token with an expiration of, let's say, 1 week. And then when the user comes back the next day with the token, you know that user is still logged in to your system.

View File

@@ -1,5 +0,0 @@
# Define this here and not in the main mkdocs.yml file because that one is auto
# updated and written, and the script would remove the env var
markdown_extensions:
pymdownx.highlight:
linenums: !ENV [LINENUMS, false]

View File

@@ -1,10 +1,10 @@
INHERIT: ../en/mkdocs.env.yml
site_name: FastAPI
site_description: FastAPI framework, high performance, easy to learn, fast to code, ready for production
site_url: https://fastapi.tiangolo.com/
theme:
variant: classic
name: material
custom_dir: ../en/overrides
custom_dir: overrides
palette:
- media: (prefers-color-scheme)
toggle:
@@ -45,38 +45,13 @@ theme:
- search.suggest
- toc.follow
icon:
repo: fontawesome/brands/github-alt
repo: octicons/mark-github-24
logo: img/icon-white.svg
favicon: img/favicon.png
language: en
repo_name: fastapi/fastapi
repo_url: https://github.com/fastapi/fastapi
plugins:
social:
cards_layout_options:
logo: ../en/docs/img/icon-white.svg
typeset: null
search: null
macros:
include_yaml:
- github_sponsors: ../en/data/github_sponsors.yml
- people: ../en/data/people.yml
- contributors: ../en/data/contributors.yml
- translators: ../en/data/translators.yml
- translation_reviewers: ../en/data/translation_reviewers.yml
- skip_users: ../en/data/skip_users.yml
- members: ../en/data/members.yml
- sponsors_badge: ../en/data/sponsors_badge.yml
- sponsors: ../en/data/sponsors.yml
- topic_repos: ../en/data/topic_repos.yml
redirects:
redirect_maps:
deployment/deta.md: deployment/cloud.md
advanced/graphql.md: how-to/graphql.md
advanced/custom-request-and-route.md: how-to/custom-request-and-route.md
advanced/conditional-openapi.md: how-to/conditional-openapi.md
advanced/extending-openapi.md: how-to/extending-openapi.md
advanced/testing-database.md: how-to/testing-database.md
mkdocstrings:
handlers:
python:
@@ -102,13 +77,13 @@ plugins:
nav:
- FastAPI: index.md
- features.md
- Learn:
- "":
- learn/index.md
- python-types.md
- async.md
- environment-variables.md
- virtual-environments.md
- Tutorial - User Guide:
- "":
- tutorial/index.md
- tutorial/first-steps.md
- tutorial/path-params.md
@@ -137,14 +112,14 @@ nav:
- tutorial/path-operation-configuration.md
- tutorial/encoder.md
- tutorial/body-updates.md
- Dependencies:
- "":
- tutorial/dependencies/index.md
- tutorial/dependencies/classes-as-dependencies.md
- tutorial/dependencies/sub-dependencies.md
- tutorial/dependencies/dependencies-in-path-operation-decorators.md
- tutorial/dependencies/global-dependencies.md
- tutorial/dependencies/dependencies-with-yield.md
- Security:
- "":
- tutorial/security/index.md
- tutorial/security/first-steps.md
- tutorial/security/get-current-user.md
@@ -161,7 +136,7 @@ nav:
- tutorial/static-files.md
- tutorial/testing.md
- tutorial/debugging.md
- Advanced User Guide:
- "":
- advanced/index.md
- advanced/stream-data.md
- advanced/path-operation-advanced-configuration.md
@@ -173,7 +148,7 @@ nav:
- advanced/response-headers.md
- advanced/response-change-status-code.md
- advanced/advanced-dependencies.md
- Advanced Security:
- "":
- advanced/security/index.md
- advanced/security/oauth2-scopes.md
- advanced/security/http-basic-auth.md
@@ -199,7 +174,7 @@ nav:
- advanced/strict-content-type.md
- fastapi-cli.md
- editor-support.md
- Deployment:
- "":
- deployment/index.md
- deployment/versions.md
- deployment/fastapicloud.md
@@ -209,7 +184,7 @@ nav:
- deployment/cloud.md
- deployment/server-workers.md
- deployment/docker.md
- How To - Recipes:
- "":
- how-to/index.md
- how-to/general.md
- how-to/migrate-from-pydantic-v1-to-pydantic-v2.md
@@ -222,7 +197,7 @@ nav:
- how-to/configure-swagger-ui.md
- how-to/testing-database.md
- how-to/authentication-error-status-code.md
- Reference (Code API):
- "":
- reference/index.md
- reference/fastapi.md
- reference/parameters.md
@@ -238,7 +213,7 @@ nav:
- reference/response.md
- reference/responses.md
- reference/middleware.md
- OpenAPI:
- "":
- reference/openapi/index.md
- reference/openapi/docs.md
- reference/openapi/models.md
@@ -248,15 +223,15 @@ nav:
- reference/templating.md
- reference/testclient.md
- fastapi-people.md
- Resources:
- "":
- resources/index.md
- help-fastapi.md
- contributing.md
- translations.md
- project-generation.md
- external-links.md
- newsletter.md
- management-tasks.md
- About:
- "":
- about/index.md
- alternatives.md
- history-design-future.md
@@ -264,10 +239,7 @@ nav:
- management.md
- release-notes.md
markdown_extensions:
material.extensions.preview:
targets:
include:
- '*'
zensical.extensions.macros: null
abbr: null
attr_list: null
footnotes: null
@@ -312,16 +284,16 @@ markdown_extensions:
markdown_include_variants: null
extra:
social:
- icon: fontawesome/brands/github-alt
- icon: octicons/mark-github-24
link: https://github.com/fastapi/fastapi
- icon: fontawesome/brands/discord
link: https://discord.gg/VQjSZaeJmf
- icon: fontawesome/brands/twitter
- icon: fontawesome/brands/x-twitter
link: https://x.com/fastapi
- icon: fontawesome/brands/bluesky
link: https://bsky.app/profile/fastapi.tiangolo.com
- icon: fontawesome/brands/linkedin
link: https://www.linkedin.com/company/fastapi
- icon: fontawesome/solid/globe
link: https://tiangolo.com
alternate:
- link: /
name: en - English
@@ -331,8 +303,6 @@ extra:
name: es - español
- link: /fr/
name: fr - français
- link: /hi/
name: hi - हिन्दी
- link: /ja/
name: ja - 日本語
- link: /ko/
@@ -356,5 +326,5 @@ extra_javascript:
- js/termynal.js
- js/custom.js
- js/init_kapa_widget.js
hooks:
- ../../scripts/mkdocs_hooks.py
validation:
unresolved_references: false

View File

@@ -4,8 +4,8 @@
</div>
{% if not config.extra.generator == false %}
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
<a href="https://zensical.org" target="_blank" rel="noopener">
Zensical
</a>
{% endif %}
</div>

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,503 +0,0 @@
# LLM परीक्षण फ़ाइल { #llm-test-file }
यह दस्तावेज़ यह परखता है कि <abbr title="Large Language Model - बड़ा भाषा मॉडल">LLM</abbr>, जो डॉक्यूमेंटेशन का अनुवाद करता है, `scripts/translate.py` में दिए गए `general_prompt` और `docs/{language code}/llm-prompt.md` में दिए गए भाषा-विशिष्ट प्रॉम्प्ट को समझता है या नहीं। भाषा-विशिष्ट प्रॉम्प्ट को `general_prompt` के साथ जोड़ा जाता है।
यहाँ जो परीक्षण जोड़े गए हैं, वे भाषा-विशिष्ट प्रॉम्प्ट के सभी डिज़ाइनर्स को दिखाई देंगे।
उपयोग इस प्रकार करें:
* एक भाषा-विशिष्ट प्रॉम्प्ट रखें - `docs/{language code}/llm-prompt.md`
* इस दस्तावेज़ का अपने इच्छित लक्ष्य-भाषा में नया अनुवाद करें (उदाहरण के लिए `translate.py` के `translate-page` कमांड को देखें)। यह अनुवाद `docs/{language code}/docs/_llm-test.md` के अंतर्गत बना देगा।
* जाँचें कि अनुवाद में सब कुछ ठीक है।
* आवश्यकता होने पर, अपने भाषा-विशिष्ट प्रॉम्प्ट, जनरल प्रॉम्प्ट या अंग्रेज़ी दस्तावेज़ में सुधार करें।
* फिर अनुवाद में बचे हुए मुद्दों को हाथ से ठीक करें ताकि यह एक अच्छा अनुवाद बन जाए।
* दुबारा अनुवाद करें, इस बार अच्छा अनुवाद जगह पर रहते हुए। आदर्श परिणाम होगा कि LLM अब अनुवाद में कोई परिवर्तन न करे। इसका मतलब है कि जनरल प्रॉम्प्ट और आपका भाषा-विशिष्ट प्रॉम्प्ट जितने अच्छे हो सकते हैं उतने अच्छे हैं (कभी-कभी यह कुछ यादृच्छिक-से परिवर्तन कर देगा, कारण यह है कि [LLM नियतात्मक एल्गोरिथ्म नहीं हैं](https://doublespeak.chat/#/handbook#deterministic-output))।
परीक्षण:
## कोड स्निपेट्स { #code-snippets }
//// tab | परीक्षण
यह एक कोड स्निपेट है: `foo`। और यह एक और कोड स्निपेट है: `bar`। और एक और: `baz quux`
////
//// tab | जानकारी
कोड स्निपेट्स की सामग्री को ज्यों का त्यों छोड़ देना चाहिए।
`scripts/translate.py` में जनरल प्रॉम्प्ट के सेक्शन `### Content of code snippets` को देखें।
////
## उद्धरण { #quotes }
//// tab | परीक्षण
कल, मेरे दोस्त ने लिखा: "अगर आप 'गलत' को सही लिखते हैं, तो आपने उसे गलत लिखा है"। जिसके जवाब में मैंने कहा: "सही, लेकिन 'गलत' गलत है '"गलत"' नहीं"।
/// note | टिप्पणी
LLM संभवतः इसे गलत अनुवादित करेगा। दिलचस्प यह है कि पुनः-अनुवाद करने पर क्या यह ठीक किया हुआ अनुवाद बनाए रखता है।
///
////
//// tab | जानकारी
प्रॉम्प्ट डिज़ाइनर यह चुन सकते हैं कि वे साधारण कोट्स को टाइपोग्राफ़िक कोट्स में बदलना चाहते हैं या नहीं। उन्हें ज्यों का त्यों छोड़ना भी ठीक है।
उदाहरण के लिए `docs/de/llm-prompt.md` में सेक्शन `### Quotes` देखें।
////
## कोड स्निपेट्स में उद्धरण { #quotes-in-code-snippets }
//// tab | परीक्षण
`pip install "foo[bar]"`
कोड स्निपेट्स में स्ट्रिंग लिटरल्स के उदाहरण: `"this"`, `'that'`.
कोड स्निपेट्स में स्ट्रिंग लिटरल्स का एक कठिन उदाहरण: `f"I like {'oranges' if orange else "apples"}"`
हार्डकोर: `Yesterday, my friend wrote: "If you spell incorrectly correctly, you have spelled it incorrectly". To which I answered: "Correct, but 'incorrectly' is incorrectly not '"incorrectly"'"`
////
//// tab | जानकारी
... लेकिन, कोड स्निपेट्स के अंदर के उद्धरण ज्यों के त्यों रहने चाहिए।
////
## कोड ब्लॉक्स { #code-blocks }
//// tab | परीक्षण
एक Bash कोड उदाहरण...
```bash
# ब्रह्मांड के लिए अभिवादन प्रिंट करें
echo "Hello universe"
```
...और एक कंसोल कोड उदाहरण...
```console
$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u>
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting server
Searching for package file structure
```
...और एक अन्य कंसोल कोड उदाहरण...
```console
// "Code" नाम की डायरेक्टरी बनाएँ
$ mkdir code
// उस डायरेक्टरी में जाएँ
$ cd code
```
...और एक Python कोड उदाहरण...
```Python
wont_work() # यह काम नहीं करेगा 😱
works(foo="bar") # यह काम करता है 🎉
```
...और बस इतना ही।
////
//// tab | जानकारी
कोड ब्लॉक्स के अंदर के कोड में बदलाव नहीं होना चाहिए, सिवाय टिप्पणियों (comments) के।
`scripts/translate.py` में जनरल प्रॉम्प्ट के सेक्शन `### Content of code blocks` को देखें।
////
## टैब और रंगीन बॉक्स { #tabs-and-colored-boxes }
//// tab | परीक्षण
/// info | जानकारी
कुछ पाठ
///
/// note | टिप्पणी
कुछ पाठ
///
/// note | तकनीकी विवरण
कुछ पाठ
///
/// check | जांच
कुछ पाठ
///
/// tip | सुझाव
कुछ पाठ
///
/// warning | चेतावनी
कुछ पाठ
///
/// danger | खतरा
कुछ पाठ
///
////
//// tab | जानकारी
टैब और `Info`/`Note`/`Warning`/आदि ब्लॉक्स में उनके शीर्षक का अनुवाद ऊर्ध्वाधर रेखा (`|`) के बाद जोड़ा जाना चाहिए।
`scripts/translate.py` में जनरल प्रॉम्प्ट के सेक्शन `### Special blocks` और `### Tab blocks` देखें।
////
## वेब और आंतरिक लिंक { #web-and-internal-links }
//// tab | परीक्षण
लिंक का टेक्स्ट अनुवादित होना चाहिए, लिंक का पता अपरिवर्तित रहे:
* [ऊपर दिए गए शीर्षक का लिंक](#code-snippets)
* [आंतरिक लिंक](index.md#installation)
* [बाहरी लिंक](https://sqlmodel.tiangolo.com/)
* [एक स्टाइल का लिंक](https://fastapi.tiangolo.com/css/styles.css)
* [एक स्क्रिप्ट का लिंक](https://fastapi.tiangolo.com/js/logic.js)
* [एक छवि का लिंक](https://fastapi.tiangolo.com/img/foo.jpg)
लिंक का टेक्स्ट अनुवादित होना चाहिए, लिंक का पता अनुवाद की ओर इशारा करना चाहिए:
* [FastAPI लिंक](https://fastapi.tiangolo.com/hi/)
////
//// tab | जानकारी
लिंक अनुवादित होने चाहिए, लेकिन उनके पते अपरिवर्तित रहें। अपवाद है FastAPI डॉक्यूमेंटेशन के पेजों के पूर्ण (absolute) लिंक। उस स्थिति में लिंक अनुवाद की ओर इशारा करना चाहिए।
`scripts/translate.py` में जनरल प्रॉम्प्ट के सेक्शन `### Links` देखें।
////
## HTML "abbr" एलिमेंट्स { #html-abbr-elements }
//// tab | परीक्षण
यहाँ HTML "abbr" एलिमेंट्स में लिपटी कुछ चीज़ें हैं (कुछ गढ़ी हुई भी):
### abbr एक पूरा वाक्यांश देता है { #the-abbr-gives-a-full-phrase }
* <abbr title="Getting Things Done - काम पूरे करना">GTD</abbr>
* <abbr title="less than - से कम"><code>lt</code></abbr>
* <abbr title="XML Web Token - XML वेब टोकन">XWT</abbr>
* <abbr title="Parallel Server Gateway Interface - समानांतर सर्वर गेटवे इंटरफ़ेस">PSGI</abbr>
### abbr एक पूरा वाक्यांश और उसका स्पष्टीकरण देता है { #the-abbr-gives-a-full-phrase-and-an-explanation }
* <abbr title="Mozilla Developer Network - मोज़िला डेवलपर नेटवर्क: डेवलपर्स के लिए प्रलेखन, फ़ायरफ़ॉक्स टीम द्वारा लिखा गया">MDN</abbr>
* <abbr title="Input/Output - इनपुट/आउटपुट: डिस्क का पढ़ना या लिखना, नेटवर्क संचार।">I/O</abbr>.
////
//// tab | जानकारी
"abbr" एलिमेंट्स के "title" ऐट्रिब्यूट्स का अनुवाद कुछ विशिष्ट निर्देशों का पालन करते हुए किया जाता है।
अनुवाद अपने स्वयं के "abbr" एलिमेंट्स जोड़ सकते हैं जिन्हें LLM को हटाना नहीं चाहिए। जैसे अंग्रेज़ी शब्दों को समझाने के लिए।
`scripts/translate.py` में जनरल प्रॉम्प्ट के सेक्शन `### HTML abbr elements` देखें।
////
## HTML "dfn" एलिमेंट्स { #html-dfn-elements }
* <dfn title="ऐसी मशीनों का समूह जिन्हें किसी तरह से एक-दूसरे से जुड़ने और साथ काम करने के लिए कॉन्फ़िगर किया गया है।">क्लस्टर</dfn>
* <dfn title="मशीन लर्निंग की एक विधि जो इनपुट और आउटपुट लेयर्स के बीच कई छुपी हुई लेयर्स वाले कृत्रिम न्यूरल नेटवर्क्स का उपयोग करती है, इस प्रकार एक व्यापक आंतरिक संरचना विकसित करती है">डीप लर्निंग</dfn>
## शीर्षक { #headings }
//// tab | परीक्षण
### एक वेबऐप विकसित करें - एक ट्यूटोरियल { #develop-a-webapp-a-tutorial }
नमस्ते।
### टाइप हिंट्स और -एनोटेशन्स { #type-hints-and-annotations }
फिर से नमस्ते।
### सुपर- और सबक्लासेज़ { #super-and-subclasses }
फिर से नमस्ते।
////
//// tab | जानकारी
शीर्षकों के लिए एकमात्र कड़ा नियम यह है कि LLM कर्ली ब्रैकेट्स के अंदर के हैश-पार्ट को अपरिवर्तित छोड़े, जिससे लिंक न टूटें।
`scripts/translate.py` में जनरल प्रॉम्प्ट के सेक्शन `### Headings` देखें।
कुछ भाषा-विशिष्ट निर्देशों के लिए, जैसे `docs/de/llm-prompt.md` में सेक्शन `### Headings` देखें।
////
## डॉक्स में प्रयुक्त शब्द { #terms-used-in-the-docs }
//// tab | परीक्षण
* आप
* आपका
* उदा.
* आदि
* `foo` एक `int` के रूप में
* `bar` एक `str` के रूप में
* `baz` एक `list` के रूप में
* ट्यूटोरियल - उपयोगकर्ता गाइड
* उन्नत उपयोगकर्ता गाइड
* SQLModel डॉक्स
* API डॉक्स
* स्वचालित डॉक्स
* डेटा साइंस
* डीप लर्निंग
* मशीन लर्निंग
* डिपेंडेंसी इंजेक्शन
* HTTP बेसिक ऑथेंटिकेशन
* HTTP डाइजेस्ट
* ISO फ़ॉरमैट
* JSON Schema मानक
* JSON स्कीमा
* स्कीमा परिभाषा
* पासवर्ड फ्लो
* मोबाइल
* अप्रचलित
* डिज़ाइन किया गया
* अमान्य
* तुरंत
* मानक
* डिफ़ॉल्ट
* केस-संवेदी
* केस-असंवेदी
* एप्लिकेशन को सर्व करना
* पेज को सर्व करना
* ऐप
* एप्लिकेशन
* रिक्वेस्ट
* रिस्पांस
* त्रुटि रिस्पांस
* पाथ ऑपरेशन
* पाथ ऑपरेशन डेकोरेटर
* पाथ ऑपरेशन फ़ंक्शन
* बॉडी
* रिक्वेस्ट बॉडी
* रिस्पांस बॉडी
* JSON बॉडी
* फॉर्म बॉडी
* फ़ाइल बॉडी
* फ़ंक्शन बॉडी
* पैरामीटर
* बॉडी पैरामीटर
* पाथ पैरामीटर
* क्वेरी पैरामीटर
* कुकी पैरामीटर
* हेडर पैरामीटर
* फॉर्म पैरामीटर
* फ़ंक्शन पैरामीटर
* इवेंट
* स्टार्टअप इवेंट
* सर्वर का स्टार्टअप
* शटडाउन इवेंट
* लाइफस्पैन इवेंट
* हैंडलर
* इवेंट हैंडलर
* एक्सेप्शन हैंडलर
* हैंडल करना
* मॉडल
* Pydantic मॉडल
* डेटा मॉडल
* डेटाबेस मॉडल
* फॉर्म मॉडल
* मॉडल ऑब्जेक्ट
* क्लास
* बेस क्लास
* पैरेंट क्लास
* सबक्लास
* चाइल्ड क्लास
* सिब्लिंग क्लास
* क्लास मेथड
* हेडर
* हेडर्स
* ऑथराइज़ेशन हेडर
* `Authorization` हेडर
* फॉरवर्डेड हेडर
* डिपेंडेंसी इंजेक्शन सिस्टम
* डिपेंडेंसी
* डिपेंडेबल
* डिपेन्डन्ट
* I/O बाउंड
* CPU बाउंड
* समकालिकता
* समान्तरता
* मल्टीप्रोसेसिंग
* env var
* पर्यावरण चर
* `PATH`
* `PATH` वेरिएबल
* प्रमाणीकरण
* प्रमाणीकरण प्रदाता
* अधिकारीकरण
* अधिकारीकरण फॉर्म
* अधिकारीकरण प्रदाता
* उपयोगकर्ता प्रमाणीकरण करता है
* सिस्टम उपयोगकर्ता का प्रमाणीकरण करता है
* CLI
* कमांड लाइन इंटरफेस
* सर्वर
* क्लाइंट
* क्लाउड प्रदाता
* क्लाउड सेवा
* विकास
* विकास चरण
* dict
* डिक्शनरी
* एन्युमरेशन
* एनम
* एनम सदस्य
* एन्कोडर
* डीकोडर
* एन्कोड करना
* डीकोड करना
* एक्सेप्शन
* रेज़ करना
* एक्सप्रेशन
* स्टेटमेंट
* फ्रंटएंड
* बैकएंड
* GitHub चर्चा
* GitHub इश्यू
* प्रदर्शन
* प्रदर्शन अनुकूलन
* रिटर्न टाइप
* रिटर्न वैल्यू
* सुरक्षा
* सुरक्षा स्कीम
* टास्क
* बैकग्राउंड टास्क
* टास्क फ़ंक्शन
* टेम्पलेट
* टेम्पलेट इंजन
* टाइप एनोटेशन
* टाइप हिंट
* सर्वर वर्कर
* Uvicorn वर्कर
* Gunicorn Worker
* वर्कर प्रोसेस
* वर्कर क्लास
* वर्कलोड
* डिप्लॉयमेंट
* डिप्लॉय करना
* SDK
* सॉफ़्टवेयर डेवलपमेंट किट
* `APIRouter`
* `requirements.txt`
* Bearer Token
* ब्रेकिंग चेंज
* बग
* बटन
* कॉल करने योग्य
* कोड
* कमिट
* कॉन्टेक्स्ट मैनेजर
* कोरूटीन
* डेटाबेस सेशन
* डिस्क
* डोमेन
* इंजन
* नकली X
* HTTP GET मेथड
* आइटम
* लाइब्रेरी
* लाइफस्पैन
* लॉक
* मिडलवेयर
* मोबाइल एप्लिकेशन
* मॉड्यूल
* माउंटिंग
* नेटवर्क
* ओरिजिन
* ओवरराइड
* पेलोड
* प्रोसेसर
* प्रॉपर्टी
* प्रॉक्सी
* पुल रिक्वेस्ट
* क्वेरी
* RAM
* रिमोट मशीन
* स्टेटस कोड
* स्ट्रिंग
* टैग
* वेब फ़्रेमवर्क
* वाइल्डकार्ड
* वापस करना
* सत्यापित करना
////
//// tab | जानकारी
यह डॉक्स में दिखने वाले (ज़्यादातर) तकनीकी शब्दों की न तो पूर्ण और न ही मानक सूची है। यह प्रॉम्प्ट डिज़ाइनर को यह समझने में मदद कर सकती है कि किन शब्दों के लिए LLM को सहायक निर्देशों की ज़रूरत है। उदाहरण के लिए जब यह एक अच्छे अनुवाद को कमतर अनुवाद में वापस बदल देता है। या जब इसे आपकी भाषा में किसी शब्द का रूपांतरण/विभक्ति करने में समस्या होती है।
उदाहरण के लिए `docs/de/llm-prompt.md` में सेक्शन `### List of English terms and their preferred German translations` देखें।
////

View File

@@ -1,580 +0,0 @@
# FastAPI { #fastapi }
<style>
.md-content .md-typeset h1 { display: none; }
</style>
<p align="center">
<a href="https://fastapi.tiangolo.com/hi"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" alt="FastAPI"></a>
</p>
<p align="center">
<em>FastAPI फ़्रेमवर्क, उच्च प्रदर्शन, सीखने में आसान, कोड लिखने में तेज़, प्रोडक्शन के लिए तैयार</em>
</p>
<p align="center">
<a href="https://github.com/fastapi/fastapi/actions?query=workflow%3ATest+event%3Apush+branch%3Amaster">
<img src="https://github.com/fastapi/fastapi/actions/workflows/test.yml/badge.svg?event=push&branch=master" alt="टेस्ट">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/fastapi">
<img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/fastapi.svg" alt="कवरेज">
</a>
<a href="https://pypi.org/project/fastapi">
<img src="https://img.shields.io/pypi/v/fastapi?color=%2334D058&label=pypi%20package" alt="पैकेज संस्करण">
</a>
<a href="https://pypi.org/project/fastapi">
<img src="https://img.shields.io/pypi/pyversions/fastapi.svg?color=%2334D058" alt="समर्थित Python संस्करण">
</a>
</p>
---
दस्तावेज़: [https://fastapi.tiangolo.com](https://fastapi.tiangolo.com/hi)
स्रोत कोड: [https://github.com/fastapi/fastapi](https://github.com/fastapi/fastapi)
---
FastAPI एक आधुनिक, तेज़ (उच्च-प्रदर्शन) वेब फ़्रेमवर्क है जो मानक Python type hints के आधार पर Python से APIs बनाने के लिए है।
मुख्य विशेषताएँ:
* तेज़: बहुत उच्च प्रदर्शन, **NodeJS** और **Go** के समकक्ष (Starlette और Pydantic की बदौलत)। [उपलब्ध सबसे तेज़ Python फ़्रेमवर्क्स में से एक](#performance)।
* कोड लिखने में तेज़: फ़ीचर्स विकसित करने की गति लगभग 200% से 300% तक बढ़ाएँ। *
* कम बग्स: मानवीय (डेवलपर) त्रुटियों में लगभग 40% की कमी। *
* सहज: बेहतरीन एडिटर सपोर्ट। हर जगह <dfn title="उर्फ़: ऑटो-कम्प्लीट, ऑटोकम्प्लीशन, IntelliSense">ऑटो-कम्प्लीट</dfn>। डिबगिंग में कम समय।
* आसान: इस्तेमाल और सीखने में आसान। दस्तावेज़ पढ़ने में कम समय।
* संक्षिप्त: कोड डुप्लीकेशन को न्यूनतम करें। प्रत्येक parameter declaration से कई फ़ीचर्स। कम बग्स।
* मजबूत: प्रोडक्शन-रेडी कोड प्राप्त करें। स्वतः इंटरैक्टिव दस्तावेज़ीकरण के साथ।
* मानकों पर आधारित: APIs के खुले मानकों पर आधारित (और पूर्णतः अनुकूल): [OpenAPI](https://github.com/OAI/OpenAPI-Specification) (जिसे पहले Swagger कहा जाता था) और [JSON Schema](https://json-schema.org/)।
<small>* आंतरिक डेवलपमेंट टीम द्वारा प्रोडक्शन ऐप्स बनाते समय किए गए परीक्षणों के आधार पर अनुमान।</small>
## प्रायोजक { #sponsors }
<!-- sponsors -->
### कीस्टोन प्रायोजक { #keystone-sponsor }
<div class="fastapi-sponsors fastapi-sponsors--keystone">
{% for sponsor in sponsors.keystone -%}
<a class="fastapi-sponsors__card fastapi-sponsors__card--keystone" href="{{ sponsor.url }}" title="{{ sponsor.title }}"><img class="fastapi-sponsors__banner" src="{{ sponsor.img }}" alt="{{ sponsor.title }}"></a>
{% endfor -%}
</div>
### गोल्ड प्रायोजक { #gold-sponsors }
<div class="fastapi-sponsors fastapi-sponsors--gold">
{% for sponsor in sponsors.gold -%}
<a class="fastapi-sponsors__card fastapi-sponsors__card--gold" href="{{ sponsor.url }}" title="{{ sponsor.title }}"><img class="fastapi-sponsors__banner" src="{{ sponsor.img }}" alt="{{ sponsor.title }}" loading="lazy"></a>
{% endfor -%}
</div>
### सिल्वर प्रायोजक { #silver-sponsors }
<div class="fastapi-sponsors fastapi-sponsors--silver">
{% for sponsor in sponsors.silver -%}
<a class="fastapi-sponsors__card fastapi-sponsors__card--silver" href="{{ sponsor.url }}" title="{{ sponsor.title }}"><img class="fastapi-sponsors__banner" src="{{ sponsor.img }}" alt="{{ sponsor.title }}" loading="lazy"></a>
{% endfor %}
</div>
<!-- /sponsors -->
[अन्य प्रायोजक](https://fastapi.tiangolo.com/hi/fastapi-people/#sponsors)
## विचार { #opinions }
<!-- only-mkdocs -->
<div class="fastapi-opinions" data-fastapi-opinions>
<div class="fastapi-opinions__tabs" role="tablist" aria-label="Companies using FastAPI">
<button class="fastapi-opinions__tab" role="tab" type="button" id="fo-tab-microsoft" aria-controls="fo-panel-microsoft" aria-selected="true" tabindex="0">
<span class="fastapi-opinions__mark"><img src="/img/logos/microsoft.svg" alt="Microsoft" loading="lazy"></span>
</button>
<button class="fastapi-opinions__tab" role="tab" type="button" id="fo-tab-uber" aria-controls="fo-panel-uber" aria-selected="false" tabindex="-1">
<span class="fastapi-opinions__mark"><img src="/img/logos/uber.svg" alt="Uber" loading="lazy"></span>
</button>
<button class="fastapi-opinions__tab" role="tab" type="button" id="fo-tab-netflix" aria-controls="fo-panel-netflix" aria-selected="false" tabindex="-1">
<span class="fastapi-opinions__mark"><img src="/img/logos/netflix.svg" alt="Netflix" loading="lazy"></span>
</button>
<button class="fastapi-opinions__tab" role="tab" type="button" id="fo-tab-cisco" aria-controls="fo-panel-cisco" aria-selected="false" tabindex="-1">
<span class="fastapi-opinions__mark"><img src="/img/logos/cisco.svg" alt="Cisco" loading="lazy"></span>
</button>
</div>
<div class="fastapi-opinions__panel" id="fo-panel-microsoft" role="tabpanel" aria-labelledby="fo-tab-microsoft" tabindex="0">
<blockquote class="fastapi-opinions__quote">"मैं इन दिनों <strong>FastAPI</strong> का बहुत उपयोग कर रहा/रही हूँ। वास्तव में मैं अपनी टीम की <strong>Microsoft में ML सेवाओं</strong> के लिए इसे उपयोग करने की योजना बना रहा/रही हूँ। इनमें से कुछ को मुख्य <strong>Windows</strong> प्रोडक्ट और कुछ <strong>Office</strong> प्रोडक्ट्स में इंटीग्रेट किया जा रहा है।"</blockquote>
<div class="fastapi-opinions__attr">— कबीर खान, <strong>Microsoft</strong> <a href="https://github.com/fastapi/fastapi/pull/26">(संदर्भ)</a></div>
</div>
<div class="fastapi-opinions__panel" id="fo-panel-uber" role="tabpanel" aria-labelledby="fo-tab-uber" tabindex="0" hidden>
<blockquote class="fastapi-opinions__quote">"हमने <strong>FastAPI</strong> लाइब्रेरी अपनाई ताकि एक <strong>REST</strong> सर्वर स्पॉन किया जा सके जिसे <strong>अन्दाज़ों/अनुमानों</strong> को प्राप्त करने के लिए क्वेरी किया जा सके।" <em>[Ludwig के लिए]</em></blockquote>
<div class="fastapi-opinions__attr">— पिएरो मोलिनो, यारोस्लाव डुडिन, साई सुमंत मिर्याला, <strong>Uber</strong> <a href="https://eng.uber.com/ludwig-v0-2/">(संदर्भ)</a></div>
</div>
<div class="fastapi-opinions__panel" id="fo-panel-netflix" role="tabpanel" aria-labelledby="fo-tab-netflix" tabindex="0" hidden>
<blockquote class="fastapi-opinions__quote">"<strong>Netflix</strong> हमारे <strong>संकट प्रबंधन</strong> ऑर्केस्ट्रेशन फ़्रेमवर्क: <strong>Dispatch</strong> के ओपन-सोर्स रिलीज़ की घोषणा करते हुए प्रसन्न है!" <em>[FastAPI के साथ बनाया गया]</em></blockquote>
<div class="fastapi-opinions__attr">— केविन ग्लिसन, मार्क विलानोवा, फॉरेस्ट मॉन्सेन, <strong>Netflix</strong> <a href="https://netflixtechblog.com/introducing-dispatch-da4b8a2a8072">(संदर्भ)</a></div>
</div>
<div class="fastapi-opinions__panel" id="fo-panel-cisco" role="tabpanel" aria-labelledby="fo-tab-cisco" tabindex="0" hidden>
<blockquote class="fastapi-opinions__quote">"यदि कोई प्रोडक्शन Python API बनाना चाहता है, तो मैं <strong>FastAPI</strong> की अत्यधिक अनुशंसा करूंगा/करूंगी। यह <strong>सुंदरता से डिज़ाइन</strong> किया गया है, <strong>उपयोग में सरल</strong> है और <strong>बेहद स्केलेबल</strong> है — यह हमारी API-फर्स्ट डेवलपमेंट रणनीति का <strong>मुख्य घटक</strong> बन गया है।"</blockquote>
<div class="fastapi-opinions__attr">— डीयोन पिल्सबरी, <strong>Cisco</strong> <a href="https://www.linkedin.com/posts/deonpillsbury_cisco-cx-python-activity-6963242628536487936-trAp/">(संदर्भ)</a></div>
</div>
</div>
<!-- /only-mkdocs -->
<div class="only-github" markdown="1">
"_[...] मैं इन दिनों **FastAPI** का बहुत उपयोग कर रहा/रही हूँ। [...] वास्तव में मैं अपनी टीम की **Microsoft में ML सेवाओं** के लिए इसे उपयोग करने की योजना बना रहा/रही हूँ। इनमें से कुछ को मुख्य **Windows** प्रोडक्ट और कुछ **Office** प्रोडक्ट्स में इंटीग्रेट किया जा रहा है._"
<div style="text-align: right; margin-right: 10%;">कबीर खान - <strong>Microsoft</strong> <a href="https://github.com/fastapi/fastapi/pull/26"><small>(संदर्भ)</small></a></div>
---
"_हमने **FastAPI** लाइब्रेरी अपनाई ताकि एक **REST** सर्वर स्पॉन किया जा सके जिसे **अनुमानों** को प्राप्त करने के लिए क्वेरी किया जा सके। [Ludwig के लिए]_"
<div style="text-align: right; margin-right: 10%;">पिएरो मोलिनो, यारोस्लाव डुडिन, और साई सुमंत मिर्याला - <strong>Uber</strong> <a href="https://eng.uber.com/ludwig-v0-2/"><small>(संदर्भ)</small></a></div>
---
"_**Netflix** हमारे **संकट प्रबंधन** ऑर्केस्ट्रेशन फ़्रेमवर्क: **Dispatch** के ओपन-सोर्स रिलीज़ की घोषणा करते हुए प्रसन्न है! [**FastAPI** के साथ बनाया गया]_"
<div style="text-align: right; margin-right: 10%;">केविन ग्लिसन, मार्क विलानोवा, फॉरेस्ट मॉन्सेन - <strong>Netflix</strong> <a href="https://netflixtechblog.com/introducing-dispatch-da4b8a2a8072"><small>(संदर्भ)</small></a></div>
---
"_यदि कोई प्रोडक्शन Python API बनाना चाहता है, तो मैं **FastAPI** की अत्यधिक अनुशंसा करूंगा/करूंगी। यह **सुंदरता से डिज़ाइन** किया गया है, **उपयोग में सरल** है और **बेहद स्केलेबल** है, यह हमारी API-फ़र्स्ट डेवलपमेंट रणनीति का **मुख्य घटक** बन गया है और हमारे Virtual TAC Engineer जैसे कई ऑटोमेशन्स और सेवाओं को चला रहा है._"
<div style="text-align: right; margin-right: 10%;">डीयोन पिल्सबरी - <strong>Cisco</strong> <a href="https://www.linkedin.com/posts/deonpillsbury_cisco-cx-python-activity-6963242628536487936-trAp/"><small>(संदर्भ)</small></a></div>
---
</div>
## FastAPI कॉन्फ़ { #fastapi-conf }
[**FastAPI Conf '26**](https://fastapiconf.com) **28 अक्टूबर, 2026** को **एम्स्टर्डम, नीदरलैंड्स** में हो रही है। सब कुछ FastAPI के बारे में, सीधे स्रोत से। 🎤
<a class="fastapi-feature-banner" href="https://fastapiconf.com"><img src="https://fastapi.tiangolo.com/img/fastapi-conf.jpeg" alt="FastAPI Conf '26 - 28 अक्टूबर, 2026 - एम्स्टर्डम, NL"></a>
## FastAPI मिनी डॉक्यूमेंट्री { #fastapi-mini-documentary }
साल 2025 के अंत में एक [FastAPI मिनी डॉक्यूमेंट्री](https://www.youtube.com/watch?v=mpR8ngthqiE) रिलीज़ हुई, आप इसे ऑनलाइन देख सकते हैं:
<a class="fastapi-feature-banner" href="https://www.youtube.com/watch?v=mpR8ngthqiE"><img src="https://fastapi.tiangolo.com/img/fastapi-documentary.jpg" alt="FastAPI मिनी डॉक्यूमेंट्री"></a>
## Typer, CLIs का FastAPI { #typer-the-fastapi-of-clis }
<a href="https://typer.tiangolo.com"><img src="https://typer.tiangolo.com/img/logo-margin/logo-margin-vector.svg" style="width: 20%;"></a>
यदि आप वेब API के बजाय टर्मिनल में उपयोग होने वाला <abbr title="Command Line Interface - आदेश पंक्ति इंटरफ़ेस">CLI</abbr> ऐप बना रहे हैं, तो [**Typer**](https://typer.tiangolo.com/) देखें।
**Typer**, FastAPI का छोटा भाई/बहन है। और इसका उद्देश्य **CLIs का FastAPI** होना है। ⌨️ 🚀
## आवश्यकताएँ { #requirements }
FastAPI दिग्गजों के कंधों पर खड़ा है:
* वेब हिस्सों के लिए [Starlette](https://www.starlette.dev/)।
* डेटा हिस्सों के लिए [Pydantic](https://docs.pydantic.dev/)।
## स्थापना { #installation }
एक [वर्चुअल एन्वायरनमेंट](https://fastapi.tiangolo.com/hi/virtual-environments/) बनाएँ और सक्रिय करें, और फिर FastAPI स्थापित करें:
<div class="termy">
```console
$ pip install "fastapi[standard]"
---> 100%
```
</div>
नोट: सुनिश्चित करें कि आप सभी टर्मिनलों में काम करने के लिए `"fastapi[standard]"` को उद्धरण-चिह्नों में रखें।
## उदाहरण { #example }
### इसे बनाएँ { #create-it }
`main.py` फ़ाइल बनाएँ और इसमें लिखें:
```Python
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
```
<details markdown="1">
<summary>या <code>async def</code> का उपयोग करें...</summary>
यदि आपका कोड `async` / `await` का उपयोग करता है, तो `async def` का उपयोग करें:
```Python hl_lines="7 12"
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
async def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
```
नोट:
यदि आप नहीं जानते, तो _"जल्दी में?"_ सेक्शन देखें: दस्तावेज़ में [`async` और `await`](https://fastapi.tiangolo.com/hi/async/#in-a-hurry) के बारे में।
</details>
### इसे चलाएँ { #run-it }
सर्वर को इस कमांड से चलाएँ:
<div class="termy">
```console
$ fastapi dev
╭────────── FastAPI CLI - Development mode ───────────╮
│ │
│ Serving at: http://127.0.0.1:8000 │
│ │
│ API docs: http://127.0.0.1:8000/docs │
│ │
│ Running in development mode, for production use: │
│ │
│ fastapi run │
│ │
╰─────────────────────────────────────────────────────╯
INFO: Will watch for changes in these directories: ['/home/user/code/awesomeapp']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [2248755] using WatchFiles
INFO: Started server process [2248757]
INFO: Waiting for application startup.
INFO: Application startup complete.
```
</div>
<details markdown="1">
<summary><code>fastapi dev</code> कमांड के बारे में...</summary>
`fastapi dev` कमांड आपका `main.py` फ़ाइल स्वतः पढ़ता है, उसमें **FastAPI** ऐप का पता लगाता है, और [Uvicorn](https://www.uvicorn.dev) का उपयोग करके सर्वर शुरू करता है।
डिफ़ॉल्ट रूप से, `fastapi dev` लोकल डेवलपमेंट के लिए auto-reload सक्षम करके शुरू होगा।
आप इसके बारे में और पढ़ सकते हैं: [FastAPI CLI दस्तावेज़](https://fastapi.tiangolo.com/hi/fastapi-cli/) में।
</details>
### इसे जाँचें { #check-it }
अपने ब्राउज़र में [http://127.0.0.1:8000/items/5?q=somequery](http://127.0.0.1:8000/items/5?q=somequery) खोलें।
आपको JSON प्रतिक्रिया इस प्रकार दिखेगी:
```JSON
{"item_id": 5, "q": "somequery"}
```
आपने पहले ही एक API बना ली है जो:
* _paths_ `/` और `/items/{item_id}` पर HTTP अनुरोध स्वीकार करती है।
* दोनों _paths_ `GET` <em>operations</em> लेती हैं (जिन्हें HTTP _methods_ भी कहा जाता है)।
* _path_ `/items/{item_id}` में एक _path parameter_ `item_id` है जो `int` होना चाहिए।
* _path_ `/items/{item_id}` में एक वैकल्पिक `str` _query parameter_ `q` है।
### इंटरैक्टिव API दस्तावेज़ { #interactive-api-docs }
अब [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) पर जाएँ।
आपको स्वचालित इंटरैक्टिव API दस्तावेज़ीकरण दिखेगा (जो [Swagger UI](https://github.com/swagger-api/swagger-ui) द्वारा प्रदान किया जाता है):
![Swagger UI](https://fastapi.tiangolo.com/img/index/index-01-swagger-ui-simple.png)
### वैकल्पिक API दस्तावेज़ { #alternative-api-docs }
और अब, [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc) पर जाएँ।
आपको वैकल्पिक स्वचालित दस्तावेज़ीकरण दिखेगा (जो [ReDoc](https://github.com/Rebilly/ReDoc) द्वारा प्रदान किया जाता है):
![ReDoc](https://fastapi.tiangolo.com/img/index/index-02-redoc-simple.png)
## उदाहरण उन्नयन { #example-upgrade }
अब `PUT` अनुरोध से body प्राप्त करने के लिए `main.py` फ़ाइल संशोधित करें।
Pydantic की बदौलत, body को मानक Python प्रकारों से घोषित करें।
```Python hl_lines="2 7-10 23-25"
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: str
price: float
is_offer: bool | None = None
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
@app.put("/items/{item_id}")
def update_item(item_id: int, item: Item):
return {"item_name": item.name, "item_id": item_id}
```
`fastapi dev` सर्वर स्वतः रीलोड होना चाहिए।
### इंटरैक्टिव API दस्तावेज़ उन्नयन { #interactive-api-docs-upgrade }
अब [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) पर जाएँ।
* इंटरैक्टिव API दस्तावेज़ स्वतः अपडेट हो जाएगा, नए body सहित:
![Swagger UI](https://fastapi.tiangolo.com/img/index/index-03-swagger-02.png)
* "Try it out" बटन पर क्लिक करें, यह आपको parameters भरने और सीधे API के साथ इंटरेक्ट करने की अनुमति देता है:
![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-04-swagger-03.png)
* फिर "Execute" बटन पर क्लिक करें, यूज़र इंटरफ़ेस आपकी API से संवाद करेगा, parameters भेजेगा, परिणाम प्राप्त करेगा और उन्हें स्क्रीन पर दिखाएगा:
![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-05-swagger-04.png)
### वैकल्पिक API दस्तावेज़ उन्नयन { #alternative-api-docs-upgrade }
और अब, [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc) पर जाएँ।
* वैकल्पिक दस्तावेज़ भी नए query parameter और body को दर्शाएगा:
![ReDoc](https://fastapi.tiangolo.com/img/index/index-06-redoc-02.png)
### पुनरावलोकन { #recap }
संक्षेप में, आप parameters, body, आदि के प्रकार फ़ंक्शन parameters के रूप में **एक बार** घोषित करते हैं।
आप यह मानक आधुनिक Python प्रकारों से करते हैं।
आपको किसी नई सिंटैक्स, किसी विशेष लाइब्रेरी के methods या classes, आदि सीखने की आवश्यकता नहीं है।
बस मानक **Python**।
उदाहरण के लिए, एक `int` के लिए:
```Python
item_id: int
```
या एक अधिक जटिल `Item` मॉडल के लिए:
```Python
item: Item
```
...और केवल उसी एक घोषणा के साथ आपको मिलता है:
* एडिटर सपोर्ट, जिसमें शामिल है:
* कम्प्लीशन।
* प्रकार जाँच।
* डेटा का वैधीकरण:
* जब डेटा अमान्य हो तो स्वतः और स्पष्ट त्रुटियाँ।
* गहराई से nested JSON objects के लिए भी वैधीकरण।
* इनपुट डेटा का <dfn title="उर्फ़: सीरियलाइज़ेशन, पार्सिंग, मार्शलिंग">रूपांतरण</dfn>: नेटवर्क से Python डेटा और प्रकारों में। इनमें से पढ़ना:
* JSON।
* Path parameters।
* Query parameters।
* Cookies।
* Headers।
* Forms।
* Files।
* आउटपुट डेटा का <dfn title="उर्फ़: सीरियलाइज़ेशन, पार्सिंग, मार्शलिंग">रूपांतरण</dfn>: Python डेटा और प्रकारों से नेटवर्क डेटा (JSON के रूप में) में:
* Python प्रकारों का रूपांतरण (`str`, `int`, `float`, `bool`, `list`, आदि)।
* `datetime` ऑब्जेक्ट्स।
* `UUID` ऑब्जेक्ट्स।
* डेटाबेस मॉडल्स।
* ...और बहुत कुछ।
* स्वचालित इंटरैक्टिव API दस्तावेज़ीकरण, जिनमें 2 वैकल्पिक यूज़र इंटरफ़ेस शामिल हैं:
* Swagger UI।
* ReDoc।
---
पिछले कोड उदाहरण पर लौटते हुए, **FastAPI** यह करेगा:
* `GET` और `PUT` अनुरोधों के लिए path में `item_id` है, यह सत्यापित करेगा।
* `GET` और `PUT` अनुरोधों के लिए `item_id` का प्रकार `int` है, यह सत्यापित करेगा।
* यदि नहीं है, तो क्लाइंट को एक उपयोगी, स्पष्ट त्रुटि दिखाई देगी।
* `GET` अनुरोधों के लिए यह जाँच करेगा कि `q` नाम का एक वैकल्पिक query parameter है (जैसे `http://127.0.0.1:8000/items/foo?q=somequery`)।
* क्योंकि `q` parameter `= None` के साथ घोषित है, यह वैकल्पिक है।
* `None` के बिना यह आवश्यक होता (जैसे `PUT` के मामले में body आवश्यक है)।
* `/items/{item_id}` पर `PUT` अनुरोधों के लिए, body को JSON के रूप में पढ़ेगा:
* यह जाँचेगा कि एक आवश्यक attribute `name` है जो `str` होना चाहिए।
* यह जाँचेगा कि एक आवश्यक attribute `price` है जो `float` होना चाहिए।
* यह जाँचेगा कि एक वैकल्पिक attribute `is_offer` है, जो यदि मौजूद है तो `bool` होना चाहिए।
* यह सब गहराई से nested JSON objects के लिए भी काम करेगा।
* JSON से और JSON में स्वतः रूपांतरण।
* हर चीज़ को OpenAPI के साथ दस्तावेज़ित करेगा, जिसे निम्न द्वारा उपयोग किया जा सकता है:
* इंटरैक्टिव दस्तावेज़ीकरण प्रणालियाँ।
* कई भाषाओं के लिए स्वचालित क्लाइंट कोड जनरेशन प्रणालियाँ।
* सीधे 2 इंटरैक्टिव दस्तावेज़ीकरण वेब इंटरफेसेज़ प्रदान करेगा।
---
हमने केवल सतह को छुआ है, लेकिन आपको पहले ही समझ आ गया होगा कि यह सब कैसे काम करता है।
इस पंक्ति को बदलकर देखें:
```Python
return {"item_name": item.name, "item_id": item_id}
```
...यहाँ से:
```Python
... "item_name": item.name ...
```
...यहाँ तक:
```Python
... "item_price": item.price ...
```
...और देखें कि आपका एडिटर attributes को कैसे auto-complete करेगा और उनके प्रकार जानेगा:
![editor support](https://fastapi.tiangolo.com/img/vscode-completion.png)
अधिक फ़ीचर्स सहित एक अधिक सम्पूर्ण उदाहरण के लिए, <a href="https://fastapi.tiangolo.com/hi/tutorial/">ट्यूटोरियल - यूज़र गाइड</a> देखें।
चेतावनी: ट्यूटोरियल - यूज़र गाइड में शामिल है:
* विभिन्न स्थानों से **parameters** की घोषणा: **headers**, **cookies**, **form fields** और **files**।
* `maximum_length` या `regex` जैसी **validation constraints** कैसे सेट करें।
* एक बहुत शक्तिशाली और उपयोग में आसान **<dfn title="उर्फ़: कॉम्पोनेंट्स, रिसोर्सेज़, प्रोवाइडर्स, सर्विसेज़, इंजेक्टेबल्स">डिपेंडेंसी इंजेक्शन</dfn>** सिस्टम।
* सुरक्षा और प्रमाणीकरण, जिसमें **OAuth2** के साथ **JWT tokens** और **HTTP Basic** auth का समर्थन शामिल है।
* **गहराई से nested JSON मॉडल्स** घोषित करने की अधिक उन्नत (पर समान रूप से आसान) तकनीकें (Pydantic की बदौलत)।
* [Strawberry](https://strawberry.rocks) और अन्य लाइब्रेरीज़ के साथ **GraphQL** एकीकरण।
* कई अतिरिक्त फ़ीचर्स (Starlette की बदौलत) जैसे:
* **WebSockets**
* HTTPX और `pytest` पर आधारित अत्यंत आसान टेस्ट्स
* **CORS**
* **Cookie Sessions**
* ...आदि।
### अपनी ऐप परिनियोजित करें (वैकल्पिक) { #deploy-your-app-optional }
आप वैकल्पिक रूप से अपनी FastAPI ऐप को [FastAPI Cloud](https://fastapicloud.com) पर डिप्लॉय कर सकते हैं, यदि अभी तक नहीं किया है तो वेटिंग लिस्ट में जुड़ें। 🚀
यदि आपके पास पहले से **FastAPI Cloud** अकाउंट है (हमने आपको वेटिंग लिस्ट से आमंत्रित किया 😉), तो आप एक कमांड से अपनी एप्लिकेशन डिप्लॉय कर सकते हैं।
<div class="termy">
```console
$ fastapi deploy
Deploying to FastAPI Cloud...
✅ Deployment successful!
🐔 Ready the chicken! Your app is ready at https://myapp.fastapicloud.dev
```
</div>
बस इतना ही! अब आप उस URL पर अपनी ऐप एक्सेस कर सकते हैं। ✨
#### FastAPI Cloud के बारे में { #about-fastapi-cloud }
**[FastAPI Cloud](https://fastapicloud.com)** को **FastAPI** के ही लेखक और टीम ने बनाया है।
यह न्यूनतम प्रयास में किसी API को **बनाने**, **डिप्लॉय** करने और **एक्सेस** करने की प्रक्रिया को सरल बनाता है।
यह FastAPI के साथ ऐप्स बनाने के उसी **डेवलपर अनुभव** को उन्हें क्लाउड में **डिप्लॉय** करने तक लाता है। 🎉
FastAPI Cloud, *FastAPI and friends* ओपन सोर्स प्रोजेक्ट्स के लिए मुख्य प्रायोजक और फंडिंग प्रदाता है। ✨
#### अन्य क्लाउड प्रदाताओं पर डिप्लॉय करें { #deploy-to-other-cloud-providers }
FastAPI ओपन सोर्स है और मानकों पर आधारित है। आप FastAPI ऐप्स को किसी भी क्लाउड प्रदाता पर डिप्लॉय कर सकते हैं।
अपने क्लाउड प्रदाता के गाइड्स का पालन करें और उनके साथ FastAPI ऐप्स डिप्लॉय करें। 🤓
## प्रदर्शन { #performance }
स्वतंत्र TechEmpower बेंचमार्क दिखाते हैं कि Uvicorn के तहत चलने वाले **FastAPI** एप्लीकेशन्स [उपलब्ध सबसे तेज़ Python फ़्रेमवर्क्स में से एक](https://www.techempower.com/benchmarks/#section=test&runid=7464e520-0dc2-473d-bd34-dbdfd7e85911&hw=ph&test=query&l=zijzen-7) हैं, केवल Starlette और Uvicorn (जो FastAPI द्वारा आंतरिक रूप से उपयोग किए जाते हैं) से नीचे। (*)
इसके बारे में अधिक समझने के लिए, [बेंचमार्क्स](https://fastapi.tiangolo.com/hi/benchmarks/) सेक्शन देखें।
## निर्भरताएँ { #dependencies }
FastAPI, Pydantic और Starlette पर निर्भर करता है।
### `standard` निर्भरताएँ { #standard-dependencies }
जब आप `pip install "fastapi[standard]"` के साथ FastAPI स्थापित करते हैं, तो यह `standard` समूह की वैकल्पिक निर्भरताओं के साथ आता है:
Pydantic द्वारा उपयोग किया गया:
* [`email-validator`](https://github.com/JoshData/python-email-validator) - ईमेल वैधीकरण के लिए।
Starlette द्वारा उपयोग किया गया:
* [`httpx`](https://www.python-httpx.org) - यदि आप `TestClient` का उपयोग करना चाहते हैं तो आवश्यक।
* [`jinja2`](https://jinja.palletsprojects.com) - यदि आप डिफ़ॉल्ट टेम्पलेट कॉन्फ़िगरेशन का उपयोग करना चाहते हैं तो आवश्यक।
* [`python-multipart`](https://github.com/Kludex/python-multipart) - यदि आप फॉर्म <dfn title="HTTP अनुरोध से आने वाली स्ट्रिंग को Python डेटा में बदलना">"पार्सिंग"</dfn> का समर्थन करना चाहते हैं, `request.form()` के साथ, तो आवश्यक।
FastAPI द्वारा उपयोग किया गया:
* [`uvicorn`](https://www.uvicorn.dev) - वह सर्वर जो आपकी एप्लिकेशन को लोड और सर्व करता है। इसमें `uvicorn[standard]` शामिल है, जिसमें उच्च-प्रदर्शन सर्विंग के लिए कुछ निर्भरताएँ (जैसे `uvloop`) शामिल हैं।
* `fastapi-cli[standard]` - `fastapi` कमांड प्रदान करने के लिए।
* इसमें `fastapi-cloud-cli` शामिल है, जो आपको अपनी FastAPI एप्लिकेशन को [FastAPI Cloud](https://fastapicloud.com) पर डिप्लॉय करने की अनुमति देता है।
### `standard` निर्भरताओं के बिना { #without-standard-dependencies }
यदि आप `standard` वैकल्पिक निर्भरताओं को शामिल नहीं करना चाहते, तो आप `pip install fastapi` के साथ स्थापित कर सकते हैं, `pip install "fastapi[standard]"` के बजाय।
### `fastapi-cloud-cli` के बिना { #without-fastapi-cloud-cli }
यदि आप standard निर्भरताओं के साथ लेकिन `fastapi-cloud-cli` के बिना FastAPI स्थापित करना चाहते हैं, तो `pip install "fastapi[standard-no-fastapi-cloud-cli]"` के साथ स्थापित कर सकते हैं।
### अतिरिक्त वैकल्पिक निर्भरताएँ { #additional-optional-dependencies }
कुछ अतिरिक्त निर्भरताएँ हैं जिन्हें आप स्थापित करना चाहेंगे।
अतिरिक्त वैकल्पिक Pydantic निर्भरताएँ:
* [`pydantic-settings`](https://docs.pydantic.dev/latest/usage/pydantic_settings/) - सेटिंग्स प्रबंधन के लिए।
* [`pydantic-extra-types`](https://docs.pydantic.dev/latest/usage/types/extra_types/extra_types/) - Pydantic के साथ उपयोग करने के लिए अतिरिक्त प्रकारों हेतु।
अतिरिक्त वैकल्पिक FastAPI निर्भरताएँ:
* [`orjson`](https://github.com/ijl/orjson) - यदि आप `ORJSONResponse` उपयोग करना चाहते हैं तो आवश्यक।
* [`ujson`](https://github.com/esnme/ultrajson) - यदि आप `UJSONResponse` उपयोग करना चाहते हैं तो आवश्यक।
## लाइसेंस { #license }
यह प्रोजेक्ट MIT लाइसेंस की शर्तों के अंतर्गत लाइसेंस प्राप्त है।

View File

@@ -1,11 +0,0 @@
/// details | 🌐 एआई और मनुष्यों द्वारा किया गया अनुवाद
यह अनुवाद मनुष्यों के मार्गदर्शन में एआई द्वारा किया गया है। 🤝
इसमें मूल अर्थ को गलत समझने या अप्राकृतिक लगने आदि जैसी गलतियाँ हो सकती हैं। 🤖
आप [हमें एआई LLM को बेहतर मार्गदर्शन करने में मदद करके](https://fastapi.tiangolo.com/hi/contributing/#translations) इस अनुवाद को बेहतर बना सकते हैं।
[अंग्रेज़ी संस्करण](ENGLISH_VERSION_URL)
///

View File

@@ -1,5 +0,0 @@
### Target language
Translate to Hindi (हिन्दी).
Language code: hi.

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -41,7 +41,7 @@ Vamos começar com uma aplicação FastAPI simples:
{* ../../docs_src/generate_clients/tutorial001_py310.py hl[7:9,12:13,16:17,21] *}
Note que as *operações de rota* definem os modelos que usam para o corpo da requisição e o corpo da resposta, usando os modelos `Item` e `ResponseMessage`.
Observe que as *operações de rota* definem os modelos que usam para o corpo da requisição e o corpo da resposta, usando os modelos `Item` e `ResponseMessage`.
### Documentação da API { #api-docs }
@@ -49,11 +49,11 @@ Se você for para `/docs`, verá que ela tem os **schemas** para os dados a sere
<img src="/img/tutorial/generate-clients/image01.png">
Você pode ver esses schemas porque eles foram declarados com os modelos no app.
Você pode ver esses schemas porque eles foram declarados com os modelos na aplicação.
Essas informações estão disponíveis no **schema OpenAPI** do app e são mostradas na documentação da API.
Essas informações estão disponíveis no **schema OpenAPI da aplicação** e são mostradas na documentação da API.
E essas mesmas informações dos modelos que estão incluídas no OpenAPI são o que pode ser usado para **gerar o código do cliente**.
E essas mesmas informações dos modelos incluídas no OpenAPI podem ser usadas para **gerar o código do cliente**.
### Hey API { #hey-api }
@@ -120,9 +120,9 @@ Agora os nomes dos métodos gerados como `createItemItemsPost` não parecem muit
ItemsService.createItemItemsPost({name: "Plumbus", price: 5})
```
...isso ocorre porque o gerador de clientes usa o **ID de operação** interno do OpenAPI para cada *operação de rota*.
...isso ocorre porque o gerador de clientes usa o **ID de operação interno do OpenAPI** para cada *operação de rota*.
O OpenAPI exige que cada ID de operação seja único em todas as *operações de rota*, então o FastAPI usa o **nome da função**, o **path** e o **método/operação HTTP** para gerar esse ID de operação, porque dessa forma ele pode garantir que os IDs de operação sejam únicos.
O OpenAPI exige que cada ID de operação seja único em todas as *operações de rota*, então o FastAPI usa o **nome da função**, o **path** e o **método HTTP** para gerar esse ID de operação, porque dessa forma ele pode garantir que os IDs de operação sejam únicos.
Mas eu vou te mostrar como melhorar isso a seguir. 🤓
@@ -156,7 +156,7 @@ Como você pode ver, os nomes dos métodos agora têm a tag e, em seguida, o nom
### Pré-processar a especificação OpenAPI para o gerador de clientes { #preprocess-the-openapi-specification-for-the-client-generator }
O código gerado ainda tem algumas **informações duplicadas**.
O código gerado ainda pode ter algumas **informações duplicadas**.
Nós já sabemos que esse método está relacionado aos **items** porque essa palavra está no `ItemsService` (retirada da tag), mas ainda temos o nome da tag prefixado no nome do método também. 😕

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,3 +1,8 @@
---
include_yaml:
sponsors: data/sponsors.yml
---
# FastAPI { #fastapi }
<style>

View File

@@ -1 +0,0 @@
INHERIT: ../en/mkdocs.yml

View File

@@ -1,6 +1,6 @@
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
__version__ = "0.136.1"
__version__ = "0.136.3"
from starlette import status as status

View File

@@ -826,6 +826,10 @@ def request_params_to_args(
if value is not None:
params_to_process[get_validation_alias(field)] = value
processed_keys.add(alias or get_validation_alias(field))
# For headers with convert_underscores=True, mark both the converted
# header name and the original field alias as processed to avoid
# accepting the original alias as an extra header.
processed_keys.add(get_validation_alias(field))
for key in received_params.keys():
if key not in processed_keys:

View File

@@ -33,10 +33,20 @@ class EventSourceResponse(StreamingResponse):
media_type = "text/event-stream"
def _check_id_no_null(v: str | None) -> str | None:
def _check_single_line(v: str | None, field_name: str) -> str | None:
if v is not None and ("\r" in v or "\n" in v):
raise ValueError(f"SSE '{field_name}' must be a single line")
return v
def _check_event_single_line(v: str | None) -> str | None:
return _check_single_line(v, "event")
def _check_id_valid(v: str | None) -> str | None:
if v is not None and "\0" in v:
raise ValueError("SSE 'id' must not contain null characters")
return v
return _check_single_line(v, "id")
class ServerSentEvent(BaseModel):
@@ -86,24 +96,27 @@ class ServerSentEvent(BaseModel):
] = None
event: Annotated[
str | None,
AfterValidator(_check_event_single_line),
Doc(
"""
Optional event type name.
Maps to `addEventListener(event, ...)` on the browser. When omitted,
the browser dispatches on the generic `message` event.
the browser dispatches on the generic `message` event. Must be a
single line.
"""
),
] = None
id: Annotated[
str | None,
AfterValidator(_check_id_no_null),
AfterValidator(_check_id_valid),
Doc(
"""
Optional event ID.
The browser sends this value back as the `Last-Event-ID` header on
automatic reconnection. **Must not contain null (`\\0`) characters.**
automatic reconnection. **Must be a single line** and must not contain
null (`\\0`) characters.
"""
),
] = None

View File

@@ -132,21 +132,17 @@ docs = [
{ include-group = "docs-tests" },
"black >=25.1.0",
"cairosvg >=2.8.2",
# for MkDocs live reload
"click==8.2.1",
"griffe-typingdoc >=0.3.0",
"griffe-warnings-deprecated >=1.1.0",
"jieba >=0.42.1",
"markdown-include-variants >=0.0.8",
"mdx-include >=1.4.1,<2.0.0",
"mkdocs-macros-plugin >=1.5.0",
"mkdocs-material >=9.7.0",
"mkdocs-redirects >=1.2.1,<1.3.0",
"mkdocstrings[python] >=0.30.1",
"mkdocstrings[python] >=1.0.3",
"pillow >=11.3.0",
"python-slugify >=8.0.4",
"pyyaml >=5.3.1,<7.0.0",
"typer >=0.21.1",
"zensical >=0.0.42",
]
docs-tests = [
"httpx >=0.23.0,<1.0.0",
@@ -354,7 +350,6 @@ extend-exclude = [
"docs/uk/",
"docs/zh/",
"docs/zh-hant/",
"docs/hi/",
"htmlcov/",
"scripts/general-llm-prompt.md",
"scripts/tests/test_translation_fixer/test_complex_doc/",

View File

@@ -10,7 +10,6 @@ from multiprocessing import Pool
from pathlib import Path
from typing import Any
import mkdocs.utils
import typer
import yaml
from jinja2 import Template
@@ -32,7 +31,6 @@ SUPPORTED_LANGS = {
"uk",
"zh",
"zh-hant",
"hi",
}
@@ -40,10 +38,6 @@ app = typer.Typer()
mkdocs_name = "mkdocs.yml"
missing_translation_snippet = """
{!../../docs/missing-translation.md!}
"""
non_translated_sections = (
f"reference{os.sep}",
"release-notes.md",
@@ -53,13 +47,14 @@ non_translated_sections = (
"management-tasks.md",
"management.md",
"contributing.md",
"translations.md",
)
docs_path = Path("docs")
en_docs_path = Path("docs/en")
en_config_path: Path = en_docs_path / mkdocs_name
site_path = Path("site").absolute()
build_site_path = Path("site_build").absolute()
zensical_src_path = Path("site_zensical_src").absolute()
header_pattern = re.compile(r"^(#{1,6}) (.+?)(?:\s*\{\s*(#.*)\s*\})?\s*$")
header_with_permalink_pattern = re.compile(r"^(#{1,6}) (.+?)(\s*\{\s*#.*\s*\})\s*$")
@@ -106,7 +101,7 @@ def slugify(text: str) -> str:
def get_en_config() -> dict[str, Any]:
return mkdocs.utils.yaml_load(en_config_path.read_text(encoding="utf-8"))
return yaml.unsafe_load(en_config_path.read_text(encoding="utf-8"))
def get_lang_paths() -> list[Path]:
@@ -143,8 +138,6 @@ def new_lang(lang: str = typer.Argument(..., callback=lang_callback)):
typer.echo(f"The language was already created: {lang}")
raise typer.Abort()
new_path.mkdir()
new_config_path: Path = Path(new_path) / mkdocs_name
new_config_path.write_text("INHERIT: ../en/mkdocs.yml\n", encoding="utf-8")
new_llm_prompt_path: Path = new_path / "llm-prompt.md"
new_llm_prompt_path.write_text("", encoding="utf-8")
print(f"Successfully initialized: {new_path}")
@@ -160,29 +153,158 @@ def build_lang(
"""
Build the docs for a language.
"""
lang_path: Path = Path("docs") / lang
if not lang_path.is_dir():
build_zensical_lang_to_stage(lang)
copy_zensical_stage_to_site(lang)
typer.secho(f"Successfully built docs for: {lang}", color=typer.colors.GREEN)
def split_markdown_header(markdown: str) -> tuple[str, str]:
prefix = ""
if markdown.startswith("---\n"):
front_matter_end = markdown.find("\n---\n", 4)
if front_matter_end != -1:
front_matter_end += len("\n---\n")
prefix = markdown[:front_matter_end]
markdown = markdown[front_matter_end:]
if markdown.startswith("#"):
header, separator, body = markdown.partition("\n\n")
if separator:
return f"{prefix}{header}", body
if prefix:
return prefix.rstrip("\n"), markdown
return "", markdown
def add_markdown_notice(markdown: str, notice: str) -> str:
header, body = split_markdown_header(markdown)
if header:
return f"{header}\n\n{notice}\n\n{body}"
return f"{notice}\n\n{body}"
def is_non_translated_path(path: Path) -> bool:
src_path = path.as_posix()
return any(src_path.startswith(section) for section in non_translated_sections)
def get_en_url(path: Path) -> str:
url_path = path.with_suffix("").as_posix()
if url_path.endswith("/index"):
url_path = url_path.removesuffix("index")
elif url_path != "index":
url_path = f"{url_path}/"
else:
url_path = ""
return f"https://fastapi.tiangolo.com/{url_path}"
def get_zensical_theme_language(lang: str) -> str:
if lang == "zh-hant":
return "zh-Hant"
return lang
def stage_zensical_docs(lang: str) -> Path:
lang_docs_path = docs_path / lang / "docs"
if not lang_docs_path.is_dir():
typer.echo(f"The language translation doesn't seem to exist yet: {lang}")
raise typer.Abort()
typer.echo(f"Building docs for: {lang}")
build_site_dist_path = build_site_path / lang
en_docs_source_path = en_docs_path / "docs"
staged_docs_src_path = zensical_src_path / "docs_src"
if not staged_docs_src_path.exists():
shutil.copytree(Path("docs_src"), staged_docs_src_path, dirs_exist_ok=True)
lang_stage_path = zensical_src_path / lang
staged_docs_path = lang_stage_path / "content"
shutil.rmtree(lang_stage_path, ignore_errors=True)
shutil.copytree(en_docs_source_path, staged_docs_path)
missing_translation = (docs_path / "missing-translation.md").read_text(
encoding="utf-8"
)
translation_banner_path = lang_docs_path / "translation-banner.md"
if not translation_banner_path.is_file():
translation_banner_path = en_docs_source_path / "translation-banner.md"
translation_banner = translation_banner_path.read_text(encoding="utf-8")
if lang != "en":
for staged_file in staged_docs_path.rglob("*.md"):
relative_path = staged_file.relative_to(staged_docs_path)
translated_file = lang_docs_path / relative_path
if translated_file.is_file():
markdown = translated_file.read_text(encoding="utf-8")
if relative_path.name == "translation-banner.md":
staged_file.write_text(markdown, encoding="utf-8")
continue
en_url = get_en_url(relative_path)
banner = translation_banner.replace("ENGLISH_VERSION_URL", en_url)
staged_file.write_text(
add_markdown_notice(markdown, banner), encoding="utf-8"
)
elif not is_non_translated_path(relative_path):
markdown = staged_file.read_text(encoding="utf-8")
staged_file.write_text(
add_markdown_notice(markdown, missing_translation),
encoding="utf-8",
)
shutil.copytree(en_docs_path / "data", lang_stage_path / "data")
shutil.copytree(en_docs_path / "overrides", lang_stage_path / "overrides")
config = get_updated_config_content()
config["docs_dir"] = "content"
config["site_dir"] = "site"
if lang == "en":
config["site_url"] = "https://fastapi.tiangolo.com/"
else:
config["site_url"] = f"https://fastapi.tiangolo.com/{lang}/"
config.setdefault("theme", {})
config["theme"]["language"] = get_zensical_theme_language(lang)
if lang != "en":
# The root English build owns shared static assets; translated builds should
# reference those root paths instead of emitting language-local copies.
if "logo" in config["theme"]:
config["theme"]["logo"] = "/" + config["theme"]["logo"].lstrip("/")
if "favicon" in config["theme"]:
config["theme"]["favicon"] = "/" + config["theme"]["favicon"].lstrip("/")
config["extra_css"] = ["/" + path.lstrip("/") for path in config["extra_css"]]
config["extra_javascript"] = [
"/" + path.lstrip("/") for path in config["extra_javascript"]
]
config_path = lang_stage_path / mkdocs_name
config_path.write_text(
yaml.dump(config, sort_keys=False, width=200, allow_unicode=True),
encoding="utf-8",
)
return config_path
def build_zensical_config(config_path: Path) -> None:
subprocess.run(
["zensical", "build", "--config-file", config_path.name],
check=True,
cwd=config_path.parent,
)
def build_zensical_lang_to_stage(lang: str) -> Path:
typer.echo(f"Building Zensical docs for: {lang}")
config_path = stage_zensical_docs(lang)
config = yaml.unsafe_load(config_path.read_text(encoding="utf-8"))
build_site_dist_path = config_path.parent / config["site_dir"]
shutil.rmtree(build_site_dist_path, ignore_errors=True)
build_zensical_config(config_path)
return build_site_dist_path
def copy_zensical_stage_to_site(lang: str) -> None:
build_site_dist_path = zensical_src_path / lang / "site"
if lang == "en":
dist_path = site_path
# Don't remove en dist_path as it might already contain other languages.
# When running build_all(), that function already removes site_path.
# All this is only relevant locally, on GitHub Actions all this is done through
# artifacts and multiple workflows, so it doesn't matter if directories are
# removed or not.
else:
dist_path = site_path / lang
shutil.rmtree(dist_path, ignore_errors=True)
current_dir = os.getcwd()
os.chdir(lang_path)
shutil.rmtree(build_site_dist_path, ignore_errors=True)
subprocess.run(["mkdocs", "build", "--site-dir", build_site_dist_path], check=True)
shutil.copytree(build_site_dist_path, dist_path, dirs_exist_ok=True)
os.chdir(current_dir)
typer.secho(f"Successfully built docs for: {lang}", color=typer.colors.GREEN)
index_sponsors_template = """
@@ -224,7 +346,7 @@ def generate_readme_content() -> str:
match_start = re.search(r"<!-- sponsors -->", content)
match_end = re.search(r"<!-- /sponsors -->", content)
sponsors_data_path = en_docs_path / "data" / "sponsors.yml"
sponsors = mkdocs.utils.yaml_load(sponsors_data_path.read_text(encoding="utf-8"))
sponsors = yaml.safe_load(sponsors_data_path.read_text(encoding="utf-8"))
if not (match_start and match_end):
raise RuntimeError("Couldn't auto-generate sponsors section")
if not match_pre:
@@ -266,27 +388,33 @@ def generate_readme() -> None:
@app.command()
def build_all() -> None:
"""
Build mkdocs site for en, and then build each language inside, end result is located
at directory ./site/ with each language inside.
Build the full translated docs site into ./site/.
"""
update_languages()
shutil.rmtree(site_path, ignore_errors=True)
shutil.rmtree(zensical_src_path, ignore_errors=True)
shutil.copytree(Path("docs_src"), zensical_src_path / "docs_src")
langs = [
lang.name
for lang in get_lang_paths()
if (lang.is_dir() and lang.name in SUPPORTED_LANGS)
]
cpu_count = os.cpu_count() or 1
process_pool_size = cpu_count * 4
process_pool_size = min(4, len(langs), os.cpu_count() or 1)
typer.echo(f"Using process pool size: {process_pool_size}")
with Pool(process_pool_size) as p:
p.map(build_lang, langs)
p.map(build_zensical_lang_to_stage, langs)
if "en" in langs:
copy_zensical_stage_to_site("en")
for lang in langs:
if lang != "en":
copy_zensical_stage_to_site(lang)
typer.secho("Successfully built all docs", color=typer.colors.GREEN)
@app.command()
def update_languages() -> None:
"""
Update the mkdocs.yml file Languages section including all the available languages.
Update the docs config Languages section including all the available languages.
"""
old_config = get_en_config()
updated_config = get_updated_config_content()
@@ -306,7 +434,7 @@ def serve() -> None:
"""
A quick server to preview a built site with translations.
For development, prefer the command live (or just mkdocs serve).
For development, prefer the command live.
This is here only to preview a site with translations already built.
@@ -324,31 +452,21 @@ def serve() -> None:
@app.command()
def live(
lang: str = typer.Argument(
None, callback=lang_callback, autocompletion=complete_existing_lang
),
dirty: bool = False,
) -> None:
def live() -> None:
"""
Serve with livereload a docs site for a specific language.
This only shows the actual translated files, not the placeholders created with
build-all.
Takes an optional LANG argument with the name of the language to serve, by default
en.
Serve the English docs with livereload from the source files.
"""
# Enable line numbers during local development to make it easier to highlight
if lang is None:
lang = "en"
lang_path: Path = docs_path / lang
# Enable line numbers during local development to make it easier to highlight
args = ["mkdocs", "serve", "--dev-addr", "127.0.0.1:8008"]
if dirty:
args.append("--dirty")
subprocess.run(
args, env={**os.environ, "LINENUMS": "true"}, cwd=lang_path, check=True
[
"zensical",
"serve",
"--config-file",
mkdocs_name,
"--dev-addr",
"127.0.0.1:8008",
],
cwd=en_docs_path,
check=True,
)
@@ -359,7 +477,7 @@ def get_updated_config_content() -> dict[str, Any]:
# Language names sourced from https://quickref.me/iso-639-1
# Contributors may wish to update or change these, e.g. to fix capitalization.
language_names_path = Path(__file__).parent / "../docs/language_names.yml"
local_language_names: dict[str, str] = mkdocs.utils.yaml_load(
local_language_names: dict[str, str] = yaml.safe_load(
language_names_path.read_text(encoding="utf-8")
)
for lang_path in get_lang_paths():

View File

@@ -1,182 +0,0 @@
from functools import lru_cache
from pathlib import Path
from typing import Any
import material
from mkdocs.config.defaults import MkDocsConfig
from mkdocs.structure.files import File, Files
from mkdocs.structure.nav import Link, Navigation, Section
from mkdocs.structure.pages import Page
non_translated_sections = [
"reference/",
"release-notes.md",
"fastapi-people.md",
"external-links.md",
"newsletter.md",
"management-tasks.md",
"management.md",
]
@lru_cache
def get_missing_translation_content(docs_dir: str) -> str:
docs_dir_path = Path(docs_dir)
missing_translation_path = docs_dir_path.parent.parent / "missing-translation.md"
return missing_translation_path.read_text(encoding="utf-8")
@lru_cache
def get_translation_banner_content(docs_dir: str) -> str:
docs_dir_path = Path(docs_dir)
translation_banner_path = docs_dir_path / "translation-banner.md"
if not translation_banner_path.is_file():
translation_banner_path = (
docs_dir_path.parent.parent / "en" / "docs" / "translation-banner.md"
)
return translation_banner_path.read_text(encoding="utf-8")
@lru_cache
def get_mkdocs_material_langs() -> list[str]:
material_path = Path(material.__file__).parent
material_langs_path = material_path / "templates" / "partials" / "languages"
langs = [file.stem for file in material_langs_path.glob("*.html")]
return langs
class EnFile(File):
pass
def on_config(config: MkDocsConfig, **kwargs: Any) -> MkDocsConfig:
available_langs = get_mkdocs_material_langs()
dir_path = Path(config.docs_dir)
lang = dir_path.parent.name
if lang in available_langs:
config.theme["language"] = lang
if not (config.site_url or "").endswith(f"{lang}/") and lang != "en":
config.site_url = f"{config.site_url}{lang}/"
return config
def resolve_file(*, item: str, files: Files, config: MkDocsConfig) -> None:
item_path = Path(config.docs_dir) / item
if not item_path.is_file():
en_src_dir = (Path(config.docs_dir) / "../../en/docs").resolve()
potential_path = en_src_dir / item
if potential_path.is_file():
files.append(
EnFile(
path=item,
src_dir=str(en_src_dir),
dest_dir=config.site_dir,
use_directory_urls=config.use_directory_urls,
)
)
def resolve_files(*, items: list[Any], files: Files, config: MkDocsConfig) -> None:
for item in items:
if isinstance(item, str):
resolve_file(item=item, files=files, config=config)
elif isinstance(item, dict):
assert len(item) == 1
values = list(item.values())
if not values:
continue
if isinstance(values[0], str):
resolve_file(item=values[0], files=files, config=config)
elif isinstance(values[0], list):
resolve_files(items=values[0], files=files, config=config)
else:
raise ValueError(f"Unexpected value: {values}")
def on_files(files: Files, *, config: MkDocsConfig) -> Files:
resolve_files(items=config.nav or [], files=files, config=config)
if "logo" in config.theme:
resolve_file(item=config.theme["logo"], files=files, config=config)
if "favicon" in config.theme:
resolve_file(item=config.theme["favicon"], files=files, config=config)
resolve_files(items=config.extra_css, files=files, config=config)
resolve_files(items=config.extra_javascript, files=files, config=config)
return files
def generate_renamed_section_items(
items: list[Page | Section | Link], *, config: MkDocsConfig
) -> list[Page | Section | Link]:
new_items: list[Page | Section | Link] = []
for item in items:
if isinstance(item, Section):
new_title = item.title
new_children = generate_renamed_section_items(item.children, config=config)
first_child = new_children[0]
if isinstance(first_child, Page):
if first_child.file.src_path.endswith("index.md"):
# Read the source so that the title is parsed and available
first_child.read_source(config=config)
new_title = first_child.title or new_title
# Creating a new section makes it render it collapsed by default
# no idea why, so, let's just modify the existing one
# new_section = Section(title=new_title, children=new_children)
item.title = new_title.split("{ #")[0]
item.children = new_children
new_items.append(item)
else:
new_items.append(item)
return new_items
def on_nav(
nav: Navigation, *, config: MkDocsConfig, files: Files, **kwargs: Any
) -> Navigation:
new_items = generate_renamed_section_items(nav.items, config=config)
return Navigation(items=new_items, pages=nav.pages)
def on_pre_page(page: Page, *, config: MkDocsConfig, files: Files) -> Page:
return page
def on_page_markdown(
markdown: str, *, page: Page, config: MkDocsConfig, files: Files
) -> str:
# Set metadata["social"]["cards_layout_options"]["title"] to clean title (without
# permalink)
title = page.title
clean_title = title.split("{ #")[0]
if clean_title:
page.meta.setdefault("social", {})
page.meta["social"].setdefault("cards_layout_options", {})
page.meta["social"]["cards_layout_options"]["title"] = clean_title
if isinstance(page.file, EnFile):
for excluded_section in non_translated_sections:
if page.file.src_path.startswith(excluded_section):
return markdown
missing_translation_content = get_missing_translation_content(config.docs_dir)
header = ""
body = markdown
if markdown.startswith("#"):
header, _, body = markdown.partition("\n\n")
return f"{header}\n\n{missing_translation_content}\n\n{body}"
docs_dir_path = Path(config.docs_dir)
en_docs_dir_path = docs_dir_path.parent.parent / "en/docs"
if docs_dir_path == en_docs_dir_path:
return markdown
# For translated pages add translation banner
translation_banner_content = get_translation_banner_content(config.docs_dir)
en_url = "https://fastapi.tiangolo.com/" + page.url.lstrip("/")
translation_banner_content = translation_banner_content.replace(
"ENGLISH_VERSION_URL", en_url
)
header = ""
body = markdown
if markdown.startswith("#"):
header, _, body = markdown.partition("\n\n")
return f"{header}\n\n{translation_banner_content}\n\n{body}"

View File

@@ -24,6 +24,7 @@ non_translated_sections = (
"management-tasks.md",
"management.md",
"contributing.md",
"translations.md",
)
general_prompt_path = Path(__file__).absolute().parent / "general-llm-prompt.md"

View File

@@ -16,6 +16,7 @@ non_translated_sections = (
"management-tasks.md",
"management.md",
"contributing.md",
"translations.md",
)

View File

@@ -11,6 +11,10 @@ class Model(BaseModel):
model_config = {"extra": "allow"}
class AuthHeaders(BaseModel):
x_user_id: str
@app.get("/query")
async def query_model_with_extra(data: Model = Query()):
return data
@@ -26,6 +30,11 @@ async def cookies_model_with_extra(data: Model = Cookie()):
return data
@app.get("/header-requires-hyphen")
async def header_model_requires_hyphen(data: AuthHeaders = Header()):
return data
def test_query_pass_extra_list():
client = TestClient(app)
resp = client.get(
@@ -91,6 +100,32 @@ def test_header_pass_extra_single():
assert resp_json["param2"] == "456"
def test_header_model_prefers_hyphenated_header_with_convert_underscores():
client = TestClient(app)
resp = client.get(
"/header-requires-hyphen",
headers=[
("x-user-id", "hyphenated-value"),
("x_user_id", "underscore-value"),
],
)
assert resp.status_code == 200
assert resp.json() == {"x_user_id": "hyphenated-value"}
def test_header_model_rejects_underscore_header_with_convert_underscores():
client = TestClient(app)
resp = client.get(
"/header-requires-hyphen", headers={"x_user_id": "underscore-value"}
)
assert resp.status_code == 422
assert resp.json()["detail"][0]["loc"] == ["header", "x_user_id"]
def test_cookie_pass_extra_list():
client = TestClient(app)
client.cookies = [

View File

@@ -221,6 +221,15 @@ def test_server_sent_event_null_id_rejected():
ServerSentEvent(data="test", id="has\0null")
@pytest.mark.parametrize("field_name", ["event", "id"])
@pytest.mark.parametrize("value", ["first\nsecond", "first\rsecond", "first\r\nsecond"])
def test_server_sent_event_single_line_fields_reject_newlines(
field_name: str, value: str
):
with pytest.raises(ValueError, match=f"SSE '{field_name}' must be a single line"):
ServerSentEvent(data="test", **{field_name: value})
def test_server_sent_event_negative_retry_rejected():
with pytest.raises(ValueError):
ServerSentEvent(data="test", retry=-1)

View File

@@ -1,4 +1,5 @@
import importlib
from functools import lru_cache
from types import ModuleType
import pytest
@@ -14,6 +15,7 @@ from ...utils import needs_py310
pytest.param("tutorial005_py310", marks=needs_py310),
pytest.param("tutorial005_an_py310", marks=needs_py310),
],
scope="module",
)
def get_mod(request: pytest.FixtureRequest):
mod = importlib.import_module(f"docs_src.security.{request.param}")
@@ -21,6 +23,20 @@ def get_mod(request: pytest.FixtureRequest):
return mod
@pytest.fixture(scope="module", autouse=True)
def cache_verify_password(mod: ModuleType):
assert hasattr(mod, "verify_password"), (
f"Module {mod.__name__} does not have attribute 'verify_password'"
)
original_func = mod.verify_password
cached_func = lru_cache()(original_func)
mod.verify_password = cached_func
yield
mod.verify_password = original_func
def get_access_token(
*, username="johndoe", password="secret", scope=None, client: TestClient
):

View File

@@ -25,6 +25,7 @@ def clear_sqlmodel():
pytest.param("tutorial001_py310", marks=needs_py310),
pytest.param("tutorial001_an_py310", marks=needs_py310),
],
scope="module",
)
def get_client(request: pytest.FixtureRequest):
clear_sqlmodel()

View File

@@ -25,6 +25,7 @@ def clear_sqlmodel():
pytest.param("tutorial002_py310", marks=needs_py310),
pytest.param("tutorial002_an_py310", marks=needs_py310),
],
scope="module",
)
def get_client(request: pytest.FixtureRequest):
clear_sqlmodel()

1075
uv.lock generated
View File

File diff suppressed because it is too large Load Diff