-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
feature: api documentation versioning #5676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds slug-based versioning to the PublishedDocs model, enabling multiple versions of the same documentation to be published under a common slug identifier. The changes migrate from an ID-based URL scheme (/view/{id}/{version}) to a slug-based scheme (/view/{slug}/{version}), improving URL stability and user experience when publishing multiple versions of API documentation.
Key changes:
- Added
slugfield toPublishedDocswith a unique constraint on[slug, version] - Implemented slug generation logic that reuses slugs for the same collection across versions
- Added new REST endpoint
/published-docs/slug/:slug/:versionfor slug-based access - Removed
TreeLevelquery parameter (collections now always export with full tree)
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
prisma/schema.prisma |
Added slug field with unique constraint on [slug, version] and index on collectionID |
prisma/migrations/20251207122817_add_slug_to_published_docs/migration.sql |
Migration to add slug column, handle duplicates, and create indexes |
published-docs/published-docs.model.ts |
Added PublishedDocsVersion model and slug/versions fields to PublishedDocs |
published-docs/published-docs.service.ts |
Added getOrGenerateSlug(), getPublishedDocsVersions(), getPublishedDocBySlugPublic() methods; updated URL generation to use slug |
published-docs/published-docs.service.spec.ts |
Added comprehensive tests for new slug-based functionality and version retrieval |
published-docs/published-docs.resolver.ts |
Added versions field resolver for GraphQL |
published-docs/published-docs.controller.ts |
Added slug-based endpoint /slug/:slug/:version; deprecated ID-based endpoint |
published-docs/published-docs.dto.ts |
Removed TreeLevel enum and GetPublishedDocsQueryDto class (no longer needed) |
user-collection/user-collection.service.ts |
Removed withChildren parameter from exportUserCollectionToJSONObject() (always exports full tree) |
team-collection/team-collection.service.ts |
Removed withChildren parameter from exportCollectionToJSONObject() (always exports full tree) |
prisma/prisma.service.ts |
Enhanced acquireLocks() and lockTableExclusive() to support non-public database schemas |
mock-server/mock-server.service.spec.ts |
Code formatting improvements (no functional changes) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes BE-685
What's changed
Backend Changes
Adds stable slugs to PublishedDocs and a new public endpoint to fetch docs by slug and version, enabling consistent URLs and version lists. The old id-based endpoint remains but is deprecated.
New Features
slug=idand removes duplicate docs per collection+version.PublishedDocsincludesslugandversions[]resolver returns all versions for the slug.createPublishedDocreuses a collection’s slug for new versions, retries on unique constraint races, and snapshots documentTree whenautoSync=false.Database Migration
pnpx prisma migrate deployFrontend Changes
Notes to reviewers
Run DB migration.
Summary by cubic
Adds stable slugs to PublishedDocs and a new public endpoint to fetch docs by slug and version, enabling consistent URLs and version lists. The old id-based endpoint remains but is deprecated.
New Features
Migration
Written for commit 5b4bf5b. Summary will update automatically on new commits.