Skip to content

[CSM Portal] Align GET /cases/{id} OpenAPI spec with entity-service - #819

Merged
cloby99 merged 3 commits into
wso2-open-operations:v2from
Rashmika998:task/csm-portal-get-case-by-id
Jun 7, 2026
Merged

cloby99 merged 3 commits into
wso2-open-operations:v2from
Rashmika998:task/csm-portal-get-case-by-id

Conversation

@Rashmika998

@Rashmika998 Rashmika998 commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Aligns the CSM portal GET /cases/{id} OpenAPI spec with the entity-service contract introduced in [Customer Entity] Add GET /cases/{id} endpoint #818
  • Adds format: uuid to the path parameter (entity-service validates UUID format server-side → 400)
  • Adds a typed 200 response body referencing the Case schema
  • Adds 400 (malformed UUID), 403, 404, and 500 responses with ErrorPayload schema references
  • Handler logic is unchanged — the existing raw passthrough with next_states injection continues to work

Test plan

  • Existing TestGetCase subtests continue to pass (auth, empty ID, happy path, upstream errors, next_states injection)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated API specification with improved parameter format validation for the cases endpoint. Enhanced response documentation with comprehensive schemas and descriptive status information across all response scenarios.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Rashmika998, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 18 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 567c939d-c36d-4fd3-8055-eddcf0cf44c2

📥 Commits

Reviewing files that changed from the base of the PR and between c65af89 and b9aac29.

📒 Files selected for processing (4)
  • apps/csm-portal/backend/CLAUDE.md
  • apps/csm-portal/backend/internal/handler/cases.go
  • apps/csm-portal/backend/internal/handler/cases_test.go
  • apps/csm-portal/backend/openapi.yaml
📝 Walkthrough

Walkthrough

The GET /cases/{id} endpoint specification in the OpenAPI schema is updated to enforce UUID format on the {id} path parameter and document structured JSON response bodies with explicit schemas for success and error cases.

Changes

Cases Endpoint API Contract

Layer / File(s) Summary
GET /cases/{id} API contract
apps/csm-portal/backend/openapi.yaml
The {id} path parameter is constrained to UUID format, and all response statuses (200/400/401/403/404/500) are documented with explicit application/json response bodies: Case schema for 200 responses and ErrorPayload schema for error statuses, accompanied by enhanced status descriptions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • wso2-open-operations/cs-tools#38: Both PRs update the "GET /cases/{id}" contract by aligning the cases-by-ID API behavior and response schemas through OpenAPI specification and endpoint implementation.
  • wso2-open-operations/cs-tools#812: The main PR explicitly documents the Case schema in OpenAPI responses, which is the same schema extended by the retrieved PR with a next_states computed field.
  • wso2-open-operations/cs-tools#202: Both PRs affect the Case/case-response contract: the main PR documents it in OpenAPI, while the retrieved PR modifies the backend response shape with additional fields.

Suggested labels

Type/Improvement, App/CSM Portal, Area/Backend

Suggested reviewers

  • cloby99
  • v15a1

Poem

🐰 An OpenAPI tale unfolds so clear,
UUID formats drawing boundaries dear,
Case schemas strutting with ErrorPayload grace,
Each response now documented in its place! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides a clear summary of changes and test plan, but is missing several required sections from the template such as Purpose, Goals, Approach, Release notes, and other organizational requirements. Add missing template sections including Purpose (with issue links), Goals, Approach, Release notes, and other required sections. Alternatively, document why sections are not applicable to this change.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: aligning the GET /cases/{id} OpenAPI spec with the entity-service, which is the primary focus of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@Rashmika998 Rashmika998 self-assigned this Jun 7, 2026
@Rashmika998 Rashmika998 added Type/New Feature Represents a request or task for a new feature Type/Improvement Marks enhancements or improvements to existing features Area/Backend App/CSM Portal labels Jun 7, 2026

@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: 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/csm-portal/backend/openapi.yaml`:
- Around line 86-90: The path parameter "id" in the POST endpoints
/cases/{id}/comments and /cases/{id}/comments/search is missing the UUID format;
update the parameter schema for the path parameter named id in both handler
definitions to include format: uuid (matching the GET /cases/{id} parameter) so
all case ID parameters consistently declare type: string and format: uuid for
validation and codegen.
- Around line 86-90: GetCase currently only checks for empty caseID and relies
on OpenAPI docs for UUID validity; add explicit UUID parsing/validation in
internal/handler/cases.go (e.g., in GetCase or a shared helper used by GetCase)
using a UUID parser (uuid.Parse/ParseUUID) and return a 400 with a clear
malformed-UUID error when parsing fails; update internal/handler/response.go to
ensure that malformed-UUID returns the intended ErrMsgBadRequest (or add a
specific error message constant) and extend internal/handler/cases_test.go with
a test case for a malformed UUID to assert the handler returns 400 and the
expected error message.
🪄 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: CHILL

Plan: Pro

Run ID: 97cdfca6-d77a-4e91-bafb-9edb86dc665d

📥 Commits

Reviewing files that changed from the base of the PR and between 73ae327 and c65af89.

📒 Files selected for processing (1)
  • apps/csm-portal/backend/openapi.yaml

Comment thread apps/csm-portal/backend/openapi.yaml
@Rashmika998
Rashmika998 force-pushed the task/csm-portal-get-case-by-id branch from c65af89 to 6f3d461 Compare June 7, 2026 02:57
@Rashmika998
Rashmika998 requested a review from cloby99 June 7, 2026 02:58
Rashmika998 and others added 3 commits June 7, 2026 08:33
- Add format: uuid to path parameter
- Add 200 response body referencing the Case schema
- Add 400 (malformed UUID), 403, 404, 500 responses with ErrorPayload
- Matches the GET /cases/{id} contract introduced in entity-service PR wso2-open-operations#818

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add format: uuid to /cases/{id}/comments and /cases/{id}/comments/search
  path parameters for consistency
- Add explicit UUID validation in GetCase handler to fail-fast with 400
  before forwarding a malformed ID to the entity service
- Update TestGetCase to use valid UUIDs; add malformed UUID subtest

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Rashmika998
Rashmika998 force-pushed the task/csm-portal-get-case-by-id branch from 6f3d461 to b9aac29 Compare June 7, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/CSM Portal Area/Backend Type/Improvement Marks enhancements or improvements to existing features Type/New Feature Represents a request or task for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants