docs(api): document 403 on permission-gated routes#884
Conversation
Every operation in openapi.yaml whose handler calls requirePermission now declares '403: $ref: "#/components/responses/Forbidden"' alongside the existing 401. 27 operations updated across dashboard, config, recommendations, plans, planned-purchases, purchases, history, and api-keys sections. The components/responses/Forbidden component already existed (used in the users/groups section); this change wires it consistently across all remaining permission-gated routes. Adds openapi_403_test.go: a source-reading regression guard that walks router.go to map each route's handler wrapper to its delegate h.* function, then checks whether that function calls requirePermission, and asserts the spec operation declares 403. The test fails as soon as a new permission-gated route is wired in router.go without a matching 403 in the spec.
|
Warning Review limit reached
More reviews will be available in 17 minutes and 25 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Closes #476
Summary
403: $ref: '#/components/responses/Forbidden'to 27 operations ininternal/api/openapi.yamlwhose handlers callrequirePermission()but previously only declared401components/responses/Forbiddencomponent (already present in users/groups section)internal/api/openapi_403_test.go: a source-reading regression guard that walks router.go to resolve each route's delegate handler, checks whether it callsrequirePermission, and asserts the spec operation declares 403 -- the test fails immediately when a new permission-gated route is added without the matching 403Test plan
go test ./internal/api/ -run TestOpenAPI403OnPermissionGatedRoutespassesgo test ./internal/api/...passes (1356 tests)requirePermissionwithout a 403 in the spec and confirm the test fails