Skip to content

feat(openapi): Update openapi specs for v2 pool balances#487

Merged
laouji merged 3 commits into
mainfrom
PMNT-91-v2
Jul 9, 2025
Merged

feat(openapi): Update openapi specs for v2 pool balances#487
laouji merged 3 commits into
mainfrom
PMNT-91-v2

Conversation

@laouji

@laouji laouji commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Fixes: PMNT-91

@coderabbitai

coderabbitai Bot commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • .github/actions/default/action.yml is excluded by !**/*.yml
  • .github/workflows/main.yml is excluded by !**/*.yml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce a new PoolBalancesLatestResponse model and update all related client code, documentation, and tests to use this new structure for the "latest pool balances" endpoint. The response field and getter methods are renamed and refactored accordingly, and an additional test covers the v1 API path.

Changes

File(s) Change Summary
pkg/client/models/components/poolbalanceslatestresponse.go, pkg/client/docs/models/components/poolbalanceslatestresponse.md Added new PoolBalancesLatestResponse struct and its documentation.
pkg/client/models/operations/getpoolbalanceslatest.go, pkg/client/docs/models/operations/getpoolbalanceslatestresponse.md Updated response struct and documentation to use PoolBalancesLatestResponse and renamed methods.
pkg/client/v1.go, pkg/client/docs/sdks/v1/README.md Updated client logic and SDK usage examples to use new response type and field.
test/e2e/api_pools_test.go Added v1 API test for pool balances; updated context description.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant V1SDK
    participant API
    participant DB

    Client->>V1SDK: GetPoolBalancesLatest()
    V1SDK->>API: GET /pool/balances/latest
    API->>DB: Query latest balances
    DB-->>API: Return balances
    API-->>V1SDK: Respond with PoolBalancesLatestResponse
    V1SDK-->>Client: Return PoolBalancesLatestResponse.Data
Loading

Assessment against linked issues

Objective Addressed Explanation
Return latest balance if future timestamp is provided (PMNT-91) The code changes focus on response struct updates and new endpoint usage, but do not show explicit logic handling future timestamps or returning 400 errors.
Update client models and SDK to support new "latest pool balances" response (PMNT-91)
Add or update tests for the new/latest pool balances endpoint (PMNT-91)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Generalizing test context description (test/e2e/api_pools_test.go) The context description change is cosmetic and not directly related to the objectives in PMNT-91.

Possibly related PRs

Suggested reviewers

  • paul-nicolas

Poem

In the pools where balances swim and play,
A rabbit hops through code today.
New structs abound, responses neat—
The latest balances, a tidy feat!
Tests now check both v1 and v3,
All is clear as code can be.
🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch PMNT-91-v2

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@laouji laouji marked this pull request as ready for review July 9, 2025 15:01
@laouji laouji requested a review from a team as a code owner July 9, 2025 15:01

@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: 0

🧹 Nitpick comments (1)
pkg/client/docs/models/components/poolbalanceslatestresponse.md (1)

1-10: Documentation structure looks good with minor formatting suggestion.

The documentation accurately describes the PoolBalancesLatestResponse model and its required Data field.

Consider improving the formatting around the "OK" status indicator for better readability:

# PoolBalancesLatestResponse

-OK
+**Status:** OK
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75786d9 and fa4852d.

