jsonrpc.API¶
fastapi_jsonrpc.API is a subclass of fastapi.FastAPI. It behaves exactly like a regular FastAPI app, plus it knows how to bind Entrypoint instances and expose the OpenRPC schema.
app = jsonrpc.API(
title='My service',
openrpc_url='/openrpc.json', # set to None to disable
fastapi_jsonrpc_components_fine_names=True,
)
Parameters¶
openrpc_url: str | None— URL for the generated OpenRPC schema. Default:/openrpc.json. PassNoneto turn it off.fastapi_jsonrpc_components_fine_names: bool— controls the naming strategy for generated Pydantic components in the OpenAPI schema. Default:True. Set toFalseif the default names collide with your own schemas. Seetests/test_openapi.pyfor exact behaviour.- Everything else is forwarded to
FastAPI.
Binding entrypoints¶
bind_entrypoint registers both the JSON-RPC entrypoint route and one POST route per method under it.
Shutdown hooks¶
API adds a single shutdown handler that closes the aiojobs scheduler owned by every bound entrypoint. You can register your own shutdown callables via FastAPI's standard mechanisms (lifespan= or add_event_handler).