python3-cyberfusion-rabbitmq-consumer-documentation-server


Namepython3-cyberfusion-rabbitmq-consumer-documentation-server JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttps://vcs.cyberfusion.nl/core/python3-cyberfusion-rabbitmq-consumer-documentation-server
SummaryDocumentation server for RabbitMQ consumer (lean RPC framework).
upload_time2024-08-13 14:07:29
maintainerNone
docs_urlNone
authorWilliam Edwards
requires_python>=3.11
licenseMIT
keywords cyberfusion rabbitmq amqp rpc
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python3-cyberfusion-rabbitmq-consumer-documentation-server

Documentation server for [RabbitMQ consumer](https://github.com/CyberfusionIO/python3-cyberfusion-rabbitmq-consumer) (lean RPC framework).

Features:

* Human-readable HTML documentation.
* [JSON schemas](https://json-schema.org/) for exchange response/request models.
* [Pydantic](https://docs.pydantic.dev/latest/) model generation for exchange request/request models (*definitions*).
* * This allows for strong-contracted bidirectional communication (identical, enforced models on server and client), similar to the intent of [protobuf](https://protobuf.dev/).

## HTML documentation

URL: `/`

![HTML documentation: request](assets/request.png)
*Request*

![HTML documentation: response](assets/response.png)
*Response*

## JSON schemas

URL: `/schemas`

The root returns a list of schemas. Every schema can be accessed as a subpath. For example: `/schemas/dx_example.json`

The list always includes a schema called `head.json`. This schema includes all schemas.

## Pydantic model generation

Automatically generate [Pydantic](https://docs.pydantic.dev/latest/) for request/response models of all installed exchanges.

One Python file (containing Pydantic models) is written per exchange, in a single directory (which is output to stdout).

Example:

```bash
$ rabbitmq-consumer-documentation-server create-client-models
/tmp/ce2e67f5-b756-4526-a4ac-45008d6f6526

$ ls -l /tmp/ce2e67f5-b756-4526-a4ac-45008d6f6526
total 24
-rw-r--r--  1 example  example  1024 Aug 13 15:16 dx_example.py
```

Example Python file (`dx_example.py`):

```python
# generated by datamodel-codegen:
#   filename:  dx_example.json
#   timestamp: 2024-08-13T13:16:16+00:00

from __future__ import annotations

from enum import Enum
from typing import Optional

from pydantic import BaseModel, Field, PositiveInt


class FavouriteFoodEnum(Enum):
    onion = 'onion'
    orange = 'orange'
    banana = 'banana'


class RPCRequestExample(BaseModel):
    favourite_food: FavouriteFoodEnum = Field(
        ..., description='Human-readable favourite food.'
    )
    chance_percentage: Optional[PositiveInt] = Field(
        20, description='Chances of favourite food passing.', title='Chance Percentage'
    )


class RPCResponseDataExample(BaseModel):
    tolerable: bool = Field(..., title='Tolerable')


class RPCResponseExample(BaseModel):
    success: bool = Field(..., title='Success')
    message: str = Field(..., title='Message')
    data: Optional[RPCResponseDataExample] = None


class DxExample(BaseModel):
    request_model: RPCRequestExample
    response_model: RPCResponseExample
```

# Install

## PyPI

Run the following command to install the package from PyPI:

    pip3 install python3-cyberfusion-rabbitmq-consumer-documentation-server

## Generic

Run the following command to create a source distribution:

    python3 setup.py sdist

## Debian

Run the following commands to build a Debian package:

    mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'
    dpkg-buildpackage -us -uc

# Configure

No configuration is supported.

# Usage

## Start server (serve HTML documentation + JSON schemas)

### Manually

    /usr/bin/rabbitmq-consumer-documentation-server run-server --host=:: --port=9012

### systemd

    systemctl start rabbitmq-consumer-documentation-server.service

## Generate Pydantic models

See '[Pydantic model generation](#pydantic-model-generation)'.

#### Environment variables

* `HOST` (`--host`). Default: `::`
* `PORT` (`--port`). Default: `9012`

# Tests

Run tests with pytest:

    pytest tests/

            

Raw data

            {
    "_id": null,
    "home_page": "https://vcs.cyberfusion.nl/core/python3-cyberfusion-rabbitmq-consumer-documentation-server",
    "name": "python3-cyberfusion-rabbitmq-consumer-documentation-server",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "cyberfusion, rabbitmq, amqp, rpc",
    "author": "William Edwards",
    "author_email": "wedwards@cyberfusion.nl",
    "download_url": "https://files.pythonhosted.org/packages/51/8d/38abe8538b866de4b57ca85b12040af4d43b54dac64742cfbd66768e3e1a/python3-cyberfusion-rabbitmq-consumer-documentation-server-1.1.1.tar.gz",
    "platform": "linux",
    "description": "# python3-cyberfusion-rabbitmq-consumer-documentation-server\n\nDocumentation server for [RabbitMQ consumer](https://github.com/CyberfusionIO/python3-cyberfusion-rabbitmq-consumer) (lean RPC framework).\n\nFeatures:\n\n* Human-readable HTML documentation.\n* [JSON schemas](https://json-schema.org/) for exchange response/request models.\n* [Pydantic](https://docs.pydantic.dev/latest/) model generation for exchange request/request models (*definitions*).\n* * This allows for strong-contracted bidirectional communication (identical, enforced models on server and client), similar to the intent of [protobuf](https://protobuf.dev/).\n\n## HTML documentation\n\nURL: `/`\n\n![HTML documentation: request](assets/request.png)\n*Request*\n\n![HTML documentation: response](assets/response.png)\n*Response*\n\n## JSON schemas\n\nURL: `/schemas`\n\nThe root returns a list of schemas. Every schema can be accessed as a subpath. For example: `/schemas/dx_example.json`\n\nThe list always includes a schema called `head.json`. This schema includes all schemas.\n\n## Pydantic model generation\n\nAutomatically generate [Pydantic](https://docs.pydantic.dev/latest/) for request/response models of all installed exchanges.\n\nOne Python file (containing Pydantic models) is written per exchange, in a single directory (which is output to stdout).\n\nExample:\n\n```bash\n$ rabbitmq-consumer-documentation-server create-client-models\n/tmp/ce2e67f5-b756-4526-a4ac-45008d6f6526\n\n$ ls -l /tmp/ce2e67f5-b756-4526-a4ac-45008d6f6526\ntotal 24\n-rw-r--r--  1 example  example  1024 Aug 13 15:16 dx_example.py\n```\n\nExample Python file (`dx_example.py`):\n\n```python\n# generated by datamodel-codegen:\n#   filename:  dx_example.json\n#   timestamp: 2024-08-13T13:16:16+00:00\n\nfrom __future__ import annotations\n\nfrom enum import Enum\nfrom typing import Optional\n\nfrom pydantic import BaseModel, Field, PositiveInt\n\n\nclass FavouriteFoodEnum(Enum):\n    onion = 'onion'\n    orange = 'orange'\n    banana = 'banana'\n\n\nclass RPCRequestExample(BaseModel):\n    favourite_food: FavouriteFoodEnum = Field(\n        ..., description='Human-readable favourite food.'\n    )\n    chance_percentage: Optional[PositiveInt] = Field(\n        20, description='Chances of favourite food passing.', title='Chance Percentage'\n    )\n\n\nclass RPCResponseDataExample(BaseModel):\n    tolerable: bool = Field(..., title='Tolerable')\n\n\nclass RPCResponseExample(BaseModel):\n    success: bool = Field(..., title='Success')\n    message: str = Field(..., title='Message')\n    data: Optional[RPCResponseDataExample] = None\n\n\nclass DxExample(BaseModel):\n    request_model: RPCRequestExample\n    response_model: RPCResponseExample\n```\n\n# Install\n\n## PyPI\n\nRun the following command to install the package from PyPI:\n\n    pip3 install python3-cyberfusion-rabbitmq-consumer-documentation-server\n\n## Generic\n\nRun the following command to create a source distribution:\n\n    python3 setup.py sdist\n\n## Debian\n\nRun the following commands to build a Debian package:\n\n    mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'\n    dpkg-buildpackage -us -uc\n\n# Configure\n\nNo configuration is supported.\n\n# Usage\n\n## Start server (serve HTML documentation + JSON schemas)\n\n### Manually\n\n    /usr/bin/rabbitmq-consumer-documentation-server run-server --host=:: --port=9012\n\n### systemd\n\n    systemctl start rabbitmq-consumer-documentation-server.service\n\n## Generate Pydantic models\n\nSee '[Pydantic model generation](#pydantic-model-generation)'.\n\n#### Environment variables\n\n* `HOST` (`--host`). Default: `::`\n* `PORT` (`--port`). Default: `9012`\n\n# Tests\n\nRun tests with pytest:\n\n    pytest tests/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Documentation server for RabbitMQ consumer (lean RPC framework).",
    "version": "1.1.1",
    "project_urls": {
        "Homepage": "https://vcs.cyberfusion.nl/core/python3-cyberfusion-rabbitmq-consumer-documentation-server"
    },
    "split_keywords": [
        "cyberfusion",
        " rabbitmq",
        " amqp",
        " rpc"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "518d38abe8538b866de4b57ca85b12040af4d43b54dac64742cfbd66768e3e1a",
                "md5": "638b365519dcb04d5dafe51a27b89021",
                "sha256": "6e8e045ef01bbf2a2e693817f24869bb5242ebdb2450c0628ac3fb365478bdba"
            },
            "downloads": -1,
            "filename": "python3-cyberfusion-rabbitmq-consumer-documentation-server-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "638b365519dcb04d5dafe51a27b89021",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 9023,
            "upload_time": "2024-08-13T14:07:29",
            "upload_time_iso_8601": "2024-08-13T14:07:29.102568Z",
            "url": "https://files.pythonhosted.org/packages/51/8d/38abe8538b866de4b57ca85b12040af4d43b54dac64742cfbd66768e3e1a/python3-cyberfusion-rabbitmq-consumer-documentation-server-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-13 14:07:29",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "python3-cyberfusion-rabbitmq-consumer-documentation-server"
}
        
Elapsed time: 3.80873s