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.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 716d6472dfa80d5ec9f33b0c156c9a4859f8ce56778ec8cc8c23d9f856d0ffe7 |
|
MD5 | b1c4c56981101a6162a019d1f85b8650 |
|
BLAKE2b-256 | 4f35e52bb24136c007865202eefc2b0ab2eff34735ad56c5ec56d00dd320b777 |
Close
Hashes for fastapi_request_helper-0.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a085a89c61c9496a8a1ac8b76783f9554f052f1e275701b546e6893ee72dadc |
|
MD5 | 0df618995682e9daaa0f8f4fe1a54cf5 |
|
BLAKE2b-256 | e5915cf42b32e864b695e66420664d042ff50c756ab5c695db9feb9cf110ee39 |