Skip to content

[WIP] Update isomorphic-fetch file to allow for response streaming#1

Merged
Rezrazi merged 3 commits intomasterfrom
copilot/update-isomorphic-fetch-response-streaming
Jan 11, 2026
Merged

[WIP] Update isomorphic-fetch file to allow for response streaming#1
Rezrazi merged 3 commits intomasterfrom
copilot/update-isomorphic-fetch-response-streaming

Conversation

Copy link

Copilot AI commented Jan 11, 2026

  • Explore repository structure and understand the code
  • Modify isomorphic-fetch.mustache to add stream() function for Node.js platform
  • Update http.mustache to add stream method to ResponseBody interface for Node.js
  • Add stream() implementation to SelfDecodingBody class for Node.js (returns null)
  • Change stream?() (optional) to stream() (required) per user feedback
  • Verify changes don't break existing functionality (both default and browser samples compile)
  • Run code review
  • Run security checks
Original prompt

change modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache to allow for response streaming

by default, we're in the nodejs context platform, so we need to be unidici compatible

we don't stream in browser

and stream should be an optional function


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 11, 2026 21:48
…form

Co-authored-by: Rezrazi <2086576+Rezrazi@users.noreply.github.com>
…s platform

Co-authored-by: Rezrazi <2086576+Rezrazi@users.noreply.github.com>
@Rezrazi Rezrazi marked this pull request as ready for review January 11, 2026 21:53
Copilot AI review requested due to automatic review settings January 11, 2026 21:53
@Rezrazi Rezrazi merged commit 30f1f36 into master Jan 11, 2026
4 checks passed
Copilot AI requested a review from Rezrazi January 11, 2026 21:54
Copilot stopped work on behalf of Rezrazi due to an error January 11, 2026 21:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds response streaming support to the TypeScript OpenAPI Generator for Node.js environments. The implementation enables access to the underlying response stream from undici's fetch implementation while maintaining compatibility with existing code.

Changes:

  • Added stream() method to the ResponseBody interface for Node.js platform
  • Implemented stream() in IsomorphicFetchHttpLibrary to expose undici's response body stream
  • Provided null-returning stream() implementation in SelfDecodingBody for non-streaming contexts

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
modules/openapi-generator/src/main/resources/typescript/http/http.mustache Adds stream() method to ResponseBody interface and SelfDecodingBody class for Node.js platform
modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache Implements stream() to return resp.body from undici's Response
samples/openapi3/client/petstore/typescript/builds/default/http/http.ts Generated sample with required stream() method
samples/openapi3/client/petstore/typescript/builds/default/http/isomorphic-fetch.ts Generated sample implementing stream access
samples/openapi3/client/petstore/typescript/builds/object_params/http/http.ts Generated sample with optional stream?() method (inconsistent)
samples/openapi3/client/petstore/typescript/builds/object_params/http/isomorphic-fetch.ts Generated sample implementing stream access
samples/openapi3/client/petstore/typescript/builds/inversify/http/http.ts Generated sample with optional stream?() method (inconsistent)
samples/openapi3/client/petstore/typescript/builds/inversify/http/isomorphic-fetch.ts Generated sample implementing stream access
samples/openapi3/client/petstore/typescript/builds/browser/http/http.ts Browser build correctly excludes stream method
samples/client/echo_api/typescript/build/http/http.ts Generated sample with optional stream?() method (inconsistent)
samples/client/echo_api/typescript/build/http/isomorphic-fetch.ts Generated sample implementing stream access

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

export interface ResponseBody {
text(): Promise<string>;
binary(): Promise<Buffer>;
stream?(): ReadableStream<Uint8Array> | null;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The stream method is marked as optional in the ResponseBody interface, but it's implemented as a required method in the SelfDecodingBody class. This creates an inconsistency with the template definition in http.mustache (line 221) which defines it as required. The interface should have stream() without the question mark to match the template and ensure all implementations provide this method.

Suggested change
stream?(): ReadableStream<Uint8Array> | null;
stream(): ReadableStream<Uint8Array> | null;

Copilot uses AI. Check for mistakes.
export interface ResponseBody {
text(): Promise<string>;
binary(): Promise<Buffer>;
stream?(): ReadableStream<Uint8Array> | null;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The stream method is marked as optional in the ResponseBody interface, but it's implemented as a required method in the SelfDecodingBody class. This creates an inconsistency with the template definition in http.mustache (line 221) which defines it as required. The interface should have stream() without the question mark to match the template and ensure all implementations provide this method.

Suggested change
stream?(): ReadableStream<Uint8Array> | null;
stream(): ReadableStream<Uint8Array> | null;

Copilot uses AI. Check for mistakes.
export interface ResponseBody {
text(): Promise<string>;
binary(): Promise<Buffer>;
stream?(): ReadableStream<Uint8Array> | null;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The stream method is marked as optional in the ResponseBody interface, but it's implemented as a required method in the SelfDecodingBody class. This creates an inconsistency with the template definition in http.mustache (line 221) which defines it as required. The interface should have stream() without the question mark to match the template and ensure all implementations provide this method.

Suggested change
stream?(): ReadableStream<Uint8Array> | null;
stream(): ReadableStream<Uint8Array> | null;

Copilot uses AI. Check for mistakes.
}

{{#platforms}}
{{#node}}
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The stream method implementation always returns null in SelfDecodingBody. Consider adding a comment explaining that this implementation doesn't support streaming and that streaming is only available through the actual fetch response body in IsomorphicFetchHttpLibrary. This would help developers understand when they can expect a usable stream versus null.

Suggested change
{{#node}}
{{#node}}
// SelfDecodingBody does not support streaming. A readable stream is only
// available from the underlying fetch Response body in IsomorphicFetchHttpLibrary.

Copilot uses AI. Check for mistakes.
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.

3 participants