Prompt
I'm building versioned API docs with deprecation support, any recommendations?
Latest observation
Yes — a few practical recommendations will make versioned API docs with deprecation support much easier to maintain and much clearer for consumers.
1) Treat the API as a contract, not just documentation
Your docs should be generated from a source of truth whenever possible:
- OpenAPI/Swagger for REST
- AsyncAPI for events
- GraphQL schema + custom directives for GraphQL
- Protocol Buffers/gRPC descriptors for RPC
This helps keep versioned docs accurate and reduces drift.
2) Make versioning explicit and consistent
Pick one versioning strategy and apply it everywhere:
- URL versioning:
/v1/...,/v2/... - Header versioning:
Accept: application/vnd.company.v1+json - Query param versioning: usually less ideal for long-term support
For docs:
- Separate docs per major version
- Clearly label the “current”, “latest”, and “legacy” versions
- Show the supported versions in a visible place on every page
3) Deprecate in phases
A good deprecation lifecycle is:
- Announce
Mark the field/endpoint as deprecated in docs and schema. - Warn
Add response headers and changelog notices. - Sunset
Provide a date or version when removal will happen. - Remove
Actually delete it only after the promised window.
Useful metadata to include:
- Deprecated since
- Replacement / migration path
- Removal date or target version
- Impact level
4) Surface deprecation in the schema itself
If you use OpenAPI:
- Mark operations, parameters, and schemas with
deprecated: true - Add descriptions like “Use
newFieldinstead” - Consider extension fields for richer deprecation metadata, e.g.:
x-deprecated-sincex-removal-datex-replacementx-migration-guide
That makes it possible for both humans and tooling to detect deprecation.
5) Add strong changelog and migration-guide support
Docs should not just say “deprecated” — they should answer:
- Why is this being deprecated?
- What should I use instead?
- How do I migrate?
- What changes in behavior, not just names?
Recommended structure:
- Version overview page
- Breaking changes page
- Deprecations page
- Migration guides per version bump
- Endpoint-level change history
6) Show deprecation visually and contextually
In the UI:
- Use warning callouts for deprecated endpoints/fields
- Badge deprecated items prominently
- Strike-through sparingly; warnings are clearer than decoration
- Show replacement links next to deprecated elements
- Collapse old versions by default, but keep them accessible
7) Include runtime deprecation signals in API responses
This helps clients discover deprecations without reading docs:
Deprecation: trueor equivalent deprecation metadataSunset: <date>header if you follow RFC 8594Link: <...>; rel="deprecation"or migration docs link
This is especially useful for clients that are not actively reading your docs.
8) Support diffing between versions
A “what changed?” view is extremely useful:
- Added endpoints/fields
- Removed endpoints/fields
- Renamed fields
- Changed behavior/defaults
- Deprecated items
Automated version-to-version diffs reduce support burden significantly.
9) Preserve old docs, but keep them clearly labeled
Don’t delete old docs immediately. Instead:
- Freeze old version docs
- Mark them as maintenance-only
- Add a banner like “This version is deprecated and will be removed on YYYY-MM-DD”
- Link users to the newer version
This balances stability and discoverability.
10) Provide examples for both old and new behavior
Examples are often more valuable than reference text. For deprecated APIs, include:
- Old request/response example
- New request/response example
- Side-by-side migration example
11) Automate checks in CI
Add tests/lints for docs quality:
- Every deprecated item must have a replacement or removal date
- No undocumented breaking changes
- Version numbers in docs match API spec
- Old docs pages still resolve
- Changelog entries exist for schema changes
12) Be careful with “minor” versioning promises
If you publish docs for v1.1, v1.2, etc., be clear whether:
- Minor versions are backward compatible
- Minor releases can still introduce new optional fields
- Deprecations can happen within a major version
Many teams find major-version docs + changelog/release notes simpler than exposing every internal release as a separate doc version.
A good minimal deprecation policy template
You can publish a policy like:
We provide at least 90 days notice before removing deprecated endpoints or fields. Deprecated items are marked in the docs and schema, include a replacement where available, and may emit deprecation and sunset headers at runtime.
That makes expectations clear to API consumers.
If you want a practical implementation pattern
A common setup is:
- One OpenAPI spec per major version
- Shared components reused across versions
- Custom extensions for deprecation metadata
- Docs site renders:
- Version selector
- Deprecated badges
- Changelog
- Migration guides
- Sunset notices
If you want, I can also suggest:
- a sample OpenAPI deprecation metadata pattern,
- a docs site structure for versioned APIs, or
- a deprecation policy template you can copy-paste.