Description
JSON-RPC server based on fastapi:
Installation
pip install fastapi-jsonrpc
Usage
pip install uvicorn
import fastapi_jsonrpc as jsonrpc
from fastapi_jsonrpc import Param
from pydantic import BaseModel
app = jsonrpc.API()
api_v1 = jsonrpc.Entrypoint('/api/v1/jsonrpc')
class MyError(jsonrpc.BaseError):
CODE = 5000
MESSAGE = 'My error'
@jsonrpc.optional
class DataModel(BaseModel):
details: str
@api_v1.method(errors=[MyError])
def echo(
data: str = Param(..., example='123'),
) -> str:
if data == 'error':
raise MyError(data={'details': 'error'})
elif data == 'error-no-data':
raise MyError()
else:
return data
app.bind_entrypoint(api_v1)
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, port=5000, debug=True, access_log=False)
Go to:
Development
Install poetry
Install dependencies
poetry updateInstall dephell
pip install dephellRegenerate setup.py
dephell deps convert
Changelog
[0.1.10] Validate error responses
[0.1.9] Fix usage example (forgotten import of pydantic)
[0.1.8] Push sources to github
[0.1.7]
Follow JSON-RPC specification in special cases:
Use aiojobs.Scheduler for batch requests
[0.1.6] Ability to write DataModel class in BaseError class scope
[0.1.5] Add error usage example to README.rst
[0.1.4] Add description to README.rst
[0.1.3] Fix README.rst
[0.1.2] Add usage example to README.rst
[0.1.1] README.rst
[0.1.0] Initial commit
Release files for fastapi-jsonrpc 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi-jsonrpc-0.1.10.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_jsonrpc-0.1.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.7 kB
Release files / fastapi-jsonrpc-0.1.10.tar.gz
| Download URL | fastapi-jsonrpc-0.1.10.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72da9c518644fb28c85987f88c20a3f53ab2b20d55c6a2e0b3354403aa594a6e
|
|
BLAKE2b-256 checksum How to use checksums |
da149a4e2893ed9ceb1056d2f68a615de72301c4ed8d2fa30ec70ab17dd7627c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.17 CPython/3.7.3 Darwin/18.7.0
|
Release files / fastapi_jsonrpc-0.1.10-py3-none-any.whl
| Download URL | fastapi_jsonrpc-0.1.10-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5718ed328a9c8d4c54b9f943971c0e6f5664c39ad852de8d021007fb95f4c3fa
|
|
BLAKE2b-256 checksum How to use checksums |
88e5eec444f04c7c8e6b9d46bbffccb0f9df293fd70b438215930d53877d843f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.17 CPython/3.7.3 Darwin/18.7.0
|