Conversation
Greptile SummaryThis PR refactors the OpenAPI specification to improve compatibility with Stainless SDK generation by adding discriminators to polymorphic types, converting single-value enums to const, and extracting inline schemas into reusable components. Key Changes:
Issues Found:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| openapi/components/schemas/quotes/QuoteRequest.yaml | Added discriminators for source and destination oneOf schemas to improve SDK generation. Clean implementation with proper discriminator property names. |
| openapi/components/schemas/external_accounts/LightningExternalAccountInfo.yaml | Changed from oneOf with mutual exclusivity to flattened structure with all three optional fields (invoice, bolt12, lightningAddress). This allows multiple destination types simultaneously, which may not be intended behavior. |
| openapi/components/schemas/customers/CreateCustomerRequest.yaml | New extracted schema with customerType discriminator (enum INDIVIDUAL/BUSINESS) properly mapping to customer update schemas. |
| openapi/components/schemas/transactions/Transaction.yaml | Added discriminators for destination oneOf (ACCOUNT/UMA_ADDRESS) and type discriminator for INCOMING/OUTGOING transaction subtypes. |
| openapi/components/schemas/quotes/QuoteRealtimeFundingSource.yaml | New extracted schema for real-time funding source. customerId marked as required but description states it's optional for platform-level quotes - potential validation issue. |
| openapi/paths/platform/platform_external_accounts.yaml | Renamed response field from accounts to data for consistency with API patterns. Clean breaking change. |
Sequence Diagram
sequenceDiagram
participant Client as SDK Client
participant API as Grid API
participant Quote as Quote Service
participant Transaction as Transaction Service
Note over Client,API: Quote Creation with Discriminators
Client->>API: POST /quotes<br/>{source: {sourceType: "ACCOUNT", accountId: "..."}, <br/>destination: {destinationType: "UMA_ADDRESS", umaAddress: "$user@domain.com"}}
API->>Quote: Validate discriminator fields
Quote->>Quote: Route to appropriate handler<br/>based on sourceType & destinationType
Quote-->>API: Quote created with discriminated types
API-->>Client: Quote response<br/>{destination: {destinationType: "UMA_ADDRESS", ...}}
Note over Client,API: Transaction Retrieval
Client->>API: GET /transactions/{id}
API->>Transaction: Fetch transaction
Transaction-->>API: Transaction with discriminators<br/>{type: "OUTGOING", source: {sourceType: "ACCOUNT"}, <br/>destination: {destinationType: "UMA_ADDRESS"}}
API-->>Client: SDK deserializes to correct type<br/>based on discriminators
Note over Client,API: Customer Management
Client->>API: POST /customers<br/>{customerType: "INDIVIDUAL", fullName: "...", ...}
API->>API: Discriminator routes to<br/>IndividualCustomerUpdate schema
API-->>Client: Customer created
Client->>API: PUT /customers/{id}<br/>{customerType: "BUSINESS", businessInfo: {...}}
API->>API: Discriminator routes to<br/>BusinessCustomerUpdate schema
API-->>Client: Customer updated
There was a problem hiding this comment.
Additional Comments (1)
-
openapi/components/schemas/common/PaymentLightningInvoiceInfo.yaml, line 2 (link)logic: This file still references
./PaymentAccountOrWalletInfo.yamlbut all other Payment* schemas had this reference removed. This will cause schema resolution errors.
55 files reviewed, 2 comments
openapi/components/schemas/external_accounts/LightningExternalAccountInfo.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Additional Comments (1)
-
openapi/components/schemas/common/PaymentLightningInvoiceInfo.yaml, line 2 (link)logic: This reference to
PaymentAccountOrWalletInfo.yamlmust be removed. All other Payment* schemas in this PR had this reference removed, but this file was missed. This will cause schema resolution to fail.
69 files reviewed, 6 comments
openapi/components/schemas/external_accounts/LightningExternalAccountInfo.yaml
Outdated
Show resolved
Hide resolved
openapi/components/schemas/quotes/QuoteRealtimeFundingSource.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Additional Comments (1)
-
openapi/components/schemas/common/PaymentLightningInvoiceInfo.yaml, line 1-2 (link)logic: Circular dependency exists:
PaymentLightningInvoiceInfoextendsPaymentAccountOrWalletInfo, butPaymentAccountOrWalletInfodiscriminator mapping referencesPaymentLightningInvoiceInfo. This creates an infinite loop that will prevent OpenAPI schema resolution and Stainless code generation from working.All other Payment* schemas (PaymentUsAccountInfo, PaymentClabeAccountInfo, etc.) extend their base schemas (UsAccountInfo, ClabeAccountInfo) which do NOT have this circular reference. Follow the same pattern here.
87 files reviewed, 2 comments
There was a problem hiding this comment.
Additional Comments (1)
-
openapi/components/schemas/common/PaymentLightningInvoiceInfo.yaml, line 1-2 (link)logic:
PaymentAccountOrWalletInforeference should be removed for consistency with other Payment* schemasAll other Payment* schemas (PaymentClabeAccountInfo, PaymentUsAccountInfo, PaymentPixAccountInfo, etc.) had their
$ref: ./PaymentAccountOrWalletInfo.yamlremoved in this PR. This file was missed.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
89 files reviewed, 1 comment
cc858e0 to
13ee030
Compare
Summary of API Changes in Branch
peng-stainless_initThis branch contains significant OpenAPI schema changes primarily focused on improving SDK generation compatibility (likely for Stainless SDK). The main themes are:
enum: [SINGLE_VALUE]toconst: SINGLE_VALUEfor single-value enumsErrortoGridErrorto avoid naming conflictsDetailed API Changes with JSON Examples
1. Quote Request - Destination Discriminator Added
Before: Destination was a
oneOfwithout a discriminatorAfter: Added
destinationTypediscriminator field2. Quote Request - Source Discriminator Added
Before: Source was a
oneOfwithout a discriminatorAfter: Added
sourceTypediscriminator field3. Quote Response - Destination Discriminator Added
Before: Inline destination types
After: Extracted to
QuoteAccountDestinationandQuoteUmaAddressDestinationwith discriminator4. Transaction - Source/Destination Discriminators Added
Before: Inline source/destination types
After: Extracted with
sourceTypeanddestinationTypediscriminators5. Lightning External Account - Flattened Structure
Before: Nested
oneOfwith separate invoice/bolt12/lightningAddress objectsAfter: Flattened to single object with optional fields
6. Create Customer Request - Discriminator Added
Before: Inline
oneOfwith individual/business typesAfter: Extracted to
CreateCustomerRequestwithcustomerTypediscriminator7. Update Customer Request - Discriminator Added
Before: Inline
oneOfAfter: Extracted to
UpdateCustomerRequestwithcustomerTypediscriminator8. Customer Response -
aliasField RemovedBefore: Customer had an
aliasfieldAfter:
aliasfield removed from Customer schema9. Platform External Accounts - Response Field Renamed
Before:
accountsarray in responseAfter:
dataarray in response10. Error Schema Renamed
Before:
Error.yamlAfter:
GridError.yamlwithadditionalProperties: trueon details{ "code": "INVALID_REQUEST", "message": "The request was invalid", "details": { "field": "email", "reason": "Invalid format" } }11. Single-Value Enums →
constAll single-value enums converted to
constfor better SDK typing:accountType: enum: [LIGHTNING]→accountType: const: LIGHTNINGcustomerType: enum: [INDIVIDUAL]→customerType: const: INDIVIDUALstatus: enum: [400]→status: const: 400This affects account types (IBAN, CLABE, FBO, PIX, NGN, etc.), customer types, and error status codes.
12. PaymentInstructions - New Field Added
After: Added
isPlatformAccountboolean field{ "instructions": "Please include reference code in memo", "isPlatformAccount": true, "accountOrWalletInfo": { "accountType": "IBAN", "iban": "DE89370400440532013000", "swiftBic": "COBADEFFXXX" } }13. IndividualCustomerUpdate -
platformCustomerIdAddedAfter: Added
platformCustomerIdfield to individual customer update schema{ "customerType": "INDIVIDUAL", "fullName": "Jane Doe", "platformCustomerId": "9f84e0c2a72c4fa" }