Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@mirarifhasan
Copy link
Contributor

@mirarifhasan mirarifhasan commented Dec 8, 2025

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

  • Added slug to PublishedDocs with unique (slug, version); migration backfills slug=id and removes duplicate docs per collection+version.
  • New public endpoint: GET /published-docs/:slug/:version; id-based route kept but deprecated.
  • GraphQL: PublishedDocs includes slug and versions[] resolver returns all versions for the slug.
  • createPublishedDoc reuses a collection’s slug for new versions, retries on unique constraint races, and snapshots documentTree when autoSync=false.
  • URL generation now uses slug/version.

Database Migration

  • Run pnpx prisma migrate deploy

Frontend 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

    • Added slug to PublishedDocs with unique (slug, version); migration backfills slug=id and removes duplicate docs per collection+version.
    • New public endpoint: GET /published-docs/:slug/:version; id-based route kept but deprecated.
    • GraphQL: PublishedDocs includes slug and versions[]; resolver returns all versions for the slug.
    • createPublishedDoc reuses a collection’s slug for new versions, retries on unique constraint races, and snapshots documentTree when autoSync=false.
    • URL generation now uses slug/version.
    • PrismaService: validate DB schema and use schema-qualified locks to support non-public schemas.
  • Migration

    • Run prisma migrate; existing docs get slugs and duplicates are cleaned (keeps most recent).
    • Update clients to use the slug-based endpoint and show versions; the tree query param is removed.
    • Existing id-based links still work for now but should be moved to slug URLs.

Written for commit 5b4bf5b. Summary will update automatically on new commits.

Copy link
Contributor

Copilot AI left a 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 slug field to PublishedDocs with 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/:version for slug-based access
  • Removed TreeLevel query 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.

@mirarifhasan mirarifhasan changed the title feat: add slug to PublishedDocs and update API endpoints feature: api documentation versioning Dec 9, 2025
@mirarifhasan mirarifhasan self-assigned this Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.