gitmyhub

connexion

Python ★ 4.6k updated 28d ago

Connexion is a modern Python web framework that makes spec-first and api-first development easy.

A Python web framework where you write your API description as a YAML file first, and the framework automatically wires up routes, validates every request, and generates live interactive documentation, no manual boilerplate required.

PythonOpenAPIYAMLFlaskAsyncIOsetup: easycomplexity 3/5

Connexion is a Python web framework built around the idea of writing an API description document first, then having the framework wire up everything else. The description format it uses is called OpenAPI (sometimes still called Swagger), which is a standard way of defining what URLs your API has, what parameters each one accepts, what authentication it requires, and what responses it returns.

In a typical web framework you write code first: you create a function, attach a route decorator to it, add validation by hand, and later generate documentation as an afterthought. Connexion reverses this. You write the specification file in YAML format, point Connexion at it, and the framework automatically registers your routes, validates incoming requests against the rules you described, handles authentication separately from your business logic, and makes sure responses match the shape you declared.

Your Python functions stay clean because Connexion extracts the parameters from each request and passes them directly as function arguments. You return a plain Python object or a string; Connexion handles turning it into a proper HTTP response. A built-in Swagger UI is optionally included, giving you a browser-based page where you can read the live documentation for your API and test each endpoint interactively.

The framework can run as a standalone application using either a lightweight async mode or a Flask-compatible mode for teams already invested in the Flask ecosystem. It can also wrap an existing application built in another framework, adding Connexion's validation and routing on top without replacing the underlying code.

A command-line tool lets you run and mock a specification file before writing any application code, which is useful for agreeing on an API contract with other teams early in a project. The project is open source under the Apache 2.0 license.

Where it fits