⛔ Files ignored due to path filters (3)
  • openapi.yaml is excluded by !**/*.yaml
  • openapi/v1-2/v1-2.yaml is excluded by !**/*.yaml
  • pkg/client/.speakeasy/gen.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (7)
  • pkg/client/docs/models/components/poolbalanceslatestresponse.md (1 hunks)
  • pkg/client/docs/models/operations/getpoolbalanceslatestresponse.md (1 hunks)
  • pkg/client/docs/sdks/v1/README.md (1 hunks)
  • pkg/client/models/components/poolbalanceslatestresponse.go (1 hunks)
  • pkg/client/models/operations/getpoolbalanceslatest.go (2 hunks)
  • pkg/client/v1.go (1 hunks)
  • test/e2e/api_pools_test.go (2 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: laouji
PR: formancehq/payments#193
File: internal/connectors/plugins/public/dummypay/client/client.go:104-131
Timestamp: 2024-12-12T12:45:27.164Z
Learning: The `Balance` struct in `internal/connectors/plugins/public/dummypay/client/client.go` is only used in tests, so changing `AmountInMinors` from `int64` to `*big.Int` is not necessary.
test/e2e/api_pools_test.go (4)
Learnt from: fguery
PR: formancehq/payments#427
File: internal/connectors/plugins/public/qonto/balances.go:20-55
Timestamp: 2025-05-15T16:35:29.660Z
Learning: The Qonto connector plugin has unit tests for fetchNextBalances in internal/connectors/plugins/public/qonto/balances_test.go, covering success cases, missing FromPayload, invalid JSON handling, and other error conditions.
Learnt from: laouji
PR: formancehq/payments#193
File: internal/connectors/plugins/public/dummypay/client/client.go:104-131
Timestamp: 2024-12-12T12:45:27.164Z
Learning: The `Balance` struct in `internal/connectors/plugins/public/dummypay/client/client.go` is only used in tests, so changing `AmountInMinors` from `int64` to `*big.Int` is not necessary.
Learnt from: laouji
PR: formancehq/payments#193
File: test/e2e/api_accounts_test.go:97-106
Timestamp: 2024-12-12T11:00:02.458Z
Learning: In `test/e2e/api_accounts_test.go`, the `Subscribe` function already includes error handling, so it's unnecessary to add additional error handling when calling it in tests.
Learnt from: laouji
PR: formancehq/payments#317
File: internal/api/v2/handler_bank_accounts_forward_to_connector.go:17-17
Timestamp: 2025-02-07T15:47:17.240Z
Learning: In the bank accounts forward to connector handler, the connectorID validator tag is deliberately omitted to maintain error code consistency (ErrMissingOrInvalidBody for missing connectorID). The validation is instead performed manually later in the handler using models.ConnectorIDFromString.
pkg/client/models/components/poolbalanceslatestresponse.go (1)
Learnt from: laouji
PR: formancehq/payments#193
File: internal/connectors/plugins/public/dummypay/client/client.go:104-131
Timestamp: 2024-12-12T12:45:27.164Z
Learning: The `Balance` struct in `internal/connectors/plugins/public/dummypay/client/client.go` is only used in tests, so changing `AmountInMinors` from `int64` to `*big.Int` is not necessary.
pkg/client/models/operations/getpoolbalanceslatest.go (1)
Learnt from: laouji
PR: formancehq/payments#193
File: internal/connectors/plugins/public/dummypay/client/client.go:104-131
Timestamp: 2024-12-12T12:45:27.164Z
Learning: The `Balance` struct in `internal/connectors/plugins/public/dummypay/client/client.go` is only used in tests, so changing `AmountInMinors` from `int64` to `*big.Int` is not necessary.
pkg/client/v1.go (1)

undefined

<retrieved_learning>
Learnt from: laouji
PR: #193
File: internal/connectors/plugins/public/dummypay/client/client.go:104-131
Timestamp: 2024-12-12T12:45:27.164Z
Learning: The Balance struct in internal/connectors/plugins/public/dummypay/client/client.go is only used in tests, so changing AmountInMinors from int64 to *big.Int is not necessary.
</retrieved_learning>

🧬 Code Graph Analysis (3)
test/e2e/api_pools_test.go (3)
pkg/client/v3.go (1)
  • V3 (20-22)
pkg/client/v1.go (1)
  • V1 (20-22)
pkg/client/models/operations/getpoolbalanceslatest.go (1)
  • GetPoolBalancesLatestResponse (21-27)
pkg/client/models/operations/getpoolbalanceslatest.go (1)
pkg/client/models/components/poolbalanceslatestresponse.go (1)
  • PoolBalancesLatestResponse (6-8)
pkg/client/v1.go (1)
pkg/client/models/components/poolbalanceslatestresponse.go (1)
  • PoolBalancesLatestResponse (6-8)
🪛 LanguageTool
pkg/client/docs/models/components/poolbalanceslatestresponse.md

[grammar] ~1-~1: There might be a problem here.
Context: # PoolBalancesLatestResponse OK ## Fields | Field ...

(QB_NEW_EN_MERGED_MATCH)

🔇 Additional comments (10)
pkg/client/docs/sdks/v1/README.md (1)

1141-1147: Field rename propagated correctly – looks good

The example now checks res.PoolBalancesLatestResponse, in line with the new model introduced in the PR. No other adjustments are required in this snippet.

test/e2e/api_pools_test.go (3)

323-323: Good generalization of test description.

The updated test description better reflects that this test context now covers both v1 and v3 API endpoints for fetching pool balances.


376-382: Existing v3 test looks correct.

The v3 test properly validates the response structure and data, checking that the returned balance matches the expected asset and amount.


384-390: Excellent addition of v1 API test coverage.

This new test ensures that the v1 API endpoint works correctly with the new PoolBalancesLatestResponse model. The test logic is consistent with the v3 test and properly validates the response structure and data.

pkg/client/v1.go (1)

4292-4297: All references to the new PoolBalancesLatestResponse are correct; historical PoolBalancesResponse remains only in the v1 historical endpoint

I verified that:

  • The GetPoolBalancesLatest method in pkg/client/v1.go (and its operation/model in models/operations/getpoolbalanceslatest.go) consistently uses components.PoolBalancesLatestResponse.
  • E2E tests for V1’s latest balances (GetPoolBalancesLatest) call and assert against GetPoolBalancesLatestResponse().
  • The only remaining uses of the old components.PoolBalancesResponse are in the historical GetPoolBalances method and its models—which is intentional and should not be changed.

The refactoring is complete and consistent.

pkg/client/docs/models/operations/getpoolbalanceslatestresponse.md (1)

6-10: Documentation correctly reflects the updated API model.

The field name and type reference changes are consistent with the new PoolBalancesLatestResponse model. The documentation accurately documents the updated response structure.

pkg/client/models/components/poolbalanceslatestresponse.go (2)

6-8: Well-structured response model.

The PoolBalancesLatestResponse struct is properly defined with appropriate JSON tags for the Data field containing pool balance information.


10-15: Good nil-safety implementation.

The GetData() method correctly handles nil receivers by returning an empty slice, which prevents potential nil pointer dereferences and provides a safe default behavior.

pkg/client/models/operations/getpoolbalanceslatest.go (2)

24-24: Note: This is a breaking change for client code.

The field name change from PoolBalancesResponse to PoolBalancesLatestResponse will require updates to any client code that accesses this field directly. Since this is generated code, ensure that the OpenAPI specification change is intentional and properly versioned.


36-41: Getter method correctly updated.

The getter method has been properly renamed and updated to return the new PoolBalancesLatestResponse type, with appropriate nil-safety checks consistent with the other getter methods in the struct.

cursor[bot]

This comment was marked as outdated.

@fguery fguery 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.

I don't really follow what I'm looking at if I"m being honest, but it's just a speakeasy run right?

@laouji

laouji commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

@fguery Yes. Just openapi I backported a missing endpoint to payments v2 here so this updates the openapi specs to match the v2 implementation. Frontend team will use it to generate their typescript SDK

@codecov

codecov Bot commented Jul 9, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.65%. Comparing base (75786d9) to head (1bc4b42).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #487   +/-   ##
=======================================
  Coverage   69.65%   69.65%           
=======================================
  Files         627      627           
  Lines       32208    32208           
=======================================
  Hits        22436    22436           
  Misses       8558     8558           
  Partials     1214     1214           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@laouji laouji added this pull request to the merge queue Jul 9, 2025
Merged via the queue into main with commit ead2eb3 Jul 9, 2025
9 checks passed
@laouji laouji deleted the PMNT-91-v2 branch July 9, 2025 16:14
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.

2 participants