Commit Graph
4 Commits
Author SHA1 Message Date
Sebastián Ramírez cfb00b2119 ♻️ Refactor internals for test coverage and performance (#9691)
* ♻️ Tweak import of Annotated from typing_extensions, they are installed anyway

* ♻️ Refactor _compat to define functions for Pydantic v1 or v2 once instead of checking inside

* ✅ Add test for UploadFile for Pydantic v2

* ♻️ Refactor types and remove logic for impossible cases

* ✅ Add missing tests from test refactor for path params

* ✅ Add tests for new decimal encoder

* 💡 Add TODO comment for decimals in encoders

* 🔥 Remove unneeded dummy function

* 🔥 Remove section of code in field_annotation_is_scalar covered by sub-call to field_annotation_is_complex

* ♻️ Refactor and tweak variables and types in _compat

* ✅ Add tests for corner cases and compat with Pydantic v1 and v2

* ♻️ Refactor type annotations
2023-06-20 17:07:53 +02:00
Adrian Garcia BadaraccoandSebastián Ramírez ac9f56ea5e 🐛 Close FormData (uploaded files) after the request is done (#5465)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-11-03 13:06:52 +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
Sebastián Ramírez 0b9fe62a10 Add support for UploadFile class annotations (#63)
* ✨ Add support for UploadFile annotations

* 📝 Update File upload docs with FileUpload class

* ✅ Add tests for UploadFile support

* 📝 Update UploadFile docs
2019-03-03 20:52:37 +04:00