Skip to content

Conversation

@pengying
Copy link
Contributor

@pengying pengying commented Jan 24, 2026

TL;DR

Refactored OpenAPI schema definitions for customer-related endpoints to improve maintainability and consistency.

What changed?

  • Created dedicated schema components for CreateCustomerRequest and UpdateCustomerRequest
  • Moved inline schema definitions from API paths to reusable component schemas
  • Changed enum: [INDIVIDUAL] to const: INDIVIDUAL in the IndividualCustomerUpdate schema for better semantics
  • Added platformCustomerId directly to the IndividualCustomerUpdate schema
  • Removed redundant examples from the API paths as they're now defined in the schema components

@greptile-apps
Copy link

greptile-apps bot commented Jan 24, 2026

Greptile Overview

Greptile Summary

Refactored customer API schemas by extracting inline definitions into reusable components (CreateCustomerRequest and UpdateCustomerRequest), improving maintainability. Changed enum: [INDIVIDUAL] to const: INDIVIDUAL in IndividualCustomerUpdate for better OpenAPI semantics.

Key Changes

  • Created dedicated schema components for create and update customer requests
  • Moved platformCustomerId from inline CREATE-only definition to IndividualCustomerUpdate base schema
  • Removed inline examples from path definitions
  • Simplified path files by referencing new schema components

Issues Found

  • Breaking change: platformCustomerId is no longer required for CREATE operations (was required via allOf previously)
  • Missing field: BusinessCustomerUpdate doesn't have platformCustomerId field at all
  • Removed field: kycUrl response field was completely removed from CREATE endpoint
  • API behavior change: platformCustomerId now appears in UPDATE operations (wasn't there before)
  • Documentation: Inline examples removed from endpoints, reducing API documentation clarity

Confidence Score: 2/5

  • This PR has breaking API changes that affect required fields for customer creation
  • The refactoring improves code organization but introduces breaking changes to the API contract. The platformCustomerId field is no longer enforced as required for CREATE operations, and BusinessCustomerUpdate is missing this field entirely. The kycUrl field was also removed. These changes will break existing API clients that rely on the previous validation behavior.
  • Pay close attention to CreateCustomerRequest.yaml and BusinessCustomerUpdate.yaml which need the platformCustomerId requirement restored

Important Files Changed

Filename Overview
openapi/components/schemas/customers/CreateCustomerRequest.yaml New schema component created, but missing required platformCustomerId field and kycUrl field from original CREATE endpoint
openapi/components/schemas/customers/IndividualCustomerUpdate.yaml Changed enum to const for customerType, added platformCustomerId field but not marked as required
openapi/paths/customers/customers.yaml Simplified to use CreateCustomerRequest schema, but removed inline examples and lost kycUrl field and platformCustomerId requirement
openapi/components/schemas/customers/BusinessCustomerUpdate.yaml Missing platformCustomerId field that was required in the previous CREATE endpoint

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as Grid API
    participant Schema as CreateCustomerRequest Schema
    participant Individual as IndividualCustomerUpdate
    participant Business as BusinessCustomerUpdate

    Note over Client,Business: Create Customer Flow (POST /customers)
    Client->>API: POST /customers with customerType
    API->>Schema: Validate request body
    
    alt customerType = INDIVIDUAL
        Schema->>Individual: Validate against IndividualCustomerUpdate
        Individual-->>Schema: Validation result
        Note over Individual: customerType: const INDIVIDUAL<br/>platformCustomerId: optional<br/>fullName, birthDate, etc.
    else customerType = BUSINESS
        Schema->>Business: Validate against BusinessCustomerUpdate
        Business-->>Schema: Validation result
        Note over Business: customerType: const BUSINESS<br/>businessInfo, address, etc.<br/>Missing: platformCustomerId
    end
    
    Schema-->>API: Schema validation complete
    API-->>Client: 201 Created with Customer object

    Note over Client,Business: Update Customer Flow (PATCH /customers/{customerId})
    Client->>API: PATCH /customers/{id} with customerType
    API->>Schema: Validate against UpdateCustomerRequest
    
    alt customerType = INDIVIDUAL
        Schema->>Individual: Same schema as CREATE
        Individual-->>Schema: Validation result
    else customerType = BUSINESS
        Schema->>Business: Same schema as CREATE
        Business-->>Schema: Validation result
    end
    
    Schema-->>API: Schema validation complete
    API-->>Client: 200 OK with updated Customer
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link

greptile-apps bot commented Jan 24, 2026

Additional Comments (1)

openapi/components/schemas/customers/BusinessCustomerUpdate.yaml
Missing platformCustomerId field. The previous CREATE endpoint required this for business customers via allOf. Either add it to this schema (like IndividualCustomerUpdate.yaml) or handle it differently in CreateCustomerRequest.yaml.

Prompt To Fix With AI
This is a comment left during a code review.
Path: openapi/components/schemas/customers/BusinessCustomerUpdate.yaml
Line: 1:33

Comment:
Missing `platformCustomerId` field. The previous CREATE endpoint required this for business customers via `allOf`. Either add it to this schema (like `IndividualCustomerUpdate.yaml`) or handle it differently in `CreateCustomerRequest.yaml`.

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants