Registry / web-framework / connexion

connexion

JSON →
library3.3.0pypypi✓ verified 30d ago

Connexion is a modern Python web framework that facilitates API-first development using OpenAPI (formerly Swagger) specifications. It automatically handles routing, request validation, authentication, parameter parsing, and response serialization based on your specification. Version 3.3.0 is the latest stable release, offering a modular, ASGI-compatible architecture with support for both Flask (WSGI) and Starlette (ASGI) backends. The library maintains an active release cadence, frequently publishing updates and new features.

pip install connexion
INSTALL
IMPORT
SIG · CONNEXION
C
connexion
web-frameworkpythonv3.3.0
Install
4.5s avg
Import
1295ms
Disk
53MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.925 runs
installs and imports cleanly · install 0.0s · import 1.351s · 50.4MB
glibc
py 3.10–3.925 runs
installs and imports cleanly · install 4.5s · import 1.239s · 54MB
53MB installed
● package 53MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AsyncApp
✓ from connexion import AsyncApp
✗ from connexion import App # App is alias for FlaskApp unless explicitly configured otherwise in older versions
AsyncApp is the recommended standalone application for new ASGI projects in v3+. For Flask-based apps, use FlaskApp.
FlaskApp
✓ from connexion import FlaskApp
Used for Flask-based (WSGI) applications, especially when migrating from Connexion 2.x.
ConnexionMiddleware
✓ from connexion import ConnexionMiddleware
Use to wrap an existing ASGI or WSGI application with Connexion's spec-first capabilities.
request
✓ from connexion import request
The global request object. In v3, this is a Starlette Request when using AsyncApp, unlike Flask Request in v2.x.

This quickstart demonstrates how to create a simple 'Hello World' API using Connexion's `AsyncApp` (ASGI backend). It defines an API using an `openapi.yaml` specification file and links an operation to a Python function. The application can be run using `uvicorn` (e.g., `uvicorn app:app --reload` from the command line, assuming the Python file is named `app.py`). Ensure `openapi.yaml` is in the same directory as `app.py`.

