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
- Setup file .pypirc
$ cd ~/
$ vim .pypirc
Copy to file .pypirc
[pypi]
username=****
password=****
[testpypi]
username=__token__
password=*****
[distutils]
index-servers =
pypi
testpypi
gitlab
[gitlab]
repository = https://gitlab.com/api/v4/projects/50838104/packages/pypi
username = gitlab+deploy-token-3497403
password = ****
- Increase the version in
pyproject.toml
- Run command
$ ./build_and_test.sh
- install package
$ pip install --no-cache-dir --upgrade -i https://test.pypi.org/simple/ fastapi-request-helper==x.y.z --no-dependencies
$ pip install -i https://test.pypi.org/simple/ fastapi-request-helper==x.y.z
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.15.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e4ddcb10ad7329a9496fd0b0a5e47fb434dbe2a001631f550ac82a956dca7d9 |
|
MD5 | 046ca864bff134e45850bc7e130b4efa |
|
BLAKE2b-256 | 2e4fd195730ce2e61a9f19892cb2939dd8a635b8af3af49552fb4c511983caae |
Close
Hashes for fastapi_request_helper-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26bf30285b76c68e66fd9f9e376d804c0ba8d2fea8a57d73ff359d1abd2c7ebb |
|
MD5 | 3db2d70f212a9850b8a7b47e0537dd60 |
|
BLAKE2b-256 | 44fad4a0c093eed6d07a00d6c4d401f8919f6b16e7f8e8c502ab55f6904d37b2 |