Skip to content

fix(api-v2): align openapi contract with prisma schema for destinatio…#29536

Open
GAURAV07C wants to merge 3 commits into
calcom:mainfrom
GAURAV07C:fix/schema-drift-v2
Open

fix(api-v2): align openapi contract with prisma schema for destinatio…#29536
GAURAV07C wants to merge 3 commits into
calcom:mainfrom
GAURAV07C:fix/schema-drift-v2

Conversation

@GAURAV07C

Copy link
Copy Markdown

Description

Fixes #29531
This PR resolves strict contract mismatches in the API v2 OpenAPI specification (openapi.json) by aligning the NestJS DTOs with the underlying Prisma schema.

✨ Key Fixes:

  • DestinationCalendar: Aligned API contract with Prisma schema by making previously required fields optional. OpenAPI previously marked these fields as required, but Prisma defines them as nullable, making the API contract overly strict compared to runtime behavior.
  • BookingReference: Updated API contract to reflect actual Prisma schema:
    • Renamed eventUiduid
    • Removed destinationCalendarId (not present in Prisma schema and not reliably populated at runtime).
    • ⚠️ Potential breaking change for external clients relying on legacy response shape.
  • CalVideoSettings: Removed sendTranscriptionEmails from the DTO as it does not exist in the Prisma schema and was incorrectly exposed in the API contract.

🛠 Infrastructure / Build Fix (unrelated to schema drift):

  • Fixed a MODULE_NOT_FOUND error blocking yarn generate-swagger execution in API v2 by explicitly re-exporting app-store properties from @calcom/platform-libraries/index.ts.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (API response shape updated: removed/renamed fields)

How Has This Been Tested?

  • Compared docs/api-reference/v2/openapi.json with packages/prisma/schema.prisma to verify drift resolution.
  • Ran yarn test in apps/api/v2 to verify no existing internal tests break due to destructive field removals (all 275 tests passed).
  • Verified yarn generate-swagger completes without build/import errors.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings or type errors (yarn type-check:ci --force passes)
  • I have run yarn biome check --write . to lint and format the changes

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @GAURAV07C! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e840629b-36e5-4828-b530-8765a2651455

📥 Commits

Reviewing files that changed from the base of the PR and between 3ed3cba and e5a5a9c.

📒 Files selected for processing (2)
  • apps/api/v2/src/modules/cal-unified-calendars/controllers/cal-unified-calendars.controller.ts
  • docs/api-reference/v2/openapi.json
✅ Files skipped from review due to trivial changes (1)
  • apps/api/v2/src/modules/cal-unified-calendars/controllers/cal-unified-calendars.controller.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/api-reference/v2/openapi.json

📝 Walkthrough

Walkthrough

This PR re-exports app-store symbols from packages/platform/libraries, updates imports to use the new public entry point, replaces BookingReference's eventUid/destinationCalendarId with uid in DTOs/services/docs, removes CalVideoSettings.sendTranscriptionEmails from types and service mapping, marks several DestinationCalendar fields as optional with matching Swagger decorators, updates controller ApiParam descriptions to reference bookingReference.uid, and removes INSTANT_MEETING from webhook trigger enums in the OpenAPI spec.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(api-v2): align openapi contract with prisma schema for destinatio…' clearly summarizes the main change: aligning the API v2 OpenAPI specification with the Prisma schema.
Description check ✅ Passed The description comprehensively explains the PR's purpose, detailing fixes to DestinationCalendar, BookingReference, and CalVideoSettings to align OpenAPI contracts with the Prisma schema, plus infrastructure fixes for module exports.
Linked Issues check ✅ Passed The PR directly addresses all three contract mismatches identified in issue #29531: DestinationCalendar fields marked optional, BookingReference uid/eventUid renaming and destinationCalendarId removal, and CalVideoSettings sendTranscriptionEmails removal.
Out of Scope Changes check ✅ Passed All changes are in-scope: DTOs and OpenAPI spec updates directly address schema drift, while the module re-exports fix unblocks yarn generate-swagger needed for the PR's core objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/api/v2/src/platform/calendars/outputs/connected-calendars.output.ts (1)

209-211: ⚠️ Potential issue | 🟡 Minor

Align DestinationCalendar.id DTO type with Prisma and caching.

apps/api/v2/src/platform/calendars/outputs/connected-calendars.output.ts declares id!: number | string with @IsInt(), but DestinationCalendar’s Prisma model uses id Int, and getConnectedDestinationCalendarsAndEnsureDefaultsInDb populates destinationCalendar directly from Prisma create/update results; the API also caches the whole object in Redis using JSON.stringify/parse, which preserves numbers. Since id should be numeric, the | string union is misleading (and would break if response validation runs). Change the DTO to id!: number.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/api/v2/src/platform/calendars/outputs/connected-calendars.output.ts`
around lines 209 - 211, Change the DestinationCalendar DTO property to a
numeric-only id: remove the union type and declare id as number (i.e., change
id!: number | string to id!: number) so it matches the Prisma model (id Int),
the Redis JSON cached objects, and the `@IsInt`() validation; update the
declaration in connected-calendars.output.ts for the
DestinationCalendar/connected calendar output class (the id property) and ensure
any related usages (e.g., getConnectedDestinationCalendarsAndEnsureDefaultsInDb
consumers) expect a number.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/api-reference/v2/openapi.json`:
- Around line 1964-1968: Update the OpenAPI description for the path parameter
"eventUid" to explicitly state that callers must populate this calendar eventId
from the booking reference object's "uid" field returned by GET
/v2/bookings/{bookingUid}/references (the response no longer contains
"eventUid"); apply the same wording change to all other "eventUid" parameter
descriptions in the spec so they reference booking reference "uid" instead of
"eventUid".

---

Outside diff comments:
In `@apps/api/v2/src/platform/calendars/outputs/connected-calendars.output.ts`:
- Around line 209-211: Change the DestinationCalendar DTO property to a
numeric-only id: remove the union type and declare id as number (i.e., change
id!: number | string to id!: number) so it matches the Prisma model (id Int),
the Redis JSON cached objects, and the `@IsInt`() validation; update the
declaration in connected-calendars.output.ts for the
DestinationCalendar/connected calendar output class (the id property) and ensure
any related usages (e.g., getConnectedDestinationCalendarsAndEnsureDefaultsInDb
consumers) expect a number.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e8f509b4-9ac1-4ff4-a83b-38349a03b315

📥 Commits

Reviewing files that changed from the base of the PR and between a216f6b and 3ed3cba.

📒 Files selected for processing (8)
  • apps/api/v2/src/filters/calendar-service-exception.filter.ts
  • apps/api/v2/src/platform/bookings/2024-08-13/outputs/booking-references.output.ts
  • apps/api/v2/src/platform/bookings/2024-08-13/services/output-booking-references.service.ts
  • apps/api/v2/src/platform/calendars/outputs/connected-calendars.output.ts
  • apps/api/v2/src/platform/event-types/event-types_2024_06_14/services/input-event-types.service.ts
  • docs/api-reference/v2/openapi.json
  • packages/platform/libraries/index.ts
  • packages/platform/types/event-types/event-types_2024_06_14/inputs/create-event-type.input.ts
💤 Files with no reviewable changes (1)
  • packages/platform/types/event-types/event-types_2024_06_14/inputs/create-event-type.input.ts

Comment thread docs/api-reference/v2/openapi.json
@CLAassistant

CLAassistant commented Jun 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API v2 reference: DestinationCalendar marks nullable DB fields as required; BookingReference documents fields that don't exist on the model

2 participants