-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add Quote/Transaction discriminators and remove inline examples #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 01-24-feat_flatten_lightningexternalaccountinfo_schema_split
Are you sure you want to change the base?
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Greptile OverviewGreptile SummaryThis PR refactors the OpenAPI schema to implement proper discriminator patterns for polymorphic types in quotes and transactions, significantly improving code generation capabilities. Key changes:
Impact: Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| openapi/components/schemas/transactions/Transaction.yaml | Refactored to use discriminator pattern for polymorphic destination types, improving code generation |
| openapi/components/schemas/transactions/AccountSource.yaml | New schema file with sourceType discriminator field for account source type |
| openapi/components/schemas/transactions/AccountDestination.yaml | New schema file with destinationType discriminator field for account destination type |
| openapi/components/schemas/quotes/Quote.yaml | Refactored destination to use discriminator pattern, removed inline examples from paymentInstructions |
| openapi/components/schemas/quotes/QuoteSource.yaml | Updated to use discriminator pattern with sourceType for polymorphic quote sources |
| openapi/components/schemas/quotes/QuoteRequest.yaml | Updated to use discriminator pattern for polymorphic destination types in quote requests |
| openapi/paths/quotes/quotes.yaml | Removed inline examples from POST request body, delegating examples to schema definitions |
Sequence Diagram
sequenceDiagram
participant Client
participant API as Grid API
participant Schema as OpenAPI Schema
participant CodeGen as Code Generator
Note over Client,CodeGen: Quote Creation Flow with Discriminators
Client->>API: POST /quotes<br/>{source: {sourceType: "ACCOUNT", ...}, <br/>destination: {destinationType: "UMA_ADDRESS", ...}}
API->>Schema: Validate request against QuoteRequest schema
Schema->>Schema: Check discriminator.propertyName: "sourceType"
Schema->>Schema: Route to QuoteAccountSource via mapping
Schema->>Schema: Check discriminator.propertyName: "destinationType"
Schema->>Schema: Route to QuoteRequestUmaAddressDestination via mapping
Schema-->>API: Validation successful
API->>API: Create quote with typed source/destination
API-->>Client: 201 Created<br/>{quoteId, source: {sourceType: "ACCOUNT"}, <br/>destination: {destinationType: "UMA_ADDRESS"}}
Note over Client,CodeGen: Transaction Retrieval Flow
Client->>API: GET /transactions/{id}
API->>API: Retrieve transaction
API->>Schema: Serialize with Transaction schema
Schema->>Schema: Apply discriminator for type: OUTGOING
Schema->>Schema: Include source with sourceType discriminator
Schema->>Schema: Include destination with destinationType discriminator
API-->>Client: 200 OK<br/>{type: "OUTGOING", <br/>source: {sourceType: "ACCOUNT"}, <br/>destination: {destinationType: "UMA_ADDRESS"}}
Note over CodeGen: Code Generation Benefits
CodeGen->>Schema: Parse OpenAPI spec
Schema-->>CodeGen: Discriminator mappings found
CodeGen->>CodeGen: Generate type-safe unions<br/>with discriminated types
CodeGen->>CodeGen: Create proper inheritance/polymorphism<br/>in target language

TL;DR
Refactored OpenAPI schema to use proper discriminators for polymorphic types in transaction and quote models.
What changed?
sourceTypeanddestinationType) to polymorphic types in the API schema/quotesendpoint request body