├── .github ├── DISCUSSION_TEMPLATE │ ├── general.yml │ └── questions.yml ├── ISSUE_TEMPLATE │ ├── config.yml │ └── privileged.yml ├── actions │ ├── comment-docs-preview-in-pr │ │ ├── Dockerfile │ │ ├── action.yml │ │ └── app │ │ │ └── main.py │ ├── notify-translations │ │ ├── Dockerfile │ │ ├── action.yml │ │ └── app │ │ │ ├── main.py │ │ │ └── translations.yml │ └── people │ │ ├── Dockerfile │ │ ├── action.yml │ │ └── app │ │ ├── debug.sh │ │ └── main.py └── workflows │ ├── build-docs.yml │ ├── deploy-docs.yml │ ├── issue-manager.yml │ ├── label-approved.yml │ ├── latest-changes.yml │ ├── notify-translations.yml │ ├── people.yml │ ├── release-notes.jinja2 │ ├── smokeshow.yml │ ├── test.yml │ └── tmate.yml ├── .gitignore ├── LICENSE ├── README.md ├── app ├── __init__.py ├── main.py └── utils.py ├── docs-comment-deploy.sh ├── docs ├── en │ ├── data │ │ ├── external_links.yml │ │ ├── github_sponsors.yml │ │ ├── people.yml │ │ ├── sponsors.yml │ │ └── sponsors_badge.yml │ ├── docs │ │ ├── advanced │ │ │ ├── additional-responses.md │ │ │ ├── additional-status-codes.md │ │ │ ├── advanced-dependencies.md │ │ │ ├── async-sql-databases.md │ │ │ ├── async-tests.md │ │ │ ├── behind-a-proxy.md │ │ │ ├── conditional-openapi.md │ │ │ ├── custom-request-and-route.md │ │ │ ├── custom-response.md │ │ │ ├── dataclasses.md │ │ │ ├── events.md │ │ │ ├── extending-openapi.md │ │ │ ├── generate-clients.md │ │ │ ├── graphql.md │ │ │ ├── index.md │ │ │ ├── middleware.md │ │ │ ├── nosql-databases.md │ │ │ ├── openapi-callbacks.md │ │ │ ├── path-operation-advanced-configuration.md │ │ │ ├── response-change-status-code.md │ │ │ ├── response-cookies.md │ │ │ ├── response-directly.md │ │ │ ├── response-headers.md │ │ │ ├── security │ │ │ │ ├── http-basic-auth.md │ │ │ │ ├── index.md │ │ │ │ └── oauth2-scopes.md │ │ │ ├── settings.md │ │ │ ├── sql-databases-peewee.md │ │ │ ├── sub-applications.md │ │ │ ├── templates.md │ │ │ ├── testing-database.md │ │ │ ├── testing-dependencies.md │ │ │ ├── testing-events.md │ │ │ ├── testing-websockets.md │ │ │ ├── using-request-directly.md │ │ │ ├── websockets.md │ │ │ └── wsgi.md │ │ ├── alternatives.md │ │ ├── async.md │ │ ├── benchmarks.md │ │ ├── contributing.md │ │ ├── css │ │ │ ├── custom.css │ │ │ └── termynal.css │ │ ├── deployment │ │ │ ├── concepts.md │ │ │ ├── deta.md │ │ │ ├── docker.md │ │ │ ├── https.md │ │ │ ├── index.md │ │ │ ├── manually.md │ │ │ ├── server-workers.md │ │ │ └── versions.md │ │ ├── external-links.md │ │ ├── fastapi-people.md │ │ ├── features.md │ │ ├── help-fastapi.md │ │ ├── history-design-future.md │ │ ├── img │ │ │ ├── async │ │ │ │ ├── concurrent-burgers │ │ │ │ │ ├── concurrent-burgers-01.png │ │ │ │ │ ├── concurrent-burgers-02.png │ │ │ │ │ ├── concurrent-burgers-03.png │ │ │ │ │ ├── concurrent-burgers-04.png │ │ │ │ │ ├── concurrent-burgers-05.png │ │ │ │ │ ├── concurrent-burgers-06.png │ │ │ │ │ └── concurrent-burgers-07.png │ │ │ │ └── parallel-burgers │ │ │ │ │ ├── parallel-burgers-01.png │ │ │ │ │ ├── parallel-burgers-02.png │ │ │ │ │ ├── parallel-burgers-03.png │ │ │ │ │ ├── parallel-burgers-04.png │ │ │ │ │ ├── parallel-burgers-05.png │ │ │ │ │ └── parallel-burgers-06.png │ │ │ ├── deployment │ │ │ │ ├── concepts │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── process-ram.drawio │ │ │ │ │ └── process-ram.svg │ │ │ │ ├── deta │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── image02.png │ │ │ │ │ ├── image03.png │ │ │ │ │ ├── image04.png │ │ │ │ │ ├── image05.png │ │ │ │ │ └── image06.png │ │ │ │ └── https │ │ │ │ │ ├── https.drawio │ │ │ │ │ ├── https.svg │ │ │ │ │ ├── https01.drawio │ │ │ │ │ ├── https01.svg │ │ │ │ │ ├── https02.drawio │ │ │ │ │ ├── https02.svg │ │ │ │ │ ├── https03.drawio │ │ │ │ │ ├── https03.svg │ │ │ │ │ ├── https04.drawio │ │ │ │ │ ├── https04.svg │ │ │ │ │ ├── https05.drawio │ │ │ │ │ ├── https05.svg │ │ │ │ │ ├── https06.drawio │ │ │ │ │ ├── https06.svg │ │ │ │ │ ├── https07.drawio │ │ │ │ │ ├── https07.svg │ │ │ │ │ ├── https08.drawio │ │ │ │ │ └── https08.svg │ │ │ ├── favicon.png │ │ │ ├── github-social-preview.png │ │ │ ├── github-social-preview.svg │ │ │ ├── icon-transparent-bg.png │ │ │ ├── icon-white-bg.png │ │ │ ├── icon-white.svg │ │ │ ├── index │ │ │ │ ├── index-01-swagger-ui-simple.png │ │ │ │ ├── index-02-redoc-simple.png │ │ │ │ ├── index-03-swagger-02.png │ │ │ │ ├── index-04-swagger-03.png │ │ │ │ ├── index-05-swagger-04.png │ │ │ │ └── index-06-redoc-02.png │ │ │ ├── logo-margin │ │ │ │ ├── logo-teal-vector.svg │ │ │ │ ├── logo-teal.png │ │ │ │ ├── logo-teal.svg │ │ │ │ └── logo-white-bg.png │ │ │ ├── logo-teal-vector.svg │ │ │ ├── logo-teal.svg │ │ │ ├── pycharm-completion.png │ │ │ ├── python-types │ │ │ │ ├── image01.png │ │ │ │ ├── image02.png │ │ │ │ ├── image03.png │ │ │ │ ├── image04.png │ │ │ │ ├── image05.png │ │ │ │ └── image06.png │ │ │ ├── sponsors │ │ │ │ ├── budget-insight.svg │ │ │ │ ├── calmcode.jpg │ │ │ │ ├── classiq-banner.png │ │ │ │ ├── classiq.png │ │ │ │ ├── cryptapi-banner.svg │ │ │ │ ├── cryptapi.svg │ │ │ │ ├── databento.svg │ │ │ │ ├── deta-banner.svg │ │ │ │ ├── deta.svg │ │ │ │ ├── docarray-top-banner.svg │ │ │ │ ├── docarray.svg │ │ │ │ ├── doist-banner.svg │ │ │ │ ├── doist.svg │ │ │ │ ├── dropbase-banner.svg │ │ │ │ ├── dropbase.svg │ │ │ │ ├── exoflare.png │ │ │ │ ├── fastapi-course-bundle-banner.png │ │ │ │ ├── fastapi-course-bundle-banner.svg │ │ │ │ ├── flint.png │ │ │ │ ├── haystack-fastapi.svg │ │ │ │ ├── imgwhale-banner.svg │ │ │ │ ├── imgwhale.svg │ │ │ │ ├── ines-course.jpg │ │ │ │ ├── investsuite.svg │ │ │ │ ├── jina-ai-banner.png │ │ │ │ ├── jina-ai.png │ │ │ │ ├── jina-banner.svg │ │ │ │ ├── jina-top-banner.svg │ │ │ │ ├── jina.svg │ │ │ │ ├── jina2.svg │ │ │ │ ├── platform-sh-banner.png │ │ │ │ ├── platform-sh.png │ │ │ │ ├── powens.png │ │ │ │ ├── striveworks-banner.png │ │ │ │ ├── striveworks.png │ │ │ │ ├── striveworks2.png │ │ │ │ ├── svix.svg │ │ │ │ ├── talkpython.png │ │ │ │ ├── testdriven.svg │ │ │ │ ├── vimso.png │ │ │ │ └── wetransfer.svg │ │ │ ├── tutorial │ │ │ │ ├── additional-responses │ │ │ │ │ └── image01.png │ │ │ │ ├── async-sql-databases │ │ │ │ │ └── image01.png │ │ │ │ ├── behind-a-proxy │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── image02.png │ │ │ │ │ └── image03.png │ │ │ │ ├── bigger-applications │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── package.drawio │ │ │ │ │ └── package.svg │ │ │ │ ├── body-fields │ │ │ │ │ ├── image01.png │ │ │ │ │ └── image02.png │ │ │ │ ├── body-nested-models │ │ │ │ │ └── image01.png │ │ │ │ ├── body │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── image02.png │ │ │ │ │ ├── image03.png │ │ │ │ │ ├── image04.png │ │ │ │ │ └── image05.png │ │ │ │ ├── custom-response │ │ │ │ │ └── image01.png │ │ │ │ ├── dataclasses │ │ │ │ │ └── image01.png │ │ │ │ ├── debugging │ │ │ │ │ ├── image01.png │ │ │ │ │ └── image02.png │ │ │ │ ├── dependencies │ │ │ │ │ ├── image01.png │ │ │ │ │ └── image02.png │ │ │ │ ├── extending-openapi │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── image02.png │ │ │ │ │ ├── image03.png │ │ │ │ │ └── image04.png │ │ │ │ ├── generate-clients │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── image02.png │ │ │ │ │ ├── image03.png │ │ │ │ │ ├── image04.png │ │ │ │ │ ├── image05.png │ │ │ │ │ ├── image06.png │ │ │ │ │ ├── image07.png │ │ │ │ │ └── image08.png │ │ │ │ ├── graphql │ │ │ │ │ └── image01.png │ │ │ │ ├── metadata │ │ │ │ │ ├── image01.png │ │ │ │ │ └── image02.png │ │ │ │ ├── openapi-callbacks │ │ │ │ │ └── image01.png │ │ │ │ ├── path-operation-advanced-configuration │ │ │ │ │ └── image01.png │ │ │ │ ├── path-operation-configuration │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── image02.png │ │ │ │ │ ├── image03.png │ │ │ │ │ ├── image04.png │ │ │ │ │ └── image05.png │ │ │ │ ├── path-params │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── image02.png │ │ │ │ │ └── image03.png │ │ │ │ ├── query-params-str-validations │ │ │ │ │ ├── image01.png │ │ │ │ │ └── image02.png │ │ │ │ ├── response-model │ │ │ │ │ ├── image01.png │ │ │ │ │ └── image02.png │ │ │ │ ├── response-status-code │ │ │ │ │ ├── image01.png │ │ │ │ │ └── image02.png │ │ │ │ ├── security │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── image02.png │ │ │ │ │ ├── image03.png │ │ │ │ │ ├── image04.png │ │ │ │ │ ├── image05.png │ │ │ │ │ ├── image06.png │ │ │ │ │ ├── image07.png │ │ │ │ │ ├── image08.png │ │ │ │ │ ├── image09.png │ │ │ │ │ ├── image10.png │ │ │ │ │ ├── image11.png │ │ │ │ │ └── image12.png │ │ │ │ ├── sql-databases │ │ │ │ │ ├── image01.png │ │ │ │ │ └── image02.png │ │ │ │ ├── sub-applications │ │ │ │ │ ├── image01.png │ │ │ │ │ └── image02.png │ │ │ │ └── websockets │ │ │ │ │ ├── image01.png │ │ │ │ │ ├── image02.png │ │ │ │ │ ├── image03.png │ │ │ │ │ ├── image04.png │ │ │ │ │ └── image05.png │ │ │ └── vscode-completion.png │ │ ├── index.md │ │ ├── js │ │ │ ├── chat.js │ │ │ ├── custom.js │ │ │ └── termynal.js │ │ ├── newsletter.md │ │ ├── project-generation.md │ │ ├── python-types.md │ │ ├── release-notes.md │ │ └── tutorial │ │ │ ├── background-tasks.md │ │ │ ├── bigger-applications.md │ │ │ ├── body-fields.md │ │ │ ├── body-multiple-params.md │ │ │ ├── body-nested-models.md │ │ │ ├── body-updates.md │ │ │ ├── body.md │ │ │ ├── cookie-params.md │ │ │ ├── cors.md │ │ │ ├── debugging.md │ │ │ ├── dependencies │ │ │ ├── classes-as-dependencies.md │ │ │ ├── dependencies-in-path-operation-decorators.md │ │ │ ├── dependencies-with-yield.md │ │ │ ├── global-dependencies.md │ │ │ ├── index.md │ │ │ └── sub-dependencies.md │ │ │ ├── encoder.md │ │ │ ├── extra-data-types.md │ │ │ ├── extra-models.md │ │ │ ├── first-steps.md │ │ │ ├── handling-errors.md │ │ │ ├── header-params.md │ │ │ ├── index.md │ │ │ ├── metadata.md │ │ │ ├── middleware.md │ │ │ ├── path-operation-configuration.md │ │ │ ├── path-params-numeric-validations.md │ │ │ ├── path-params.md │ │ │ ├── query-params-str-validations.md │ │ │ ├── query-params.md │ │ │ ├── request-files.md │ │ │ ├── request-forms-and-files.md │ │ │ ├── request-forms.md │ │ │ ├── response-model.md │ │ │ ├── response-status-code.md │ │ │ ├── schema-extra-example.md │ │ │ ├── security │ │ │ ├── first-steps.md │ │ │ ├── get-current-user.md │ │ │ ├── index.md │ │ │ ├── oauth2-jwt.md │ │ │ └── simple-oauth2.md │ │ │ ├── sql-databases.md │ │ │ ├── static-files.md │ │ │ └── testing.md │ ├── mkdocs.yml │ └── overrides │ │ └── main.html ├── es │ ├── docs │ │ ├── advanced │ │ │ ├── additional-status-codes.md │ │ │ ├── index.md │ │ │ ├── path-operation-advanced-configuration.md │ │ │ └── response-directly.md │ │ ├── async.md │ │ ├── features.md │ │ ├── index.md │ │ ├── python-types.md │ │ └── tutorial │ │ │ ├── first-steps.md │ │ │ ├── index.md │ │ │ ├── path-params.md │ │ │ └── query-params.md │ ├── mkdocs.yml │ └── overrides │ │ └── .gitignore ├── ja │ ├── docs │ │ ├── advanced │ │ │ ├── additional-status-codes.md │ │ │ ├── conditional-openapi.md │ │ │ ├── custom-response.md │ │ │ ├── index.md │ │ │ ├── nosql-databases.md │ │ │ ├── path-operation-advanced-configuration.md │ │ │ ├── response-directly.md │ │ │ └── websockets.md │ │ ├── alternatives.md │ │ ├── async.md │ │ ├── benchmarks.md │ │ ├── contributing.md │ │ ├── deployment │ │ │ ├── deta.md │ │ │ ├── docker.md │ │ │ ├── index.md │ │ │ ├── manually.md │ │ │ └── versions.md │ │ ├── external-links.md │ │ ├── fastapi-people.md │ │ ├── features.md │ │ ├── help-fastapi.md │ │ ├── history-design-future.md │ │ ├── index.md │ │ ├── project-generation.md │ │ └── tutorial │ │ │ ├── body-updates.md │ │ │ ├── body.md │ │ │ ├── cookie-params.md │ │ │ ├── cors.md │ │ │ ├── debugging.md │ │ │ ├── first-steps.md │ │ │ ├── header-params.md │ │ │ ├── index.md │ │ │ ├── middleware.md │ │ │ ├── path-params.md │ │ │ ├── query-params-str-validations.md │ │ │ ├── query-params.md │ │ │ ├── request-forms.md │ │ │ ├── security │ │ │ ├── first-steps.md │ │ │ └── oauth2-jwt.md │ │ │ ├── static-files.md │ │ │ └── testing.md │ ├── mkdocs.yml │ └── overrides │ │ └── .gitignore └── missing-translation.md ├── docs_src ├── additional_responses │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial003.py │ └── tutorial004.py ├── additional_status_codes │ ├── tutorial001.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py310.py │ ├── tutorial001_an_py39.py │ └── tutorial001_py310.py ├── advanced_middleware │ ├── tutorial001.py │ ├── tutorial002.py │ └── tutorial003.py ├── app_testing │ ├── __init__.py │ ├── app_b │ │ ├── __init__.py │ │ ├── main.py │ │ └── test_main.py │ ├── app_b_an │ │ ├── __init__.py │ │ ├── main.py │ │ └── test_main.py │ ├── app_b_an_py310 │ │ ├── __init__.py │ │ ├── main.py │ │ └── test_main.py │ ├── app_b_an_py39 │ │ ├── __init__.py │ │ ├── main.py │ │ └── test_main.py │ ├── app_b_py310 │ │ ├── __init__.py │ │ ├── main.py │ │ └── test_main.py │ ├── main.py │ ├── test_main.py │ ├── tutorial001.py │ ├── tutorial002.py │ └── tutorial003.py ├── async_sql_databases │ └── tutorial001.py ├── async_tests │ ├── __init__.py │ ├── main.py │ └── test_main.py ├── background_tasks │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial002_an.py │ ├── tutorial002_an_py310.py │ ├── tutorial002_an_py39.py │ └── tutorial002_py310.py ├── behind_a_proxy │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial003.py │ └── tutorial004.py ├── bigger_applications │ ├── __init__.py │ ├── app │ │ ├── __init__.py │ │ ├── dependencies.py │ │ ├── internal │ │ │ ├── __init__.py │ │ │ └── admin.py │ │ ├── main.py │ │ └── routers │ │ │ ├── __init__.py │ │ │ ├── items.py │ │ │ └── users.py │ ├── app_an │ │ ├── __init__.py │ │ ├── dependencies.py │ │ ├── internal │ │ │ ├── __init__.py │ │ │ └── admin.py │ │ ├── main.py │ │ └── routers │ │ │ ├── __init__.py │ │ │ ├── items.py │ │ │ └── users.py │ └── app_an_py39 │ │ ├── __init__.py │ │ ├── dependencies.py │ │ ├── internal │ │ ├── __init__.py │ │ └── admin.py │ │ ├── main.py │ │ └── routers │ │ ├── __init__.py │ │ ├── items.py │ │ └── users.py ├── body │ ├── tutorial001.py │ ├── tutorial001_py310.py │ ├── tutorial002.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_py310.py │ ├── tutorial004.py │ └── tutorial004_py310.py ├── body_fields │ ├── tutorial001.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py310.py │ ├── tutorial001_an_py39.py │ └── tutorial001_py310.py ├── body_multiple_params │ ├── tutorial001.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py310.py │ ├── tutorial001_an_py39.py │ ├── tutorial001_py310.py │ ├── tutorial002.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_an.py │ ├── tutorial003_an_py310.py │ ├── tutorial003_an_py39.py │ ├── tutorial003_py310.py │ ├── tutorial004.py │ ├── tutorial004_an.py │ ├── tutorial004_an_py310.py │ ├── tutorial004_an_py39.py │ ├── tutorial004_py310.py │ ├── tutorial005.py │ ├── tutorial005_an.py │ ├── tutorial005_an_py310.py │ ├── tutorial005_an_py39.py │ └── tutorial005_py310.py ├── body_nested_models │ ├── tutorial001.py │ ├── tutorial001_py310.py │ ├── tutorial002.py │ ├── tutorial002_py310.py │ ├── tutorial002_py39.py │ ├── tutorial003.py │ ├── tutorial003_py310.py │ ├── tutorial003_py39.py │ ├── tutorial004.py │ ├── tutorial004_py310.py │ ├── tutorial004_py39.py │ ├── tutorial005.py │ ├── tutorial005_py310.py │ ├── tutorial005_py39.py │ ├── tutorial006.py │ ├── tutorial006_py310.py │ ├── tutorial006_py39.py │ ├── tutorial007.py │ ├── tutorial007_py310.py │ ├── tutorial007_py39.py │ ├── tutorial008.py │ ├── tutorial008_py39.py │ ├── tutorial009.py │ └── tutorial009_py39.py ├── body_updates │ ├── tutorial001.py │ ├── tutorial001_py310.py │ ├── tutorial001_py39.py │ ├── tutorial002.py │ ├── tutorial002_py310.py │ └── tutorial002_py39.py ├── conditional_openapi │ └── tutorial001.py ├── cookie_params │ ├── tutorial001.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py310.py │ ├── tutorial001_an_py39.py │ └── tutorial001_py310.py ├── cors │ └── tutorial001.py ├── custom_request_and_route │ ├── tutorial001.py │ ├── tutorial002.py │ └── tutorial003.py ├── custom_response │ ├── tutorial001.py │ ├── tutorial001b.py │ ├── tutorial002.py │ ├── tutorial003.py │ ├── tutorial004.py │ ├── tutorial005.py │ ├── tutorial006.py │ ├── tutorial006b.py │ ├── tutorial006c.py │ ├── tutorial007.py │ ├── tutorial008.py │ ├── tutorial009.py │ ├── tutorial009b.py │ ├── tutorial009c.py │ └── tutorial010.py ├── dataclasses │ ├── tutorial001.py │ ├── tutorial002.py │ └── tutorial003.py ├── debugging │ └── tutorial001.py ├── dependencies │ ├── tutorial001.py │ ├── tutorial001_02_an.py │ ├── tutorial001_02_an_py310.py │ ├── tutorial001_02_an_py39.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py310.py │ ├── tutorial001_an_py39.py │ ├── tutorial001_py310.py │ ├── tutorial002.py │ ├── tutorial002_an.py │ ├── tutorial002_an_py310.py │ ├── tutorial002_an_py39.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_an.py │ ├── tutorial003_an_py310.py │ ├── tutorial003_an_py39.py │ ├── tutorial003_py310.py │ ├── tutorial004.py │ ├── tutorial004_an.py │ ├── tutorial004_an_py310.py │ ├── tutorial004_an_py39.py │ ├── tutorial004_py310.py │ ├── tutorial005.py │ ├── tutorial005_an.py │ ├── tutorial005_an_py310.py │ ├── tutorial005_an_py39.py │ ├── tutorial005_py310.py │ ├── tutorial006.py │ ├── tutorial006_an.py │ ├── tutorial006_an_py39.py │ ├── tutorial007.py │ ├── tutorial008.py │ ├── tutorial008_an.py │ ├── tutorial008_an_py39.py │ ├── tutorial009.py │ ├── tutorial010.py │ ├── tutorial011.py │ ├── tutorial011_an.py │ ├── tutorial011_an_py39.py │ ├── tutorial012.py │ ├── tutorial012_an.py │ └── tutorial012_an_py39.py ├── dependency_testing │ ├── tutorial001.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py310.py │ ├── tutorial001_an_py39.py │ └── tutorial001_py310.py ├── encoder │ ├── tutorial001.py │ └── tutorial001_py310.py ├── events │ ├── tutorial001.py │ ├── tutorial002.py │ └── tutorial003.py ├── extending_openapi │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial003.py │ ├── tutorial004.py │ └── tutorial005.py ├── extra_data_types │ ├── tutorial001.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py310.py │ ├── tutorial001_an_py39.py │ └── tutorial001_py310.py ├── extra_models │ ├── tutorial001.py │ ├── tutorial001_py310.py │ ├── tutorial002.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_py310.py │ ├── tutorial004.py │ ├── tutorial004_py39.py │ ├── tutorial005.py │ └── tutorial005_py39.py ├── first_steps │ ├── tutorial001.py │ ├── tutorial002.py │ └── tutorial003.py ├── generate_clients │ ├── tutorial001.py │ ├── tutorial001_py39.py │ ├── tutorial002.py │ ├── tutorial002_py39.py │ ├── tutorial003.py │ ├── tutorial003_py39.py │ └── tutorial004.py ├── graphql │ └── tutorial001.py ├── handling_errors │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial003.py │ ├── tutorial004.py │ ├── tutorial005.py │ └── tutorial006.py ├── header_params │ ├── tutorial001.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py310.py │ ├── tutorial001_an_py39.py │ ├── tutorial001_py310.py │ ├── tutorial002.py │ ├── tutorial002_an.py │ ├── tutorial002_an_py310.py │ ├── tutorial002_an_py39.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_an.py │ ├── tutorial003_an_py310.py │ ├── tutorial003_an_py39.py │ ├── tutorial003_py310.py │ └── tutorial003_py39.py ├── metadata │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial003.py │ └── tutorial004.py ├── middleware │ └── tutorial001.py ├── nosql_databases │ └── tutorial001.py ├── openapi_callbacks │ └── tutorial001.py ├── path_operation_advanced_configuration │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial003.py │ ├── tutorial004.py │ ├── tutorial005.py │ ├── tutorial006.py │ └── tutorial007.py ├── path_operation_configuration │ ├── tutorial001.py │ ├── tutorial001_py310.py │ ├── tutorial001_py39.py │ ├── tutorial002.py │ ├── tutorial002_py310.py │ ├── tutorial002_py39.py │ ├── tutorial002b.py │ ├── tutorial003.py │ ├── tutorial003_py310.py │ ├── tutorial003_py39.py │ ├── tutorial004.py │ ├── tutorial004_py310.py │ ├── tutorial004_py39.py │ ├── tutorial005.py │ ├── tutorial005_py310.py │ ├── tutorial005_py39.py │ └── tutorial006.py ├── path_params │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial003.py │ ├── tutorial003b.py │ ├── tutorial004.py │ └── tutorial005.py ├── path_params_numeric_validations │ ├── tutorial001.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py310.py │ ├── tutorial001_an_py39.py │ ├── tutorial001_py310.py │ ├── tutorial002.py │ ├── tutorial002_an.py │ ├── tutorial002_an_py39.py │ ├── tutorial003.py │ ├── tutorial003_an.py │ ├── tutorial003_an_py39.py │ ├── tutorial004.py │ ├── tutorial004_an.py │ ├── tutorial004_an_py39.py │ ├── tutorial005.py │ ├── tutorial005_an.py │ ├── tutorial005_an_py39.py │ ├── tutorial006.py │ ├── tutorial006_an.py │ └── tutorial006_an_py39.py ├── python_types │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial003.py │ ├── tutorial004.py │ ├── tutorial005.py │ ├── tutorial006.py │ ├── tutorial006_py39.py │ ├── tutorial007.py │ ├── tutorial007_py39.py │ ├── tutorial008.py │ ├── tutorial008_py39.py │ ├── tutorial008b.py │ ├── tutorial008b_py310.py │ ├── tutorial009.py │ ├── tutorial009_py310.py │ ├── tutorial009b.py │ ├── tutorial009c.py │ ├── tutorial009c_py310.py │ ├── tutorial010.py │ ├── tutorial011.py │ ├── tutorial011_py310.py │ ├── tutorial011_py39.py │ ├── tutorial012.py │ ├── tutorial013.py │ └── tutorial013_py39.py ├── query_params │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_py310.py │ ├── tutorial004.py │ ├── tutorial004_py310.py │ ├── tutorial005.py │ ├── tutorial006.py │ ├── tutorial006_py310.py │ └── tutorial006b.py ├── query_params_str_validations │ ├── tutorial001.py │ ├── tutorial001_py310.py │ ├── tutorial002.py │ ├── tutorial002_an.py │ ├── tutorial002_an_py310.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_an.py │ ├── tutorial003_an_py310.py │ ├── tutorial003_an_py39.py │ ├── tutorial003_py310.py │ ├── tutorial004.py │ ├── tutorial004_an.py │ ├── tutorial004_an_py310.py │ ├── tutorial004_an_py39.py │ ├── tutorial004_py310.py │ ├── tutorial005.py │ ├── tutorial005_an.py │ ├── tutorial005_an_py39.py │ ├── tutorial006.py │ ├── tutorial006_an.py │ ├── tutorial006_an_py39.py │ ├── tutorial006b.py │ ├── tutorial006b_an.py │ ├── tutorial006b_an_py39.py │ ├── tutorial006c.py │ ├── tutorial006c_an.py │ ├── tutorial006c_an_py310.py │ ├── tutorial006c_an_py39.py │ ├── tutorial006c_py310.py │ ├── tutorial006d.py │ ├── tutorial006d_an.py │ ├── tutorial006d_an_py39.py │ ├── tutorial007.py │ ├── tutorial007_an.py │ ├── tutorial007_an_py310.py │ ├── tutorial007_an_py39.py │ ├── tutorial007_py310.py │ ├── tutorial008.py │ ├── tutorial008_an.py │ ├── tutorial008_an_py310.py │ ├── tutorial008_an_py39.py │ ├── tutorial008_py310.py │ ├── tutorial009.py │ ├── tutorial009_an.py │ ├── tutorial009_an_py310.py │ ├── tutorial009_an_py39.py │ ├── tutorial009_py310.py │ ├── tutorial010.py │ ├── tutorial010_an.py │ ├── tutorial010_an_py310.py │ ├── tutorial010_an_py39.py │ ├── tutorial010_py310.py │ ├── tutorial011.py │ ├── tutorial011_an.py │ ├── tutorial011_an_py310.py │ ├── tutorial011_an_py39.py │ ├── tutorial011_py310.py │ ├── tutorial011_py39.py │ ├── tutorial012.py │ ├── tutorial012_an.py │ ├── tutorial012_an_py39.py │ ├── tutorial012_py39.py │ ├── tutorial013.py │ ├── tutorial013_an.py │ ├── tutorial013_an_py39.py │ ├── tutorial014.py │ ├── tutorial014_an.py │ ├── tutorial014_an_py310.py │ ├── tutorial014_an_py39.py │ └── tutorial014_py310.py ├── request_files │ ├── tutorial001.py │ ├── tutorial001_02.py │ ├── tutorial001_02_an.py │ ├── tutorial001_02_an_py310.py │ ├── tutorial001_02_an_py39.py │ ├── tutorial001_02_py310.py │ ├── tutorial001_03.py │ ├── tutorial001_03_an.py │ ├── tutorial001_03_an_py39.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py39.py │ ├── tutorial002.py │ ├── tutorial002_an.py │ ├── tutorial002_an_py39.py │ ├── tutorial002_py39.py │ ├── tutorial003.py │ ├── tutorial003_an.py │ ├── tutorial003_an_py39.py │ └── tutorial003_py39.py ├── request_forms │ ├── tutorial001.py │ ├── tutorial001_an.py │ └── tutorial001_an_py39.py ├── request_forms_and_files │ ├── tutorial001.py │ ├── tutorial001_an.py │ └── tutorial001_an_py39.py ├── response_change_status_code │ └── tutorial001.py ├── response_cookies │ ├── tutorial001.py │ └── tutorial002.py ├── response_directly │ ├── tutorial001.py │ └── tutorial002.py ├── response_headers │ ├── tutorial001.py │ └── tutorial002.py ├── response_model │ ├── tutorial001.py │ ├── tutorial001_01.py │ ├── tutorial001_01_py310.py │ ├── tutorial001_01_py39.py │ ├── tutorial001_py310.py │ ├── tutorial001_py39.py │ ├── tutorial002.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_01.py │ ├── tutorial003_01_py310.py │ ├── tutorial003_02.py │ ├── tutorial003_03.py │ ├── tutorial003_04.py │ ├── tutorial003_04_py310.py │ ├── tutorial003_05.py │ ├── tutorial003_05_py310.py │ ├── tutorial003_py310.py │ ├── tutorial004.py │ ├── tutorial004_py310.py │ ├── tutorial004_py39.py │ ├── tutorial005.py │ ├── tutorial005_py310.py │ ├── tutorial006.py │ └── tutorial006_py310.py ├── response_status_code │ ├── tutorial001.py │ └── tutorial002.py ├── schema_extra_example │ ├── tutorial001.py │ ├── tutorial001_py310.py │ ├── tutorial002.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_an.py │ ├── tutorial003_an_py310.py │ ├── tutorial003_an_py39.py │ ├── tutorial003_py310.py │ ├── tutorial004.py │ ├── tutorial004_an.py │ ├── tutorial004_an_py310.py │ ├── tutorial004_an_py39.py │ └── tutorial004_py310.py ├── security │ ├── tutorial001.py │ ├── tutorial001_an.py │ ├── tutorial001_an_py39.py │ ├── tutorial002.py │ ├── tutorial002_an.py │ ├── tutorial002_an_py310.py │ ├── tutorial002_an_py39.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ ├── tutorial003_an.py │ ├── tutorial003_an_py310.py │ ├── tutorial003_an_py39.py │ ├── tutorial003_py310.py │ ├── tutorial004.py │ ├── tutorial004_an.py │ ├── tutorial004_an_py310.py │ ├── tutorial004_an_py39.py │ ├── tutorial004_py310.py │ ├── tutorial005.py │ ├── tutorial005_an.py │ ├── tutorial005_an_py310.py │ ├── tutorial005_an_py39.py │ ├── tutorial005_py310.py │ ├── tutorial005_py39.py │ ├── tutorial006.py │ ├── tutorial006_an.py │ ├── tutorial006_an_py39.py │ ├── tutorial007.py │ ├── tutorial007_an.py │ └── tutorial007_an_py39.py ├── settings │ ├── app01 │ │ ├── __init__.py │ │ ├── config.py │ │ └── main.py │ ├── app02 │ │ ├── __init__.py │ │ ├── config.py │ │ ├── main.py │ │ └── test_main.py │ ├── app02_an │ │ ├── __init__.py │ │ ├── config.py │ │ ├── main.py │ │ └── test_main.py │ ├── app02_an_py39 │ │ ├── __init__.py │ │ ├── config.py │ │ ├── main.py │ │ └── test_main.py │ ├── app03 │ │ ├── __init__.py │ │ ├── config.py │ │ └── main.py │ ├── app03_an │ │ ├── __init__.py │ │ ├── config.py │ │ └── main.py │ ├── app03_an_py39 │ │ ├── __init__.py │ │ ├── config.py │ │ └── main.py │ └── tutorial001.py ├── sql_databases │ ├── __init__.py │ ├── sql_app │ │ ├── __init__.py │ │ ├── alt_main.py │ │ ├── crud.py │ │ ├── database.py │ │ ├── main.py │ │ ├── models.py │ │ ├── schemas.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ └── test_sql_app.py │ ├── sql_app_py310 │ │ ├── __init__.py │ │ ├── alt_main.py │ │ ├── crud.py │ │ ├── database.py │ │ ├── main.py │ │ ├── models.py │ │ ├── schemas.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ └── test_sql_app.py │ └── sql_app_py39 │ │ ├── __init__.py │ │ ├── alt_main.py │ │ ├── crud.py │ │ ├── database.py │ │ ├── main.py │ │ ├── models.py │ │ ├── schemas.py │ │ └── tests │ │ ├── __init__.py │ │ └── test_sql_app.py ├── sql_databases_peewee │ ├── __init__.py │ └── sql_app │ │ ├── __init__.py │ │ ├── crud.py │ │ ├── database.py │ │ ├── main.py │ │ ├── models.py │ │ └── schemas.py ├── static_files │ └── tutorial001.py ├── sub_applications │ └── tutorial001.py ├── templates │ ├── static │ │ └── styles.css │ ├── templates │ │ └── item.html │ └── tutorial001.py ├── using_request_directly │ └── tutorial001.py ├── websockets │ ├── __init__.py │ ├── tutorial001.py │ ├── tutorial002.py │ ├── tutorial002_an.py │ ├── tutorial002_an_py310.py │ ├── tutorial002_an_py39.py │ ├── tutorial002_py310.py │ ├── tutorial003.py │ └── tutorial003_py39.py └── wsgi │ └── tutorial001.py ├── pyproject.toml ├── requirements-docs.txt ├── scripts ├── docs.py └── zip-docs.sh └── tests ├── test_something.py └── test_utils.py /.github/actions/comment-docs-preview-in-pr/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.7 2 | 3 | RUN pip install httpx "pydantic==1.5.1" pygithub 4 | 5 | COPY ./app /app 6 | 7 | CMD ["python", "/app/main.py"] 8 | -------------------------------------------------------------------------------- /.github/actions/comment-docs-preview-in-pr/action.yml: -------------------------------------------------------------------------------- 1 | name: Comment Docs Preview in PR 2 | description: Comment with the docs URL preview in the PR 3 | author: Sebastián Ramírez 4 | inputs: 5 | token: 6 | description: Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }} 7 | required: true 8 | deploy_url: 9 | description: The deployment URL to comment in the PR 10 | required: true 11 | runs: 12 | using: docker 13 | image: Dockerfile 14 | -------------------------------------------------------------------------------- /.github/actions/notify-translations/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.7 2 | 3 | RUN pip install httpx PyGithub "pydantic==1.5.1" "pyyaml>=5.3.1,<6.0.0" 4 | 5 | COPY ./app /app 6 | 7 | CMD ["python", "/app/main.py"] 8 | -------------------------------------------------------------------------------- /.github/actions/notify-translations/action.yml: -------------------------------------------------------------------------------- 1 | name: "Notify Translations" 2 | description: "Notify in the issue for a translation when there's a new PR available" 3 | author: "Sebastián Ramírez " 4 | inputs: 5 | token: 6 | description: 'Token, to read the GitHub API. Can be passed in using {{ secrets.GITHUB_TOKEN }}' 7 | required: true 8 | runs: 9 | using: 'docker' 10 | image: 'Dockerfile' 11 | -------------------------------------------------------------------------------- /.github/actions/notify-translations/app/translations.yml: -------------------------------------------------------------------------------- 1 | es: 53 2 | ja: 52 3 | -------------------------------------------------------------------------------- /.github/actions/people/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.7 2 | 3 | RUN pip install httpx PyGithub "pydantic==1.5.1" "pyyaml>=5.3.1,<6.0.0" rich 4 | 5 | COPY ./app /app 6 | 7 | # CMD ["python", "/app/main.py"] 8 | CMD ["bash", "/app/debug.sh"] 9 | -------------------------------------------------------------------------------- /.github/actions/people/action.yml: -------------------------------------------------------------------------------- 1 | name: "Generate FastAPI People" 2 | description: "Generate the data for the FastAPI People page" 3 | author: "Sebastián Ramírez " 4 | inputs: 5 | token: 6 | description: 'User token, to read the GitHub API. Can be passed in using {{ secrets.PEOPLE_TOKEN }}' 7 | required: true 8 | standard_token: 9 | description: 'Default GitHub Action token, used for the PR. Can be passed in using {{ secrets.GITHUB_TOKEN }}' 10 | required: true 11 | runs: 12 | using: 'docker' 13 | image: 'Dockerfile' 14 | -------------------------------------------------------------------------------- /.github/actions/people/app/debug.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | set -ex 4 | 5 | echo "Debugging..." 6 | pwd 7 | ls -la 8 | python /app/main.py 9 | -------------------------------------------------------------------------------- /.github/workflows/release-notes.jinja2: -------------------------------------------------------------------------------- 1 | #### Woohoo new stuff! 🎉 2 | 3 | This changed: {{pr.title}}. Done by [the GitHub user {{pr.user.login}}]({{pr.user.html_url}}). Check the [Pull Request {{pr.number}} with the changes and stuff]({{pr.html_url}}). now back to code. 🤓 4 | 5 | 🥳 🕺 💃 6 | 7 | ...okay, back to code. 🤓 8 | 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .ipynb_checkpoints 3 | .mypy_cache 4 | .vscode 5 | __pycache__ 6 | .pytest_cache 7 | htmlcov 8 | dist 9 | site 10 | .coverage 11 | coverage.xml 12 | .netlify 13 | test.db 14 | log.txt 15 | Pipfile.lock 16 | env3.* 17 | env 18 | docs_build 19 | site_build 20 | venv 21 | docs.zip 22 | archive.zip 23 | 24 | # vim temporary files 25 | *~ 26 | .*.sw? 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2020 Sebastián Ramírez 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tiangolo's GitHub Actions Sandbox 😺 2 | 3 | This is not useful for you. 4 | 5 | Nope. 6 | 7 | It's just a GitHub repo for me to try out stuff and develop GitHub Actions. 8 | 9 | Just because I can't do that locally 🤷 10 | 11 | Hellooooo darkness my old friend. Here I come to you again. 12 | 13 | --- 14 | 15 | Let's run a Docker CI cycle to time it with Python slim. 16 | 17 | # Licence 18 | 19 | This project is licensed under the terms of the WTFPL license. 20 | 21 | Yep, that's the license. 22 | -------------------------------------------------------------------------------- /app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/app/__init__.py -------------------------------------------------------------------------------- /app/main.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | 5 | def bad_code(name="World"): 6 | print("Hello") 7 | print(name) 8 | -------------------------------------------------------------------------------- /app/utils.py: -------------------------------------------------------------------------------- 1 | def get_name(): 2 | return "World" 3 | -------------------------------------------------------------------------------- /docs-comment-deploy.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | set -x 4 | set -e 5 | 6 | PR=${PR:?Variable not set} 7 | DEPLOY_URL=${DEPLOY_URL:?Variable not set} 8 | GITHUB_TOKEN=${GITHUB_TOKEN:?Variable not set} 9 | COMMIT=${COMMIT:?Variable not set} 10 | 11 | curl \ 12 | -H "Authorization: token ${GITHUB_TOKEN}" \ 13 | https://api.github.com/repos/tiangolo/github-actions-sandbox/issues/${PR}/comments \ 14 | -d '{"body": "📝 Docs preview for commit '"${COMMIT} at: ${DEPLOY_URL}"'"}' 15 | -------------------------------------------------------------------------------- /docs/en/data/sponsors_badge.yml: -------------------------------------------------------------------------------- 1 | logins: 2 | - jina-ai 3 | - deta 4 | - investsuite 5 | - mikeckennedy 6 | - deepset-ai 7 | - cryptapi 8 | - xoflare 9 | - DropbaseHQ 10 | - VincentParedes 11 | - BLUE-DEVIL1134 12 | - ObliviousAI 13 | - Doist 14 | - nihpo 15 | - svix 16 | - armand-sauzay 17 | - databento-bot 18 | - nanram22 19 | - Flint-company 20 | -------------------------------------------------------------------------------- /docs/en/docs/advanced/testing-events.md: -------------------------------------------------------------------------------- 1 | # Testing Events: startup - shutdown 2 | 3 | When you need your event handlers (`startup` and `shutdown`) to run in your tests, you can use the `TestClient` with a `with` statement: 4 | 5 | ```Python hl_lines="9-12 20-24" 6 | {!../../../docs_src/app_testing/tutorial003.py!} 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/en/docs/advanced/testing-websockets.md: -------------------------------------------------------------------------------- 1 | # Testing WebSockets 2 | 3 | You can use the same `TestClient` to test WebSockets. 4 | 5 | For this, you use the `TestClient` in a `with` statement, connecting to the WebSocket: 6 | 7 | ```Python hl_lines="27-31" 8 | {!../../../docs_src/app_testing/tutorial002.py!} 9 | ``` 10 | 11 | !!! note 12 | For more details, check Starlette's documentation for testing WebSockets. 13 | -------------------------------------------------------------------------------- /docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-01.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-02.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-03.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-04.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-05.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-06.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/concurrent-burgers/concurrent-burgers-07.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/parallel-burgers/parallel-burgers-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/parallel-burgers/parallel-burgers-01.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/parallel-burgers/parallel-burgers-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/parallel-burgers/parallel-burgers-02.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/parallel-burgers/parallel-burgers-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/parallel-burgers/parallel-burgers-03.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/parallel-burgers/parallel-burgers-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/parallel-burgers/parallel-burgers-04.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/parallel-burgers/parallel-burgers-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/parallel-burgers/parallel-burgers-05.png -------------------------------------------------------------------------------- /docs/en/docs/img/async/parallel-burgers/parallel-burgers-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/async/parallel-burgers/parallel-burgers-06.png -------------------------------------------------------------------------------- /docs/en/docs/img/deployment/concepts/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/deployment/concepts/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/deployment/deta/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/deployment/deta/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/deployment/deta/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/deployment/deta/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/deployment/deta/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/deployment/deta/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/deployment/deta/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/deployment/deta/image04.png -------------------------------------------------------------------------------- /docs/en/docs/img/deployment/deta/image05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/deployment/deta/image05.png -------------------------------------------------------------------------------- /docs/en/docs/img/deployment/deta/image06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/deployment/deta/image06.png -------------------------------------------------------------------------------- /docs/en/docs/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/favicon.png -------------------------------------------------------------------------------- /docs/en/docs/img/github-social-preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/github-social-preview.png -------------------------------------------------------------------------------- /docs/en/docs/img/icon-transparent-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/icon-transparent-bg.png -------------------------------------------------------------------------------- /docs/en/docs/img/icon-white-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/icon-white-bg.png -------------------------------------------------------------------------------- /docs/en/docs/img/index/index-01-swagger-ui-simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/index/index-01-swagger-ui-simple.png -------------------------------------------------------------------------------- /docs/en/docs/img/index/index-02-redoc-simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/index/index-02-redoc-simple.png -------------------------------------------------------------------------------- /docs/en/docs/img/index/index-03-swagger-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/index/index-03-swagger-02.png -------------------------------------------------------------------------------- /docs/en/docs/img/index/index-04-swagger-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/index/index-04-swagger-03.png -------------------------------------------------------------------------------- /docs/en/docs/img/index/index-05-swagger-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/index/index-05-swagger-04.png -------------------------------------------------------------------------------- /docs/en/docs/img/index/index-06-redoc-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/index/index-06-redoc-02.png -------------------------------------------------------------------------------- /docs/en/docs/img/logo-margin/logo-teal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/logo-margin/logo-teal.png -------------------------------------------------------------------------------- /docs/en/docs/img/logo-margin/logo-white-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/logo-margin/logo-white-bg.png -------------------------------------------------------------------------------- /docs/en/docs/img/pycharm-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/pycharm-completion.png -------------------------------------------------------------------------------- /docs/en/docs/img/python-types/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/python-types/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/python-types/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/python-types/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/python-types/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/python-types/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/python-types/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/python-types/image04.png -------------------------------------------------------------------------------- /docs/en/docs/img/python-types/image05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/python-types/image05.png -------------------------------------------------------------------------------- /docs/en/docs/img/python-types/image06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/python-types/image06.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/calmcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/calmcode.jpg -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/classiq-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/classiq-banner.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/classiq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/classiq.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/exoflare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/exoflare.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/fastapi-course-bundle-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/fastapi-course-bundle-banner.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/flint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/flint.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/ines-course.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/ines-course.jpg -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/jina-ai-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/jina-ai-banner.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/jina-ai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/jina-ai.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/platform-sh-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/platform-sh-banner.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/platform-sh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/platform-sh.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/powens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/powens.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/striveworks-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/striveworks-banner.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/striveworks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/striveworks.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/striveworks2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/striveworks2.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/talkpython.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/talkpython.png -------------------------------------------------------------------------------- /docs/en/docs/img/sponsors/vimso.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/sponsors/vimso.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/additional-responses/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/additional-responses/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/async-sql-databases/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/async-sql-databases/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/behind-a-proxy/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/behind-a-proxy/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/behind-a-proxy/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/behind-a-proxy/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/behind-a-proxy/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/behind-a-proxy/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/bigger-applications/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/bigger-applications/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/body-fields/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/body-fields/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/body-fields/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/body-fields/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/body-nested-models/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/body-nested-models/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/body/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/body/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/body/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/body/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/body/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/body/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/body/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/body/image04.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/body/image05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/body/image05.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/custom-response/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/custom-response/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/dataclasses/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/dataclasses/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/debugging/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/debugging/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/debugging/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/debugging/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/dependencies/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/dependencies/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/dependencies/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/dependencies/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/extending-openapi/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/extending-openapi/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/extending-openapi/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/extending-openapi/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/extending-openapi/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/extending-openapi/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/extending-openapi/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/extending-openapi/image04.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/generate-clients/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/generate-clients/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/generate-clients/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/generate-clients/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/generate-clients/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/generate-clients/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/generate-clients/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/generate-clients/image04.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/generate-clients/image05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/generate-clients/image05.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/generate-clients/image06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/generate-clients/image06.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/generate-clients/image07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/generate-clients/image07.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/generate-clients/image08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/generate-clients/image08.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/graphql/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/graphql/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/metadata/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/metadata/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/metadata/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/metadata/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/openapi-callbacks/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/openapi-callbacks/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/path-operation-advanced-configuration/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/path-operation-advanced-configuration/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/path-operation-configuration/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/path-operation-configuration/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/path-operation-configuration/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/path-operation-configuration/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/path-operation-configuration/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/path-operation-configuration/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/path-operation-configuration/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/path-operation-configuration/image04.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/path-operation-configuration/image05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/path-operation-configuration/image05.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/path-params/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/path-params/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/path-params/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/path-params/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/path-params/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/path-params/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/query-params-str-validations/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/query-params-str-validations/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/query-params-str-validations/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/query-params-str-validations/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/response-model/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/response-model/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/response-model/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/response-model/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/response-status-code/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/response-status-code/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/response-status-code/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/response-status-code/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image04.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image05.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image06.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image07.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image08.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image09.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image10.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image11.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/security/image12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/security/image12.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/sql-databases/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/sql-databases/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/sql-databases/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/sql-databases/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/sub-applications/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/sub-applications/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/sub-applications/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/sub-applications/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/websockets/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/websockets/image01.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/websockets/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/websockets/image02.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/websockets/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/websockets/image03.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/websockets/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/websockets/image04.png -------------------------------------------------------------------------------- /docs/en/docs/img/tutorial/websockets/image05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/tutorial/websockets/image05.png -------------------------------------------------------------------------------- /docs/en/docs/img/vscode-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/en/docs/img/vscode-completion.png -------------------------------------------------------------------------------- /docs/en/docs/js/chat.js: -------------------------------------------------------------------------------- 1 | ((window.gitter = {}).chat = {}).options = { 2 | room: 'tiangolo/fastapi' 3 | }; 4 | -------------------------------------------------------------------------------- /docs/en/docs/newsletter.md: -------------------------------------------------------------------------------- 1 | # FastAPI and friends newsletter 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/es/overrides/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/es/overrides/.gitignore -------------------------------------------------------------------------------- /docs/ja/docs/deployment/index.md: -------------------------------------------------------------------------------- 1 | # デプロイ - イントロ 2 | 3 | **FastAPI** 製のアプリケーションは比較的容易にデプロイできます。 4 | 5 | ユースケースや使用しているツールによっていくつかの方法に分かれます。 6 | 7 | 次のセクションでより詳しくそれらの方法について説明します。 8 | -------------------------------------------------------------------------------- /docs/ja/overrides/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs/ja/overrides/.gitignore -------------------------------------------------------------------------------- /docs/missing-translation.md: -------------------------------------------------------------------------------- 1 | !!! warning 2 | The current page still doesn't have a translation for this language. 3 | 4 | But you can help translating it: [Contributing](https://fastapi.tiangolo.com/contributing/){.internal-link target=_blank}. 5 | -------------------------------------------------------------------------------- /docs_src/advanced_middleware/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware 3 | 4 | app = FastAPI() 5 | 6 | app.add_middleware(HTTPSRedirectMiddleware) 7 | 8 | 9 | @app.get("/") 10 | async def main(): 11 | return {"message": "Hello World"} 12 | -------------------------------------------------------------------------------- /docs_src/advanced_middleware/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.middleware.trustedhost import TrustedHostMiddleware 3 | 4 | app = FastAPI() 5 | 6 | app.add_middleware( 7 | TrustedHostMiddleware, allowed_hosts=["example.com", "*.example.com"] 8 | ) 9 | 10 | 11 | @app.get("/") 12 | async def main(): 13 | return {"message": "Hello World"} 14 | -------------------------------------------------------------------------------- /docs_src/advanced_middleware/tutorial003.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.middleware.gzip import GZipMiddleware 3 | 4 | app = FastAPI() 5 | 6 | app.add_middleware(GZipMiddleware, minimum_size=1000) 7 | 8 | 9 | @app.get("/") 10 | async def main(): 11 | return "somebigcontent" 12 | -------------------------------------------------------------------------------- /docs_src/app_testing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/app_testing/__init__.py -------------------------------------------------------------------------------- /docs_src/app_testing/app_b/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/app_testing/app_b/__init__.py -------------------------------------------------------------------------------- /docs_src/app_testing/app_b_an/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/app_testing/app_b_an/__init__.py -------------------------------------------------------------------------------- /docs_src/app_testing/app_b_an_py310/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/app_testing/app_b_an_py310/__init__.py -------------------------------------------------------------------------------- /docs_src/app_testing/app_b_an_py39/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/app_testing/app_b_an_py39/__init__.py -------------------------------------------------------------------------------- /docs_src/app_testing/app_b_py310/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/app_testing/app_b_py310/__init__.py -------------------------------------------------------------------------------- /docs_src/app_testing/main.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/") 7 | async def read_main(): 8 | return {"msg": "Hello World"} 9 | -------------------------------------------------------------------------------- /docs_src/app_testing/test_main.py: -------------------------------------------------------------------------------- 1 | from fastapi.testclient import TestClient 2 | 3 | from .main import app 4 | 5 | client = TestClient(app) 6 | 7 | 8 | def test_read_main(): 9 | response = client.get("/") 10 | assert response.status_code == 200 11 | assert response.json() == {"msg": "Hello World"} 12 | -------------------------------------------------------------------------------- /docs_src/app_testing/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.testclient import TestClient 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/") 8 | async def read_main(): 9 | return {"msg": "Hello World"} 10 | 11 | 12 | client = TestClient(app) 13 | 14 | 15 | def test_read_main(): 16 | response = client.get("/") 17 | assert response.status_code == 200 18 | assert response.json() == {"msg": "Hello World"} 19 | -------------------------------------------------------------------------------- /docs_src/async_tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/async_tests/__init__.py -------------------------------------------------------------------------------- /docs_src/async_tests/main.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/") 7 | async def root(): 8 | return {"message": "Tomato"} 9 | -------------------------------------------------------------------------------- /docs_src/async_tests/test_main.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from httpx import AsyncClient 3 | 4 | from .main import app 5 | 6 | 7 | @pytest.mark.anyio 8 | async def test_root(): 9 | async with AsyncClient(app=app, base_url="http://test") as ac: 10 | response = await ac.get("/") 11 | assert response.status_code == 200 12 | assert response.json() == {"message": "Tomato"} 13 | -------------------------------------------------------------------------------- /docs_src/behind_a_proxy/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Request 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/app") 7 | def read_main(request: Request): 8 | return {"message": "Hello World", "root_path": request.scope.get("root_path")} 9 | -------------------------------------------------------------------------------- /docs_src/behind_a_proxy/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Request 2 | 3 | app = FastAPI(root_path="/api/v1") 4 | 5 | 6 | @app.get("/app") 7 | def read_main(request: Request): 8 | return {"message": "Hello World", "root_path": request.scope.get("root_path")} 9 | -------------------------------------------------------------------------------- /docs_src/behind_a_proxy/tutorial003.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Request 2 | 3 | app = FastAPI( 4 | servers=[ 5 | {"url": "https://stag.example.com", "description": "Staging environment"}, 6 | {"url": "https://prod.example.com", "description": "Production environment"}, 7 | ], 8 | root_path="/api/v1", 9 | ) 10 | 11 | 12 | @app.get("/app") 13 | def read_main(request: Request): 14 | return {"message": "Hello World", "root_path": request.scope.get("root_path")} 15 | -------------------------------------------------------------------------------- /docs_src/behind_a_proxy/tutorial004.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Request 2 | 3 | app = FastAPI( 4 | servers=[ 5 | {"url": "https://stag.example.com", "description": "Staging environment"}, 6 | {"url": "https://prod.example.com", "description": "Production environment"}, 7 | ], 8 | root_path="/api/v1", 9 | root_path_in_servers=False, 10 | ) 11 | 12 | 13 | @app.get("/app") 14 | def read_main(request: Request): 15 | return {"message": "Hello World", "root_path": request.scope.get("root_path")} 16 | -------------------------------------------------------------------------------- /docs_src/bigger_applications/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/app/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app/dependencies.py: -------------------------------------------------------------------------------- 1 | from fastapi import Header, HTTPException 2 | 3 | 4 | async def get_token_header(x_token: str = Header()): 5 | if x_token != "fake-super-secret-token": 6 | raise HTTPException(status_code=400, detail="X-Token header invalid") 7 | 8 | 9 | async def get_query_token(token: str): 10 | if token != "jessica": 11 | raise HTTPException(status_code=400, detail="No Jessica token provided") 12 | -------------------------------------------------------------------------------- /docs_src/bigger_applications/app/internal/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/app/internal/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app/internal/admin.py: -------------------------------------------------------------------------------- 1 | from fastapi import APIRouter 2 | 3 | router = APIRouter() 4 | 5 | 6 | @router.post("/") 7 | async def update_admin(): 8 | return {"message": "Admin getting schwifty"} 9 | -------------------------------------------------------------------------------- /docs_src/bigger_applications/app/routers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/app/routers/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app/routers/users.py: -------------------------------------------------------------------------------- 1 | from fastapi import APIRouter 2 | 3 | router = APIRouter() 4 | 5 | 6 | @router.get("/users/", tags=["users"]) 7 | async def read_users(): 8 | return [{"username": "Rick"}, {"username": "Morty"}] 9 | 10 | 11 | @router.get("/users/me", tags=["users"]) 12 | async def read_user_me(): 13 | return {"username": "fakecurrentuser"} 14 | 15 | 16 | @router.get("/users/{username}", tags=["users"]) 17 | async def read_user(username: str): 18 | return {"username": username} 19 | -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/app_an/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an/dependencies.py: -------------------------------------------------------------------------------- 1 | from fastapi import Header, HTTPException 2 | from typing_extensions import Annotated 3 | 4 | 5 | async def get_token_header(x_token: Annotated[str, Header()]): 6 | if x_token != "fake-super-secret-token": 7 | raise HTTPException(status_code=400, detail="X-Token header invalid") 8 | 9 | 10 | async def get_query_token(token: str): 11 | if token != "jessica": 12 | raise HTTPException(status_code=400, detail="No Jessica token provided") 13 | -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an/internal/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/app_an/internal/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an/internal/admin.py: -------------------------------------------------------------------------------- 1 | from fastapi import APIRouter 2 | 3 | router = APIRouter() 4 | 5 | 6 | @router.post("/") 7 | async def update_admin(): 8 | return {"message": "Admin getting schwifty"} 9 | -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an/routers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/app_an/routers/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an/routers/users.py: -------------------------------------------------------------------------------- 1 | from fastapi import APIRouter 2 | 3 | router = APIRouter() 4 | 5 | 6 | @router.get("/users/", tags=["users"]) 7 | async def read_users(): 8 | return [{"username": "Rick"}, {"username": "Morty"}] 9 | 10 | 11 | @router.get("/users/me", tags=["users"]) 12 | async def read_user_me(): 13 | return {"username": "fakecurrentuser"} 14 | 15 | 16 | @router.get("/users/{username}", tags=["users"]) 17 | async def read_user(username: str): 18 | return {"username": username} 19 | -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an_py39/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/app_an_py39/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an_py39/dependencies.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import Header, HTTPException 4 | 5 | 6 | async def get_token_header(x_token: Annotated[str, Header()]): 7 | if x_token != "fake-super-secret-token": 8 | raise HTTPException(status_code=400, detail="X-Token header invalid") 9 | 10 | 11 | async def get_query_token(token: str): 12 | if token != "jessica": 13 | raise HTTPException(status_code=400, detail="No Jessica token provided") 14 | -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an_py39/internal/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/app_an_py39/internal/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an_py39/internal/admin.py: -------------------------------------------------------------------------------- 1 | from fastapi import APIRouter 2 | 3 | router = APIRouter() 4 | 5 | 6 | @router.post("/") 7 | async def update_admin(): 8 | return {"message": "Admin getting schwifty"} 9 | -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an_py39/routers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/bigger_applications/app_an_py39/routers/__init__.py -------------------------------------------------------------------------------- /docs_src/bigger_applications/app_an_py39/routers/users.py: -------------------------------------------------------------------------------- 1 | from fastapi import APIRouter 2 | 3 | router = APIRouter() 4 | 5 | 6 | @router.get("/users/", tags=["users"]) 7 | async def read_users(): 8 | return [{"username": "Rick"}, {"username": "Morty"}] 9 | 10 | 11 | @router.get("/users/me", tags=["users"]) 12 | async def read_user_me(): 13 | return {"username": "fakecurrentuser"} 14 | 15 | 16 | @router.get("/users/{username}", tags=["users"]) 17 | async def read_user(username: str): 18 | return {"username": username} 19 | -------------------------------------------------------------------------------- /docs_src/body/tutorial001.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: Union[str, None] = None 10 | price: float 11 | tax: Union[float, None] = None 12 | 13 | 14 | app = FastAPI() 15 | 16 | 17 | @app.post("/items/") 18 | async def create_item(item: Item): 19 | return item 20 | 21 | print("hello") -------------------------------------------------------------------------------- /docs_src/body/tutorial001_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel 3 | 4 | 5 | class Item(BaseModel): 6 | name: str 7 | description: str | None = None 8 | price: float 9 | tax: float | None = None 10 | 11 | 12 | app = FastAPI() 13 | 14 | 15 | @app.post("/items/") 16 | async def create_item(item: Item): 17 | return item 18 | -------------------------------------------------------------------------------- /docs_src/body/tutorial002.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: Union[str, None] = None 10 | price: float 11 | tax: Union[float, None] = None 12 | 13 | 14 | app = FastAPI() 15 | 16 | 17 | @app.post("/items/") 18 | async def create_item(item: Item): 19 | item_dict = item.dict() 20 | if item.tax: 21 | price_with_tax = item.price + item.tax 22 | item_dict.update({"price_with_tax": price_with_tax}) 23 | return item_dict 24 | -------------------------------------------------------------------------------- /docs_src/body/tutorial002_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel 3 | 4 | 5 | class Item(BaseModel): 6 | name: str 7 | description: str | None = None 8 | price: float 9 | tax: float | None = None 10 | 11 | 12 | app = FastAPI() 13 | 14 | 15 | @app.post("/items/") 16 | async def create_item(item: Item): 17 | item_dict = item.dict() 18 | if item.tax: 19 | price_with_tax = item.price + item.tax 20 | item_dict.update({"price_with_tax": price_with_tax}) 21 | return item_dict 22 | -------------------------------------------------------------------------------- /docs_src/body/tutorial003.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: Union[str, None] = None 10 | price: float 11 | tax: Union[float, None] = None 12 | 13 | 14 | app = FastAPI() 15 | 16 | 17 | @app.put("/items/{item_id}") 18 | async def create_item(item_id: int, item: Item): 19 | return {"item_id": item_id, **item.dict()} 20 | -------------------------------------------------------------------------------- /docs_src/body/tutorial003_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel 3 | 4 | 5 | class Item(BaseModel): 6 | name: str 7 | description: str | None = None 8 | price: float 9 | tax: float | None = None 10 | 11 | 12 | app = FastAPI() 13 | 14 | 15 | @app.put("/items/{item_id}") 16 | async def create_item(item_id: int, item: Item): 17 | return {"item_id": item_id, **item.dict()} 18 | -------------------------------------------------------------------------------- /docs_src/body/tutorial004.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: Union[str, None] = None 10 | price: float 11 | tax: Union[float, None] = None 12 | 13 | 14 | app = FastAPI() 15 | 16 | 17 | @app.put("/items/{item_id}") 18 | async def create_item(item_id: int, item: Item, q: Union[str, None] = None): 19 | result = {"item_id": item_id, **item.dict()} 20 | if q: 21 | result.update({"q": q}) 22 | return result 23 | -------------------------------------------------------------------------------- /docs_src/body/tutorial004_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel 3 | 4 | 5 | class Item(BaseModel): 6 | name: str 7 | description: str | None = None 8 | price: float 9 | tax: float | None = None 10 | 11 | 12 | app = FastAPI() 13 | 14 | 15 | @app.put("/items/{item_id}") 16 | async def create_item(item_id: int, item: Item, q: str | None = None): 17 | result = {"item_id": item_id, **item.dict()} 18 | if q: 19 | result.update({"q": q}) 20 | return result 21 | -------------------------------------------------------------------------------- /docs_src/body_multiple_params/tutorial002_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel 3 | 4 | app = FastAPI() 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: str | None = None 10 | price: float 11 | tax: float | None = None 12 | 13 | 14 | class User(BaseModel): 15 | username: str 16 | full_name: str | None = None 17 | 18 | 19 | @app.put("/items/{item_id}") 20 | async def update_item(item_id: int, item: Item, user: User): 21 | results = {"item_id": item_id, "item": item, "user": user} 22 | return results 23 | -------------------------------------------------------------------------------- /docs_src/body_multiple_params/tutorial005.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import Body, FastAPI 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: Union[str, None] = None 12 | price: float 13 | tax: Union[float, None] = None 14 | 15 | 16 | @app.put("/items/{item_id}") 17 | async def update_item(item_id: int, item: Item = Body(embed=True)): 18 | results = {"item_id": item_id, "item": item} 19 | return results 20 | -------------------------------------------------------------------------------- /docs_src/body_multiple_params/tutorial005_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import Body, FastAPI 4 | from pydantic import BaseModel 5 | from typing_extensions import Annotated 6 | 7 | app = FastAPI() 8 | 9 | 10 | class Item(BaseModel): 11 | name: str 12 | description: Union[str, None] = None 13 | price: float 14 | tax: Union[float, None] = None 15 | 16 | 17 | @app.put("/items/{item_id}") 18 | async def update_item(item_id: int, item: Annotated[Item, Body(embed=True)]): 19 | results = {"item_id": item_id, "item": item} 20 | return results 21 | -------------------------------------------------------------------------------- /docs_src/body_multiple_params/tutorial005_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import Body, FastAPI 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: str | None = None 12 | price: float 13 | tax: float | None = None 14 | 15 | 16 | @app.put("/items/{item_id}") 17 | async def update_item(item_id: int, item: Annotated[Item, Body(embed=True)]): 18 | results = {"item_id": item_id, "item": item} 19 | return results 20 | -------------------------------------------------------------------------------- /docs_src/body_multiple_params/tutorial005_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import Body, FastAPI 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: Union[str, None] = None 12 | price: float 13 | tax: Union[float, None] = None 14 | 15 | 16 | @app.put("/items/{item_id}") 17 | async def update_item(item_id: int, item: Annotated[Item, Body(embed=True)]): 18 | results = {"item_id": item_id, "item": item} 19 | return results 20 | -------------------------------------------------------------------------------- /docs_src/body_multiple_params/tutorial005_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import Body, FastAPI 2 | from pydantic import BaseModel 3 | 4 | app = FastAPI() 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: str | None = None 10 | price: float 11 | tax: float | None = None 12 | 13 | 14 | @app.put("/items/{item_id}") 15 | async def update_item(item_id: int, item: Item = Body(embed=True)): 16 | results = {"item_id": item_id, "item": item} 17 | return results 18 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial001.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: Union[str, None] = None 12 | price: float 13 | tax: Union[float, None] = None 14 | tags: list = [] 15 | 16 | 17 | @app.put("/items/{item_id}") 18 | async def update_item(item_id: int, item: Item): 19 | results = {"item_id": item_id, "item": item} 20 | return results 21 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial001_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel 3 | 4 | app = FastAPI() 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: str | None = None 10 | price: float 11 | tax: float | None = None 12 | tags: list = [] 13 | 14 | 15 | @app.put("/items/{item_id}") 16 | async def update_item(item_id: int, item: Item): 17 | results = {"item_id": item_id, "item": item} 18 | return results 19 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial002.py: -------------------------------------------------------------------------------- 1 | from typing import List, Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: Union[str, None] = None 12 | price: float 13 | tax: Union[float, None] = None 14 | tags: List[str] = [] 15 | 16 | 17 | @app.put("/items/{item_id}") 18 | async def update_item(item_id: int, item: Item): 19 | results = {"item_id": item_id, "item": item} 20 | return results 21 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial002_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel 3 | 4 | app = FastAPI() 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: str | None = None 10 | price: float 11 | tax: float | None = None 12 | tags: list[str] = [] 13 | 14 | 15 | @app.put("/items/{item_id}") 16 | async def update_item(item_id: int, item: Item): 17 | results = {"item_id": item_id, "item": item} 18 | return results 19 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial002_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: Union[str, None] = None 12 | price: float 13 | tax: Union[float, None] = None 14 | tags: list[str] = [] 15 | 16 | 17 | @app.put("/items/{item_id}") 18 | async def update_item(item_id: int, item: Item): 19 | results = {"item_id": item_id, "item": item} 20 | return results 21 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial003.py: -------------------------------------------------------------------------------- 1 | from typing import Set, Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: Union[str, None] = None 12 | price: float 13 | tax: Union[float, None] = None 14 | tags: Set[str] = set() 15 | 16 | 17 | @app.put("/items/{item_id}") 18 | async def update_item(item_id: int, item: Item): 19 | results = {"item_id": item_id, "item": item} 20 | return results 21 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial003_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel 3 | 4 | app = FastAPI() 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: str | None = None 10 | price: float 11 | tax: float | None = None 12 | tags: set[str] = set() 13 | 14 | 15 | @app.put("/items/{item_id}") 16 | async def update_item(item_id: int, item: Item): 17 | results = {"item_id": item_id, "item": item} 18 | return results 19 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial003_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: Union[str, None] = None 12 | price: float 13 | tax: Union[float, None] = None 14 | tags: set[str] = set() 15 | 16 | 17 | @app.put("/items/{item_id}") 18 | async def update_item(item_id: int, item: Item): 19 | results = {"item_id": item_id, "item": item} 20 | return results 21 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial008.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel, HttpUrl 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Image(BaseModel): 10 | url: HttpUrl 11 | name: str 12 | 13 | 14 | @app.post("/images/multiple/") 15 | async def create_multiple_images(images: List[Image]): 16 | return images 17 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial008_py39.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel, HttpUrl 3 | 4 | app = FastAPI() 5 | 6 | 7 | class Image(BaseModel): 8 | url: HttpUrl 9 | name: str 10 | 11 | 12 | @app.post("/images/multiple/") 13 | async def create_multiple_images(images: list[Image]): 14 | return images 15 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial009.py: -------------------------------------------------------------------------------- 1 | from typing import Dict 2 | 3 | from fastapi import FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.post("/index-weights/") 9 | async def create_index_weights(weights: Dict[int, float]): 10 | return weights 11 | -------------------------------------------------------------------------------- /docs_src/body_nested_models/tutorial009_py39.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.post("/index-weights/") 7 | async def create_index_weights(weights: dict[int, float]): 8 | return weights 9 | -------------------------------------------------------------------------------- /docs_src/conditional_openapi/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseSettings 3 | 4 | 5 | class Settings(BaseSettings): 6 | openapi_url: str = "/openapi.json" 7 | 8 | 9 | settings = Settings() 10 | 11 | app = FastAPI(openapi_url=settings.openapi_url) 12 | 13 | 14 | @app.get("/") 15 | def root(): 16 | return {"message": "Hello World"} 17 | -------------------------------------------------------------------------------- /docs_src/cookie_params/tutorial001.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import Cookie, FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(ads_id: Union[str, None] = Cookie(default=None)): 10 | return {"ads_id": ads_id} 11 | -------------------------------------------------------------------------------- /docs_src/cookie_params/tutorial001_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import Cookie, FastAPI 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(ads_id: Annotated[Union[str, None], Cookie()] = None): 11 | return {"ads_id": ads_id} 12 | -------------------------------------------------------------------------------- /docs_src/cookie_params/tutorial001_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import Cookie, FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(ads_id: Annotated[str | None, Cookie()] = None): 10 | return {"ads_id": ads_id} 11 | -------------------------------------------------------------------------------- /docs_src/cookie_params/tutorial001_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import Cookie, FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(ads_id: Annotated[Union[str, None], Cookie()] = None): 10 | return {"ads_id": ads_id} 11 | -------------------------------------------------------------------------------- /docs_src/cookie_params/tutorial001_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import Cookie, FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(ads_id: str | None = Cookie(default=None)): 8 | return {"ads_id": ads_id} 9 | -------------------------------------------------------------------------------- /docs_src/cors/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.middleware.cors import CORSMiddleware 3 | 4 | app = FastAPI() 5 | 6 | origins = [ 7 | "http://localhost.tiangolo.com", 8 | "https://localhost.tiangolo.com", 9 | "http://localhost", 10 | "http://localhost:8080", 11 | ] 12 | 13 | app.add_middleware( 14 | CORSMiddleware, 15 | allow_origins=origins, 16 | allow_credentials=True, 17 | allow_methods=["*"], 18 | allow_headers=["*"], 19 | ) 20 | 21 | 22 | @app.get("/") 23 | async def main(): 24 | return {"message": "Hello World"} 25 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import UJSONResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/", response_class=UJSONResponse) 8 | async def read_items(): 9 | return [{"item_id": "Foo"}] 10 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial001b.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import ORJSONResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/", response_class=ORJSONResponse) 8 | async def read_items(): 9 | return ORJSONResponse([{"item_id": "Foo"}]) 10 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import HTMLResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/", response_class=HTMLResponse) 8 | async def read_items(): 9 | return """ 10 | 11 | 12 | Some HTML in here 13 | 14 | 15 |

