Django jsonrpc implementation
Project description
Django jsonrpc implementation
Advantages
- Complete support jsonrpc 2.0 (Request, Notificatin, Batch)
- Auto generation openrpc.json 1.3.2 version
- Auto generation OpenRPC documentation (like swagger)
- Async support
Create methods
We provide several methods creating methods.
- Using
method_prefix - Using
jsonrpc_methoddecorator - Rename existing func to new name
from jsonrpc_framework import BaseController
from jsonrpc_framework.controller.decor import jsonrpc_method
class EchoController(BaseController):
def method_echo_hello(self, name: str) -> str:
return f"hello {name}"
@jsonrpc_method
def echo_goodbye(self, name: str) -> str:
return f"goodbye {name}"
@jsonrpc_method("echo_see_you")
def wrong_name(self, name) -> str:
return "See you fron echo_see_you method"
Adding several controllers to one controller
from jsonrpc_framework import RouteController
class PrintController(BaseController):
async def method_print_hello(self, name) -> None:
print(f"hello {name}")
@jsonrpc_method
async def print_goodbye(self, name) -> None:
print(f"goodbye {name}")
route = RouteController(
'jsonrpc',
controllers=[
PrintController,
EchoController,
]
)
Generation openrpc.json and OpenRpc documentation
from jsonrpc_framework.controller.openrpc.collectors import OpenRpcCollector
collector = OpenRpcCollector(
PrintController,
EchoController,
title='My mini API'
)
urlpatterns = [
path('echorpc', EchoController,as_view),
path('jsonrpc', route.as_view()),
path('openrpc.json', OpenRpcJsonView.as_view(collector=collector)),
path('docs', OpenRpcDocView.as_view()),
]
Openrpc.json example
Openrpc doc example
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 django_jsonrpc_framework-0.1.0.tar.gz.
File metadata
- Download URL: django_jsonrpc_framework-0.1.0.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11a4cbb06b9838dcbb20c97bcc98c22a731f571b1ae6e94495d78b81f877abca
|
|
| MD5 |
4c05fa00b212940ab2ca21e2c86a8f5f
|
|
| BLAKE2b-256 |
6b02b4c0aa6d1e5fe7fdf873c20a35f5a3fc841c122b1584714f4e6641a8c66a
|
File details
Details for the file django_jsonrpc_framework-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_jsonrpc_framework-0.1.0-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b663d57fb0ad2394871686f547a565fd8b1a8f5b50d32524043f2455fde44e27
|
|
| MD5 |
af9c56fecc54388fdc31583a1127d1a4
|
|
| BLAKE2b-256 |
fd535e99d41c0e21fdd304b9e4a843fe8ae8fbc94569c15dca2a7f669f8130a1
|