-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added optional param to force empty object #1506
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
Conversation
|
✱ Stainless preview buildsThis PR will update the
|
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.
No issues found across 2 files
Greptile SummaryAdded optional
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as SDK Client
participant Stainless as Stainless Generator
participant OpenAPI as OpenAPI Spec
participant Zod as Zod Schema
participant Server as Fastify Server
Note over OpenAPI,Zod: Before: properties: {}
Note over Client: Problem: Empty object doesn't<br/>force body parameter
Note over OpenAPI,Zod: After: properties with _forceBody
Stainless->>OpenAPI: Read SessionEndRequest schema
OpenAPI-->>Stainless: _forceBody with not: {} constraint
Note over Stainless: Detects property exists,<br/>generates body parameter
Stainless->>Client: Generate SDK with body param
Client->>Server: POST /v1/sessions/{id}/end<br/>Content-Type: application/json<br/>Body: {}
Server->>Zod: Validate request body
Note over Zod: _forceBody: z.undefined().optional()<br/>Accepts {} (field omitted)
Zod-->>Server: Validation passes
Server-->>Client: 200 OK { success: true }
|
why
Generated sdks need to send empty object for /end endpoint to match prod api
what changed
Added dummy optional param to schema to force proper code gen
test plan
Confirmed that the generated wheel linked below by stainless is correct.
Summary by cubic
Added an optional _forceBody field to SessionEndRequest so Stainless generates a body parameter for the endpoint. The server still accepts {} and clients can omit the field, fixing missing-body issues on session end requests.
Written for commit 7f8a7bc. Summary will update on new commits.