fastapi latest version

v0.62.0


fastapi v0.62.0 Release Notes

Release Date: 2020εΉ΄11月29ζ—₯ // about 5 years ago
  • πŸ”‹ Features

    • 🍱 ✨ Add support for shared/top-level parameters (dependencies, tags, etc). PR #2434 by @tiangolo.

    Up to now, for several options, the only way to apply them to a group of path operations was in include_router. That works well, but the call to app.include_router() or router.include_router() is normally done in another file.

    That means that, for example, to apply authentication to all the path operations in a router it would end up being done in a different file, instead of keeping related logic together.

    πŸ”§ Setting options in include_router still makes sense in some cases, for example, to override or increase configurations from a third party router included in an app. But in a router that is part of a bigger application, it would probably make more sense to add those settings when creating the APIRouter.

    In FastAPI

    This allows setting the (mostly new) parameters (additionally to the already existing parameters):

    • default_response_class: updated to handle defaults in APIRouter and include_router.
    • 🍱 dependencies: to include ✨ top-level dependencies ✨ that apply to the whole application. E.g. to add global authentication.
    • callbacks: OpenAPI callbacks that apply to all the path operations.
    • deprecated: to mark all the path operations as deprecated. 🀷
    • include_in_schema: to allow excluding all the path operations from the OpenAPI schema.
    • responses: OpenAPI responses that apply to all the path operations.

    For example:

    from fastapi import FastAPI, Dependsasync def some\_dependency(): returnapp = FastAPI(dependencies=[Depends(some\_dependency)])
    

    In APIRouter

    This allows setting the (mostly new) parameters (additionally to the already existing parameters):

    • default_response_class: updated to handle defaults in APIRouter and include_router. For example, it's not needed to set it explicitly when creating callbacks.
    • dependencies: to include ✨ router-level dependencies ✨ that apply to all the path operations in a router. Up to now, this was only possible with include_router.
    • callbacks: OpenAPI callbacks that apply to all the path operations in this router.
    • deprecated: to mark all the path operations in a router as deprecated.
    • include_in_schema: to allow excluding all the path operations in a router from the OpenAPI schema.
    • responses: OpenAPI responses that apply to all the path operations in a router.
    • prefix: to set the path prefix for a router. Up to now, this was only possible when calling include_router.
    • tags: OpenAPI tags to apply to all the path operations in this router.

    For example:

    from fastapi import APIRouter, Dependsasync def some\_dependency(): returnrouter = APIRouter(prefix="/users", dependencies=[Depends(some\_dependency)])
    

    In include_router

    πŸ‘ Most of these settings are now supported in APIRouter, which normally lives closer to the related code, so it is recommended to use APIRouter when possible.

    But include_router is still useful to, for example, adding options (like dependencies, prefix, and tags) when including a third party router, or a generic router that is shared between several projects.

    This PR allows setting the (mostly new) parameters (additionally to the already existing parameters):

    • default_response_class: updated to handle defaults in APIRouter and FastAPI.
    • deprecated: to mark all the path operations in a router as deprecated in OpenAPI.
    • include_in_schema: to allow disabling all the path operations from showing in the OpenAPI schema.
    • callbacks: OpenAPI callbacks that apply to all the path operations in this router.

    Note: all the previous parameters are still there, so it's still possible to declare dependencies in include_router.

    πŸ’₯ Breaking Changes

    • PR #2434 includes several improvements that shouldn't affect normal use cases, but could affect in advanced scenarios:
      • If you are testing the generated OpenAPI (you shouldn't, FastAPI already tests it extensively for you): the order for tags in include_router and path operations was updated for consistency, but it's a simple order change.
      • If you have advanced custom logic to access each route's route.response_class, or the router.default_response_class, or the app.default_response_class: the default value for response_class in APIRoute and for default_response_class in APIRouter and FastAPI is now a DefaultPlaceholder used internally to handle and solve default values and overrides. The actual response class inside the DefaultPlaceholder is available at route.response_class.value.

    πŸ“„ Docs

    ⚑️ PR #2434 (above) includes new or updated docs:

    - Tutorial - Dependencies - Global Dependencies.

    🍱 πŸ“ Add FastAPI monitoring blog post to External Links. PR #2324 by @louisguitton.

    🍱 ✏️ Fix typo in Deta tutorial. PR #2320 by @tiangolo.

    🍱 ✨ Add Discord chat. PR #2322 by @tiangolo.

    🍱 πŸ“ Fix image links for sponsors. PR #2304 by @tiangolo.

    🌐 Translations

    • 🌐 Add Japanese translation for Advanced - Custom Response. PR #2193 by @Attsun1031.
    • 🌐 Add Chinese translation for Benchmarks. PR #2119 by @spaceack.
    • 🌐 Add Chinese translation for Tutorial - Body - Nested Models. PR #1609 by @waynerv.
    • 🌐 Add Chinese translation for Advanced - Custom Response. PR #1459 by @RunningIkkyu.
    • 🌐 Add Chinese translation for Advanced - Return a Response Directly. PR #1452 by @RunningIkkyu.
    • 🌐 Add Chinese translation for Advanced - Additional Status Codes. PR #1451 by @RunningIkkyu.
    • 🌐 Add Chinese translation for Advanced - Path Operation Advanced Configuration. PR #1447 by @RunningIkkyu.
    • 🌐 Add Chinese translation for Advanced User Guide - Intro. PR #1445 by @RunningIkkyu.

    Internal

    • ⚑️ πŸ”§ Update TestDriven link to course in sponsors section. PR #2435 by @tiangolo.
    • ⚑️ 🍱 Update sponsor logos. PR #2418 by @tiangolo.
    • 🍱 πŸ’š Fix disabling install of Material for MkDocs Insiders in forks, strike 1 ⚾. PR #2340 by @tiangolo.
    • 🍱 πŸ› Fix disabling Material for MkDocs Insiders install in forks. PR #2339 by @tiangolo.
    • 🍱 ✨ Add silver sponsor WeTransfer. PR #2338 by @tiangolo.
    • 🍱 ✨ Set up and enable Material for MkDocs Insiders for the docs. PR #2325 by @tiangolo.

Previous changes from v0.61.2

  • πŸ›  Fixes

    • 🍱 πŸ“Œ Relax Swagger UI version pin. PR #2089 by @jmriebold.
    • 🍱 πŸ› Fix bug overriding custom HTTPException and RequestValidationError from exception_handlers. PR #1924 by @uriyyo.
    • 🍱 ✏️ Fix typo on dependencies utils and cleanup unused variable. PR #1912 by @Kludex.

    πŸ“„ Docs

    • 🍱 ✏️ Fix typo in Tutorial - Path Parameters. PR #2231 by @mariacamilagl.
    • 🍱 ✏ Fix a stylistic error in docs. PR #2206 by @ddobrinskiy.
    • 🍱 ✏ Fix capitalizaiton typo in docs. PR #2204 by @imba-tjd.
    • 🍱 ✏ Fix typo in docs. PR #2179 by @ammarasmro.
    • ⚑️ πŸ“ Update/fix links in docs to use HTTPS. PR #2165 by @imba-tjd.
    • 🍱 ✏ Fix typos and add rewording in docs. PR #2159 by @nukopy.
    • 🍱 πŸ“ Fix code consistency in examples for Tutorial - User Guide - Path Parameters. PR #2158 by @nukopy.
    • 🍱 πŸ“ Fix renamed parameter content_type typo. PR #2135 by @TeoZosa.
    • 🍱 ✏ Fix minor typos in docs. PR #2122 by @TeoZosa.
    • 🍱 ✏ Fix typos in docs and source examples. PR #2102 by @AdrianDeAnda.
    • 🍱 ✏ Fix incorrect Celery URLs in docs. PR #2100 by @CircleOnCircles.
    • 🍱 πŸ“ Simplify intro to Python Types, all currently supported Python versions include type hints πŸŽ‰. PR #2085 by @ninjaaron.
    • 🍱 πŸ“ Fix example code with sets in Tutorial - Body - Nested Models 3. PR #2054 by @hitrust.
    • 🍱 πŸ“ Fix example code with sets in Tutorial - Body - Nested Models 2. PR #2053 by @hitrust.
    • 🍱 πŸ“ Fix example code with sets in Tutorial - Body - Nested Models. PR #2052 by @hitrust.
    • 🍱 ✏ Fix typo in Benchmarks. PR #1995 by @AlejoAsd.
    • πŸ“ Add note in CORS tutorial about allow_origins with ["*"] and allow_credentials. PR #1895 by @dsmurrell.
    • πŸš€ πŸ“ Add deployment to Deta, the first gold sponsor πŸŽ‰. PR #2303 by @tiangolo.
    • πŸ‘₯ Update FastAPI People. PR #2282 by @github-actions[bot].
    • 🍱 ✏️ Fix uppercase in Tutorial - Query parameters. PR #2245 by @mariacamilagl.
    • 🍱 πŸ“ Add articles to External Links. PR #2247 by @tiangolo.
    • 🍱 ✏ Fix typo in Spanish tutorial index. PR #2020 by @aviloncho.

    🌐 Translations

    • 🌐 Add Japanese translation for Advanced Tutorial - Response Directly. PR #2191 by @Attsun1031.
    • πŸ”’ πŸ“ Add Japanese translation for Tutorial - Security - First Steps. PR #2153 by @komtaki.
    • 🌐 Add Japanese translation for Tutorial - Query Parameters and String Validations. PR #1901 by @SwftAlpc.
    • 🌐 Add Portuguese translation for External Links. PR #1443 by @Serrones.
    • 🌐 Add Japanese translation for Tutorial - CORS. PR #2125 by @tokusumi.
    • 🌐 Add Japanese translation for Contributing. PR #2067 by @komtaki.
    • 🌐 Add Japanese translation for Project Generation. PR #2050 by @tokusumi.
    • 🌐 Add Japanese translation for Alternatives. PR #2043 by @Attsun1031.
    • 🌐 Add Japanese translation for History Design and Future. PR #2002 by @komtaki.
    • 🌐 Add Japanese translation for Benchmarks. PR #1992 by @komtaki.
    • 🌐 Add Japanese translation for Tutorial - Header Parameters. PR #1935 by @SwftAlpc.
    • 🌐 Add Portuguese translation for Tutorial - First Steps. PR #1861 by @jessicapaz.
    • 🌐 Add Portuguese translation for Python Types. PR #1796 by @izaguerreiro.
    • 🌐 Add Japanese translation for Help FastAPI. PR #1692 by @tokusumi.
    • 🌐 Add Japanese translation for Tutorial - Body. PR #1683 by @tokusumi.
    • 🌐 Add Japanese translation for Tutorial - Query Params. PR #1674 by @tokusumi.
    • 🌐 Add Japanese translation for tutorial/path-params.md. PR #1671 by @tokusumi.
    • 🌐 Add Japanese translation for tutorial/first-steps.md. PR #1658 by @tokusumi.
    • 🌐 Add Japanese translation for tutorial/index.md. PR #1656 by @tokusumi.
    • 🌐 Add translation to Portuguese for Project Generation. PR #1602 by @Serrones.
    • 🌐 Add Japanese translation for Features. PR #1625 by @tokusumi.
    • 🌐 Initialize new language Korean for translations. PR #2018 by @hard-coders.
    • 🌐 Add Portuguese translation of Deployment. PR #1374 by @Serrones.

    Internal

    • ⬆️ πŸ”₯ Cleanup after upgrade for Docs Previews GitHub Action. PR #2248 by @tiangolo.
    • πŸ‘· πŸ› Fix CI docs preview, unzip docs. PR #2246 by @tiangolo.
    • πŸš€ ✨ Add instant docs deploy previews for PRs from forks. PR #2244 by @tiangolo.
    • πŸ— ⚑️ Build docs for languages in parallel in subprocesses to speed up CI. PR #2242 by @tiangolo.
    • 🌐 πŸ› Fix docs order generation for partial translations. PR #2238 by @tiangolo.
    • πŸ‘₯ Update FastAPI People. PR #2202 by @github-actions[bot].
    • ⚑️ ♻️ Update FastAPI People GitHub Action to send the PR as github-actions. PR #2201 by @tiangolo.
    • ⚑️ πŸ”§ Update FastAPI People GitHub Action config, run monthly. PR #2199 by @tiangolo.
    • 🐳 πŸ› Fix FastAPI People GitHub Action Docker dependency, strike 1 ⚾. PR #2198 by @tiangolo.
    • 🐳 πŸ› Fix FastAPI People GitHub Action Docker dependencies. PR #2197 by @tiangolo.
    • 🍱 πŸ› Fix FastAPI People GitHub Action when there's nothing to change. PR #2196 by @tiangolo.
    • πŸ‘₯ Add new section FastAPI People. PR #2195 by @tiangolo.
    • ⬆️ ⬆️ Upgrade GitHub Action Latest Changes. PR #2190 by @tiangolo.
    • ⬆️ ⬆️ Upgrade GitHub Action Label Approved. PR #2189 by @tiangolo.
    • ⚑️ πŸ”§ Update GitHub Action Label Approved, run at 12:00. PR #2185 by @tiangolo.
    • ⬆️ πŸ‘· Upgrade GitHub Action Latest Changes. PR #2184 by @tiangolo.
    • 🍱 πŸ‘· Set GitHub Action Label Approved to run daily, not every minute. PR #2163 by @tiangolo.
    • 🍱 πŸ”₯ Remove pr-approvals GitHub Action as it's not compatible with forks. Use the new one. PR #2162 by @tiangolo.
    • 🍱 πŸ‘· Add GitHub Action Latest Changes. PR #2160.
    • 🍱 πŸ‘· Add GitHub Action Label Approved. PR #2161.
Awesome Python is part of the LibHunt network. Terms. Privacy Policy.

(CC)
BY-SA
We recommend Spin The Wheel Of Names for a cryptographically secure random name picker.

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /