Fastapi-async-safe-dependencies

Latest version: v0.1.1

Safety actively analyzes 681812 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.1.1

* Add dependency-injector integration. [7](https://github.com/uriyyo/fastapi-async-safe-dependencies/pull/7)

0.1.0

Basic `fastapi-async-safe-dependencies` implementation:

py
from typing import Union

from fastapi import Depends, FastAPI
from fastapi_async_safe import async_safe, init_app

app = FastAPI()
init_app(app) don't forget to initialize application

fake_items_db = [
{"item_name": "Foo"},
{"item_name": "Bar"},
{"item_name": "Baz"},
]

async_safe you just need to add this decorator to your dependency
class CommonQueryParams:
def __init__(
self,
q: str | None = None,
skip: int = 0,
limit: int = 100,
) -> None:
self.q = q
self.skip = skip
self.limit = limit


app.get("/items/")
async def read_items(commons: CommonQueryParams = Depends(CommonQueryParams)):
response = {}
if commons.q:
response.update({"q": commons.q})
items = fake_items_db[commons.skip: commons.skip + commons.limit]
response.update({"items": items})
return response

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.