[feature/deprecation-headers 04037c9d] Add Deprecation, Sunset and successor Link response headers
 5 files changed, 1506 insertions(+), 3 deletions(-)
 create mode 100644 fastapi/middleware/deprecation.py
 create mode 100644 tests/test_deprecation_headers.py
commit 04037c9db05248a91e2e6236b57392d8c7317ac0
Author: Mavis <mavis@localhost>
Date:   Mon Sep 7 08:20:46 2026 +0000

    Add Deprecation, Sunset and successor Link response headers
    
    Extend the routing layer so API deprecations are detectable at runtime,
    not only in the OpenAPI schema:
    
    * Routes (and routers, include_router() calls and the FastAPI app) accept
      new sunset, deprecation_date and successor_url parameters, following the
      same nearest-ancestor inheritance rules as deprecated, which now also
      uses is-not-None precedence so route-level values always win.
    * Responses emit standards-based headers: Deprecation: true (or the
      deprecation date as an RFC 7231 HTTP-date, which takes precedence over
      deprecated=True), Sunset as an RFC 7231 HTTP-date, and
      Link: <url>; rel="successor-version". Existing Deprecation/Sunset
      headers are preserved (case-insensitively) and an existing Link header
      is merged per RFC 8288 list semantics.
    * OpenAPI operations expose x-deprecation-date, x-sunset (ISO 8601) and
      x-successor-url when configured.
    * New DeprecationTrackingMiddleware (fastapi.middleware.deprecation)
      tracks per-path deprecated_hits/sunset_hits for HTTP requests, with
      get_stats() (copy semantics) and reset_stats().

 fastapi/applications.py           | 424 +++++++++++++++++++++++++++++
 fastapi/middleware/deprecation.py |  77 ++++++
 fastapi/openapi/utils.py          |   6 +
 fastapi/routing.py                | 558 +++++++++++++++++++++++++++++++++++++-
 tests/test_deprecation_headers.py | 444 ++++++++++++++++++++++++++++++
 5 files changed, 1506 insertions(+), 3 deletions(-)
