Deprecated Decorator

Explicitly mark endpoints as deprecated to signal upcoming removal to clients.

Usage

The @deprecated decorator adds standard headers to inform clients about the deprecation status and alternative endpoints.

routes/legacy.py
from jec_api.decorators import deprecated

@deprecated("Use /v2/users instead", alternative="/v2/users", sunset="2025-06-01")
async def get_users_old():
    ...

Side Effects

  • Adds Deprecation: true header.
  • Adds Sunset: <date> header if provided.
  • Adds X-Deprecation-Alternative: <path> header if provided.

Signature

def deprecated(
    message=None, *, 
    alternative: str = None, 
    sunset: str = None
)
  • message: Human-readable deprecation notice for clients.
  • alternative: Path or URL to the replacement endpoint.
  • sunset: ISO 8601 date string indicating when the endpoint will be removed.