$ show spec-first/connexion
Connexion is a Python library and framework for building web APIs using an OpenAPI/Swagger-first approach. It consumes an OpenAPI (3.x) or Swagger (2.0) specification and automatically handles routing, request/response validation, security (API keys, OAuth2, Basic, Bearer, JWT), parameter injection, response serialization, and Swagger UI generation. The system supports both ASGI (via Starlette) and WSGI (via Flask) through a modular middleware stack, with pluggable validators, resolvers, and security handlers. It can be used as a standalone application (AsyncApp, FlaskApp) or as middleware (ConnexionMiddleware) wrapping an existing ASGI/WSGI app. The architecture is cleanly layered: middleware stack for cross-cutting concerns, operation abstraction for spec parsing, decorator chain for view function wrapping, and framework abstraction for Flask/Starlette integration. The codebase is well-structured, extensively tested, and actively maintained, making it a robust choice for spec-driven API development in Python.
The LLM identified 3 files worth highlighting for reuse:
Implements MediaTypeDict, a dict subclass with content-type-aware matching. It supports wildcard types (e.g., 'application/*'), quality factors, and case-insensitive keys. This is a self-contained, reusable data structure for media type negotiation, applicable in any HTTP framework or library that needs to match Accept/Content-Type headers against a set of supported types.
Provides a hierarchy of URI parsers (AbstractURIParser, OpenAPIURIParser, Swagger2URIParser, FirstValueURIParser, AlwaysMultiURIParser) that handle query, path, and header parameter parsing according to the OpenAPI/Swagger specification. Includes support for primitive types, arrays, and serialization styles (form, deepObject, etc.). The parsers are spec-aware, testable, and could be extracted for use in other OpenAPI tooling.
Contains JSON Schema validation logic with $ref resolution using a custom RefResolver. It validates request bodies, response bodies, and parameters against schema definitions from the OpenAPI spec. The validation is extensible and handles JSON Schema draft versions. This module is a standalone component for JSON Schema validation that could be reused in any Python project needing schema validation with reference resolution.