connexion


Nameconnexion JSON
Version 3.0.6 PyPI version JSON
download
home_pagehttps://github.com/spec-first/connexion
SummaryConnexion - API first applications with OpenAPI/Swagger
upload_time2024-02-14 08:35:18
maintainerRobbe Sneyders
docs_urlNone
authorRobbe Sneyders
requires_python>=3.8,<4.0
licenseApache-2.0
keywords api swagger openapi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
             <a id="top"></a>
 <p align="center">
     <img src="https://raw.githubusercontent.com/spec-first/connexion/main/docs/images/logo_banner.svg" width="100%"/>
 </p>
 <p align="center">
     <a href="https://pypi.org/project/connexion"><img alt="coveralls" src="https://img.shields.io/pypi/status/connexion.svg?style=flat-square&color=brightgreen"></a>
     <a href="https://pypi.org/project/connexion"><img alt="PyPI version" src="https://img.shields.io/pypi/v/connexion?color=brightgreen&style=flat-square"></a>
     <a href="https://github.com/spec-first/connexion/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/pypi/l/connexion?style=flat-square&color=brightgreen"></a>
     <a href="https://github.com/spec-first/connexion/actions/workflows/pipeline.yml"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/spec-first/connexion/pipeline.yml?style=flat-square"></a>
     <a href="https://coveralls.io/github/spec-first/connexion?branch=main"><img alt="Coveralls" src="https://img.shields.io/coverallsCoverage/github/spec-first/connexion?style=flat-square"></a>
     <br>
     <br>
     <a href="https://connexion.readthedocs.io/en/stable/"><strong>Explore the docs ยป</strong></a>
 </p>

---

Connexion is a modern Python web framework that makes spec-first and api-first development easy.
You describe your API in an [OpenAPI][OpenAPI] (or [Swagger][Swagger]) specification with as much 
detail as you want and Connexion will guarantee that it works as you specified.

It works either standalone, or in combination with any ASGI or WSGI-compatible framework!

<p align="center">
   <br>
   <a href="https://connexion.readthedocs.io/en/latest/v3.html"><strong>๐Ÿ“ข Connexion 3 was recently released! Read about the changes here ยป</strong></a>
   <br>
   <br>
</p>

## โœจ Features

Connexion provides the following functionality **based on your specification**:

- ๐Ÿš **Automatic route registration**, no ``@route`` decorators needed
- ๐Ÿ”’ **Authentication**, split from your application logic
- ๐Ÿ”Ž **Request and response validation** of headers, parameters, and body
- ๐Ÿ“ฌ **Parameter parsing and injection**, no request object needed
- ๐Ÿ“จ **Response serialization**, you can return regular Python objects
- ๐Ÿ“บ **A Swagger UI console** with live documentation and โ€˜try it outโ€™ feature
- ๐Ÿงฉ **Pluggability**, in all dimensions

Connexion also **helps you write your OpenAPI specification** and develop against it by providing a command line interface which lets you test and mock your specification.

```shell
   connexion run openapi.yaml
```

 <p align="right">(<a href="#top">back to top</a>)</p>


## ๐Ÿซถ Sponsors

<a href="https://www.ml6.eu"><img src="https://raw.githubusercontent.com/spec-first/connexion/main/docs/images/sponsors/ML6.png" title=ML6 height="100"></a>
<a href="https://www.devmark.ai/fern/?utm_source=connexion&utm_loc=readme&utm_type=logo"><img src="https://raw.githubusercontent.com/spec-first/connexion/main/docs/images/sponsors/Fern.png" title=Fern height="100"></a>

Sponsors help us dedicate time to maintain Connexion. Want to help?

<a href="https://github.com/sponsors/spec-first"><strong>Explore the options ยป</strong></a>

<p align="right">(<a href="#top">back to top</a>)</p>

## ๐Ÿชค Why Connexion

With Connexion, you write the spec first. Connexion then calls your Python
code, handling the mapping from the specification to the code. This
incentivizes you to write the specification so that all of your
developers can understand what your API does, even before you write a
single line of code.

If multiple teams depend on your APIs, you can use Connexion to easily
send them the documentation of your API. This guarantees that your API will
follow the specification that you wrote. This is a different process from
the one offered by most frameworks, which generate a specification
*after* you've written the code.
Some disadvantages of generating specifications based on code is that
they often end up lacking details or mix your documentation with the implementation
logic of your application.

<p align="right">(<a href="#top">back to top</a>)</p>

## โš’๏ธ How to Use

### Installation

You can install connexion using pip:

```shell
    $ pip install connexion
```

Connexion provides 'extras' with optional dependencies to unlock additional features:

