Skip to content

refactor: uses oapi generate claim filter struct#119

Merged
semmet95 merged 1 commit into
mainfrom
fix/claim-param-struct
May 26, 2026
Merged

refactor: uses oapi generate claim filter struct#119
semmet95 merged 1 commit into
mainfrom
fix/claim-param-struct

Conversation

@semmet95
Copy link
Copy Markdown
Contributor

@semmet95 semmet95 commented May 26, 2026

Summary by CodeRabbit

  • New Features

    • The claims retrieval endpoint now supports an optional checked query parameter, enabling users to filter and retrieve results by claim verification status (checked or unchecked claims)
  • Bug Fixes

    • Improved error response messages for invalid query parameters provided to API endpoints, delivering clearer and more descriptive feedback to clients

Review Change Stack

Signed-off-by: Amit Singh <singhamitch@outlook.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1fb18208-717a-44de-a1df-a8f01e11cfa5

📥 Commits

Reviewing files that changed from the base of the PR and between 7fb3435 and bf1015d.

📒 Files selected for processing (10)
  • acceptance/claim_test.go
  • pkg/api/server.gen.go
  • pkg/domain/claim/claim_repository.go
  • pkg/domain/claim/claim_repository_test.go
  • pkg/domain/claim/claim_service.go
  • pkg/domain/claim/claim_service_test.go
  • pkg/domain/claim/claimfakes/fake_claim_repository.go
  • pkg/domain/claim/claimfakes/fake_claim_service.go
  • pkg/handlers/claim.go
  • pkg/http/router.go

📝 Walkthrough

Walkthrough

This PR consolidates query parameter handling by replacing the domain-level ClaimFilter struct with the API-generated GetClaimsParams type. Query binding moves from manual handler parsing to generated middleware, and the parameter type is threaded through handler, service, and repository layers. Domain ClaimFilter is removed, and all tests and fakes are updated.

Changes

Query Parameter Refactoring: Consolidate ClaimFilter to API Layer

Layer / File(s) Summary
API Schema & Query Parameter Binding
pkg/api/server.gen.go
Introduce GetClaimsParams struct with Checked field, update ServerInterface.GetClaims signature, and implement middleware to bind the checked query parameter, validate it, and forward params to handler.
Handler & Router Integration
pkg/handlers/claim.go, pkg/http/router.go
Update handler to accept and forward api.GetClaimsParams, removing manual query parsing and strconv import. Update router to import api and pass params to handler.
Service & Repository Layer Updates
pkg/domain/claim/claim_repository.go, pkg/domain/claim/claim_service.go
Remove domain-level ClaimFilter struct. Update service and repository GetClaims signatures to accept *api.GetClaimsParams and simplify repository implementation to pass params directly to FindAll.
Tests, Fakes & Acceptance Tests
pkg/domain/claim/claim_repository_test.go, pkg/domain/claim/claim_service_test.go, pkg/domain/claim/claimfakes/, acceptance/claim_test.go
Update all test calls to use api.GetClaimsParams. Update fake repository and service method signatures and stub fields. Update acceptance test to expect error message in errResp["msg"] with "invalid format for parameter checked".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • SatyaLens/source-score#117: Both PRs implement the GET /api/v1/claims checked query parameter by updating the same GetClaims call chain (router/handler → service → repository and related fakes/tests), though this PR consolidates to api.GetClaimsParams whereas the prior PR uses claim.ClaimFilter.

Poem

🐰 Filter refactoring hops along,
From domain down to API strong,
One params type to rule them all,
Through handler, service, repo call!
ClaimFilter fades, GetClaimsParams stays—
Cleaner code for brighter days! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring: replacing a domain-layer ClaimFilter with the OpenAPI-generated GetClaimsParams struct across multiple layers.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/claim-param-struct

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.

@semmet95 semmet95 marked this pull request as ready for review May 26, 2026 13:47
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 10 files

Re-trigger cubic

@semmet95 semmet95 merged commit 52c937e into main May 26, 2026
6 checks passed
@semmet95 semmet95 deleted the fix/claim-param-struct branch May 26, 2026 13:54
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.

1 participant