Look ma! HTML!

16 | 17 | 18 | """ 19 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial003.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import HTMLResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/") 8 | async def read_items(): 9 | html_content = """ 10 | 11 | 12 | Some HTML in here 13 | 14 | 15 |

Look ma! HTML!

16 | 17 | 18 | """ 19 | return HTMLResponse(content=html_content, status_code=200) 20 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial005.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import PlainTextResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/", response_class=PlainTextResponse) 8 | async def main(): 9 | return "Hello World" 10 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial006.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import RedirectResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/typer") 8 | async def redirect_typer(): 9 | return RedirectResponse("https://typer.tiangolo.com") 10 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial006b.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import RedirectResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/fastapi", response_class=RedirectResponse) 8 | async def redirect_fastapi(): 9 | return "https://fastapi.tiangolo.com" 10 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial006c.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import RedirectResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/pydantic", response_class=RedirectResponse, status_code=302) 8 | async def redirect_pydantic(): 9 | return "https://pydantic-docs.helpmanual.io/" 10 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial007.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import StreamingResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | async def fake_video_streamer(): 8 | for i in range(10): 9 | yield b"some fake video bytes" 10 | 11 | 12 | @app.get("/") 13 | async def main(): 14 | return StreamingResponse(fake_video_streamer()) 15 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial008.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import StreamingResponse 3 | 4 | some_file_path = "large-video-file.mp4" 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/") 9 | def main(): 10 | def iterfile(): # (1) 11 | with open(some_file_path, mode="rb") as file_like: # (2) 12 | yield from file_like # (3) 13 | 14 | return StreamingResponse(iterfile(), media_type="video/mp4") 15 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial009.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import FileResponse 3 | 4 | some_file_path = "large-video-file.mp4" 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/") 9 | async def main(): 10 | return FileResponse(some_file_path) 11 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial009b.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import FileResponse 3 | 4 | some_file_path = "large-video-file.mp4" 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/", response_class=FileResponse) 9 | async def main(): 10 | return some_file_path 11 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial009c.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | import orjson 4 | from fastapi import FastAPI, Response 5 | 6 | app = FastAPI() 7 | 8 | 9 | class CustomORJSONResponse(Response): 10 | media_type = "application/json" 11 | 12 | def render(self, content: Any) -> bytes: 13 | assert orjson is not None, "orjson must be installed" 14 | return orjson.dumps(content, option=orjson.OPT_INDENT_2) 15 | 16 | 17 | @app.get("/", response_class=CustomORJSONResponse) 18 | async def main(): 19 | return {"message": "Hello World"} 20 | -------------------------------------------------------------------------------- /docs_src/custom_response/tutorial010.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import ORJSONResponse 3 | 4 | app = FastAPI(default_response_class=ORJSONResponse) 5 | 6 | 7 | @app.get("/items/") 8 | async def read_items(): 9 | return [{"item_id": "Foo"}] 10 | -------------------------------------------------------------------------------- /docs_src/dataclasses/tutorial001.py: -------------------------------------------------------------------------------- 1 | from dataclasses import dataclass 2 | from typing import Union 3 | 4 | from fastapi import FastAPI 5 | 6 | 7 | @dataclass 8 | class Item: 9 | name: str 10 | price: float 11 | description: Union[str, None] = None 12 | tax: Union[float, None] = None 13 | 14 | 15 | app = FastAPI() 16 | 17 | 18 | @app.post("/items/") 19 | async def create_item(item: Item): 20 | return item 21 | -------------------------------------------------------------------------------- /docs_src/debugging/tutorial001.py: -------------------------------------------------------------------------------- 1 | import uvicorn 2 | from fastapi import FastAPI 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/") 8 | def root(): 9 | a = "a" 10 | b = "b" + a 11 | return {"hello world": b} 12 | 13 | 14 | if __name__ == "__main__": 15 | uvicorn.run(app, host="0.0.0.0", port=8000) 16 | -------------------------------------------------------------------------------- /docs_src/dependencies/tutorial001.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import Depends, FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | async def common_parameters( 9 | q: Union[str, None] = None, skip: int = 0, limit: int = 100 10 | ): 11 | return {"q": q, "skip": skip, "limit": limit} 12 | 13 | 14 | @app.get("/items/") 15 | async def read_items(commons: dict = Depends(common_parameters)): 16 | return commons 17 | 18 | 19 | @app.get("/users/") 20 | async def read_users(commons: dict = Depends(common_parameters)): 21 | return commons 22 | -------------------------------------------------------------------------------- /docs_src/dependencies/tutorial001_02_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import Depends, FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100): 9 | return {"q": q, "skip": skip, "limit": limit} 10 | 11 | 12 | CommonsDep = Annotated[dict, Depends(common_parameters)] 13 | 14 | 15 | @app.get("/items/") 16 | async def read_items(commons: CommonsDep): 17 | return commons 18 | 19 | 20 | @app.get("/users/") 21 | async def read_users(commons: CommonsDep): 22 | return commons 23 | -------------------------------------------------------------------------------- /docs_src/dependencies/tutorial001_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import Depends, FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100): 9 | return {"q": q, "skip": skip, "limit": limit} 10 | 11 | 12 | @app.get("/items/") 13 | async def read_items(commons: Annotated[dict, Depends(common_parameters)]): 14 | return commons 15 | 16 | 17 | @app.get("/users/") 18 | async def read_users(commons: Annotated[dict, Depends(common_parameters)]): 19 | return commons 20 | -------------------------------------------------------------------------------- /docs_src/dependencies/tutorial001_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import Depends, FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100): 7 | return {"q": q, "skip": skip, "limit": limit} 8 | 9 | 10 | @app.get("/items/") 11 | async def read_items(commons: dict = Depends(common_parameters)): 12 | return commons 13 | 14 | 15 | @app.get("/users/") 16 | async def read_users(commons: dict = Depends(common_parameters)): 17 | return commons 18 | -------------------------------------------------------------------------------- /docs_src/dependencies/tutorial005_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import Cookie, Depends, FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | def query_extractor(q: str | None = None): 7 | return q 8 | 9 | 10 | def query_or_cookie_extractor( 11 | q: str = Depends(query_extractor), last_query: str | None = Cookie(default=None) 12 | ): 13 | if not q: 14 | return last_query 15 | return q 16 | 17 | 18 | @app.get("/items/") 19 | async def read_query(query_or_default: str = Depends(query_or_cookie_extractor)): 20 | return {"q_or_cookie": query_or_default} 21 | -------------------------------------------------------------------------------- /docs_src/dependencies/tutorial007.py: -------------------------------------------------------------------------------- 1 | async def get_db(): 2 | db = DBSession() 3 | try: 4 | yield db 5 | finally: 6 | db.close() 7 | -------------------------------------------------------------------------------- /docs_src/dependencies/tutorial010.py: -------------------------------------------------------------------------------- 1 | class MySuperContextManager: 2 | def __init__(self): 3 | self.db = DBSession() 4 | 5 | def __enter__(self): 6 | return self.db 7 | 8 | def __exit__(self, exc_type, exc_value, traceback): 9 | self.db.close() 10 | 11 | 12 | async def get_db(): 13 | with MySuperContextManager() as db: 14 | yield db 15 | -------------------------------------------------------------------------------- /docs_src/encoder/tutorial001.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from typing import Union 3 | 4 | from fastapi import FastAPI 5 | from fastapi.encoders import jsonable_encoder 6 | from pydantic import BaseModel 7 | 8 | fake_db = {} 9 | 10 | 11 | class Item(BaseModel): 12 | title: str 13 | timestamp: datetime 14 | description: Union[str, None] = None 15 | 16 | 17 | app = FastAPI() 18 | 19 | 20 | @app.put("/items/{id}") 21 | def update_item(id: str, item: Item): 22 | json_compatible_item_data = jsonable_encoder(item) 23 | fake_db[id] = json_compatible_item_data 24 | -------------------------------------------------------------------------------- /docs_src/encoder/tutorial001_py310.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | from fastapi import FastAPI 4 | from fastapi.encoders import jsonable_encoder 5 | from pydantic import BaseModel 6 | 7 | fake_db = {} 8 | 9 | 10 | class Item(BaseModel): 11 | title: str 12 | timestamp: datetime 13 | description: str | None = None 14 | 15 | 16 | app = FastAPI() 17 | 18 | 19 | @app.put("/items/{id}") 20 | def update_item(id: str, item: Item): 21 | json_compatible_item_data = jsonable_encoder(item) 22 | fake_db[id] = json_compatible_item_data 23 | -------------------------------------------------------------------------------- /docs_src/events/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | items = {} 6 | 7 | 8 | @app.on_event("startup") 9 | async def startup_event(): 10 | items["foo"] = {"name": "Fighters"} 11 | items["bar"] = {"name": "Tenders"} 12 | 13 | 14 | @app.get("/items/{item_id}") 15 | async def read_items(item_id: str): 16 | return items[item_id] 17 | -------------------------------------------------------------------------------- /docs_src/events/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.on_event("shutdown") 7 | def shutdown_event(): 8 | with open("log.txt", mode="a") as log: 9 | log.write("Application shutdown") 10 | 11 | 12 | @app.get("/items/") 13 | async def read_items(): 14 | return [{"name": "Foo"}] 15 | -------------------------------------------------------------------------------- /docs_src/extending_openapi/tutorial003.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI(swagger_ui_parameters={"syntaxHighlight": False}) 4 | 5 | 6 | @app.get("/users/{username}") 7 | async def read_user(username: str): 8 | return {"message": f"Hello {username}"} 9 | -------------------------------------------------------------------------------- /docs_src/extending_openapi/tutorial004.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI(swagger_ui_parameters={"syntaxHighlight.theme": "obsidian"}) 4 | 5 | 6 | @app.get("/users/{username}") 7 | async def read_user(username: str): 8 | return {"message": f"Hello {username}"} 9 | -------------------------------------------------------------------------------- /docs_src/extending_openapi/tutorial005.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI(swagger_ui_parameters={"deepLinking": False}) 4 | 5 | 6 | @app.get("/users/{username}") 7 | async def read_user(username: str): 8 | return {"message": f"Hello {username}"} 9 | -------------------------------------------------------------------------------- /docs_src/extra_models/tutorial004.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: str 12 | 13 | 14 | items = [ 15 | {"name": "Foo", "description": "There comes my hero"}, 16 | {"name": "Red", "description": "It's my aeroplane"}, 17 | ] 18 | 19 | 20 | @app.get("/items/", response_model=List[Item]) 21 | async def read_items(): 22 | return items 23 | -------------------------------------------------------------------------------- /docs_src/extra_models/tutorial004_py39.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel 3 | 4 | app = FastAPI() 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: str 10 | 11 | 12 | items = [ 13 | {"name": "Foo", "description": "There comes my hero"}, 14 | {"name": "Red", "description": "It's my aeroplane"}, 15 | ] 16 | 17 | 18 | @app.get("/items/", response_model=list[Item]) 19 | async def read_items(): 20 | return items 21 | -------------------------------------------------------------------------------- /docs_src/extra_models/tutorial005.py: -------------------------------------------------------------------------------- 1 | from typing import Dict 2 | 3 | from fastapi import FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/keyword-weights/", response_model=Dict[str, float]) 9 | async def read_keyword_weights(): 10 | return {"foo": 2.3, "bar": 3.4} 11 | -------------------------------------------------------------------------------- /docs_src/extra_models/tutorial005_py39.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/keyword-weights/", response_model=dict[str, float]) 7 | async def read_keyword_weights(): 8 | return {"foo": 2.3, "bar": 3.4} 9 | -------------------------------------------------------------------------------- /docs_src/first_steps/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/") 7 | async def root(): 8 | return {"message": "Hello World"} 9 | -------------------------------------------------------------------------------- /docs_src/first_steps/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | my_awesome_api = FastAPI() 4 | 5 | 6 | @my_awesome_api.get("/") 7 | async def root(): 8 | return {"message": "Hello World"} 9 | -------------------------------------------------------------------------------- /docs_src/first_steps/tutorial003.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/") 7 | def root(): 8 | return {"message": "Hello World"} 9 | -------------------------------------------------------------------------------- /docs_src/generate_clients/tutorial004.py: -------------------------------------------------------------------------------- 1 | import json 2 | from pathlib import Path 3 | 4 | file_path = Path("./openapi.json") 5 | openapi_content = json.loads(file_path.read_text()) 6 | 7 | for path_data in openapi_content["paths"].values(): 8 | for operation in path_data.values(): 9 | tag = operation["tags"][0] 10 | operation_id = operation["operationId"] 11 | to_remove = f"{tag}-" 12 | new_operation_id = operation_id[len(to_remove) :] 13 | operation["operationId"] = new_operation_id 14 | 15 | file_path.write_text(json.dumps(openapi_content)) 16 | -------------------------------------------------------------------------------- /docs_src/graphql/tutorial001.py: -------------------------------------------------------------------------------- 1 | import strawberry 2 | from fastapi import FastAPI 3 | from strawberry.asgi import GraphQL 4 | 5 | 6 | @strawberry.type 7 | class User: 8 | name: str 9 | age: int 10 | 11 | 12 | @strawberry.type 13 | class Query: 14 | @strawberry.field 15 | def user(self) -> User: 16 | return User(name="Patrick", age=100) 17 | 18 | 19 | schema = strawberry.Schema(query=Query) 20 | 21 | 22 | graphql_app = GraphQL(schema) 23 | 24 | app = FastAPI() 25 | app.add_route("/graphql", graphql_app) 26 | app.add_websocket_route("/graphql", graphql_app) 27 | -------------------------------------------------------------------------------- /docs_src/handling_errors/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, HTTPException 2 | 3 | app = FastAPI() 4 | 5 | items = {"foo": "The Foo Wrestlers"} 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_item(item_id: str): 10 | if item_id not in items: 11 | raise HTTPException(status_code=404, detail="Item not found") 12 | return {"item": items[item_id]} 13 | -------------------------------------------------------------------------------- /docs_src/handling_errors/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, HTTPException 2 | 3 | app = FastAPI() 4 | 5 | items = {"foo": "The Foo Wrestlers"} 6 | 7 | 8 | @app.get("/items-header/{item_id}") 9 | async def read_item_header(item_id: str): 10 | if item_id not in items: 11 | raise HTTPException( 12 | status_code=404, 13 | detail="Item not found", 14 | headers={"X-Error": "There goes my error"}, 15 | ) 16 | return {"item": items[item_id]} 17 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial001.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(user_agent: Union[str, None] = Header(default=None)): 10 | return {"User-Agent": user_agent} 11 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial001_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Header 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(user_agent: Annotated[Union[str, None], Header()] = None): 11 | return {"User-Agent": user_agent} 12 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial001_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(user_agent: Annotated[str | None, Header()] = None): 10 | return {"User-Agent": user_agent} 11 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial001_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(user_agent: Annotated[Union[str, None], Header()] = None): 10 | return {"User-Agent": user_agent} 11 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial001_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Header 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(user_agent: str | None = Header(default=None)): 8 | return {"User-Agent": user_agent} 9 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial002.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | strange_header: Union[str, None] = Header(default=None, convert_underscores=False) 11 | ): 12 | return {"strange_header": strange_header} 13 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial002_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Header 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items( 11 | strange_header: Annotated[ 12 | Union[str, None], Header(convert_underscores=False) 13 | ] = None 14 | ): 15 | return {"strange_header": strange_header} 16 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial002_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | strange_header: Annotated[str | None, Header(convert_underscores=False)] = None 11 | ): 12 | return {"strange_header": strange_header} 13 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial002_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | strange_header: Annotated[ 11 | Union[str, None], Header(convert_underscores=False) 12 | ] = None 13 | ): 14 | return {"strange_header": strange_header} 15 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial002_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Header 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items( 8 | strange_header: str | None = Header(default=None, convert_underscores=False) 9 | ): 10 | return {"strange_header": strange_header} 11 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial003.py: -------------------------------------------------------------------------------- 1 | from typing import List, Union 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(x_token: Union[List[str], None] = Header(default=None)): 10 | return {"X-Token values": x_token} 11 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial003_an.py: -------------------------------------------------------------------------------- 1 | from typing import List, Union 2 | 3 | from fastapi import FastAPI, Header 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(x_token: Annotated[Union[List[str], None], Header()] = None): 11 | return {"X-Token values": x_token} 12 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial003_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(x_token: Annotated[list[str] | None, Header()] = None): 10 | return {"X-Token values": x_token} 11 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial003_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, List, Union 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(x_token: Annotated[Union[List[str], None], Header()] = None): 10 | return {"X-Token values": x_token} 11 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial003_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Header 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(x_token: list[str] | None = Header(default=None)): 8 | return {"X-Token values": x_token} 9 | -------------------------------------------------------------------------------- /docs_src/header_params/tutorial003_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Header 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(x_token: Union[list[str], None] = Header(default=None)): 10 | return {"X-Token values": x_token} 11 | -------------------------------------------------------------------------------- /docs_src/metadata/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI(openapi_url="/api/v1/openapi.json") 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(): 8 | return [{"name": "Foo"}] 9 | -------------------------------------------------------------------------------- /docs_src/metadata/tutorial003.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI(docs_url="/documentation", redoc_url=None) 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(): 8 | return [{"name": "Foo"}] 9 | -------------------------------------------------------------------------------- /docs_src/middleware/tutorial001.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from fastapi import FastAPI, Request 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.middleware("http") 9 | async def add_process_time_header(request: Request, call_next): 10 | start_time = time.time() 11 | response = await call_next(request) 12 | process_time = time.time() - start_time 13 | response.headers["X-Process-Time"] = str(process_time) 14 | return response 15 | -------------------------------------------------------------------------------- /docs_src/path_operation_advanced_configuration/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/", operation_id="some_specific_id_you_define") 7 | async def read_items(): 8 | return [{"item_id": "Foo"}] 9 | -------------------------------------------------------------------------------- /docs_src/path_operation_advanced_configuration/tutorial003.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/", include_in_schema=False) 7 | async def read_items(): 8 | return [{"item_id": "Foo"}] 9 | -------------------------------------------------------------------------------- /docs_src/path_operation_advanced_configuration/tutorial005.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/", openapi_extra={"x-aperture-labs-portal": "blue"}) 7 | async def read_items(): 8 | return [{"item_id": "portal-gun"}] 9 | -------------------------------------------------------------------------------- /docs_src/path_operation_configuration/tutorial001.py: -------------------------------------------------------------------------------- 1 | from typing import Set, Union 2 | 3 | from fastapi import FastAPI, status 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: Union[str, None] = None 12 | price: float 13 | tax: Union[float, None] = None 14 | tags: Set[str] = set() 15 | 16 | 17 | @app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED) 18 | async def create_item(item: Item): 19 | return item 20 | -------------------------------------------------------------------------------- /docs_src/path_operation_configuration/tutorial001_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, status 2 | from pydantic import BaseModel 3 | 4 | app = FastAPI() 5 | 6 | 7 | class Item(BaseModel): 8 | name: str 9 | description: str | None = None 10 | price: float 11 | tax: float | None = None 12 | tags: set[str] = set() 13 | 14 | 15 | @app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED) 16 | async def create_item(item: Item): 17 | return item 18 | -------------------------------------------------------------------------------- /docs_src/path_operation_configuration/tutorial001_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, status 4 | from pydantic import BaseModel 5 | 6 | app = FastAPI() 7 | 8 | 9 | class Item(BaseModel): 10 | name: str 11 | description: Union[str, None] = None 12 | price: float 13 | tax: Union[float, None] = None 14 | tags: set[str] = set() 15 | 16 | 17 | @app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED) 18 | async def create_item(item: Item): 19 | return item 20 | -------------------------------------------------------------------------------- /docs_src/path_operation_configuration/tutorial002b.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | from fastapi import FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | class Tags(Enum): 9 | items = "items" 10 | users = "users" 11 | 12 | 13 | @app.get("/items/", tags=[Tags.items]) 14 | async def get_items(): 15 | return ["Portal gun", "Plumbus"] 16 | 17 | 18 | @app.get("/users/", tags=[Tags.users]) 19 | async def read_users(): 20 | return ["Rick", "Morty"] 21 | -------------------------------------------------------------------------------- /docs_src/path_operation_configuration/tutorial006.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/", tags=["items"]) 7 | async def read_items(): 8 | return [{"name": "Foo", "price": 42}] 9 | 10 | 11 | @app.get("/users/", tags=["users"]) 12 | async def read_users(): 13 | return [{"username": "johndoe"}] 14 | 15 | 16 | @app.get("/elements/", tags=["items"], deprecated=True) 17 | async def read_elements(): 18 | return [{"item_id": "Foo"}] 19 | -------------------------------------------------------------------------------- /docs_src/path_params/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_item(item_id): 8 | return {"item_id": item_id} 9 | -------------------------------------------------------------------------------- /docs_src/path_params/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_item(item_id: int): 8 | return {"item_id": item_id} 9 | -------------------------------------------------------------------------------- /docs_src/path_params/tutorial003.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/users/me") 7 | async def read_user_me(): 8 | return {"user_id": "the current user"} 9 | 10 | 11 | @app.get("/users/{user_id}") 12 | async def read_user(user_id: str): 13 | return {"user_id": user_id} 14 | -------------------------------------------------------------------------------- /docs_src/path_params/tutorial003b.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/users") 7 | async def read_users(): 8 | return ["Rick", "Morty"] 9 | 10 | 11 | @app.get("/users") 12 | async def read_users2(): 13 | return ["Bean", "Elfo"] 14 | -------------------------------------------------------------------------------- /docs_src/path_params/tutorial004.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/files/{file_path:path}") 7 | async def read_file(file_path: str): 8 | return {"file_path": file_path} 9 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial001.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Path, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_items( 10 | item_id: int = Path(title="The ID of the item to get"), 11 | q: Union[str, None] = Query(default=None, alias="item-query"), 12 | ): 13 | results = {"item_id": item_id} 14 | if q: 15 | results.update({"q": q}) 16 | return results 17 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial001_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Path, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/{item_id}") 10 | async def read_items( 11 | item_id: Annotated[int, Path(title="The ID of the item to get")], 12 | q: Annotated[Union[str, None], Query(alias="item-query")] = None, 13 | ): 14 | results = {"item_id": item_id} 15 | if q: 16 | results.update({"q": q}) 17 | return results 18 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial001_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Path, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_items( 10 | item_id: Annotated[int, Path(title="The ID of the item to get")], 11 | q: Annotated[str | None, Query(alias="item-query")] = None, 12 | ): 13 | results = {"item_id": item_id} 14 | if q: 15 | results.update({"q": q}) 16 | return results 17 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial001_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Path, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_items( 10 | item_id: Annotated[int, Path(title="The ID of the item to get")], 11 | q: Annotated[Union[str, None], Query(alias="item-query")] = None, 12 | ): 13 | results = {"item_id": item_id} 14 | if q: 15 | results.update({"q": q}) 16 | return results 17 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial001_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_items( 8 | item_id: int = Path(title="The ID of the item to get"), 9 | q: str | None = Query(default=None, alias="item-query"), 10 | ): 11 | results = {"item_id": item_id} 12 | if q: 13 | results.update({"q": q}) 14 | return results 15 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_items(q: str, item_id: int = Path(title="The ID of the item to get")): 8 | results = {"item_id": item_id} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial002_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/{item_id}") 8 | async def read_items( 9 | q: str, item_id: Annotated[int, Path(title="The ID of the item to get")] 10 | ): 11 | results = {"item_id": item_id} 12 | if q: 13 | results.update({"q": q}) 14 | return results 15 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial002_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Path 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_items( 10 | q: str, item_id: Annotated[int, Path(title="The ID of the item to get")] 11 | ): 12 | results = {"item_id": item_id} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial003.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_items(*, item_id: int = Path(title="The ID of the item to get"), q: str): 8 | results = {"item_id": item_id} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial003_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/{item_id}") 8 | async def read_items( 9 | item_id: Annotated[int, Path(title="The ID of the item to get")], q: str 10 | ): 11 | results = {"item_id": item_id} 12 | if q: 13 | results.update({"q": q}) 14 | return results 15 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial003_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Path 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_items( 10 | item_id: Annotated[int, Path(title="The ID of the item to get")], q: str 11 | ): 12 | results = {"item_id": item_id} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial004.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_items( 8 | *, item_id: int = Path(title="The ID of the item to get", ge=1), q: str 9 | ): 10 | results = {"item_id": item_id} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial004_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/{item_id}") 8 | async def read_items( 9 | item_id: Annotated[int, Path(title="The ID of the item to get", ge=1)], q: str 10 | ): 11 | results = {"item_id": item_id} 12 | if q: 13 | results.update({"q": q}) 14 | return results 15 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial004_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Path 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_items( 10 | item_id: Annotated[int, Path(title="The ID of the item to get", ge=1)], q: str 11 | ): 12 | results = {"item_id": item_id} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial005.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_items( 8 | *, 9 | item_id: int = Path(title="The ID of the item to get", gt=0, le=1000), 10 | q: str, 11 | ): 12 | results = {"item_id": item_id} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial005_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/{item_id}") 8 | async def read_items( 9 | item_id: Annotated[int, Path(title="The ID of the item to get", gt=0, le=1000)], 10 | q: str, 11 | ): 12 | results = {"item_id": item_id} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial005_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Path 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_items( 10 | item_id: Annotated[int, Path(title="The ID of the item to get", gt=0, le=1000)], 11 | q: str, 12 | ): 13 | results = {"item_id": item_id} 14 | if q: 15 | results.update({"q": q}) 16 | return results 17 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial006.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_items( 8 | *, 9 | item_id: int = Path(title="The ID of the item to get", ge=0, le=1000), 10 | q: str, 11 | size: float = Query(gt=0, lt=10.5), 12 | ): 13 | results = {"item_id": item_id} 14 | if q: 15 | results.update({"q": q}) 16 | return results 17 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial006_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Path, Query 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/{item_id}") 8 | async def read_items( 9 | *, 10 | item_id: Annotated[int, Path(title="The ID of the item to get", ge=0, le=1000)], 11 | q: str, 12 | size: Annotated[float, Query(gt=0, lt=10.5)], 13 | ): 14 | results = {"item_id": item_id} 15 | if q: 16 | results.update({"q": q}) 17 | return results 18 | -------------------------------------------------------------------------------- /docs_src/path_params_numeric_validations/tutorial006_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Path, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_items( 10 | *, 11 | item_id: Annotated[int, Path(title="The ID of the item to get", ge=0, le=1000)], 12 | q: str, 13 | size: Annotated[float, Query(gt=0, lt=10.5)], 14 | ): 15 | results = {"item_id": item_id} 16 | if q: 17 | results.update({"q": q}) 18 | return results 19 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial001.py: -------------------------------------------------------------------------------- 1 | def get_full_name(first_name, last_name): 2 | full_name = first_name.title() + " " + last_name.title() 3 | return full_name 4 | 5 | 6 | print(get_full_name("john", "doe")) 7 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial002.py: -------------------------------------------------------------------------------- 1 | def get_full_name(first_name: str, last_name: str): 2 | full_name = first_name.title() + " " + last_name.title() 3 | return full_name 4 | 5 | 6 | print(get_full_name("john", "doe")) 7 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial003.py: -------------------------------------------------------------------------------- 1 | def get_name_with_age(name: str, age: int): 2 | name_with_age = name + " is this old: " + age 3 | return name_with_age 4 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial004.py: -------------------------------------------------------------------------------- 1 | def get_name_with_age(name: str, age: int): 2 | name_with_age = name + " is this old: " + str(age) 3 | return name_with_age 4 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial005.py: -------------------------------------------------------------------------------- 1 | def get_items(item_a: str, item_b: int, item_c: float, item_d: bool, item_e: bytes): 2 | return item_a, item_b, item_c, item_d, item_d, item_e 3 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial006.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | 4 | def process_items(items: List[str]): 5 | for item in items: 6 | print(item) 7 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial006_py39.py: -------------------------------------------------------------------------------- 1 | def process_items(items: list[str]): 2 | for item in items: 3 | print(item) 4 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial007.py: -------------------------------------------------------------------------------- 1 | from typing import Set, Tuple 2 | 3 | 4 | def process_items(items_t: Tuple[int, int, str], items_s: Set[bytes]): 5 | return items_t, items_s 6 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial007_py39.py: -------------------------------------------------------------------------------- 1 | def process_items(items_t: tuple[int, int, str], items_s: set[bytes]): 2 | return items_t, items_s 3 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial008.py: -------------------------------------------------------------------------------- 1 | from typing import Dict 2 | 3 | 4 | def process_items(prices: Dict[str, float]): 5 | for item_name, item_price in prices.items(): 6 | print(item_name) 7 | print(item_price) 8 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial008_py39.py: -------------------------------------------------------------------------------- 1 | def process_items(prices: dict[str, float]): 2 | for item_name, item_price in prices.items(): 3 | print(item_name) 4 | print(item_price) 5 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial008b.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | 4 | def process_item(item: Union[int, str]): 5 | print(item) 6 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial008b_py310.py: -------------------------------------------------------------------------------- 1 | def process_item(item: int | str): 2 | print(item) 3 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial009.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | 4 | def say_hi(name: Optional[str] = None): 5 | if name is not None: 6 | print(f"Hey {name}!") 7 | else: 8 | print("Hello World") 9 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial009_py310.py: -------------------------------------------------------------------------------- 1 | def say_hi(name: str | None = None): 2 | if name is not None: 3 | print(f"Hey {name}!") 4 | else: 5 | print("Hello World") 6 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial009b.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | 4 | def say_hi(name: Union[str, None] = None): 5 | if name is not None: 6 | print(f"Hey {name}!") 7 | else: 8 | print("Hello World") 9 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial009c.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | 4 | def say_hi(name: Optional[str]): 5 | print(f"Hey {name}!") 6 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial009c_py310.py: -------------------------------------------------------------------------------- 1 | def say_hi(name: str | None): 2 | print(f"Hey {name}!") 3 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial010.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self, name: str): 3 | self.name = name 4 | 5 | 6 | def get_person_name(one_person: Person): 7 | return one_person.name 8 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial011_py310.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | from pydantic import BaseModel 4 | 5 | 6 | class User(BaseModel): 7 | id: int 8 | name = "John Doe" 9 | signup_ts: datetime | None = None 10 | friends: list[int] = [] 11 | 12 | 13 | external_data = { 14 | "id": "123", 15 | "signup_ts": "2017-06-01 12:22", 16 | "friends": [1, "2", b"3"], 17 | } 18 | user = User(**external_data) 19 | print(user) 20 | # > User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3] 21 | print(user.id) 22 | # > 123 23 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial012.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | from pydantic import BaseModel 4 | 5 | 6 | class User(BaseModel): 7 | name: str 8 | age: Optional[int] 9 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial013.py: -------------------------------------------------------------------------------- 1 | from typing_extensions import Annotated 2 | 3 | 4 | def say_hello(name: Annotated[str, "this is just metadata"]) -> str: 5 | return f"Hello {name}" 6 | -------------------------------------------------------------------------------- /docs_src/python_types/tutorial013_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | 4 | def say_hello(name: Annotated[str, "this is just metadata"]) -> str: 5 | return f"Hello {name}" 6 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}] 6 | 7 | 8 | @app.get("/items/") 9 | async def read_item(skip: int = 0, limit: int = 10): 10 | return fake_items_db[skip : skip + limit] 11 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial002.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_item(item_id: str, q: Union[str, None] = None): 10 | if q: 11 | return {"item_id": item_id, "q": q} 12 | return {"item_id": item_id} 13 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial002_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_item(item_id: str, q: str | None = None): 8 | if q: 9 | return {"item_id": item_id, "q": q} 10 | return {"item_id": item_id} 11 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial003.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_item(item_id: str, q: Union[str, None] = None, short: bool = False): 10 | item = {"item_id": item_id} 11 | if q: 12 | item.update({"q": q}) 13 | if not short: 14 | item.update( 15 | {"description": "This is an amazing item that has a long description"} 16 | ) 17 | return item 18 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial003_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_item(item_id: str, q: str | None = None, short: bool = False): 8 | item = {"item_id": item_id} 9 | if q: 10 | item.update({"q": q}) 11 | if not short: 12 | item.update( 13 | {"description": "This is an amazing item that has a long description"} 14 | ) 15 | return item 16 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial004.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/users/{user_id}/items/{item_id}") 9 | async def read_user_item( 10 | user_id: int, item_id: str, q: Union[str, None] = None, short: bool = False 11 | ): 12 | item = {"item_id": item_id, "owner_id": user_id} 13 | if q: 14 | item.update({"q": q}) 15 | if not short: 16 | item.update( 17 | {"description": "This is an amazing item that has a long description"} 18 | ) 19 | return item 20 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial004_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/users/{user_id}/items/{item_id}") 7 | async def read_user_item( 8 | user_id: int, item_id: str, q: str | None = None, short: bool = False 9 | ): 10 | item = {"item_id": item_id, "owner_id": user_id} 11 | if q: 12 | item.update({"q": q}) 13 | if not short: 14 | item.update( 15 | {"description": "This is an amazing item that has a long description"} 16 | ) 17 | return item 18 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial005.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_user_item(item_id: str, needy: str): 8 | item = {"item_id": item_id, "needy": needy} 9 | return item 10 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial006.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_user_item( 10 | item_id: str, needy: str, skip: int = 0, limit: Union[int, None] = None 11 | ): 12 | item = {"item_id": item_id, "needy": needy, "skip": skip, "limit": limit} 13 | return item 14 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial006_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | async def read_user_item( 8 | item_id: str, needy: str, skip: int = 0, limit: int | None = None 9 | ): 10 | item = {"item_id": item_id, "needy": needy, "skip": skip, "limit": limit} 11 | return item 12 | -------------------------------------------------------------------------------- /docs_src/query_params/tutorial006b.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/{item_id}") 9 | async def read_user_item( 10 | item_id: str, needy: str, skip: int = 0, limit: Union[int, None] = None 11 | ): 12 | item = {"item_id": item_id, "needy": needy, "skip": skip, "limit": limit} 13 | return item 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial001.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Union[str, None] = None): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial001_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: str | None = None): 8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial002.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Union[str, None] = Query(default=None, max_length=50)): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial002_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(q: Annotated[Union[str, None], Query(max_length=50)] = None): 11 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 12 | if q: 13 | results.update({"q": q}) 14 | return results 15 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial002_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[str | None, Query(max_length=50)] = None): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial002_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: str | None = Query(default=None, max_length=50)): 8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial003.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | q: Union[str, None] = Query(default=None, min_length=3, max_length=50) 11 | ): 12 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial003_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items( 11 | q: Annotated[Union[str, None], Query(min_length=3, max_length=50)] = None 12 | ): 13 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 14 | if q: 15 | results.update({"q": q}) 16 | return results 17 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial003_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | q: Annotated[str | None, Query(min_length=3, max_length=50)] = None 11 | ): 12 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial003_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | q: Annotated[Union[str, None], Query(min_length=3, max_length=50)] = None 11 | ): 12 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial003_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: str | None = Query(default=None, min_length=3, max_length=50)): 8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial004.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | q: Union[str, None] = Query( 11 | default=None, min_length=3, max_length=50, regex="^fixedquery$" 12 | ) 13 | ): 14 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 15 | if q: 16 | results.update({"q": q}) 17 | return results 18 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial004_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items( 11 | q: Annotated[ 12 | Union[str, None], Query(min_length=3, max_length=50, regex="^fixedquery$") 13 | ] = None 14 | ): 15 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 16 | if q: 17 | results.update({"q": q}) 18 | return results 19 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial004_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | q: Annotated[ 11 | str | None, Query(min_length=3, max_length=50, regex="^fixedquery$") 12 | ] = None 13 | ): 14 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 15 | if q: 16 | results.update({"q": q}) 17 | return results 18 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial004_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | q: Annotated[ 11 | Union[str, None], Query(min_length=3, max_length=50, regex="^fixedquery$") 12 | ] = None 13 | ): 14 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 15 | if q: 16 | results.update({"q": q}) 17 | return results 18 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial004_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items( 8 | q: str 9 | | None = Query(default=None, min_length=3, max_length=50, regex="^fixedquery$") 10 | ): 11 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 12 | if q: 13 | results.update({"q": q}) 14 | return results 15 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial005.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: str = Query(default="fixedquery", min_length=3)): 8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial005_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/") 8 | async def read_items(q: Annotated[str, Query(min_length=3)] = "fixedquery"): 9 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 10 | if q: 11 | results.update({"q": q}) 12 | return results 13 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial005_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[str, Query(min_length=3)] = "fixedquery"): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: str = Query(min_length=3)): 8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/") 8 | async def read_items(q: Annotated[str, Query(min_length=3)]): 9 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 10 | if q: 11 | results.update({"q": q}) 12 | return results 13 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[str, Query(min_length=3)]): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006b.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: str = Query(default=..., min_length=3)): 8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006b_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/") 8 | async def read_items(q: Annotated[str, Query(min_length=3)] = ...): 9 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 10 | if q: 11 | results.update({"q": q}) 12 | return results 13 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006b_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[str, Query(min_length=3)] = ...): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006c.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Union[str, None] = Query(default=..., min_length=3)): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006c_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(q: Annotated[Union[str, None], Query(min_length=3)] = ...): 11 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 12 | if q: 13 | results.update({"q": q}) 14 | return results 15 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006c_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[str | None, Query(min_length=3)] = ...): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006c_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[Union[str, None], Query(min_length=3)] = ...): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006c_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: str | None = Query(default=..., min_length=3)): 8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006d.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | from pydantic import Required 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/") 8 | async def read_items(q: str = Query(default=Required, min_length=3)): 9 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 10 | if q: 11 | results.update({"q": q}) 12 | return results 13 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006d_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | from pydantic import Required 3 | from typing_extensions import Annotated 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[str, Query(min_length=3)] = Required): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial006d_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | from pydantic import Required 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(q: Annotated[str, Query(min_length=3)] = Required): 11 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 12 | if q: 13 | results.update({"q": q}) 14 | return results 15 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial007.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | q: Union[str, None] = Query(default=None, title="Query string", min_length=3) 11 | ): 12 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial007_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items( 11 | q: Annotated[Union[str, None], Query(title="Query string", min_length=3)] = None 12 | ): 13 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 14 | if q: 15 | results.update({"q": q}) 16 | return results 17 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial007_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | q: Annotated[str | None, Query(title="Query string", min_length=3)] = None 11 | ): 12 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial007_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | q: Annotated[Union[str, None], Query(title="Query string", min_length=3)] = None 11 | ): 12 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 13 | if q: 14 | results.update({"q": q}) 15 | return results 16 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial007_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items( 8 | q: str | None = Query(default=None, title="Query string", min_length=3) 9 | ): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial008_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items( 8 | q: str 9 | | None = Query( 10 | default=None, 11 | title="Query string", 12 | description="Query string for the items to search in the database that have a good match", 13 | min_length=3, 14 | ) 15 | ): 16 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 17 | if q: 18 | results.update({"q": q}) 19 | return results 20 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial009.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Union[str, None] = Query(default=None, alias="item-query")): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial009_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(q: Annotated[Union[str, None], Query(alias="item-query")] = None): 11 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 12 | if q: 13 | results.update({"q": q}) 14 | return results 15 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial009_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[str | None, Query(alias="item-query")] = None): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial009_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[Union[str, None], Query(alias="item-query")] = None): 10 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 11 | if q: 12 | results.update({"q": q}) 13 | return results 14 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial009_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: str | None = Query(default=None, alias="item-query")): 8 | results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 9 | if q: 10 | results.update({"q": q}) 11 | return results 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial011.py: -------------------------------------------------------------------------------- 1 | from typing import List, Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Union[List[str], None] = Query(default=None)): 10 | query_items = {"q": q} 11 | return query_items 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial011_an.py: -------------------------------------------------------------------------------- 1 | from typing import List, Union 2 | 3 | from fastapi import FastAPI, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(q: Annotated[Union[List[str], None], Query()] = None): 11 | query_items = {"q": q} 12 | return query_items 13 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial011_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[list[str] | None, Query()] = None): 10 | query_items = {"q": q} 11 | return query_items 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial011_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[Union[list[str], None], Query()] = None): 10 | query_items = {"q": q} 11 | return query_items 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial011_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: list[str] | None = Query(default=None)): 8 | query_items = {"q": q} 9 | return query_items 10 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial011_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Union[list[str], None] = Query(default=None)): 10 | query_items = {"q": q} 11 | return query_items 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial012.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: List[str] = Query(default=["foo", "bar"])): 10 | query_items = {"q": q} 11 | return query_items 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial012_an.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from fastapi import FastAPI, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(q: Annotated[List[str], Query()] = ["foo", "bar"]): 11 | query_items = {"q": q} 12 | return query_items 13 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial012_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[list[str], Query()] = ["foo", "bar"]): 10 | query_items = {"q": q} 11 | return query_items 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial012_py39.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: list[str] = Query(default=["foo", "bar"])): 8 | query_items = {"q": q} 9 | return query_items 10 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial013.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items(q: list = Query(default=[])): 8 | query_items = {"q": q} 9 | return query_items 10 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial013_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/items/") 8 | async def read_items(q: Annotated[list, Query()] = []): 9 | query_items = {"q": q} 10 | return query_items 11 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial013_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items(q: Annotated[list, Query()] = []): 10 | query_items = {"q": q} 11 | return query_items 12 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial014.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | hidden_query: Union[str, None] = Query(default=None, include_in_schema=False) 11 | ): 12 | if hidden_query: 13 | return {"hidden_query": hidden_query} 14 | else: 15 | return {"hidden_query": "Not found"} 16 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial014_an.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Query 4 | from typing_extensions import Annotated 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items( 11 | hidden_query: Annotated[Union[str, None], Query(include_in_schema=False)] = None 12 | ): 13 | if hidden_query: 14 | return {"hidden_query": hidden_query} 15 | else: 16 | return {"hidden_query": "Not found"} 17 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial014_an_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | hidden_query: Annotated[str | None, Query(include_in_schema=False)] = None 11 | ): 12 | if hidden_query: 13 | return {"hidden_query": hidden_query} 14 | else: 15 | return {"hidden_query": "Not found"} 16 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial014_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, Union 2 | 3 | from fastapi import FastAPI, Query 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/items/") 9 | async def read_items( 10 | hidden_query: Annotated[Union[str, None], Query(include_in_schema=False)] = None 11 | ): 12 | if hidden_query: 13 | return {"hidden_query": hidden_query} 14 | else: 15 | return {"hidden_query": "Not found"} 16 | -------------------------------------------------------------------------------- /docs_src/query_params_str_validations/tutorial014_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Query 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/") 7 | async def read_items( 8 | hidden_query: str | None = Query(default=None, include_in_schema=False) 9 | ): 10 | if hidden_query: 11 | return {"hidden_query": hidden_query} 12 | else: 13 | return {"hidden_query": "Not found"} 14 | -------------------------------------------------------------------------------- /docs_src/request_files/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, File, UploadFile 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.post("/files/") 7 | async def create_file(file: bytes = File()): 8 | return {"file_size": len(file)} 9 | 10 | 11 | @app.post("/uploadfile/") 12 | async def create_upload_file(file: UploadFile): 13 | return {"filename": file.filename} 14 | -------------------------------------------------------------------------------- /docs_src/request_files/tutorial001_02_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, File, UploadFile 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.post("/files/") 7 | async def create_file(file: bytes | None = File(default=None)): 8 | if not file: 9 | return {"message": "No file sent"} 10 | else: 11 | return {"file_size": len(file)} 12 | 13 | 14 | @app.post("/uploadfile/") 15 | async def create_upload_file(file: UploadFile | None = None): 16 | if not file: 17 | return {"message": "No upload file sent"} 18 | else: 19 | return {"filename": file.filename} 20 | -------------------------------------------------------------------------------- /docs_src/request_files/tutorial001_03.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, File, UploadFile 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.post("/files/") 7 | async def create_file(file: bytes = File(description="A file read as bytes")): 8 | return {"file_size": len(file)} 9 | 10 | 11 | @app.post("/uploadfile/") 12 | async def create_upload_file( 13 | file: UploadFile = File(description="A file read as UploadFile"), 14 | ): 15 | return {"filename": file.filename} 16 | -------------------------------------------------------------------------------- /docs_src/request_files/tutorial001_03_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, File, UploadFile 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.post("/files/") 8 | async def create_file(file: Annotated[bytes, File(description="A file read as bytes")]): 9 | return {"file_size": len(file)} 10 | 11 | 12 | @app.post("/uploadfile/") 13 | async def create_upload_file( 14 | file: Annotated[UploadFile, File(description="A file read as UploadFile")], 15 | ): 16 | return {"filename": file.filename} 17 | -------------------------------------------------------------------------------- /docs_src/request_files/tutorial001_03_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, File, UploadFile 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.post("/files/") 9 | async def create_file(file: Annotated[bytes, File(description="A file read as bytes")]): 10 | return {"file_size": len(file)} 11 | 12 | 13 | @app.post("/uploadfile/") 14 | async def create_upload_file( 15 | file: Annotated[UploadFile, File(description="A file read as UploadFile")], 16 | ): 17 | return {"filename": file.filename} 18 | -------------------------------------------------------------------------------- /docs_src/request_files/tutorial001_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, File, UploadFile 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.post("/files/") 8 | async def create_file(file: Annotated[bytes, File()]): 9 | return {"file_size": len(file)} 10 | 11 | 12 | @app.post("/uploadfile/") 13 | async def create_upload_file(file: UploadFile): 14 | return {"filename": file.filename} 15 | -------------------------------------------------------------------------------- /docs_src/request_files/tutorial001_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, File, UploadFile 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.post("/files/") 9 | async def create_file(file: Annotated[bytes, File()]): 10 | return {"file_size": len(file)} 11 | 12 | 13 | @app.post("/uploadfile/") 14 | async def create_upload_file(file: UploadFile): 15 | return {"filename": file.filename} 16 | -------------------------------------------------------------------------------- /docs_src/request_forms/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Form 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.post("/login/") 7 | async def login(username: str = Form(), password: str = Form()): 8 | return {"username": username} 9 | -------------------------------------------------------------------------------- /docs_src/request_forms/tutorial001_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Form 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.post("/login/") 8 | async def login(username: Annotated[str, Form()], password: Annotated[str, Form()]): 9 | return {"username": username} 10 | -------------------------------------------------------------------------------- /docs_src/request_forms/tutorial001_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, Form 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.post("/login/") 9 | async def login(username: Annotated[str, Form()], password: Annotated[str, Form()]): 10 | return {"username": username} 11 | -------------------------------------------------------------------------------- /docs_src/request_forms_and_files/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, File, Form, UploadFile 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.post("/files/") 7 | async def create_file( 8 | file: bytes = File(), fileb: UploadFile = File(), token: str = Form() 9 | ): 10 | return { 11 | "file_size": len(file), 12 | "token": token, 13 | "fileb_content_type": fileb.content_type, 14 | } 15 | -------------------------------------------------------------------------------- /docs_src/request_forms_and_files/tutorial001_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, File, Form, UploadFile 2 | from typing_extensions import Annotated 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.post("/files/") 8 | async def create_file( 9 | file: Annotated[bytes, File()], 10 | fileb: Annotated[UploadFile, File()], 11 | token: Annotated[str, Form()], 12 | ): 13 | return { 14 | "file_size": len(file), 15 | "token": token, 16 | "fileb_content_type": fileb.content_type, 17 | } 18 | -------------------------------------------------------------------------------- /docs_src/request_forms_and_files/tutorial001_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import FastAPI, File, Form, UploadFile 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.post("/files/") 9 | async def create_file( 10 | file: Annotated[bytes, File()], 11 | fileb: Annotated[UploadFile, File()], 12 | token: Annotated[str, Form()], 13 | ): 14 | return { 15 | "file_size": len(file), 16 | "token": token, 17 | "fileb_content_type": fileb.content_type, 18 | } 19 | -------------------------------------------------------------------------------- /docs_src/response_change_status_code/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Response, status 2 | 3 | app = FastAPI() 4 | 5 | tasks = {"foo": "Listen to the Bar Fighters"} 6 | 7 | 8 | @app.put("/get-or-create-task/{task_id}", status_code=200) 9 | def get_or_create_task(task_id: str, response: Response): 10 | if task_id not in tasks: 11 | tasks[task_id] = "This didn't exist before" 12 | response.status_code = status.HTTP_201_CREATED 13 | return tasks[task_id] 14 | -------------------------------------------------------------------------------- /docs_src/response_cookies/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import JSONResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.post("/cookie/") 8 | def create_cookie(): 9 | content = {"message": "Come to the dark side, we have cookies"} 10 | response = JSONResponse(content=content) 11 | response.set_cookie(key="fakesession", value="fake-cookie-session-value") 12 | return response 13 | -------------------------------------------------------------------------------- /docs_src/response_cookies/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Response 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.post("/cookie-and-object/") 7 | def create_cookie(response: Response): 8 | response.set_cookie(key="fakesession", value="fake-cookie-session-value") 9 | return {"message": "Come to the dark side, we have cookies"} 10 | -------------------------------------------------------------------------------- /docs_src/response_directly/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Response 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/legacy/") 7 | def get_legacy_data(): 8 | data = """ 9 | 10 |
11 | Apply shampoo here. 12 |
13 | 14 | You'll have to use soap here. 15 | 16 |
17 | """ 18 | return Response(content=data, media_type="application/xml") 19 | -------------------------------------------------------------------------------- /docs_src/response_headers/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import JSONResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/headers/") 8 | def get_headers(): 9 | content = {"message": "Hello World"} 10 | headers = {"X-Cat-Dog": "alone in the world", "Content-Language": "en-US"} 11 | return JSONResponse(content=content, headers=headers) 12 | -------------------------------------------------------------------------------- /docs_src/response_headers/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Response 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/headers-and-object/") 7 | def get_headers(response: Response): 8 | response.headers["X-Cat-Dog"] = "alone in the world" 9 | return {"message": "Hello World"} 10 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial002.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel, EmailStr 5 | 6 | app = FastAPI() 7 | 8 | 9 | class UserIn(BaseModel): 10 | username: str 11 | password: str 12 | email: EmailStr 13 | full_name: Union[str, None] = None 14 | 15 | 16 | # Don't do this in production! 17 | @app.post("/user/") 18 | async def create_user(user: UserIn) -> UserIn: 19 | return user 20 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial002_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel, EmailStr 3 | 4 | app = FastAPI() 5 | 6 | 7 | class UserIn(BaseModel): 8 | username: str 9 | password: str 10 | email: EmailStr 11 | full_name: str | None = None 12 | 13 | 14 | # Don't do this in production! 15 | @app.post("/user/") 16 | async def create_user(user: UserIn) -> UserIn: 17 | return user 18 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial003_01.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel, EmailStr 5 | 6 | app = FastAPI() 7 | 8 | 9 | class BaseUser(BaseModel): 10 | username: str 11 | email: EmailStr 12 | full_name: Union[str, None] = None 13 | 14 | 15 | class UserIn(BaseUser): 16 | password: str 17 | 18 | 19 | @app.post("/user/") 20 | async def create_user(user: UserIn) -> BaseUser: 21 | return user 22 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial003_01_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel, EmailStr 3 | 4 | app = FastAPI() 5 | 6 | 7 | class BaseUser(BaseModel): 8 | username: str 9 | email: EmailStr 10 | full_name: str | None = None 11 | 12 | 13 | class UserIn(BaseUser): 14 | password: str 15 | 16 | 17 | @app.post("/user/") 18 | async def create_user(user: UserIn) -> BaseUser: 19 | return user 20 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial003_02.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Response 2 | from fastapi.responses import JSONResponse, RedirectResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/portal") 8 | async def get_portal(teleport: bool = False) -> Response: 9 | if teleport: 10 | return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") 11 | return JSONResponse(content={"message": "Here's your interdimensional portal."}) 12 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial003_03.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import RedirectResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/teleport") 8 | async def get_teleport() -> RedirectResponse: 9 | return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") 10 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial003_04.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Response 4 | from fastapi.responses import RedirectResponse 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/portal") 10 | async def get_portal(teleport: bool = False) -> Union[Response, dict]: 11 | if teleport: 12 | return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") 13 | return {"message": "Here's your interdimensional portal."} 14 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial003_04_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Response 2 | from fastapi.responses import RedirectResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/portal") 8 | async def get_portal(teleport: bool = False) -> Response | dict: 9 | if teleport: 10 | return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") 11 | return {"message": "Here's your interdimensional portal."} 12 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial003_05.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from fastapi import FastAPI, Response 4 | from fastapi.responses import RedirectResponse 5 | 6 | app = FastAPI() 7 | 8 | 9 | @app.get("/portal", response_model=None) 10 | async def get_portal(teleport: bool = False) -> Union[Response, dict]: 11 | if teleport: 12 | return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") 13 | return {"message": "Here's your interdimensional portal."} 14 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial003_05_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Response 2 | from fastapi.responses import RedirectResponse 3 | 4 | app = FastAPI() 5 | 6 | 7 | @app.get("/portal", response_model=None) 8 | async def get_portal(teleport: bool = False) -> Response | dict: 9 | if teleport: 10 | return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") 11 | return {"message": "Here's your interdimensional portal."} 12 | -------------------------------------------------------------------------------- /docs_src/response_model/tutorial003_py310.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | from fastapi import FastAPI 4 | from pydantic import BaseModel, EmailStr 5 | 6 | app = FastAPI() 7 | 8 | 9 | class UserIn(BaseModel): 10 | username: str 11 | password: str 12 | email: EmailStr 13 | full_name: str | None = None 14 | 15 | 16 | class UserOut(BaseModel): 17 | username: str 18 | email: EmailStr 19 | full_name: str | None = None 20 | 21 | 22 | @app.post("/user/", response_model=UserOut) 23 | async def create_user(user: UserIn) -> Any: 24 | return user 25 | -------------------------------------------------------------------------------- /docs_src/response_status_code/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.post("/items/", status_code=201) 7 | async def create_item(name: str): 8 | return {"name": name} 9 | -------------------------------------------------------------------------------- /docs_src/response_status_code/tutorial002.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, status 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.post("/items/", status_code=status.HTTP_201_CREATED) 7 | async def create_item(name: str): 8 | return {"name": name} 9 | -------------------------------------------------------------------------------- /docs_src/schema_extra_example/tutorial002_py310.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseModel, Field 3 | 4 | app = FastAPI() 5 | 6 | 7 | class Item(BaseModel): 8 | name: str = Field(example="Foo") 9 | description: str | None = Field(default=None, example="A very nice Item") 10 | price: float = Field(example=35.4) 11 | tax: float | None = Field(default=None, example=3.2) 12 | 13 | 14 | @app.put("/items/{item_id}") 15 | async def update_item(item_id: int, item: Item): 16 | results = {"item_id": item_id, "item": item} 17 | return results 18 | -------------------------------------------------------------------------------- /docs_src/security/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import Depends, FastAPI 2 | from fastapi.security import OAuth2PasswordBearer 3 | 4 | app = FastAPI() 5 | 6 | oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") 7 | 8 | 9 | @app.get("/items/") 10 | async def read_items(token: str = Depends(oauth2_scheme)): 11 | return {"token": token} 12 | -------------------------------------------------------------------------------- /docs_src/security/tutorial001_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import Depends, FastAPI 2 | from fastapi.security import OAuth2PasswordBearer 3 | from typing_extensions import Annotated 4 | 5 | app = FastAPI() 6 | 7 | oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") 8 | 9 | 10 | @app.get("/items/") 11 | async def read_items(token: Annotated[str, Depends(oauth2_scheme)]): 12 | return {"token": token} 13 | -------------------------------------------------------------------------------- /docs_src/security/tutorial001_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import Depends, FastAPI 4 | from fastapi.security import OAuth2PasswordBearer 5 | 6 | app = FastAPI() 7 | 8 | oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") 9 | 10 | 11 | @app.get("/items/") 12 | async def read_items(token: Annotated[str, Depends(oauth2_scheme)]): 13 | return {"token": token} 14 | -------------------------------------------------------------------------------- /docs_src/security/tutorial006.py: -------------------------------------------------------------------------------- 1 | from fastapi import Depends, FastAPI 2 | from fastapi.security import HTTPBasic, HTTPBasicCredentials 3 | 4 | app = FastAPI() 5 | 6 | security = HTTPBasic() 7 | 8 | 9 | @app.get("/users/me") 10 | def read_current_user(credentials: HTTPBasicCredentials = Depends(security)): 11 | return {"username": credentials.username, "password": credentials.password} 12 | -------------------------------------------------------------------------------- /docs_src/security/tutorial006_an.py: -------------------------------------------------------------------------------- 1 | from fastapi import Depends, FastAPI 2 | from fastapi.security import HTTPBasic, HTTPBasicCredentials 3 | from typing_extensions import Annotated 4 | 5 | app = FastAPI() 6 | 7 | security = HTTPBasic() 8 | 9 | 10 | @app.get("/users/me") 11 | def read_current_user(credentials: Annotated[HTTPBasicCredentials, Depends(security)]): 12 | return {"username": credentials.username, "password": credentials.password} 13 | -------------------------------------------------------------------------------- /docs_src/security/tutorial006_an_py39.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated 2 | 3 | from fastapi import Depends, FastAPI 4 | from fastapi.security import HTTPBasic, HTTPBasicCredentials 5 | 6 | app = FastAPI() 7 | 8 | security = HTTPBasic() 9 | 10 | 11 | @app.get("/users/me") 12 | def read_current_user(credentials: Annotated[HTTPBasicCredentials, Depends(security)]): 13 | return {"username": credentials.username, "password": credentials.password} 14 | -------------------------------------------------------------------------------- /docs_src/settings/app01/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/settings/app01/__init__.py -------------------------------------------------------------------------------- /docs_src/settings/app01/config.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseSettings 2 | 3 | 4 | class Settings(BaseSettings): 5 | app_name: str = "Awesome API" 6 | admin_email: str 7 | items_per_user: int = 50 8 | 9 | 10 | settings = Settings() 11 | -------------------------------------------------------------------------------- /docs_src/settings/app01/main.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | from .config import settings 4 | 5 | app = FastAPI() 6 | 7 | 8 | @app.get("/info") 9 | async def info(): 10 | return { 11 | "app_name": settings.app_name, 12 | "admin_email": settings.admin_email, 13 | "items_per_user": settings.items_per_user, 14 | } 15 | -------------------------------------------------------------------------------- /docs_src/settings/app02/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/settings/app02/__init__.py -------------------------------------------------------------------------------- /docs_src/settings/app02/config.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseSettings 2 | 3 | 4 | class Settings(BaseSettings): 5 | app_name: str = "Awesome API" 6 | admin_email: str 7 | items_per_user: int = 50 8 | -------------------------------------------------------------------------------- /docs_src/settings/app02/main.py: -------------------------------------------------------------------------------- 1 | from functools import lru_cache 2 | 3 | from fastapi import Depends, FastAPI 4 | 5 | from .config import Settings 6 | 7 | app = FastAPI() 8 | 9 | 10 | @lru_cache() 11 | def get_settings(): 12 | return Settings() 13 | 14 | 15 | @app.get("/info") 16 | async def info(settings: Settings = Depends(get_settings)): 17 | return { 18 | "app_name": settings.app_name, 19 | "admin_email": settings.admin_email, 20 | "items_per_user": settings.items_per_user, 21 | } 22 | -------------------------------------------------------------------------------- /docs_src/settings/app02_an/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/settings/app02_an/__init__.py -------------------------------------------------------------------------------- /docs_src/settings/app02_an/config.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseSettings 2 | 3 | 4 | class Settings(BaseSettings): 5 | app_name: str = "Awesome API" 6 | admin_email: str 7 | items_per_user: int = 50 8 | -------------------------------------------------------------------------------- /docs_src/settings/app02_an/main.py: -------------------------------------------------------------------------------- 1 | from functools import lru_cache 2 | 3 | from fastapi import Depends, FastAPI 4 | from typing_extensions import Annotated 5 | 6 | from .config import Settings 7 | 8 | app = FastAPI() 9 | 10 | 11 | @lru_cache() 12 | def get_settings(): 13 | return Settings() 14 | 15 | 16 | @app.get("/info") 17 | async def info(settings: Annotated[Settings, Depends(get_settings)]): 18 | return { 19 | "app_name": settings.app_name, 20 | "admin_email": settings.admin_email, 21 | "items_per_user": settings.items_per_user, 22 | } 23 | -------------------------------------------------------------------------------- /docs_src/settings/app02_an_py39/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/settings/app02_an_py39/__init__.py -------------------------------------------------------------------------------- /docs_src/settings/app02_an_py39/config.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseSettings 2 | 3 | 4 | class Settings(BaseSettings): 5 | app_name: str = "Awesome API" 6 | admin_email: str 7 | items_per_user: int = 50 8 | -------------------------------------------------------------------------------- /docs_src/settings/app02_an_py39/main.py: -------------------------------------------------------------------------------- 1 | from functools import lru_cache 2 | from typing import Annotated 3 | 4 | from fastapi import Depends, FastAPI 5 | 6 | from .config import Settings 7 | 8 | app = FastAPI() 9 | 10 | 11 | @lru_cache() 12 | def get_settings(): 13 | return Settings() 14 | 15 | 16 | @app.get("/info") 17 | async def info(settings: Annotated[Settings, Depends(get_settings)]): 18 | return { 19 | "app_name": settings.app_name, 20 | "admin_email": settings.admin_email, 21 | "items_per_user": settings.items_per_user, 22 | } 23 | -------------------------------------------------------------------------------- /docs_src/settings/app03/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/settings/app03/__init__.py -------------------------------------------------------------------------------- /docs_src/settings/app03/config.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseSettings 2 | 3 | 4 | class Settings(BaseSettings): 5 | app_name: str = "Awesome API" 6 | admin_email: str 7 | items_per_user: int = 50 8 | 9 | class Config: 10 | env_file = ".env" 11 | -------------------------------------------------------------------------------- /docs_src/settings/app03/main.py: -------------------------------------------------------------------------------- 1 | from functools import lru_cache 2 | 3 | from fastapi import Depends, FastAPI 4 | 5 | from . import config 6 | 7 | app = FastAPI() 8 | 9 | 10 | @lru_cache() 11 | def get_settings(): 12 | return config.Settings() 13 | 14 | 15 | @app.get("/info") 16 | async def info(settings: config.Settings = Depends(get_settings)): 17 | return { 18 | "app_name": settings.app_name, 19 | "admin_email": settings.admin_email, 20 | "items_per_user": settings.items_per_user, 21 | } 22 | -------------------------------------------------------------------------------- /docs_src/settings/app03_an/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/settings/app03_an/__init__.py -------------------------------------------------------------------------------- /docs_src/settings/app03_an/config.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseSettings 2 | 3 | 4 | class Settings(BaseSettings): 5 | app_name: str = "Awesome API" 6 | admin_email: str 7 | items_per_user: int = 50 8 | 9 | class Config: 10 | env_file = ".env" 11 | -------------------------------------------------------------------------------- /docs_src/settings/app03_an/main.py: -------------------------------------------------------------------------------- 1 | from functools import lru_cache 2 | from typing import Annotated 3 | 4 | from fastapi import Depends, FastAPI 5 | 6 | from . import config 7 | 8 | app = FastAPI() 9 | 10 | 11 | @lru_cache() 12 | def get_settings(): 13 | return config.Settings() 14 | 15 | 16 | @app.get("/info") 17 | async def info(settings: Annotated[config.Settings, Depends(get_settings)]): 18 | return { 19 | "app_name": settings.app_name, 20 | "admin_email": settings.admin_email, 21 | "items_per_user": settings.items_per_user, 22 | } 23 | -------------------------------------------------------------------------------- /docs_src/settings/app03_an_py39/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/settings/app03_an_py39/__init__.py -------------------------------------------------------------------------------- /docs_src/settings/app03_an_py39/config.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseSettings 2 | 3 | 4 | class Settings(BaseSettings): 5 | app_name: str = "Awesome API" 6 | admin_email: str 7 | items_per_user: int = 50 8 | 9 | class Config: 10 | env_file = ".env" 11 | -------------------------------------------------------------------------------- /docs_src/settings/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from pydantic import BaseSettings 3 | 4 | 5 | class Settings(BaseSettings): 6 | app_name: str = "Awesome API" 7 | admin_email: str 8 | items_per_user: int = 50 9 | 10 | 11 | settings = Settings() 12 | app = FastAPI() 13 | 14 | 15 | @app.get("/info") 16 | async def info(): 17 | return { 18 | "app_name": settings.app_name, 19 | "admin_email": settings.admin_email, 20 | "items_per_user": settings.items_per_user, 21 | } 22 | -------------------------------------------------------------------------------- /docs_src/sql_databases/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/sql_databases/__init__.py -------------------------------------------------------------------------------- /docs_src/sql_databases/sql_app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/sql_databases/sql_app/__init__.py -------------------------------------------------------------------------------- /docs_src/sql_databases/sql_app/database.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import create_engine 2 | from sqlalchemy.ext.declarative import declarative_base 3 | from sqlalchemy.orm import sessionmaker 4 | 5 | SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db" 6 | # SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db" 7 | 8 | engine = create_engine( 9 | SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False} 10 | ) 11 | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) 12 | 13 | Base = declarative_base() 14 | -------------------------------------------------------------------------------- /docs_src/sql_databases/sql_app/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/sql_databases/sql_app/tests/__init__.py -------------------------------------------------------------------------------- /docs_src/sql_databases/sql_app_py310/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/sql_databases/sql_app_py310/__init__.py -------------------------------------------------------------------------------- /docs_src/sql_databases/sql_app_py310/database.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import create_engine 2 | from sqlalchemy.ext.declarative import declarative_base 3 | from sqlalchemy.orm import sessionmaker 4 | 5 | SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db" 6 | # SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db" 7 | 8 | engine = create_engine( 9 | SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False} 10 | ) 11 | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) 12 | 13 | Base = declarative_base() 14 | -------------------------------------------------------------------------------- /docs_src/sql_databases/sql_app_py310/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/sql_databases/sql_app_py310/tests/__init__.py -------------------------------------------------------------------------------- /docs_src/sql_databases/sql_app_py39/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/sql_databases/sql_app_py39/__init__.py -------------------------------------------------------------------------------- /docs_src/sql_databases/sql_app_py39/database.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import create_engine 2 | from sqlalchemy.ext.declarative import declarative_base 3 | from sqlalchemy.orm import sessionmaker 4 | 5 | SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db" 6 | # SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db" 7 | 8 | engine = create_engine( 9 | SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False} 10 | ) 11 | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) 12 | 13 | Base = declarative_base() 14 | -------------------------------------------------------------------------------- /docs_src/sql_databases/sql_app_py39/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/sql_databases/sql_app_py39/tests/__init__.py -------------------------------------------------------------------------------- /docs_src/sql_databases_peewee/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/sql_databases_peewee/__init__.py -------------------------------------------------------------------------------- /docs_src/sql_databases_peewee/sql_app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/sql_databases_peewee/sql_app/__init__.py -------------------------------------------------------------------------------- /docs_src/static_files/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.staticfiles import StaticFiles 3 | 4 | app = FastAPI() 5 | 6 | app.mount("/static", StaticFiles(directory="static"), name="static") 7 | -------------------------------------------------------------------------------- /docs_src/sub_applications/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/app") 7 | def read_main(): 8 | return {"message": "Hello World from main app"} 9 | 10 | 11 | subapi = FastAPI() 12 | 13 | 14 | @subapi.get("/sub") 15 | def read_sub(): 16 | return {"message": "Hello World from sub API"} 17 | 18 | 19 | app.mount("/subapi", subapi) 20 | -------------------------------------------------------------------------------- /docs_src/templates/static/styles.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | color: green; 3 | } 4 | -------------------------------------------------------------------------------- /docs_src/templates/templates/item.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Item Details 4 | 5 | 6 | 7 |

Item ID: {{ id }}

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs_src/using_request_directly/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Request 2 | 3 | app = FastAPI() 4 | 5 | 6 | @app.get("/items/{item_id}") 7 | def read_root(item_id: str, request: Request): 8 | client_host = request.client.host 9 | return {"client_host": client_host, "item_id": item_id} 10 | -------------------------------------------------------------------------------- /docs_src/websockets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/docs_src/websockets/__init__.py -------------------------------------------------------------------------------- /docs_src/wsgi/tutorial001.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.middleware.wsgi import WSGIMiddleware 3 | from flask import Flask, request 4 | from markupsafe import escape 5 | 6 | flask_app = Flask(__name__) 7 | 8 | 9 | @flask_app.route("/") 10 | def flask_main(): 11 | name = request.args.get("name", "World") 12 | return f"Hello, {escape(name)} from Flask!" 13 | 14 | 15 | app = FastAPI() 16 | 17 | 18 | @app.get("/v2") 19 | def read_main(): 20 | return {"message": "Hello World"} 21 | 22 | 23 | app.mount("/v1", WSGIMiddleware(flask_app)) 24 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiangolo/github-actions-sandbox/26a82c19ae60e0da1a7b3920fd1cdc26b795ae9c/pyproject.toml -------------------------------------------------------------------------------- /requirements-docs.txt: -------------------------------------------------------------------------------- 1 | # -e . 2 | mkdocs==1.4.3 3 | mkdocs-material==9.1.16 4 | mdx-include >=1.4.1,<2.0.0 5 | mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0 6 | typer-cli >=0.0.13,<0.0.14 7 | typer[all] >=0.6.1,<0.8.0 8 | pyyaml >=5.3.1,<7.0.0 9 | 10 | -------------------------------------------------------------------------------- /scripts/zip-docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | set -e 5 | 6 | cd ./site 7 | 8 | if [ -f docs.zip ]; then 9 | rm -rf docs.zip 10 | fi 11 | zip -r docs.zip ./ 12 | -------------------------------------------------------------------------------- /tests/test_something.py: -------------------------------------------------------------------------------- 1 | def test_someting(): 2 | assert True 3 | -------------------------------------------------------------------------------- /tests/test_utils.py: -------------------------------------------------------------------------------- 1 | from app.utils import get_name 2 | 3 | 4 | def test_get_name(): 5 | assert get_name() == "World" 6 | --------------------------------------------------------------------------------