- `swagger-ui`: Enables a Swagger UI console for your application.
- `uvicorn`: Enables to run the your application using `app.run()` for
  development instead of using an external ASGI server.
- `flask`: Enables the `FlaskApp` to build applications compatible with the Flask
  ecosystem.

You can install them as follows:

```shell
    $ pip install connexion[swagger-ui]
    $ pip install connexion[swagger-ui,uvicorn].
```

<p align="right">(<a href="#top">back to top</a>)</p>

### Creating your application

Connexion can be used either as a standalone application or as a middleware wrapping an existing
ASGI (or WSGI) application written using a different framework. The standalone application can be
built using either the `AsyncApp` or `FlaskApp`.

- The `AsyncApp` is a lightweight application with native asynchronous support. Use it if you
  are starting a new project and have no specific reason to use one of the other options.

  ```Python
      from connexion import AsyncApp

      app = AsyncApp(__name__)
  ```

- The `FlaskApp` leverages the `Flask` framework, which is useful if you're migrating from
  connexion 2.X or you want to leverage the `Flask` ecosystem.

  ```python
      from connexion import FlaskApp

      app = FlaskApp(__name__)
  ```

- The `ConnexionMiddleware` can be wrapped around any existing ASGI or WSGI application.
  Use it if you already have an application written in a different framework and want to add
  functionality provided by connexion

  ```python
      from asgi_framework import App
      from connexion import ConnexionMiddleware

      app = App(__name__)
      app = ConnexionMiddleware(app)
  ```

<p align="right">(<a href="#top">back to top</a>)</p>

### Registering an API

While you can register individual routes on your application, Connexion really shines when you
register an API defined by an OpenAPI (or Swagger) specification.
The operation described in your specification is automatically linked to your Python view function via the ``operationId``

**run.py**

```python
   def post_greeting(name: str, greeting: str):  # Paramaeters are automatically unpacked
       return f"{greeting} {name}", 200          # Responses are automatically serialized

   app.add_api("openapi.yaml")
```

**openapi.yaml**

```yaml
   ...
   paths:
     /greeting/{name}:
       post:
         operationId: run.post_greeting
         responses:
           200:
             content:
               text/plain:
                 schema:
                   type: string
         parameters:
           - name: name
             in: path
             required: true
             schema:
               type: string
           - name: greeting
             in: query
             required: true
             schema:
               type: string
```

<p align="right">(<a href="#top">back to top</a>)</p>

### Running your application

If you installed connexion using `connexion[uvicorn]`, you can run it using the
`run` method. This is only recommended for development:

```python
    app.run()
```

In production, run your application using an ASGI server such as `uvicorn`. If you defined your
`app` in a python module called `run.py`, you can run it as follows:

```shell
    $ uvicorn run:app
```

Or with gunicorn:

```shell
    $ gunicorn -k uvicorn.workers.UvicornWorker run:app
```

----

Now you're able to run and use Connexion!

See the [examples][examples] folder for more examples.

<p align="right">(<a href="#top">back to top</a>)</p>

## ๐Ÿ“œ Changes

A full changelog is maintained on the [GitHub releases page][Releases].

<p align="right">(<a href="#top">back to top</a>)</p>

## ๐Ÿคฒ Contributing

We welcome your ideas, issues, and pull requests. Just follow the
usual/standard GitHub practices.

For easy development, install connexion using poetry with all extras, and
install the pre-commit hooks to automatically run black formatting and static analysis checks.

```shell
    pip install poetry
    poetry install --all-extras
    pre-commit install
```

You can find out more about how Connexion works and where to apply your changes by having a look
at our [architecture][Architecture].

Unless you explicitly state otherwise in advance, any non trivial
contribution intentionally submitted for inclusion in this project by you
to the steward of this repository shall be under the
terms and conditions of Apache License 2.0 written below, without any
additional copyright information, terms or conditions.

<p align="right">(<a href="#top">back to top</a>)</p>

## ๐Ÿ™ Thanks

We'd like to thank all of Connexion's contributors for working on this
project, Swagger/OpenAPI for their support, and Zalando for originally developing and releasing Connexion.

## ๐Ÿ“š Recommended Resources

About the advantages of working spec-first:

* [Blog Atlassian][Blog Atlassian]
* [API guidelines Zalando][API guidelines Zalando]
* [Blog ML6][Blog ML6]
* [Blog Zalando][Blog Zalando]

Tools to help you work spec-first:

* [Online swagger editor][Online swagger editor]
* [VS Code plugin][VS Code plugin]
* [Pycharm plugin][Pycharm plugin]

