Prompt
How do I add deprecation notices to API docs?
Latest observation
To add deprecation notices to API docs, the best approach depends on what documentation stack you use, but the general pattern is:
- Mark the API element as deprecated in code/spec
- Include a clear deprecation message in the docs
- State the replacement and timeline
- Keep it visible in generated docs and changelogs
Common ways to do it
1) OpenAPI / Swagger
Use the deprecated: true flag on an operation, parameter, or schema property.
paths:
/v1/users:
get:
deprecated: true
summary: List users
description: |
Deprecated. Use `/v2/users` instead.
You can also add:
descriptionwith migration guidancex-deprecation-dateor similar vendor extension- links to replacement endpoints
Example:
get:
deprecated: true
description: |
Deprecated as of 2026-01-01.
Use `GET /v2/users` instead.
Removal planned for 2026-07-01.
2) JavaScript/TypeScript docs
Use JSDoc @deprecated:
/**
* @deprecated Use getUserV2 instead.
*/
function getUser() {}
This often shows up in IDE tooltips and generated docs.
3) Python docs
Use docstrings plus warnings in runtime, and mention deprecation in the docstring:
def get_user():
"""
Deprecated. Use get_user_v2 instead.
"""
If appropriate, emit a DeprecationWarning when called.
4) Markdown / static docs
Add a prominent callout:
Deprecated: This endpoint will be removed on 2026-07-01. Use
GET /v2/usersinstead.
Or use your docs system’s alert/admonition syntax:
> **Deprecated**
> Use `/v2/users` instead. Removal planned for 2026-07-01.
5) SDK / language annotations
Many languages support deprecation annotations:
- Java:
@Deprecated - C#:
[Obsolete("Use ...")] - Go: doc comment starting with the symbol name and
Deprecated: ...
Example in Go:
// Deprecated: Use GetUserV2 instead.
func GetUser() {}
What a good deprecation notice should include
- What is deprecated
- Why / what to use instead
- When it will be removed
- Any migration steps
- Whether it still works for now
Example wording:
Deprecated:
GET /v1/usersis deprecated and will be removed on 2026-07-01. UseGET /v2/usersinstead. The response schema is mostly unchanged; only pagination differs.
Best practices
- Make it visible in generated docs and not buried in a changelog
- Be specific about the replacement
- Provide a timeline
- If possible, emit runtime warnings too
- Keep deprecation consistent across docs, SDKs, and API responses
If you tell me what docs format you’re using (OpenAPI, Swagger UI, Redoc, Docusaurus, MkDocs, etc.), I can show the exact syntax.