Conversation
Greptile OverviewGreptile SummaryRefactored customer schema architecture to separate create and update request schemas with consistent structure.
The refactoring maintains backward compatibility for the PATCH endpoint by keeping fields optional for partial updates, while enforcing stricter validation for POST requests. Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| openapi/components/schemas/customers/CustomerCreateRequest.yaml | new base schema for customer creation with missing type declaration and duplicate text |
| openapi/components/schemas/customers/CustomerCreateRequestOneOf.yaml | simple oneOf wrapper for create requests, properly configured |
| openapi/components/schemas/customers/BusinessCustomerCreateRequest.yaml | correctly extends base create request with business fields requiring legalName |
| openapi/components/schemas/customers/CustomerUpdateRequest.yaml | base schema for updates without platformCustomerId requirement |
| openapi/components/schemas/customers/BusinessInfo.yaml | business info schema requiring legalName for creation |
| openapi/components/schemas/customers/BusinessInfoUpdate.yaml | business info schema without required fields for partial updates |
Sequence Diagram
sequenceDiagram
participant Client
participant API as Grid API
participant ValidationLayer as Schema Validation
participant Database
Note over Client,Database: Customer Creation Flow
Client->>API: POST /customers
Note right of Client: CustomerCreateRequestOneOf<br/>(requires platformCustomerId)
API->>ValidationLayer: Validate request schema
ValidationLayer->>ValidationLayer: Check customerType (INDIVIDUAL/BUSINESS)
ValidationLayer->>ValidationLayer: Validate required fields<br/>(platformCustomerId, customerType)
alt Business Customer
ValidationLayer->>ValidationLayer: Validate BusinessInfo<br/>(legalName required)
else Individual Customer
ValidationLayer->>ValidationLayer: Validate IndividualCustomerFields
end
ValidationLayer->>API: Schema valid
API->>Database: Create customer record
Database->>API: Customer created
API->>Client: 201 Created (Customer object)
Note over Client,Database: Customer Update Flow
Client->>API: PATCH /customers/{customerId}
Note right of Client: CustomerUpdateRequestOneOf<br/>(platformCustomerId optional)
API->>ValidationLayer: Validate request schema
ValidationLayer->>ValidationLayer: Check customerType (INDIVIDUAL/BUSINESS)
ValidationLayer->>ValidationLayer: Validate optional fields<br/>(partial update allowed)
alt Business Customer Update
ValidationLayer->>ValidationLayer: Validate BusinessInfoUpdate<br/>(no required fields)
else Individual Customer Update
ValidationLayer->>ValidationLayer: Validate IndividualCustomerFields
end
ValidationLayer->>API: Schema valid
API->>Database: Update customer record
Database->>API: Customer updated
API->>Client: 200 OK (Updated Customer object)
openapi/components/schemas/customers/BusinessCustomerCreateRequest.yaml
Outdated
Show resolved
Hide resolved
00a920e to
4970949
Compare
e93abea to
f8c05b0
Compare
f8c05b0 to
51732f6
Compare
There was a problem hiding this comment.
should we just have the one BusinessInfo.yaml (with legalName required)?
There was a problem hiding this comment.
It was originally structured that way. The issue is that if you're patching a business, it's annoying to always include business legalName in every request.
I restructured it so legalName is required on create and in the response.
There was a problem hiding this comment.
but optional in patch
51732f6 to
96dadbd
Compare
| umaAddress: | ||
| description: >- | ||
| Optional UMA address identifier. If not provided during customer creation, one will be generated by the system. | ||
| If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer. | ||
| This is an optional identifier to route payments to the customer. |
There was a problem hiding this comment.
duplicated sentence - "This is an optional identifier to route payments to the customer." appears twice
| umaAddress: | |
| description: >- | |
| Optional UMA address identifier. If not provided during customer creation, one will be generated by the system. | |
| If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer. | |
| This is an optional identifier to route payments to the customer. | |
| umaAddress: | |
| type: string | |
| description: >- | |
| Optional UMA address identifier. If not provided during customer creation, one will be generated by the system. | |
| If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer. | |
| example: $john.doe@uma.domain.com |
Prompt To Fix With AI
This is a comment left during a code review.
Path: openapi/components/schemas/customers/CustomerCreateRequest.yaml
Line: 12:16
Comment:
duplicated sentence - "This is an optional identifier to route payments to the customer." appears twice
```suggestion
umaAddress:
type: string
description: >-
Optional UMA address identifier. If not provided during customer creation, one will be generated by the system.
If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer.
example: $john.doe@uma.domain.com
```
How can I resolve this? If you propose a fix, please make it concise.Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
openapi/components/schemas/customers/CustomerCreateRequest.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
| umaAddress: | ||
| description: >- | ||
| Optional UMA address identifier. If not provided during customer creation, one will be generated by the system. | ||
| If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer. | ||
| This is an optional identifier to route payments to the customer. |
There was a problem hiding this comment.
missing type: string for umaAddress field
| umaAddress: | |
| description: >- | |
| Optional UMA address identifier. If not provided during customer creation, one will be generated by the system. | |
| If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer. | |
| This is an optional identifier to route payments to the customer. | |
| umaAddress: | |
| type: string | |
| description: >- | |
| Optional UMA address identifier. If not provided during customer creation, one will be generated by the system. | |
| If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer. | |
| example: $john.doe@uma.domain.com |
Prompt To Fix With AI
This is a comment left during a code review.
Path: openapi/components/schemas/customers/CustomerCreateRequest.yaml
Line: 12:16
Comment:
missing `type: string` for `umaAddress` field
```suggestion
umaAddress:
type: string
description: >-
Optional UMA address identifier. If not provided during customer creation, one will be generated by the system.
If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer.
example: $john.doe@uma.domain.com
```
How can I resolve this? If you propose a fix, please make it concise.| If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer. | ||
| This is an optional identifier to route payments to the customer. |
There was a problem hiding this comment.
duplicated text - "This is an optional identifier to route payments to the customer." appears twice
| If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer. | |
| This is an optional identifier to route payments to the customer. | |
| If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer. | |
| example: $john.doe@uma.domain.com |
Prompt To Fix With AI
This is a comment left during a code review.
Path: openapi/components/schemas/customers/CustomerCreateRequest.yaml
Line: 15:16
Comment:
duplicated text - "This is an optional identifier to route payments to the customer." appears twice
```suggestion
If provided during customer update, the UMA address will be updated to the provided value. This is an optional identifier to route payments to the customer.
example: $john.doe@uma.domain.com
```
How can I resolve this? If you propose a fix, please make it concise.
TL;DR
Refactored customer schema definitions to use a consistent approach for both creation and update operations.
What changed?
CustomerCreateRequestas a base schemaIndividualCustomerCreateRequestandBusinessCustomerCreateRequestextending the base schemaCustomerCreateRequestOneOfto handle the oneOf relationship between customer typesIndividualCustomerUpdateandBusinessCustomerUpdate) with the same creation request schemas/customersto useCustomerCreateRequestOneOf/customers/{customerId}to useCustomerCreateRequestOneOf