FastAPI Request Helper
Project description
FastAPI Request helper
How to use
- Set a variable
# user_service.py
from fastapi import FastAPI
from fastapi_global_variable import GlobalVariable
app = FastAPI(title="Application")
GlobalVariable.set('app', app)
- Use variable
from fastapi_global_variable import GlobalVariable
print(GlobalVariable.get_or_fail('app'))
print(GlobalVariable.get('app'))
- Decorators
FastAPI Request Helper provides lots of helpful decorators:
- Swagger docs decorators: @controller, @tag, @get, @post, @put, @delete, @patch
- Rate limit request: @rate_limit
- FastAPI response model: @response
- FastAPI guards: @guard, @gurads
- FastAPI response status: @status
- FastAPI API info details: @description, @summary, @name
- FastAPI API response status: @status_no_content, @status_ok, @status_created
- Hide API: @hidden_when(condition: boolean)
Fast API Helper also provides Pagination Query params helper: PaginationParams
# Sample
from fastapi_request_helper import (
controller,
post,
rate_limit,
response,
status_created,
status_no_content,
status_ok,
tag,
)
@controller('authentications')
@tag('Authentication')
class AuthenticationController:
def __init__(self, auth_service: AuthenticationService = Depends()):
self.auth_service = auth_service
@post('create-email-otp')
@status_no_content()
async def create_email_otp(self):
pass
How to test in testpypi
- Increase the version in
pyproject.toml
- Run command
$ ./build_and_test.sh
How to publish new version
- Increase the version in
pyproject.toml
- Run command
$ ./build_and_publish.sh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for fastapi_request_helper-0.0.11.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a3897c91d0b9870475fa07b413bde30bd2768e9fc1d65d6ec0c6ce8bf3c0564 |
|
MD5 | 358f4f4dbfce2ab5b403a5f4b762086f |
|
BLAKE2b-256 | 5f473bcefd6e25e64a1447253127050e04573d967083514d3c9fbd11c047a48f |
Close
Hashes for fastapi_request_helper-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | faf53e8df5a6a79ae73bf25fec55f179a4ff222bb7d713e0524e63bf85b286a5 |
|
MD5 | e687b265ec4ba0ab7dcc2a109daf4b72 |
|
BLAKE2b-256 | ca33dd2490b1a5898fe18fbe7df288cef958cfa92a1f4bd1a58051b57f3bf134 |