feat(api): server swagger docs - #102
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Warning Review limit reached
Next review available in: 46 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesSwagger UI 서빙 및 StaffingRules OpenAPI 정의
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@apps/api/src/app.ts`:
- Around line 44-48: Remove the Swagger UI authorization persistence from the
setup in app.ts: the swaggerUi.setup call currently passes
swaggerOptions.persistAuthorization: true, which stores auth data in browser
storage. Update that swaggerOptions block so persistAuthorization is omitted or
set to false, keeping the rest of the SwaggerUi setup unchanged.
In `@docs/openapi.yaml`:
- Around line 464-523: The StaffingRules OpenAPI contract is missing the
domain-specific 400 error cases for create/update minimum staffing rules. Update
the minimum staffing rule paths in openapi.yaml so the
`createMinimumStaffingRule` and `updateMinimumStaffingRule` responses explicitly
document `CLOSED_DAY` and `INVALID_TIME_RANGE` alongside the existing
`ValidationError`, using either dedicated response components or clear examples
under the `MinimumStaffingRule` endpoints. Keep the change anchored around
`createMinimumStaffingRule`, `updateMinimumStaffingRule`, and the `400` response
definitions so Swagger exposes the same error contract as docs/API.md.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3c240d55-d2c9-40c2-9fff-2acfbffe9408
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (8)
.env.exampleapps/api/package.jsonapps/api/src/app.tsapps/api/src/openapi.tsapps/api/test/docs.routes.test.tsdocs/SWAGGER.mddocs/openapi.yamlpackage.json
meteorqz6
left a comment
There was a problem hiding this comment.
Addressed the review comments in 90c2e74.
- Removed Swagger UI
persistAuthorizationso auth data is not persisted in browser storage. - Added
MinimumStaffingRuleBadRequestOpenAPI response examples forVALIDATION_ERROR,CLOSED_DAY, andINVALID_TIME_RANGE. - Added route tests covering both changes.
Verified with:
corepack pnpm --filter @fragment/api lintcorepack pnpm --filter @fragment/api typecheckcorepack pnpm --filter @fragment/api testcorepack pnpm build:api
meteorqz6
left a comment
There was a problem hiding this comment.
Fixed the mismatched Swagger error examples in 5e12f4b.
What changed:
- Added explicit examples for common
400,401,403, and404response components so Swagger no longer falls back to the genericVALIDATION_ERRORschema example. - Added dedicated
409response components for duplicate email, organization already exists, draft already exists, and schedule conflict. - Added a docs route test that walks all OpenAPI response examples and fails if
example.statusCodedoes not match the documented HTTP response code.
Verified with:
corepack pnpm --filter @fragment/api lintcorepack pnpm --filter @fragment/api typecheckcorepack pnpm --filter @fragment/api testcorepack pnpm build:api
5e12f4b to
49ee4c1
Compare
meteorqz6
left a comment
There was a problem hiding this comment.
Fixed the CI failure in 49ee4c1.
Root cause:
- The
Lint & Type Checkjob failed atpnpm format:check, not API lint/typecheck. apps/api/test/docs.routes.test.tsneeded Prettier formatting after the OpenAPI response-example test was added.
Re-verified locally with the CI sequence:
corepack pnpm format:checkcorepack pnpm --filter @fragment/shared buildcorepack pnpm --filter @fragment/database db:generatecorepack pnpm --filter @fragment/database buildcorepack pnpm --filter @fragment/web lint(existing warning only, exit 0)corepack pnpm --filter @fragment/web typecheckcorepack pnpm --filter @fragment/web testcorepack pnpm --filter @fragment/api lintcorepack pnpm --filter @fragment/api typecheckcorepack pnpm --filter @fragment/api test
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/api/test/docs.routes.test.ts`:
- Around line 22-31: The docs route test currently skips over broken $ref
responses because resolveOpenApiRef() can return undefined and the loop just
continues in the docs.routes.test.ts check. Update the response validation in
the block that iterates over responses so that when responseDefinition.$ref is
present, the test first asserts the ref resolves successfully before checking
application/json; use resolveOpenApiRef, responseDefinition.$ref, and
jsonContent as the key symbols to locate the logic. This should fail the test
immediately for any unresolved `#/components/responses/`... reference instead of
silently passing.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 17ef2712-d001-40d9-b1d5-67b4f6322723
📒 Files selected for processing (3)
apps/api/src/app.tsapps/api/test/docs.routes.test.tsdocs/openapi.yaml
💤 Files with no reviewable changes (1)
- apps/api/src/app.ts
meteorqz6
left a comment
There was a problem hiding this comment.
Reviewed the latest CodeRabbit comment and decided to apply it.
Reason:
- The finding is valid: if an OpenAPI response
$refis misspelled, the existing helper could resolve toundefinedand skip the check becausejsonContentwas missing.
Change pushed in ddbc50a:
- Assert that every response
$refresolves before checking JSON examples.
Verified:
corepack pnpm format:checkcorepack pnpm --filter @fragment/api test -- docs.routes.test.ts
Summary
/api/docs/api/openapi.jsonAPI_PUBLIC_BASE_URLas the first OpenAPI server for deployed environmentsdocs/openapi.yamlVerification
corepack pnpm build:apicorepack pnpm --filter @fragment/api lintcorepack pnpm --filter @fragment/api typecheckcorepack pnpm --filter @fragment/api testDeploy Notes
API_PUBLIC_BASE_URL=https://<api-domain>/apimain, verify/api/docsand/api/openapi.jsonon the deployed API domainSummary by CodeRabbit
/api/openapi.json)도 확인할 수 있습니다.API_PUBLIC_BASE_URL환경 변수로 정확히 반영하도록 개선했습니다.