Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jvllmr/fastapi-inferring-depends
A wrapper around FastAPI's Depends function that infers its return type from its input
https://github.com/jvllmr/fastapi-inferring-depends
Last synced: about 2 months ago
JSON representation
A wrapper around FastAPI's Depends function that infers its return type from its input
- Host: GitHub
- URL: https://github.com/jvllmr/fastapi-inferring-depends
- Owner: jvllmr
- License: mit
- Created: 2023-05-27T17:28:19.000Z (over 1 year ago)
- Default Branch: dev
- Last Pushed: 2024-10-21T21:43:15.000Z (2 months ago)
- Last Synced: 2024-10-23T03:34:08.018Z (2 months ago)
- Language: Python
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastAPI inferring Depends
[![PyPI version](https://badge.fury.io/py/fastapi-inferring-depends.svg)](https://badge.fury.io/py/fastapi-inferring-depends)
[![GitHub license](https://img.shields.io/github/license/jvllmr/fastapi-inferring-depends)](https://github.com/jvllmr/fastapi-inferring-depends/blob/master/LICENSE)
![PyPI - Downloads](https://img.shields.io/pypi/dd/fastapi-inferring-depends)
![Tests](https://github.com/jvllmr/fastapi-inferring-depends/actions/workflows/test.yml/badge.svg)A wrapper around FastAPI's Depends function that infers its return type from its input
## Example
```python
from fastapi_inferring_depends import Depends
from fastapi import FastAPIapp = FastAPI()
async def answer_to_everything_dependency():
return 42@app.get("/answer")
async def get_answer_to_everything(
answer_to_everything=Depends(answer_to_everything_dependency),
):
# type of answer_to_everything is 'int' (inferred from dependency)
return {"answer": answer_to_everything}
```For more examples, look at the test/example [file](https://github.com/jvllmr/fastapi-inferring-depends/blob/dev/test_example.py) for all supported inferences.