Skip to content

Comments

feat: fixing transaction schema#207

Merged
pengying merged 1 commit intomainfrom
02-18-feat_fixing_transaction_schema
Feb 20, 2026
Merged

feat: fixing transaction schema#207
pengying merged 1 commit intomainfrom
02-18-feat_fixing_transaction_schema

Conversation

@pengying
Copy link
Contributor

@pengying pengying commented Feb 19, 2026

TL;DR

Fixed transaction schema inheritance by implementing proper polymorphic type handling for transactions.

What changed?

  • Removed the type property from the base Transaction schema to avoid conflicts when merging with child schemas
  • Added required type property with specific enum values to both IncomingTransaction and OutgoingTransaction schemas
  • Created a new TransactionOneOf schema that uses proper polymorphic discrimination between transaction types
  • Updated all API endpoints to reference TransactionOneOf instead of the base Transaction schema
  • Reorganized schema definitions for better clarity and proper inheritance

How to test?

  1. Verify that transaction-related API endpoints return the correct schema based on transaction type
  2. Confirm that the OpenAPI documentation correctly shows the discriminated transaction types
  3. Test both incoming and outgoing transaction flows to ensure proper type handling

Why make this change?

The previous schema structure had conflicting type definitions when the base Transaction schema was merged with specific transaction type schemas through allOf. This change implements proper polymorphic inheritance using the oneOf discriminator pattern, ensuring that transaction types are correctly differentiated and validated. This prevents potential issues with schema validation and improves API documentation clarity.

Copy link
Contributor Author

pengying commented Feb 19, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link

github-actions bot commented Feb 19, 2026

✱ Stainless preview builds

This PR will update the grid SDKs with the following commit messages.

kotlin

feat(api): add type discriminators to transactions, union response types for operations

openapi

fix(types): add discriminated union to transfer-in/transfer-out/transactions responses

python

fix(types): update return types in transfer_in/transfer_out/transactions

typescript

feat(api): add response types to transferIn/transferOut/transactions methods
grid-openapi studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅

grid-python studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅build ✅lint ✅test ✅

pip install https://pkg.stainless.com/s/grid-python/344a695d144a93b4a96a965fd6bbea1162d9976d/grid-0.0.1-py3-none-any.whl
grid-kotlin studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅build ✅lint ✅test ✅

grid-typescript studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅build ✅lint ✅test ✅

npm install https://pkg.stainless.com/s/grid-typescript/4fc56740809d983455cf819dbffba458357fc8f5/dist.tar.gz

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-02-20 20:33:00 UTC

@pengying pengying marked this pull request as ready for review February 19, 2026 01:05
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 19, 2026

Greptile Summary

This PR fixes transaction schema inheritance by implementing proper polymorphic type handling using the oneOf discriminator pattern.

Key Changes:

  • Created new TransactionOneOf schema that properly discriminates between IncomingTransaction and OutgoingTransaction using the type field
  • Added required type property with specific enum values (INCOMING or OUTGOING) to both transaction type schemas
  • Updated all transaction-related API endpoints (/transactions, /transactions/{transactionId}, /transfer-in, /transfer-out) to return TransactionOneOf instead of the base Transaction schema
  • Added Stainless transformation to remove the type property from the base Transaction schema to prevent allOf merge conflicts
  • Introduced new RealtimeFundingTransactionSource schema for real-time funding sources (RTP, SEPA Instant, etc.)
  • Added ExternalAccountDetailsTransactionDestination schema for inline external account details

Impact:
The previous schema structure caused conflicting type definitions when the base Transaction schema was merged with specific transaction type schemas through allOf. This change ensures proper schema validation and improves OpenAPI documentation clarity by using discriminated unions.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes implement a well-established OpenAPI pattern (oneOf discriminator) for polymorphic schemas. The transformation approach is consistent with existing patterns in the codebase. All transaction endpoints are updated consistently, and the previous merge conflict concern is outdated (no actual conflicts exist).
  • No files require special attention. The removal of paymentInstructions from required fields in OutgoingTransaction.yaml was already flagged in a previous review thread.

Important Files Changed

