-
Notifications
You must be signed in to change notification settings - Fork 3
fix: separating create customer from customer response schemas #142
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?
fix: separating create customer from customer response schemas #142
Conversation
Greptile OverviewGreptile SummaryThis PR refactors customer schema definitions to create a cleaner separation between creation and update operations using shared field definitions. Key Changes
Architecture BenefitsThe refactoring improves schema maintainability by:
Issues Already ReportedPrevious review comments identified issues with
These issues are acknowledged by the development team. Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| openapi/components/schemas/customers/CustomerCreateRequest.yaml | New base schema for customer creation with required platformCustomerId and duplicated umaAddress description |
| openapi/components/schemas/customers/CustomerUpdateRequest.yaml | New base schema for customer updates, properly designed with optional fields for partial updates |
| openapi/components/schemas/customers/BusinessCustomerCreateRequest.yaml | Combines base schema with business fields and overrides to require legalName for creation |
| openapi/components/schemas/customers/BusinessCustomerUpdateRequest.yaml | Properly allows partial updates by using BusinessInfo.yaml without required fields |
| openapi/components/schemas/customers/BusinessInfoRequired.yaml | Business information schema requiring legalName for customer creation |
| openapi/paths/customers/customers.yaml | Updated POST endpoint to reference new CustomerCreateRequestOneOf schema |
| openapi/paths/customers/customers_{customerId}.yaml | Updated PATCH endpoint to reference new CustomerUpdateRequestOneOf schema |
Sequence Diagram
sequenceDiagram
participant Client
participant API as Grid API
participant CreateSchema as CustomerCreateRequestOneOf
participant UpdateSchema as CustomerUpdateRequestOneOf
participant Response as Customer Response
Note over Client,Response: Customer Creation Flow (POST /customers)
Client->>API: POST /customers
API->>CreateSchema: Validate against schema
alt Individual Customer
CreateSchema->>CreateSchema: CustomerCreateRequest (base)<br/>+ IndividualCustomerFields<br/>Requires: customerType, platformCustomerId
else Business Customer
CreateSchema->>CreateSchema: CustomerCreateRequest (base)<br/>+ BusinessCustomerFields<br/>+ BusinessInfoRequired override<br/>Requires: customerType, platformCustomerId, legalName
end
CreateSchema-->>API: Validation passed
API->>Response: Return Customer (with generated IDs)
Response-->>Client: 201 Created
Note over Client,Response: Customer Update Flow (PATCH /customers/{customerId})
Client->>API: PATCH /customers/{customerId}
API->>UpdateSchema: Validate against schema
alt Individual Customer
UpdateSchema->>UpdateSchema: CustomerUpdateRequest (base)<br/>+ IndividualCustomerFields<br/>Requires: customerType only<br/>All other fields optional
else Business Customer
UpdateSchema->>UpdateSchema: CustomerUpdateRequest (base)<br/>+ BusinessCustomerFields<br/>Requires: customerType only<br/>businessInfo fields all optional (BusinessInfo.yaml)
end
UpdateSchema-->>API: Validation passed (partial update)
API->>Response: Return updated Customer
Response-->>Client: 200 OK
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.
4 files reviewed, 2 comments
openapi/components/schemas/customers/BusinessCustomerCreateRequest.yaml
Outdated
Show resolved
Hide resolved
00a920e to
4970949
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.
3 files reviewed, 2 comments
e93abea to
f8c05b0
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.
7 files reviewed, 1 comment
f8c05b0 to
51732f6
Compare

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