import connexion from pathlib import Path # app.py def get_hello(): return {"message": "Hello from Connexion!"}, 200 # Create the Connexion app using AsyncApp for ASGI compatibility # and look for the OpenAPI spec in the current directory. app = connexion.AsyncApp(__name__, specification_dir='.') # Add the API defined in openapi.yaml app.add_api('openapi.yaml') # To run the application (requires 'pip install connexion[uvicorn]') # if __name__ == "__main__": # import uvicorn # uvicorn.run(app, host="0.0.0.0", port=8080) # For external running (e.g., via command line: uvicorn app:app --reload) # Define your OpenAPI spec in openapi.yaml in the same directory: # openapi: 3.0.0 # info: # title: Simple Hello API # version: 1.0.0 # paths: # /hello: # get: # operationId: app.get_hello # Links to the get_hello function in app.py # responses: # '200': # description: A greeting # content: # application/json: # schema: # type: object # properties: # message: # type: string
Debug
Known issues
breakingConnexion 3.x introduced fundamental changes by adopting the ASGI interface, dropping Aiohttp support entirely. This significantly changes how applications are created and run, favoring `AsyncApp` (Starlette-based) for new asynchronous projects and `FlaskApp` (Flask-based) for WSGI compatibility or migration.
fix
For new projects, use `connexion.AsyncApp` and `pip install connexion[starlette]`. For migrating from 2.x, consider switching to `AsyncApp` or explicitly use `connexion.FlaskApp` and `pip install connexion[flask]`. Review the official migration guide for detailed steps.
affects: >=3.0.0
breakingThe global `connexion.request` object now represents a Starlette `Request` when using `AsyncApp` in Connexion 3.x, instead of a Flask `Request` as in 2.x. This impacts direct access to request attributes and methods.
fix
Adjust code that directly accesses `connexion.request` attributes to be compatible with Starlette's `Request` object if using `AsyncApp`. If relying on Flask-specific request features, ensure you are using `FlaskApp`.
affects: >=3.0.0
breakingPython 3.6 support was dropped in Connexion 3.x, and the minimum required Python version is now 3.9.
fix
Upgrade your Python environment to 3.9 or higher. The current PyPI metadata indicates `>=3.9, <4.0`.
affects: >=3.0.0
gotchaConnexion 3.x changed how `uri_parser_class` and `jsonifier` are passed. They are now arguments directly to the `App` constructor or `add_api()` method, rather than through an `options` dictionary or by setting attributes on the `Api` object.
fix
Update your application initialization to pass `uri_parser_class` and `jsonifier` directly as keyword arguments: `app = AsyncApp(__name__, uri_parser_class=MyParser, jsonifier=MyJsonifier)` or `app.add_api('spec.yaml', uri_parser_class=MyParser)`.
affects: >=3.0.0
gotchaConnexion 3.x no longer attempts to guess a content type for response serialization if multiple content types are defined in the OpenAPI specification for a given response.
fix
Ensure your API implementation explicitly returns data in the format matching one of the declared content types in your OpenAPI specification, especially for endpoints with multiple `produces` entries.
affects: >=3.0.0
gotchaThe application failed to start because the OpenAPI specification file (e.g., `openapi.yaml`) was not found at the specified path during `app.add_api()`. This is a critical error preventing Connexion from loading your API definition.
fix
Ensure that the OpenAPI specification file exists at the path provided to `app.add_api()` and is accessible by the application. Verify the file path is correct relative to the application's working directory or use an absolute path.
affects: >=3.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'connexion.apps.flask_app'
This error typically occurs when migrating from Connexion 2.x to 3.x, or when using generated code from older versions, as the internal module structure changed significantly in Connexion 3.x.
fix
Update your import statements to reflect the new Connexion 3.x structure, for example, use `from connexion import FlaskApp` instead of `from connexion.apps.flask_app import FlaskApp`. Ensure `connexion` is installed with the `flask` extra: `pip install 'connexion[flask]'`.
TypeError: <operation_id>() missing 1 required positional argument: '<parameter_name>'
Connexion could not correctly map a parameter from the incoming HTTP request (often a request body or a complex query/form parameter) to the corresponding argument in your Python handler function.
fix
For request bodies, add the `x-body-name: <parameter_name>` extension to your OpenAPI `requestBody` schema to explicitly name the parameter that Connexion should pass to your handler function. Ensure parameter names in your Python function signature exactly match those defined in the OpenAPI spec.
AttributeError: module '<module_name>' has no attribute '<operation_id>'
Connexion cannot find the Python function specified by the `operationId` in your OpenAPI document within the provided module path, usually due to a typo in the `operationId` or an incorrect module path.
fix
Carefully check the `operationId` in your OpenAPI specification for typos and ensure it exactly matches the Python function name. Verify that the Python module path (specified in `x-swagger-router-controller` or derived from `operationId`) is correct and resolvable from your application's execution context, and that the function is indeed defined and importable within that module.
connexion: Failed to find Flask application or factory in module "<module_name>"
When running a Connexion application with the Flask backend, Flask's CLI or a WSGI server cannot locate the application instance if it's not named 'app' or 'application' at the top level of the specified module, or if the `FLASK_APP` environment variable is not set correctly.
fix
Ensure your `connexion.FlaskApp` instance is assigned to a top-level variable named `app` or `application` in your main application module (e.g., `app = connexion.FlaskApp(__name__)`). Alternatively, set the `FLASK_APP` environment variable to point to your specific application instance (e.g., `export FLASK_APP=your_module:your_app_instance_name`).
Upgrade
Version history
3.3.0latest on PyPI · released Oct 13, 2025
Audit
Dependencies
packagingrequiredCore dependency for version parsing, explicitly added in v2.15.1.
FlaskoptionalOptional backend for synchronous (WSGI) applications, via `FlaskApp`.
StarletteoptionalOptional backend for asynchronous (ASGI) applications, via `AsyncApp`.
uvicornoptionalOptional dependency to run Connexion applications (especially `AsyncApp`) in development.
swagger-ui-bundleoptionalOptional dependency to enable the interactive Swagger UI.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
connexion — pip install connexion · libregistry