fix(typescript, csharp): keep examples for bytes and file upload request bodies - #17463
fix(typescript, csharp): keep examples for bytes and file upload request bodies#17463fern-api[bot] wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
AI Review Summary
Narrows exampleOmitsRequestBody to only inline/reference bodies so bytes and file-upload examples aren't silently dropped. The fix is correct and minimal, and the TS and C# copies stay in sync. Only minor nits: missing test coverage for the optional-body/flag-off combination and the now-duplicated predicate in two generators.
- 🔵 2 suggestion(s)
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Follow-up: the restored
|
Description
Refs Anduril #22930 (customer report:
uploadObjectdisappeared from the generated JS SDK'sreference.mdafter upgrading to ts-sdk 3.88.0).exampleOmitsRequestBody, added in #17373 alongside the C#respectOptionalRequestBodywork, drops any example where the endpoint declares a request body butexample.request == null.FernIr.ExampleRequestBodyonly hasinlinedRequestBodyandreferencevariants — it has no shape for abytesorfileUploadbody — so every example of an upload endpoint reads as bodyless and gets dropped. When the last example goes,SdkGeneratornever callsserviceReference.addEndpoint, so the endpoint loses itsreference.mdsection, its@exampledocstring and its snippets, even though the method is still generated inClient.ts.The predicate is now restricted to the body types an example can actually carry:
Filtering of bodyless examples for endpoints with a required (or non-
respectOptionalRequestBody-omittable) inline/reference body is unchanged, so the optional-request-body behavior the flag gates keeps working exactly as before. The same one-line copy of the predicate in the C# generator gets the same treatment.Changes Made
generators/typescript/utils/commons/.../getExampleEndpointCalls.ts: only considerinlinedRequestBody/referencebodies when deciding an example omits its request bodygenerators/csharp/sdk/src/utils/exampleUtils.ts: same fix for the C# copy of the predicaterespectOptionalRequestBodyTesting
generators/typescript/sdk/generator:exampleOmitsRequestBody.test.ts(3) +callOmitsRequestBody.test.ts(4) passseed test --generator ts-sdk --fixture bytes-upload --localproduced areference.mdcontaining only# Reference/## Service(both upload endpoints gone); with the fix, generated output is byte-identical to the checked-in snapshots forts-sdkbytes-upload,file-uploadand bothts-optional-request-bodyconfigs, and forcsharp-sdkbytes-upload,file-uploadand bothrespect-optional-request-bodyconfigs (4/4 seed cases pass, only.fern/metadata.jsonlocal-run noise, reverted)Not verified in this environment: seed post-generation installs and eslint can't run (
registry.npmjs.orgis off the network allowlist), so those are left to CI.