Developer Tools

FastAPI 0.140.7 improves OpenAPI spec by avoiding dependency flattening

The popular Python framework removes a flattening step to generate cleaner API docs.

Deep Dive

FastAPI, the lightning-fast Python web framework with over 101K GitHub stars, has released version 0.140.7. The headline change is a refactor to avoid flattening dependencies when generating OpenAPI schemas (PR #16076 by creator Sebastián Ramírez @tiangolo). Previously, the framework would flatten dependency structures during OpenAPI generation, which could produce redundant or less accurate schema representations. By removing this flattening, the new release ensures that the OpenAPI specification more faithfully reflects the actual dependency tree of your endpoints. This is particularly beneficial for complex applications with deeply nested dependencies, leading to cleaner API documentation and potentially fewer client-side errors.

In addition to the core refactor, the release includes internal upgrades: the latest-changes tool has been bumped to version 0.7.1, and a new CI job for OpenAPI dependency benchmarks has been added (PR #16075). These improvements help maintain FastAPI's performance and reliability as the framework continues to evolve. While not a major version, this update demonstrates FastAPI's commitment to precision and developer experience. Users can upgrade via pip install fastapi==0.140.7 to benefit from more accurate OpenAPI specs and faster documentation generation.

Key Points
  • Refactored OpenAPI generation to avoid flattening dependencies, improving schema accuracy (PR #16076).
  • Upgraded internal latest-changes tool to version 0.7.1 for better changelog automation.
  • Added CI benchmarks for OpenAPI dependency generation to monitor performance regressions.

Why It Matters

Cleaner OpenAPI specs mean fewer integration bugs and more reliable API documentation for FastAPI developers.

📬 Get the top 10 AI stories daily