Metadata-Version: 2.1
Name: fastapi-jsonrpc
Version: 0.1.12
Summary: JSON-RPC server based on fastapi
Home-page: https://github.com/smagafurov/fastapi-jsonrpc
License: MIT
Keywords: json-rpc,asgi,swagger,openapi,fastapi,pydantic,starlette
Author: Sergey Magafurov
Author-email: magafurov@tochka.com
Requires-Python: >=3.6,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Requires-Dist: aiojobs (>=0.2.2,<0.3.0)
Requires-Dist: fastapi (>=0.35.0,<0.36.0)
Requires-Dist: pydantic (>=0.30,<0.31)
Requires-Dist: starlette (>=0.12.7,<0.13.0)
Project-URL: Repository, https://github.com/smagafurov/fastapi-jsonrpc
Description-Content-Type: text/x-rst

Description
===========

JSON-RPC server based on fastapi:

    https://fastapi.tiangolo.com

Installation
============

.. code:: bash

    pip install fastapi-jsonrpc

Usage
=====

.. code:: bash

    pip install uvicorn

.. code:: python

    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'

        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'})
        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:

    http://127.0.0.1:5000/docs

Development
===========

1. Install poetry

    https://github.com/sdispater/poetry#installation

2. Install dependencies

    .. code:: bash

        poetry update

3. Install dephell

    .. code:: bash

        pip install dephell

4. Regenerate setup.py

    .. code:: bash

        dephell deps convert

