fix(openapi): preserve 204 status code in response conversion#14982
fix(openapi): preserve 204 status code in response conversion#14982devin-ai-integration[bot] wants to merge 4 commits intomainfrom
Conversation
Co-Authored-By: rishabh <rishabh@buildwithfern.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
Co-Authored-By: rishabh <rishabh@buildwithfern.com>
Co-Authored-By: rishabh <rishabh@buildwithfern.com>
Co-Authored-By: rishabh <rishabh@buildwithfern.com>
SDK Generation Benchmark ResultsComparing PR branch against latest nightly baseline 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 |
Description
Fixes a bug where a 204 No Content status code defined in an OpenAPI spec is displayed as "200 Successful" in Fern docs. The status code was being lost during the OpenAPI → Fern IR conversion because no-body responses produced
undefinedin the response field, and downstream defaults filled in 200.This also affects other non-200 success codes (201, 202) when the endpoint has no response body.
Changes Made
Three files in the OpenAPI importer pipeline are modified:
convertResponse.ts— Added asuccessStatusCodefield toConvertedResponsethat tracks the first success status code encountered, even when the response has no body (i.e.,valueisundefined).convertHttpOperation.ts— WhenconvertedResponse.valueisundefinedbutsuccessStatusCodeis non-200, creates aResponseWithExample.text()carrier to propagate the status code through the IR.buildEndpoint.ts— In thetextresponse handler, special-casesstatusCode === 204to emit only"status-code": 204in the Fern Definition without settingtype: "text", so the downstream IR correctly represents a no-body response.Additionally:
no-contentseed test fixture (test-definitions/fern/apis/no-content/) with an OpenAPI spec containing a DELETE endpoint returning 204ts-sdkseed output for the new fixtureResponseWithExample.text()as a "carrier" to thread the status code through the OpenAPI IR (which doesn't have a dedicated "no body" response variant). Confirm this doesn't cause unexpected behavior in other consumers of the IR.buildEndpoint.ts: ThetextResponse.statusCode === 204check is specific to 204. Other non-200 codes with no body (e.g., 201) will still gettype: "text"set in the Fern Definition. Consider whether this should be more general (e.g., checking for absence of actual text content). The ete-test snapshots show this: petstore'screatePets(201) now getsstatus-code: 201withtype: text, while 204 endpoints get onlystatus-code: 204.fern-platform'sv1ToV2.tsmigrator also hasstatusCode ?? 200and an earlyreturn undefinedwhenresponse.type == null. A separate fix there may be needed for full end-to-end correctness after re-runningfern generate --docs.ts-sdkseed output was generated. Verify whether other generators also need seed output for this fixture.Testing
ts-sdk) passes for the newno-contentfixturepnpm compilepasses for affected packagespnpm run check(biome) passes cleanlyLink to Devin session: https://app.devin.ai/sessions/59b2594a5ea74b39bdd202e1e2eb5eee