No project description provided
Project description
Wrap fastapi endpoints with RESTful API
Modern frontend frameworks encourage backend developers to follow RESTful API design. This package wraps fastapi endpoints with following structure:
{
"data": {
...
},
"code": 200,
"message": ""
}
and modify fastapi generated OpenAPI documentation to reflect the change.
Installation
pip install fastapi-restful-rsp
Usage
from fastapi import FastAPI
from fastapi_restful_rsp import restful_response
app = FastAPI()
@app.get("/foo/")
@restful_response
def foo()-> str:
return "Hello World"
Custom response structure
You can customize the response structure by passing data_name, code_key, message_name to restful_response decorator.
restful_response = create_restful_rsp_decorator(
data_name="data", code_name="my_code", message_name="message", param_dict={"status": (str, "success")}
)
@app.get("/foo/")
@restful_response
def foo()-> str:
return "Hello World"
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_restful_rsp-0.1.13.tar.gz.
File metadata
- Download URL: fastapi_restful_rsp-0.1.13.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
884b516ef6e8f2a291529f8643f61ffffb4fdcba6bbe481b769954b1375ab12d
|
|
| MD5 |
2f592fdf2f2c9358bbe9fd59ac8487dc
|
|
| BLAKE2b-256 |
de1877490a7aff8d0833c292956c420138001ae4602b0fa92e49ec03180cb816
|
File details
Details for the file fastapi_restful_rsp-0.1.13-py3-none-any.whl.
File metadata
- Download URL: fastapi_restful_rsp-0.1.13-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b398b7301fe351d8e420271730e94925b13537c80301706cbb4c4db234fd86d
|
|
| MD5 |
9805ddd3afbe56902639d67c4693c42a
|
|
| BLAKE2b-256 |
2b6af5ba710c82fca4bd4a845d8210b8f08b7170ea4730b5e3967af300125202
|