Filename Overview
openapi/components/schemas/transactions/TransactionOneOf.yaml New schema using oneOf discriminator for proper polymorphic transaction handling
openapi/components/schemas/transactions/IncomingTransaction.yaml Added required type field with INCOMING enum for proper discriminated union
openapi/components/schemas/transactions/OutgoingTransaction.yaml Added type field with OUTGOING enum, removed paymentInstructions from required (flagged in previous review)
.stainless/stainless.yml Added transformation to remove type from base Transaction schema to prevent allOf conflicts
openapi/paths/transactions/transactions.yaml Updated list endpoint to return TransactionOneOf instead of Transaction schema
openapi/components/schemas/transactions/RealtimeFundingTransactionSource.yaml New transaction source schema for real-time funding (RTP, SEPA Instant, etc.)
openapi/components/schemas/transactions/ExternalAccountDetailsTransactionDestination.yaml New destination schema for inline external account details at quote creation

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class Transaction {
        +string id
        +TransactionStatus status
        +TransactionType type
        +TransactionDestinationOneOf destination
        +string customerId
        +string platformCustomerId
        +datetime settledAt
        +datetime createdAt
        +datetime updatedAt
        +string description
        +CounterpartyInformation counterpartyInformation
    }
    
    class TransactionOneOf {
        <<oneOf>>
        discriminator: type
    }
    
    class IncomingTransaction {
        +type: "INCOMING"
        +CurrencyAmount receivedAmount
        +TransactionSourceOneOf source
        +ReconciliationInstructions reconciliationInstructions
        +IncomingRateDetails rateDetails
        +IncomingTransactionFailureReason failureReason
    }
    
    class OutgoingTransaction {
        +type: "OUTGOING"
        +CurrencyAmount sentAmount
        +CurrencyAmount receivedAmount
        +TransactionSourceOneOf source
        +number exchangeRate
        +integer fees
        +string quoteId
        +PaymentInstructions[] paymentInstructions
        +Refund refund
        +OutgoingRateDetails rateDetails
        +OutgoingTransactionFailureReason failureReason
    }
    
    class TransactionSourceOneOf {
        <<oneOf>>
        discriminator: sourceType
    }
    
    class AccountTransactionSource {
        +sourceType: "ACCOUNT"
    }
    
    class UmaAddressTransactionSource {
        +sourceType: "UMA_ADDRESS"
    }
    
    class RealtimeFundingTransactionSource {
        +sourceType: "REALTIME_FUNDING"
        +string currency
        +string customerId
    }
    
    TransactionOneOf <|-- IncomingTransaction
    TransactionOneOf <|-- OutgoingTransaction
    IncomingTransaction --|> Transaction
    OutgoingTransaction --|> Transaction
    
    IncomingTransaction --> TransactionSourceOneOf
    OutgoingTransaction --> TransactionSourceOneOf
    
    TransactionSourceOneOf <|-- AccountTransactionSource
    TransactionSourceOneOf <|-- UmaAddressTransactionSource
    TransactionSourceOneOf <|-- RealtimeFundingTransactionSource
Loading

Last reviewed commit: 33406c9

@pengying pengying force-pushed the 02-18-feat_fixing_transaction_schema branch from 2e13aea to 36ee105 Compare February 19, 2026 01:27
@pengying pengying force-pushed the 02-18-feat_fixing_transaction_schema branch from 36ee105 to c774ff0 Compare February 19, 2026 15:17
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

11 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

- $ref: ./Transaction.yaml
- type: object
required:
- type
Copy link
Contributor

Choose a reason for hiding this comment

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

Check that removing paymentInstructions from required fields is intentional and won't break existing clients

Prompt To Fix With AI
This is a comment left during a code review.
Path: openapi/components/schemas/transactions/OutgoingTransaction.yaml
Line: 5

Comment:
Check that removing `paymentInstructions` from required fields is intentional and won't break existing clients

How can I resolve this? If you propose a fix, please make it concise.

@pengying pengying force-pushed the 02-18-feat_fixing_transaction_schema branch from c774ff0 to eb98c72 Compare February 19, 2026 21:46
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

11 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 420 to 446
@@ -429,6 +430,20 @@ openapi:
# - "$.components.schemas.BusinessBeneficiary.allOf[1].properties"
# keys: [ "beneficiaryType" ]
# ── customerType: remove from base schemas ──
=======
# ── type: transaction base schema ──
- command: remove
reason: >-
Remove inline type enum from Transaction base schema to avoid
conflicting types when allOf merges with IncomingTransaction and
OutgoingTransaction which define type as single-value enums
args:
target:
- "$.components.schemas.Transaction.properties"
keys: [ "type" ]

# ── beneficiaryType: beneficiary schemas ──
>>>>>>> c774ff0 (feat: fixing transaction schema)
Copy link
Contributor

Choose a reason for hiding this comment

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

Unresolved merge conflict will break the build

Suggested change
# ── type: transaction base schema ──
- command: remove
reason: >-
Remove inline type enum from Transaction base schema to avoid
conflicting types when allOf merges with IncomingTransaction and
OutgoingTransaction which define type as single-value enums
args:
target:
- "$.components.schemas.Transaction.properties"
keys: [ "type" ]
# ── beneficiaryType: beneficiary schemas ──
Prompt To Fix With AI
This is a comment left during a code review.
Path: .stainless/stainless.yml
Line: 420-446

Comment:
Unresolved merge conflict will break the build

```suggestion
    # ── type: transaction base schema ──
    - command: remove
      reason: >-
        Remove inline type enum from Transaction base schema to avoid
        conflicting types when allOf merges with IncomingTransaction and
        OutgoingTransaction which define type as single-value enums
      args:
        target:
          - "$.components.schemas.Transaction.properties"
        keys: [ "type" ]

    # ── beneficiaryType: beneficiary schemas ──
```

How can I resolve this? If you propose a fix, please make it concise.

@pengying pengying force-pushed the 02-18-feat_fixing_transaction_schema branch from eb98c72 to 8ad3ce8 Compare February 19, 2026 21:55
@pengying pengying force-pushed the 02-18-feat_fixing_transaction_schema branch from 8ad3ce8 to 33406c9 Compare February 20, 2026 18:46
@pengying pengying enabled auto-merge (squash) February 20, 2026 20:14
@pengying pengying merged commit 5b33dc7 into main Feb 20, 2026
8 checks passed
@pengying pengying deleted the 02-18-feat_fixing_transaction_schema branch February 20, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants