Skip to content

fix(openapi): resolve streaming request name collision when multiple endpoints share a $ref body#14256

Draft
jsklan wants to merge 1 commit intomainfrom
jsklan/fix-stream-request-collision
Draft

fix(openapi): resolve streaming request name collision when multiple endpoints share a $ref body#14256
jsklan wants to merge 1 commit intomainfrom
jsklan/fix-stream-request-collision

Conversation

@jsklan
Copy link
Copy Markdown
Contributor

@jsklan jsklan commented Mar 28, 2026

Description

When two endpoints both use x-fern-streaming with stream-condition and reference the same $ref request body schema, the auto-disambiguation logic (introduced in #13568) derived the streaming request name from the shared schema name (e.g., NorthChatRequestInternalStreaming). Since the name came from the $ref rather than the endpoint, multiple endpoints sharing the same request body all produced the same streaming request name, causing "NorthChatRequestInternalStreaming is already declared in this file" errors.

Changes Made

  • convertStreamingOperation.ts: Removed the ${schemaId}Streaming auto-disambiguation. Now only passes through the explicit stream-request-name user override (if provided). Otherwise, convertHttpOperation's generatedRequestName — which is already unique per endpoint via breadcrumbs with a "stream" suffix — flows through as the natural fallback.
  • Test fixtures: Added a second endpoint (sharing the same $ref request body) to the x-fern-streaming-with-reference fixture in both openapi-ir-to-fern-tests and v3-importer-tests to cover the multi-endpoint collision case. Also added a third endpoint without x-fern-sdk-method-name to exercise the operationId-based breadcrumb path.

Context on #13568

PR #13568 introduced the ${schemaId}Streaming auto-disambiguation to prevent streaming and non-streaming variants of a single endpoint from colliding when the request body is a $ref. We attempted to reproduce that original bug by running our updated fixture against the pre-#13568 code, but the generatedRequestName (breadcrumb-based) already produced unique names in all scenarios we tested — with and without x-fern-sdk-method-name, and with various $ref schema names. The explicit stream-request-name user override added in #13568 is preserved and still works.

Testing

  • All 275 openapi-ir-to-fern-tests pass
  • All 236 v3-importer-tests pass
  • Verified fern check against the Cohere spec that originally triggered this bug — 0 errors (previously 1 error)

…endpoints share a $ref body

When two endpoints both use x-fern-streaming with stream-condition and
reference the same $ref request body schema, the auto-disambiguation
logic was deriving the streaming request name from the shared schema
name (e.g. NorthChatRequestInternalStreaming), causing duplicate
declaration errors.

Remove the ${schemaId}Streaming auto-disambiguation and instead let
convertHttpOperation's generatedRequestName (which is already unique
per endpoint via breadcrumbs with "stream" suffix) flow through as the
natural fallback. Explicit stream-request-name overrides still work.

Also adds multi-endpoint test coverage to the x-fern-streaming-with-reference
fixture to prevent regression.
@github-actions
Copy link
Copy Markdown
Contributor

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI
  • Postman

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.

@jsklan jsklan changed the title fix(openapi): resolve streaming request name collision when multiple … fix(cli): resolve streaming request name collision when multiple … Mar 28, 2026
@jsklan jsklan changed the title fix(cli): resolve streaming request name collision when multiple … fix(openapi): resolve streaming request name collision when multiple endpoints share a $ref body Mar 28, 2026
@jsklan jsklan requested a review from Swimburger March 28, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant