-
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: main
Are you sure you want to change the base?
feat: add Quote/Transaction discriminators and remove inline examples #129
Conversation
Greptile OverviewGreptile SummaryThis PR refactors the OpenAPI schema to implement proper discriminator patterns for polymorphic types across quotes and transactions. Key Changes:
Impact:
Note on Lint Ignores: Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| openapi/components/schemas/common/AccountSource.yaml | New reusable schema for account funding source with ACCOUNT discriminator - clean extraction |
| openapi/components/schemas/common/AccountDestination.yaml | New reusable schema for account destination with ACCOUNT discriminator - clean extraction |
| openapi/components/schemas/quotes/QuoteSource.yaml | Refactored to use discriminator pattern with proper $refs instead of inline schemas |
| openapi/components/schemas/quotes/Quote.yaml | Added discriminator for destination oneOf - references extracted schemas |
| openapi/components/schemas/transactions/Transaction.yaml | Added discriminator for destination oneOf - references extracted schemas |
| .redocly.lint-ignore.yaml | Added lint ignores for required at oneOf level per OpenAPI spec recommendation |
Sequence Diagram
sequenceDiagram
participant Client
participant API as Grid API
participant Validator as Schema Validator
participant CodeGen as Code Generator
Note over Client,CodeGen: Quote Creation with Discriminated Source Types
Client->>API: POST /quotes<br/>{source: {sourceType: "ACCOUNT", accountId: "..."},<br/>destination: {...}}
API->>Validator: Validate request against QuoteRequest schema
Validator->>Validator: Check source.sourceType discriminator
alt sourceType == "ACCOUNT"
Validator->>Validator: Validate against AccountSource.yaml
else sourceType == "REALTIME_FUNDING"
Validator->>Validator: Validate against QuoteRealtimeFundingSource.yaml
end
Validator->>API: Valid ✓
API->>Client: 201 Quote Created
Note over Client,CodeGen: Transaction Response with Discriminated Types
Client->>API: GET /transactions/{id}
API->>Client: 200 Transaction Response<br/>{type: "OUTGOING",<br/>source: {sourceType: "ACCOUNT", ...},<br/>destination: {destinationType: "UMA_ADDRESS", ...}}
Client->>CodeGen: Deserialize response
CodeGen->>CodeGen: Read type discriminator = "OUTGOING"
CodeGen->>CodeGen: Map to OutgoingTransaction class
CodeGen->>CodeGen: Read source.sourceType = "ACCOUNT"
CodeGen->>CodeGen: Map to AccountSource class
CodeGen->>CodeGen: Read destination.destinationType = "UMA_ADDRESS"
CodeGen->>CodeGen: Map to UmaAddressDestination class
CodeGen->>Client: Strongly-typed Transaction object
a26b5f1 to
8e458b0
Compare
e7d2ae0 to
2793eb3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
8e458b0 to
8f5820a
Compare
2793eb3 to
a6d5ea6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
941bc27 to
b9e7d56
Compare
a6d5ea6 to
ba5b137
Compare
b9e7d56 to
13de662
Compare
ba5b137 to
8e152e4
Compare
openapi/components/schemas/quotes/QuoteRequestAccountDestination.yaml
Outdated
Show resolved
Hide resolved
openapi/components/schemas/quotes/QuoteUmaAddressDestination.yaml
Outdated
Show resolved
Hide resolved
13de662 to
98da0bf
Compare
8e152e4 to
4db1ea5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 2 comments
98da0bf to
f05d11f
Compare
4db1ea5 to
152d09c
Compare
152d09c to
5adb57b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
c88c884 to
7fc9ade
Compare
7fc9ade to
36f295c
Compare

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