67 Commits

Author SHA1 Message Date
Sebastián Ramírez d566c6cbca ⬆️ Upgrade Starlette version to 0.24.0 and refactor internals for compatibility (#5985) 2023-02-10 15:13:04 +01:00
Marcelo Trylesinski 9293795e99 ⬆️ Bump Starlette from 0.22.0 to 0.23.0 (#5739)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-02-08 11:23:07 +01:00
Yurii Karabas d0573f5713 ✨ Add support for function return type annotations to declare the response_model (#1436)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-01-07 17:45:48 +04:00
Marcelo Trylesinski adcf03f2bc ⬆ Upgrade version required of Starlette from 0.19.1 to 0.20.4 (#4820)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-09-15 14:32:05 +02:00
Junghoon Yang 52b5b08910 ♻ Internal small refactor, move operation_id parameter position in delete method for consistency with the code (#4474)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-09-02 13:36:00 +00:00
Sebastián Ramírez e7b1b96a54 🎨 Update type annotations for response_model, allow things like Union[str, None] (#5294) 2022-08-22 18:49:03 +00:00
Marcelo Trylesinski f396912043 ⬆ Upgrade Starlette from 0.19.0 to 0.19.1 (#4819)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-05-10 03:22:26 +00:00
Sebastián Ramírez 8a0d4c79c1 ✨ Add support for custom generate_unique_id_function and docs for generating clients (#4650) 2022-03-04 23:02:18 +01:00
Sebastián Ramírez 9d56a3cb59 ✨ Update internal AsyncExitStack to fix context for dependencies with yield (#4575) 2022-02-17 13:40:12 +01:00
Sebastián Ramírez 569afb4378 ✨ Add support for tags with Enums (#4468) 2022-01-23 18:43:04 +01:00
John Riebold a85aa125d2 ✨ Enable configuring Swagger UI parameters (#2568)
Co-authored-by: Artem Ivanov <artem@worklife.io>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-01-16 20:26:24 +01:00
Edouard Lavery-Plante 836bb97a2d ✨ Add support for extensions and updates to the OpenAPI schema in path operations (#1922)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2021-07-29 22:01:13 +02:00
dkreeft 6f45f43709 ✨ Add additonal OpenAPI metadata parameters to FastAPI class, shown on the automatic API docs UI (#1812)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: dkreeft <dkreeft@xccelerated.io>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2021-07-29 17:10:22 +02:00
Sebastián Ramírez dc5a966548 ✨ Allow setting the response_class to RedirectResponse and returning the URL from the function (#3457) 2021-07-03 21:51:28 +02:00
Sebastián Ramírez fdb6c9ccc5 ✨ Improve type annotations, add support for mypy --strict, internally and for external packages (#2547) 2020-12-20 19:50:00 +01:00
Sebastián Ramírez 313bbe802f ✨ Add support for shared/top-level parameters (dependencies, tags, etc) (#2434)
* ✨ Add Default and DefaultPlaceholder data structures

to handle defaults and overrides

* ✨ Add utils to get values by priority handling DefaultPlaceholders

* ✨ Add support for top-level parameters in FastAPI, APIRouter, include_router

including: prefix, tags, dependencies, deprecated, include_in_schema, responses, default_response_class, callbacks

* ♻️ Update openapi utils to handle DefaultPlaceholder for response_class

* 📝 Update bigger-application example code to use top-level params

and showcase them in APIRouter, FastAPI, include_router

* 📝 Update docs for Bigger Applications, include diagrams, top-level params

* 🔥 Simplify code and docs for callbacks as default_response_class is no longer required

* 📝 Add docs for top-level dependencies, in FastAPI()

* 📝 Add docs reference to top-level dependencies in docs for decorator

* ✅ Update/increase tests for Bigger Applications including shared parameters

* ✅ Add tests for top-level dependencies in FastAPI()

* ✅ Add tests for internal DefaultPlaceholder

* ✅ Update/increase tests for callbacks with top-level parameters

* ✅ Add LOTS of tests covering branches and cases for shared parameters

in top-level FastAPI, path operations, include_router, APIRouter, its path operations, nested include_router, nested APIRouter, and its path operations

* 🎨 Format/reorder parameters for consistency in FastAPI, APIRouter, include_router
2020-11-29 18:32:18 +01:00
Yurii Karabas 4ce18167e7 🐛 Fix bug overriding custom HTTPException and RequestValidationError from exception_handlers (#1924) 2020-11-05 22:21:40 +01:00
Sebastián Ramírez e1758d107e ⬆ Require Pydantic > 1.0 (#1862)
* 🔥 Remove support for Pydantic < 1.0

* 🔥 Remove deprecated skip_defaults from jsonable_encoder and set default for exclude to None, as in Pydantic

* ♻️ Set default of response_model_exclude=None as in Pydantic

* ⬆️ Require Pydantic >=1.0.0 in requirements
2020-08-09 22:17:08 +02:00
Yurii Karabas 55b9faeb48 ♻ Simplify code syntax in several places (#1753)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-08-03 15:16:51 +02:00
Nima Mashhadi M. Reza 3223de5598 🎨 Add typing.Optional to variables that accept None as value (#1731)
Co-authored-by: nimashadix <nimashadix@pop-os.localdomain>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-08-03 14:29:07 +02:00
Bar Harel f1c5330b65 🐛 Fix app.extra type annotation (#1659)
Co-authored-by: bar.harel <bar.harel@biocatch.com>
2020-08-03 08:43:04 +02:00
Rupsi Kaushik 70a51b3aff ✨ Auto-generate OpenAPI servers from root_path (#1596)
* root_path included in servers object instead of path prefix

* ♻️ Refactor implementation of auto-including root_path in OpenAPI servers

* 📝 Update docs and examples for Behind a Proxy, including servers

* 📝 Update Extending OpenAPI as openapi_prefix is no longer needed

* ✅ Add extra tests for root_path in servers and root_path_in_servers=False

* 🍱 Update security docs images with relative token URL

* 📝 Update security docs with relative token URL

* 📝 Update example sources with relative token URLs

* ✅ Update tests with relative tokens

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-07-10 19:28:18 +02:00
Dmytro Petruk 39766d0f96 🐛 Fix link in warning logs (#1611)
Co-authored-by: Dmytro Petruk <petruk@ebu.ch>
2020-06-28 23:37:42 +02:00
mikaello b591de2ace ✨ Add support for OpenAPI servers metadata (#1547)
* feat: add servers option for OpenAPI

Closes #872

* ✨ Use dicts for OpenAPI servers

* ♻️ Update OpenAPI Server model to support relative URLs

* ✅ Add tests for OpenAPI servers

* ♻️ Re-order parameter location of servers for OpenAPI

* 🎨 Format code

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-06-14 15:38:29 +02:00
Thomas Maschler a071ddf3cd ✨ Add support for tag metadata in OpenAPI (#1348)
* Allow to add OpenAPI tag descriptions

* fix type hint

* fix type hint 2

* refactor test to assure 100% coverage

* 📝 Update tags metadata example

* 📝 Update docs for tags metadata

* ✅ Move tags metadata test to tutorial subdir

* 🎨 Update format in applications

* 🍱 Update docs UI image based on new example

* 🎨 Apply formatting after solving conflicts

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-06-13 13:58:06 +02:00
Ingmar Steen 2f478eeca6 ✨ Add support for ASGI root_path for openapi docs (#1199)
* Use ASGI root_path when it is provided and openapi_prefix is empty.

* Strip trailing slashes from root_path.

* Please mypy.

* Fix extending openapi test.

* 📝 Add docs and tutorial for using root_path behind a proxy

* ♻️ Refactor application root_path logic, use root_path, deprecate openapi_prefix

* ✅ Add tests for Behind a Proxy with root_path

* ♻️ Refactor test

* 📝 Update/add docs for Sub-applications and Behind a Proxy

* 📝 Update Extending OpenAPI with openapi_prefix parameter

* ✅ Add test for deprecated openapi_prefix

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-06-11 23:53:19 +02:00
Sebastián Ramírez 409264960e ✨ Allow disabling docs UIs by disabling OpenAPI (#1421)
* ✨ Allow disabling docs UIs by disabling openapi_url

* 📝 Add docs for disabling OpenAPI and docs in prod or other environments

* ✅ Add tests for disabling OpenAPI and docs
2020-05-16 17:45:12 +02:00
voegtlel 3397d4d69a ✨ Implement response_model_exclude_defaults and response_model_exclude_none (#1166)
* Implemented response_model_exclude_defaults and response_model_exclude_none to be compatible pydantic options.

* 🚚 Rename and invert include_none to exclude_none to keep in sync with Pydantic

Co-authored-by: Lukas Voegtle <lukas.voegtle@sick.de>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-04-05 15:04:46 +02:00
Sebastián Ramírez 4e8080f290 📌 Upgrade Starlette version (#1057) 2020-02-29 21:28:23 +01:00
Sebastián Ramírez b307d38897 ♻️ Update default API title from "Fast API" to "FastAPI" for consistency (#890) 2020-01-18 19:07:42 +01:00
Ben Dayan 73260971b5 ✨ Add support for OpenAPI Callbacks (#722) 2019-12-11 17:58:00 +01:00
dmontagu ab2b86fe2c ✨ Add support for Pydantic v1 and above 🎉 (#646)
* Make compatible with pydantic v1

* Remove unused import

* Remove unused ignores

* Update pydantic version

* Fix minor formatting issue

* ⏪ Revert removing iterate_in_threadpool

* ✨ Add backwards compatibility with Pydantic 0.32.2

with deprecation warnings

* ✅ Update tests to not break when using Pydantic < 1.0.0

* 📝 Update docs for Pydantic version 1.0.0

* 📌 Update Pydantic range version to support from 0.32.2

* 🎨 Format test imports

* ✨ Add support for Pydantic < 1.2 for populate_validators

* ✨ Add backwards compatibility for Pydantic < 1.2.0 with required fields

* 📌 Relax requirement for Pydantic to < 2.0.0 🎉 🚀

* 💚 Update pragma coverage for older Pydantic versions
2019-11-27 20:32:02 +01:00
Sebastián Ramírez 3f9f4a0f8f ✨ Add dependencies with yield (used as context managers) (#595)
* ➕ Add development/testing dependencies for Python 3.6

* ✨ Add concurrency submodule with contextmanager_in_threadpool

* ✨ Add AsyncExitStack to ASGI scope in FastAPI app call

* ✨ Use async stack for contextmanager-able dependencies

including running in threadpool sync dependencies

* ✅ Add tests for contextmanager dependencies

including internal raise checks when exceptions should be handled and when not

* ✅ Add test for fake asynccontextmanager raiser

* 🐛 Fix mypy errors and coverage

* 🔇 Remove development logs and prints

* ✅ Add tests for sub-contextmanagers, background tasks, and sync functions

* 🐛 Fix mypy errors for Python 3.7

* 💬 Fix error texts for clarity

* 📝 Add docs for dependencies with yield

* ✨ Update SQL with SQLAlchemy tutorial to use dependencies with yield

and add an alternative with a middleware (from the old tutorial)

* ✅ Update SQL tests to remove DB file during the same tests

* ✅ Add tests for example with middleware

as a copy from the tests with dependencies with yield, removing the DB in the tests

* ✏️ Fix typos with suggestions from code review

Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com>
2019-10-09 13:01:58 -05:00
Sebastián Ramírez 6c7da43e51 ⬆️ Upgrade Starlette to 0.12.9 and add State (#593) 2019-10-05 13:17:15 -05:00
Zamir Amir 8505b716af ✨ Add support for setting Swagger UI initOAuth configs (clientId, appName) (#499) 2019-10-03 18:41:04 -05:00
toppk f803c77515 ✨ Add support for specifying a default_response_class (#467) 2019-09-29 16:47:35 -05:00
dmontagu fc7d123347 ⬆️ Upgrade support to Pydantic version 0.32.2 (breaking change) (#463) 2019-08-30 19:30:03 -05:00
Sebastián Ramírez dcc1e1bcf8 ♻️ Refine internal type declarations and logic around them (#338) 2019-06-27 20:51:17 +02:00
Sebastián Ramírez 09cd7c47a1 ✨ Implement dependency overrides for testing (#291)
* ✨ Implement dependency overrides for testing

* ✅ Add docs source tests and extra tests for dependency overrides

* 📝 Add docs for testing dependencies with overrides
2019-06-05 15:43:18 +04:00
Sebastián Ramírez 62af6e0eeb ✨ Separate Pydantic's ValidationError handler and improve docs for error handling (#273)
* ✨ Implement separated ValidationError handlers and custom exceptions

* ✅ Add tutorial source examples and tests

* 📝 Add docs for custom exception handlers

* 📝 Update docs section titles
2019-05-29 16:27:55 +04:00
Sebastián Ramírez a49d45eaa9 🐛 Fix response_model type to allow List[Model] (#266) 2019-05-27 21:56:20 +04:00
Sebastián Ramírez 7b63bc5551 ✨ Add include, exclude, and by_alias to path operation methods (#264)
* ✨ Make jsonable_encoder's include and exclude receive sequences

* ✨ Add include, exclude, and by_alias to app and router

* ✨ Add and update tutorial code with new parameters

* 📝 Update docs for new parameters and add docs for updating data

* ✅ Add tests for consistency in path operation methods

* ✅ Add tests for new parameters and update tests
2019-05-27 16:08:13 +04:00
William Hayes d8716f94ae ✨ Add skip_defaults support for path operations (for #242) (#248) 2019-05-25 19:35:57 +04:00
James Kaplan b087246f26 ✨ Add support for WebSockets with dependencies, params, etc #166 (#178) 2019-05-24 20:41:41 +04:00
Steinthor Palsson 325edd5f00 ✨ Add swagger UI OAuth2 redirect page for implicit/code auth flows in API docs (#198) 2019-05-21 22:39:58 +04:00
Trim21 01b43e6e25 ⚡ Make Swagger UI, ReDoc and OpenAPI handlers be coroutines to improve performance (#241) 2019-05-20 18:34:33 +04:00
Sebastián Ramírez e92b43b5c8 ✨ Add parameter dependencies to path operation decorators and include_router (#235)
* ✨ Implement dependencies in decorator and .include_router

* 📝 Add docs for parameter dependencies

* ✅ Add tests for dependencies parameter

* 🔥 Remove debugging prints in tests

* 📝 Update release notes
2019-05-16 18:07:00 +04:00
Sebastián Ramírez 192ebba2a2 ♻️ Rename parameter content_type to response_class (#183) 2019-04-26 13:11:16 +04:00
Sebastián Ramírez 2bd775988f ✨ Add/refactor addditional responses, tests, docs 2019-04-05 13:54:00 +04:00
Mohammed 65568065e0 Remove extra code. 2019-03-23 00:47:32 +03:00