Skip to content

feat: fixing transaction schema#207

Open
pengying wants to merge 1 commit intomainfrom
02-18-feat_fixing_transaction_schema
Open

feat: fixing transaction schema#207
pengying wants to merge 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

Edit this comment to update them. They will appear in their respective SDK's changelogs.

grid-openapi studio · code · diff

Your SDK built successfully.
generate ✅

grid-python studio · code · diff

Your SDK built successfully.
generate ✅build ✅lint ✅test ✅

pip install https://pkg.stainless.com/s/grid-python/1bced3e0b6dc204e757c27c0f1087d1ff90f277d/grid-0.0.1-py3-none-any.whl
grid-typescript studio · code · diff

Your SDK built successfully.
generate ✅build ✅lint ✅test ✅

npm install https://pkg.stainless.com/s/grid-typescript/cbf123fa2d6dc1122b9a154a055231cb7ce1ef3c/dist.tar.gz
grid-kotlin studio · code · diff

Your SDK built successfully.
generate ✅build ✅lint ✅test ✅

New diagnostics (7 note)
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).

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-19 01:34:02 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

Fixed transaction schema inheritance by implementing proper polymorphic type handling using oneOf discriminator pattern. This resolves conflicts that occurred when merging the base Transaction schema with IncomingTransaction and OutgoingTransaction child schemas.

Key changes:

  • Added new TransactionOneOf schema using oneOf with discriminator on type field
  • Added explicit type property with single-value enums to both IncomingTransaction and OutgoingTransaction
  • Configured Stainless to remove type from base Transaction during bundling to prevent conflicts
  • Updated all transaction endpoints to return TransactionOneOf instead of base Transaction
  • Added SENT status to TransactionStatus enum with comprehensive status documentation table
  • Removed paymentInstructions from required fields in OutgoingTransaction (still available as optional)

Confidence Score: 4/5

  • Safe to merge with minor verification needed on breaking change
  • Solid implementation of polymorphic schema pattern that properly fixes type discrimination issues. Deducted one point for removing paymentInstructions from required fields in OutgoingTransaction, which could be a breaking change if existing API clients depend on this field always being present. This should be verified and potentially documented as a breaking change.
  • Verify that removing paymentInstructions from required fields in openapi/components/schemas/transactions/OutgoingTransaction.yaml won't break existing API clients

Important Files Changed

Filename Overview
.stainless/stainless.yml Adds Stainless config to remove type property from base Transaction schema during bundling
openapi/components/schemas/transactions/TransactionOneOf.yaml New polymorphic schema using oneOf discriminator to properly handle transaction type variants
openapi/components/schemas/transactions/IncomingTransaction.yaml Adds required type property with INCOMING enum to child schema for proper discrimination
openapi/components/schemas/transactions/OutgoingTransaction.yaml Adds type property with OUTGOING enum and removes paymentInstructions from required fields
openapi/components/schemas/transactions/TransactionStatus.yaml Adds SENT status enum value and comprehensive status documentation table

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    Transaction <|-- IncomingTransaction
    Transaction <|-- OutgoingTransaction
    TransactionOneOf o-- IncomingTransaction
    TransactionOneOf o-- OutgoingTransaction
    
    class Transaction {
        +string id
        +TransactionStatus status
        +TransactionType type
        +TransactionDestination destination
        +string customerId
        +string platformCustomerId
        +datetime settledAt
        +datetime createdAt
        +datetime updatedAt
        +string description
        +CounterpartyInformation counterpartyInformation
    }
    
    class TransactionOneOf {
        <<oneOf>>
        discriminator: type
        INCOMING → IncomingTransaction
        OUTGOING → OutgoingTransaction
    }
    
    class IncomingTransaction {
        +enum type = INCOMING
        +TransactionSource source
        +CurrencyAmount receivedAmount
        +ReconciliationInstructions reconciliationInstructions
        +IncomingRateDetails rateDetails
        +IncomingTransactionFailureReason failureReason
    }
    
    class OutgoingTransaction {
        +enum type = OUTGOING
        +TransactionSource source
        +CurrencyAmount sentAmount
        +CurrencyAmount receivedAmount
        +number exchangeRate
        +integer fees
        +string quoteId
        +PaymentInstructions[] paymentInstructions
        +Refund refund
        +OutgoingRateDetails rateDetails
        +OutgoingTransactionFailureReason failureReason
    }
Loading

Last reviewed commit: c774ff0

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

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

Comments