connexion-code-generator


Nameconnexion-code-generator JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryA CLI tool that generates Protocol or Abstract Classes based on your OpenAPI specification.
upload_time2023-05-23 14:28:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords connexion
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # connexion-code-generator

`connexion-code-generator` is a code CLI tool that generates Abstract or Protocol class definitions
based on your openapi.yaml specification. These class definitions then will be used to make sure our
connexion MethodViews are compatible with our API definition using static type checkers like `mypy` or `pyright`.

It currently only supports [**OpenAPI 3.0**](https://swagger.io/specification/v3/).

[![PyPI - Version](https://img.shields.io/pypi/v/connexion-code-generator.svg)](https://pypi.org/project/connexion-code-generator)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/connexion-code-generator.svg)](https://pypi.org/project/connexion-code-generator)

-----

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [License](#license)

## Installation

`connexion-code-generator` is available on PyPi, so you can install it using the following command.

```console
pip install connexion-code-generator
```

Keep in mind that this project in beta stage so please pin the minor version of the package,
as there will be no backward incompatible changes in patch versions with the same minor version,
but there's no backward compatibility and API stability guaranteed between minor versions.

## Usage

To run it with its default config simply run the `connexion-protocol-generator generate` command
in the same directory as your `openapi.yaml` file. It will create an `api` python module with a
`view.py` file inside it.

### Using [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator) to generate DTOs

`connexion-code-generator` does not care about the way you convert your OpenAPI object schemas to python
classes, it just assumes that any object defined in your schema has an equivalent python class in the
`api.dtos` module. As the convention for schema names in OpenAPI are snake-case but the convention for
class names in python is PascalCase, it assumes the conversion has been done, i.g: an schema with the name
`some-api-request` should have a class named `SomeApiRequest`.

This is done to prevent re-inventing the wheel as there are many good library and CLI applications that
achieve this conversion task with a high quality.

We use `datamodel-code-generator` for this. We first run `datamodel-code-generator` on our schema and store its
result in the `api.dtos` module, then we run `connexion-code-generator`.

### Advance options

`connexion-code-generator` provides the following options (available to you by running `connexion-code-generator generate -h`):

- -i, --input **OpenAPI specification file, defaults to `./openapi.yaml`**
- -d, --dto-module-path **DTOs module name, defaults to `api.dtos`**
- -o, --output **Output file path, default to `./api/views.py`**
- -e, --error-type **The DTO type for unknown error responses, defaults to `ErrorResponse`**
- --abstract **Generate abstract class instead of protocol class**
- --sync **Generate sync methods instead of async methods**

## License

`connexion-code-generator` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "connexion-code-generator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "connexion",
    "author": null,
    "author_email": "Mahdi Mohaveri <mmohaveri@gmail.com>",
    "download_url": null,
    "platform": null,
    "description": "# connexion-code-generator\n\n`connexion-code-generator` is a code CLI tool that generates Abstract or Protocol class definitions\nbased on your openapi.yaml specification. These class definitions then will be used to make sure our\nconnexion MethodViews are compatible with our API definition using static type checkers like `mypy` or `pyright`.\n\nIt currently only supports [**OpenAPI 3.0**](https://swagger.io/specification/v3/).\n\n[![PyPI - Version](https://img.shields.io/pypi/v/connexion-code-generator.svg)](https://pypi.org/project/connexion-code-generator)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/connexion-code-generator.svg)](https://pypi.org/project/connexion-code-generator)\n\n-----\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [License](#license)\n\n## Installation\n\n`connexion-code-generator` is available on PyPi, so you can install it using the following command.\n\n```console\npip install connexion-code-generator\n```\n\nKeep in mind that this project in beta stage so please pin the minor version of the package,\nas there will be no backward incompatible changes in patch versions with the same minor version,\nbut there's no backward compatibility and API stability guaranteed between minor versions.\n\n## Usage\n\nTo run it with its default config simply run the `connexion-protocol-generator generate` command\nin the same directory as your `openapi.yaml` file. It will create an `api` python module with a\n`view.py` file inside it.\n\n### Using [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator) to generate DTOs\n\n`connexion-code-generator` does not care about the way you convert your OpenAPI object schemas to python\nclasses, it just assumes that any object defined in your schema has an equivalent python class in the\n`api.dtos` module. As the convention for schema names in OpenAPI are snake-case but the convention for\nclass names in python is PascalCase, it assumes the conversion has been done, i.g: an schema with the name\n`some-api-request` should have a class named `SomeApiRequest`.\n\nThis is done to prevent re-inventing the wheel as there are many good library and CLI applications that\nachieve this conversion task with a high quality.\n\nWe use `datamodel-code-generator` for this. We first run `datamodel-code-generator` on our schema and store its\nresult in the `api.dtos` module, then we run `connexion-code-generator`.\n\n### Advance options\n\n`connexion-code-generator` provides the following options (available to you by running `connexion-code-generator generate -h`):\n\n- -i, --input **OpenAPI specification file, defaults to `./openapi.yaml`**\n- -d, --dto-module-path **DTOs module name, defaults to `api.dtos`**\n- -o, --output **Output file path, default to `./api/views.py`**\n- -e, --error-type **The DTO type for unknown error responses, defaults to `ErrorResponse`**\n- --abstract **Generate abstract class instead of protocol class**\n- --sync **Generate sync methods instead of async methods**\n\n## License\n\n`connexion-code-generator` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A CLI tool that generates Protocol or Abstract Classes based on your OpenAPI specification.",
    "version": "0.0.1",
    "project_urls": {
        "Documentation": "https://github.com/mmohaveri/connexion-code-generator#readme",
        "Issues": "https://github.com/mmohaveri/connexion-code-generator/issues",
        "Source": "https://github.com/mmohaveri/connexion-code-generator"
    },
    "split_keywords": [
        "connexion"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "26065b3e2f533dac2e9f3a0eda74d7bdc8df27469a611bed237a335b88bbef78",
                "md5": "b7bbcadadbad9563437cfc3ba46aec89",
                "sha256": "52e86f9f6194c28560dfd8dbfe8dc3fd16a5041b19003bc9959d77dab8baa99d"
            },
            "downloads": -1,
            "filename": "connexion_code_generator-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b7bbcadadbad9563437cfc3ba46aec89",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 18527,
            "upload_time": "2023-05-23T14:28:05",
            "upload_time_iso_8601": "2023-05-23T14:28:05.637128Z",
            "url": "https://files.pythonhosted.org/packages/26/06/5b3e2f533dac2e9f3a0eda74d7bdc8df27469a611bed237a335b88bbef78/connexion_code_generator-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-23 14:28:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mmohaveri",
    "github_project": "connexion-code-generator#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "connexion-code-generator"
}
        
Elapsed time: 0.05972s