Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_middleware_jsonrpc Discord

Swarmauri Middleware JsonRpc

Middleware that performs simple validation of JSON-RPC requests.

Features

  • Validates JSON request bodies for JSON-RPC payloads when the Content-Type header starts with application/json.
  • Returns 400 Bad Request with a plain-text error when the body contains invalid JSON.
  • Ensures JSON object payloads define a jsonrpc field, responding with 400 Bad Request if it is missing.

Installation

Install the middleware with your preferred Python packaging workflow:

pip install swarmauri_middleware_jsonrpc
poetry add swarmauri_middleware_jsonrpc
uv add swarmauri_middleware_jsonrpc
uv pip install swarmauri_middleware_jsonrpc

Usage

from fastapi import FastAPI
from swarmauri_middleware_jsonrpc import JsonRpcMiddleware

app = FastAPI()
app.middleware("http")(JsonRpcMiddleware().dispatch)

The middleware integrates with FastAPI's app.middleware("http") hook and is compatible with the MiddlewareBase ecosystem. Once registered, every incoming JSON request is validated before reaching subsequent middleware or route handlers.

Request Validation

  • Requests without an application/json content type bypass the middleware.
  • Malformed JSON bodies are rejected with a 400 response containing the message Invalid JSON.
  • JSON objects missing the jsonrpc key are rejected with a 400 response and the message Missing jsonrpc field.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

Release files for swarmauri_middleware_jsonrpc 0.11.0.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarmauri_middleware_jsonrpc 0.11.0.dev1
File Size Uploaded
swarmauri_middleware_jsonrpc-0.11.0.dev1.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swarmauri_middleware_jsonrpc 0.11.0.dev1
File Interpreter ABI Platform
swarmauri_middleware_jsonrpc-0.11.0.dev1-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / swarmauri_middleware_jsonrpc-0.11.0.dev1.tar.gz

Download URL swarmauri_middleware_jsonrpc-0.11.0.dev1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e9977e9a82f40b75b43ec5b6d49e75ec82a733534b8698db204b49c4ffcfcd06
BLAKE2b-256 checksum
How to use checksums
0f63cd31df264e6f0334a527808d3a7e13b927b24fbcec8f505b68a925bd4e9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / swarmauri_middleware_jsonrpc-0.11.0.dev1-py3-none-any.whl

Download URL swarmauri_middleware_jsonrpc-0.11.0.dev1-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73e8c31d09aa9592fa7e72c16aceb48380048201514dd9de4739c6a49fba50b9
BLAKE2b-256 checksum
How to use checksums
6658ce0690aa27988cfa774776bfac9c7bde34937e282acbf9fb77176e5d0d91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page