[OpenAPI]: https://openapis.org/
[Swagger]: http://swagger.io/open-source-integrations/
[Blog atlassian]: https://www.atlassian.com/blog/technology/spec-first-api-development
[Blog ML6]: https://blog.ml6.eu/why-we-decided-to-help-maintain-connexion-c9f449877083
[Blog Zalando]: https://engineering.zalando.com/posts/2016/12/crafting-effective-microservices-in-python.html
[API guidelines Zalando]: https://opensource.zalando.com/restful-api-guidelines/#api-first
[Online swagger editor]: https://editor.swagger.io/
[VS Code plugin]: https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi
[Pycharm plugin]: https://plugins.jetbrains.com/plugin/14837-openapi-swagger-editor
[examples]: https://github.com/spec-first/connexion/blob/main/examples
[Releases]: https://github.com/spec-first/connexion/releases
[Architecture]: https://github.com/spec-first/connexion/blob/main/docs/images/architecture.png

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/spec-first/connexion",
    "name": "connexion",
    "maintainer": "Robbe Sneyders",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "robbe.sneyders@gmail.com",
    "keywords": "api,swagger,openapi",
    "author": "Robbe Sneyders",
    "author_email": "robbe.sneyders@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/cb/7e/0b62de62ed9824621f69342cf08aadd1f1ba42d2eca0673079fa231634e1/connexion-3.0.6.tar.gz",
    "platform": null,
    "description": " <a id=\"top\"></a>\n <p align=\"center\">\n     <img src=\"https://raw.githubusercontent.com/spec-first/connexion/main/docs/images/logo_banner.svg\" width=\"100%\"/>\n </p>\n <p align=\"center\">\n     <a href=\"https://pypi.org/project/connexion\"><img alt=\"coveralls\" src=\"https://img.shields.io/pypi/status/connexion.svg?style=flat-square&color=brightgreen\"></a>\n     <a href=\"https://pypi.org/project/connexion\"><img alt=\"PyPI version\" src=\"https://img.shields.io/pypi/v/connexion?color=brightgreen&style=flat-square\"></a>\n     <a href=\"https://github.com/spec-first/connexion/blob/main/LICENSE\"><img alt=\"License\" src=\"https://img.shields.io/pypi/l/connexion?style=flat-square&color=brightgreen\"></a>\n     <a href=\"https://github.com/spec-first/connexion/actions/workflows/pipeline.yml\"><img alt=\"GitHub Workflow Status\" src=\"https://img.shields.io/github/actions/workflow/status/spec-first/connexion/pipeline.yml?style=flat-square\"></a>\n     <a href=\"https://coveralls.io/github/spec-first/connexion?branch=main\"><img alt=\"Coveralls\" src=\"https://img.shields.io/coverallsCoverage/github/spec-first/connexion?style=flat-square\"></a>\n     <br>\n     <br>\n     <a href=\"https://connexion.readthedocs.io/en/stable/\"><strong>Explore the docs \u00bb</strong></a>\n </p>\n\n---\n\nConnexion is a modern Python web framework that makes spec-first and api-first development easy.\nYou describe your API in an [OpenAPI][OpenAPI] (or [Swagger][Swagger]) specification with as much \ndetail as you want and Connexion will guarantee that it works as you specified.\n\nIt works either standalone, or in combination with any ASGI or WSGI-compatible framework!\n\n<p align=\"center\">\n   <br>\n   <a href=\"https://connexion.readthedocs.io/en/latest/v3.html\"><strong>\ud83d\udce2 Connexion 3 was recently released! Read about the changes here \u00bb</strong></a>\n   <br>\n   <br>\n</p>\n\n## \u2728 Features\n\nConnexion provides the following functionality **based on your specification**:\n\n- \ud83d\ude8f **Automatic route registration**, no ``@route`` decorators needed\n- \ud83d\udd12 **Authentication**, split from your application logic\n- \ud83d\udd0e **Request and response validation** of headers, parameters, and body\n- \ud83d\udcec **Parameter parsing and injection**, no request object needed\n- \ud83d\udce8 **Response serialization**, you can return regular Python objects\n- \ud83d\udcfa **A Swagger UI console** with live documentation and \u2018try it out\u2019 feature\n- \ud83e\udde9 **Pluggability**, in all dimensions\n\nConnexion also **helps you write your OpenAPI specification** and develop against it by providing a command line interface which lets you test and mock your specification.\n\n```shell\n   connexion run openapi.yaml\n```\n\n <p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n## \ud83e\udef6 Sponsors\n\n<a href=\"https://www.ml6.eu\"><img src=\"https://raw.githubusercontent.com/spec-first/connexion/main/docs/images/sponsors/ML6.png\" title=ML6 height=\"100\"></a>\n<a href=\"https://www.devmark.ai/fern/?utm_source=connexion&utm_loc=readme&utm_type=logo\"><img src=\"https://raw.githubusercontent.com/spec-first/connexion/main/docs/images/sponsors/Fern.png\" title=Fern height=\"100\"></a>\n\nSponsors help us dedicate time to maintain Connexion. Want to help?\n\n<a href=\"https://github.com/sponsors/spec-first\"><strong>Explore the options \u00bb</strong></a>\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n## \ud83e\udea4 Why Connexion\n\nWith Connexion, you write the spec first. Connexion then calls your Python\ncode, handling the mapping from the specification to the code. This\nincentivizes you to write the specification so that all of your\ndevelopers can understand what your API does, even before you write a\nsingle line of code.\n\nIf multiple teams depend on your APIs, you can use Connexion to easily\nsend them the documentation of your API. This guarantees that your API will\nfollow the specification that you wrote. This is a different process from\nthe one offered by most frameworks, which generate a specification\n*after* you've written the code.\nSome disadvantages of generating specifications based on code is that\nthey often end up lacking details or mix your documentation with the implementation\nlogic of your application.\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n## \u2692\ufe0f How to Use\n\n### Installation\n\nYou can install connexion using pip:\n\n```shell\n    $ pip install connexion\n```\n\nConnexion provides 'extras' with optional dependencies to unlock additional features:\n\n- `swagger-ui`: Enables a Swagger UI console for your application.\n- `uvicorn`: Enables to run the your application using `app.run()` for\n  development instead of using an external ASGI server.\n- `flask`: Enables the `FlaskApp` to build applications compatible with the Flask\n  ecosystem.\n\nYou can install them as follows:\n\n```shell\n    $ pip install connexion[swagger-ui]\n    $ pip install connexion[swagger-ui,uvicorn].\n```\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n### Creating your application\n\nConnexion can be used either as a standalone application or as a middleware wrapping an existing\nASGI (or WSGI) application written using a different framework. The standalone application can be\nbuilt using either the `AsyncApp` or `FlaskApp`.\n\n- The `AsyncApp` is a lightweight application with native asynchronous support. Use it if you\n  are starting a new project and have no specific reason to use one of the other options.\n\n  ```Python\n      from connexion import AsyncApp\n\n      app = AsyncApp(__name__)\n  ```\n\n- The `FlaskApp` leverages the `Flask` framework, which is useful if you're migrating from\n  connexion 2.X or you want to leverage the `Flask` ecosystem.\n\n  ```python\n      from connexion import FlaskApp\n\n      app = FlaskApp(__name__)\n  ```\n\n- The `ConnexionMiddleware` can be wrapped around any existing ASGI or WSGI application.\n  Use it if you already have an application written in a different framework and want to add\n  functionality provided by connexion\n\n  ```python\n      from asgi_framework import App\n      from connexion import ConnexionMiddleware\n\n      app = App(__name__)\n      app = ConnexionMiddleware(app)\n  ```\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n### Registering an API\n\nWhile you can register individual routes on your application, Connexion really shines when you\nregister an API defined by an OpenAPI (or Swagger) specification.\nThe operation described in your specification is automatically linked to your Python view function via the ``operationId``\n\n**run.py**\n\n```python\n   def post_greeting(name: str, greeting: str):  # Paramaeters are automatically unpacked\n       return f\"{greeting} {name}\", 200          # Responses are automatically serialized\n\n   app.add_api(\"openapi.yaml\")\n```\n\n**openapi.yaml**\n\n```yaml\n   ...\n   paths:\n     /greeting/{name}:\n       post:\n         operationId: run.post_greeting\n         responses:\n           200:\n             content:\n               text/plain:\n                 schema:\n                   type: string\n         parameters:\n           - name: name\n             in: path\n             required: true\n             schema:\n               type: string\n           - name: greeting\n             in: query\n             required: true\n             schema:\n               type: string\n```\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n### Running your application\n\nIf you installed connexion using `connexion[uvicorn]`, you can run it using the\n`run` method. This is only recommended for development:\n\n```python\n    app.run()\n```\n\nIn production, run your application using an ASGI server such as `uvicorn`. If you defined your\n`app` in a python module called `run.py`, you can run it as follows:\n\n```shell\n    $ uvicorn run:app\n```\n\nOr with gunicorn:\n\n```shell\n    $ gunicorn -k uvicorn.workers.UvicornWorker run:app\n```\n\n----\n\nNow you're able to run and use Connexion!\n\nSee the [examples][examples] folder for more examples.\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n## \ud83d\udcdc Changes\n\nA full changelog is maintained on the [GitHub releases page][Releases].\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n## \ud83e\udd32 Contributing\n\nWe welcome your ideas, issues, and pull requests. Just follow the\nusual/standard GitHub practices.\n\nFor easy development, install connexion using poetry with all extras, and\ninstall the pre-commit hooks to automatically run black formatting and static analysis checks.\n\n```shell\n    pip install poetry\n    poetry install --all-extras\n    pre-commit install\n```\n\nYou can find out more about how Connexion works and where to apply your changes by having a look\nat our [architecture][Architecture].\n\nUnless you explicitly state otherwise in advance, any non trivial\ncontribution intentionally submitted for inclusion in this project by you\nto the steward of this repository shall be under the\nterms and conditions of Apache License 2.0 written below, without any\nadditional copyright information, terms or conditions.\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n## \ud83d\ude4f Thanks\n\nWe'd like to thank all of Connexion's contributors for working on this\nproject, Swagger/OpenAPI for their support, and Zalando for originally developing and releasing Connexion.\n\n## \ud83d\udcda Recommended Resources\n\nAbout the advantages of working spec-first:\n\n* [Blog Atlassian][Blog Atlassian]\n* [API guidelines Zalando][API guidelines Zalando]\n* [Blog ML6][Blog ML6]\n* [Blog Zalando][Blog Zalando]\n\nTools to help you work spec-first:\n\n* [Online swagger editor][Online swagger editor]\n* [VS Code plugin][VS Code plugin]\n* [Pycharm plugin][Pycharm plugin]\n\n[OpenAPI]: https://openapis.org/\n[Swagger]: http://swagger.io/open-source-integrations/\n[Blog atlassian]: https://www.atlassian.com/blog/technology/spec-first-api-development\n[Blog ML6]: https://blog.ml6.eu/why-we-decided-to-help-maintain-connexion-c9f449877083\n[Blog Zalando]: https://engineering.zalando.com/posts/2016/12/crafting-effective-microservices-in-python.html\n[API guidelines Zalando]: https://opensource.zalando.com/restful-api-guidelines/#api-first\n[Online swagger editor]: https://editor.swagger.io/\n[VS Code plugin]: https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi\n[Pycharm plugin]: https://plugins.jetbrains.com/plugin/14837-openapi-swagger-editor\n[examples]: https://github.com/spec-first/connexion/blob/main/examples\n[Releases]: https://github.com/spec-first/connexion/releases\n[Architecture]: https://github.com/spec-first/connexion/blob/main/docs/images/architecture.png\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Connexion - API first applications with OpenAPI/Swagger",
    "version": "3.0.6",
    "project_urls": {
        "Homepage": "https://github.com/spec-first/connexion",
        "Repository": "https://github.com/spec-first/connexion"
    },
    "split_keywords": [
        "api",
        "swagger",
        "openapi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4a3696cf48c7d5735ca425876151e1f30bc6742fa411099c42ece5e42ea207e3",
                "md5": "29614fcdb9c1d1378179acfd1b4c0653",
                "sha256": "9172600de1fd315ca368d6005f6cd56672559f4c7a3b5b239f0b3d473a10758f"
            },
            "downloads": -1,
            "filename": "connexion-3.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "29614fcdb9c1d1378179acfd1b4c0653",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 112415,
            "upload_time": "2024-02-14T08:35:14",
            "upload_time_iso_8601": "2024-02-14T08:35:14.636630Z",
            "url": "https://files.pythonhosted.org/packages/4a/36/96cf48c7d5735ca425876151e1f30bc6742fa411099c42ece5e42ea207e3/connexion-3.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb7e0b62de62ed9824621f69342cf08aadd1f1ba42d2eca0673079fa231634e1",
                "md5": "d63e4cabac8805a56d7dc9952e6c03ac",
                "sha256": "6dba2e3d3920653a16d41b373ee8b104281d078c2a3916b773b575c8e919eb1b"
            },
            "downloads": -1,
            "filename": "connexion-3.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "d63e4cabac8805a56d7dc9952e6c03ac",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 87548,
            "upload_time": "2024-02-14T08:35:18",
            "upload_time_iso_8601": "2024-02-14T08:35:18.395030Z",
            "url": "https://files.pythonhosted.org/packages/cb/7e/0b62de62ed9824621f69342cf08aadd1f1ba42d2eca0673079fa231634e1/connexion-3.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-14 08:35:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "spec-first",
    "github_project": "connexion",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "connexion"
}
        
Elapsed time: 0.18913s