---
title: "connexion | pypx"
description: "Connexion - API first applications with OpenAPI/Swagger"
canonical_url: "https://pypx.app/packages/connexion"
meta:
  "og:description": "Connexion - API first applications with OpenAPI/Swagger"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_connexion%2Cversion_3.3.0%2Csummary_~Q29ubmV4aW9uIC0gQVBJIGZpcnN0IGFwcGxpY2F0aW9ucyB3aXRoIE9wZW5BUEkvU3dhZ2dlcg%2Clicense_Apache%2BSoftware%2BLicense%2Cp_Ii9wYWNrYWdlcy9jb25uZXhpb24i%2Cs_GgFnUpLR-HDySubL.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "connexion 3.3.0"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_connexion%2Cversion_3.3.0%2Csummary_~Q29ubmV4aW9uIC0gQVBJIGZpcnN0IGFwcGxpY2F0aW9ucyB3aXRoIE9wZW5BUEkvU3dhZ2dlcg%2Clicense_Apache%2BSoftware%2BLicense%2Cp_Ii9wYWNrYWdlcy9jb25uZXhpb24i%2Cs_GgFnUpLR-HDySubL.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **connexion**

v3.3.0

Connexion - API first applications with OpenAPI/Swagger

111 KB Python 3.9+ py3-none-anyApache Software License11 deps

[** Diff **](https://pypx.app/packages/connexion/diff)

`$ uv add connexion`

---

Connexion is a modern Python web framework that makes spec-first and api-first development easy. You describe your API in an [OpenAPI](https://openapis.org/) (or [Swagger](http://swagger.io/open-source-integrations/)) 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!

## ✨ 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.

```
   connexion run openapi.yaml
```

## 🫶 Sponsors

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

Explore the options »

## 🪤 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.

## ⚒️ How to Use

### Installation

You can install connexion using pip:

```
    $ 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:

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

### 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.

  ```
      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.

  ```
      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

  ```
      from asgi_framework import App
      from connexion import ConnexionMiddleware

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

### 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**

```
   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**

```
   ...
   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
```

### Running your application

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

```
    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:

```
    $ uvicorn run:app
```

Or with gunicorn:

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

---

Now you're able to run and use Connexion!

See the [examples](https://github.com/spec-first/connexion/blob/main/examples) folder for more examples.

## 📜 Changes

A full changelog is maintained on the [GitHub releases page](https://github.com/spec-first/connexion/releases).

## 🤲 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.

```
    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](https://github.com/spec-first/connexion/blob/main/docs/images/architecture.png).

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.

## 🙏 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](https://www.atlassian.com/blog/technology/spec-first-api-development)
- [API guidelines Zalando](https://opensource.zalando.com/restful-api-guidelines/#api-first)
- [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)

Tools to help you work spec-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)

## **Details **

<dl>

<dt>Version</dt>
<dd>3.3.0</dd>

<dt>License</dt>
<dd>Apache Software License</dd>

<dt>Python</dt>
<dd>&lt;4.0,&gt;=3.9</dd>

<dt>Maintainer</dt>
<dd>Robbe Sneyders</dd></dl>

## **Links**

- [Repository](https://github.com/spec-first/connexion)
- [View on PyPI](https://pypi.org/project/connexion/)

## **Maintainers **

- Robbe Sneyders · [robbe.sneyders@gmail.com](mailto:robbe.sneyders@gmail.com)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/connexion#webpage","@type":"WebPage","description":"Connexion - API first applications with OpenAPI/Swagger","name":"connexion","url":"https://pypx.app/packages/connexion","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/connexion"]}]},{"@id":"https://pypx.app/packages/connexion#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"Connexion - API first applications with OpenAPI/Swagger","license":"Apache Software License","name":"connexion","softwareVersion":"3.3.0"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
