Skip to content

[WIP]Add experimental SSE support to Java emitter - #12312

Draft
Xiaofei Cao (XiaofeiCao) wants to merge 23 commits into
microsoft:mainfrom
XiaofeiCao:xiaofeicao-java-sse-experimental
Draft

Xiaofei Cao (XiaofeiCao) wants to merge 23 commits into
microsoft:mainfrom
XiaofeiCao:xiaofeicao-java-sse-experimental

Conversation

@XiaofeiCao

@XiaofeiCao Xiaofei Cao (XiaofeiCao) commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Add experimental typed SSE generation for explicitly named, nonliteral JSON events in the Azure v1 flavor.

  • Generate asynchronous Flux<Event> and synchronous CloseableIterableStream<Event> convenience APIs with a base event type and typed subtypes.
  • Support named model, scalar, array, dictionary, and recursive collection payloads, including @data extraction. Decode scalar wire types with existing wire-to-client conversion, including encoded durations in nested collections. Deliver named terminal events inclusively.
  • Keep TCGC metadata in a canonical CID-keyed CodeModel.sseStreams catalog referenced by operations, without structural metadata fingerprints. Register payload models only when typed convenience APIs are generated.
  • Preserve customized operation names, visibility, protocol *WithResponse binary APIs, generation gates, SDK-only wrapper constructors, and strict generated-name/source-path checks. Qualify colliding payload references and resolve event, container, converter, and runtime-helper references against the complete client import set, including request models and enums on other methods. Preserve Reactor references in versioned-parameter validation and generate historical sync/async parameter overloads for older service versions.
  • Reuse incremental framing, cancellation, and resource-closure helpers. Unknown event names produce name-only, nonterminal wrappers.

Experimental scope

Unnamed events, mixed named/unnamed unions, all event-payload literals including [DONE], and unsupported nullable event payloads are diagnosed and retain ordinary binary APIs rather than generating partial typed output. Unnamed support is deferred to a follow-up PR. Nullable properties inside ordinary model payloads are unaffected. Reconnection and historical Search wrapper/customization migration are outside this change.

Supported Azure v1 streams are generated automatically; no dev-options.enable-sse option is required or supported. Other flavors and unsupported streams retain their existing APIs.

Cleanup

  • Keep exactly one SSE test source under tsptest: ServerSentEventStreamTests.java.
  • Consolidate emitter SSE fixtures into emitter/test/fixtures/sse.tsp, with comments separating scenarios and isolated virtual service entrypoints for each test.
  • Remove direct/default/literal generation paths, obsolete fixtures, and the redundant SSE-specific file-cleanup test.
  • Restore usage.md to its pre-PR content.
  • Consolidate the SSE changelog into one feature entry: “Support generating APIs for server-sent events (SSE).”

Validation

  • Added failing regressions before fixing unsupported-shape handling, temporal decoding, nullable fallback, protocol-only payload usage, generated type/import collisions, empty descriptions for short stream names, versioned-parameter error handling, and historical SSE overloads.
  • Full Java package build/tests, focused generator regressions, and 62 emitter tests passed.
  • Generated Java 11 module/client compilation reproduced request model/enum, container, runtime-helper, converter, versioned-validation, and missing historical-overload errors before the fixes and passed afterward.
  • Lint, typecheck, package/root formatting, Spotless, generated-client/module compilation, and git diff --check passed.
  • Verified one emitter SSE fixture, one tsptest SSE test source, no usage.md diff against the base, and one SSE changeset.
  • Copilot review of final head 9a7cdb5ba reports No open issues, with zero inline comments, no actionable body-only findings, and no unresolved review threads. This is a COMMENTED review, not human approval; the PR remains draft.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-java
Show changes

@typespec/http-client-java - feature ✏️

Support generating APIs for server-sent events (SSE).,> ,> tsp,> @events,> union Events {,> message: string,,> ,> @terminalEvent,> completed: string,,> },> ,> op stream(): SSEStream<Events>;,>

@XiaofeiCao
Xiaofei Cao (XiaofeiCao) marked this pull request as draft October 20, 2026 12:15
@XiaofeiCao Xiaofei Cao (XiaofeiCao) changed the title Add experimental SSE support to Java emitter [WIP]Add experimental SSE support to Java emitter Oct 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved generation failures, API visibility and module-export defects, and fixture-regeneration errors block approval.

6 open issues
What changed in this PR

Adds opt-in, experimental server-sent event (SSE) support to the Java emitter’s Azure flavor.

Changes:

  • Transfers SSE metadata into generated event wrappers, converters, and synchronous/asynchronous APIs.
  • Adds incremental parsing, response validation, and stream cleanup.
  • Adds generation fixtures, runtime tests, and changelog entries.
File Description
packages/​http-client-java/​generator/​http-client-generator/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​TypeSpecPlugin.java Wires SSE settings and helper generation.
packages/​http-client-java/​generator/​http-client-generator/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​model/​DevOptions.java Reads the experimental flag.
packages/​http-client-java/​generator/​http-client-generator-test/​tsp/​sse.tspconfig.yaml Enables SSE fixture generation.
packages/​http-client-java/​generator/​http-client-generator-test/​tsp/​sse.tsp Defines the integration fixture.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​test/​java/​tsptest/​sse/​models/​implementation/​sse/​ServerSentEventStreamTests.java Tests parsing and stream lifecycle.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​test/​java/​tsptest/​sse/​generated/​SseClientTestBase.java Adds generated client test setup.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​resources/​tsptest-sse.properties Supplies fixture SDK metadata.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​resources/​META-INF/​tsptest-sse_metadata.json Records generated fixture mappings.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​stream/​models/​TestStreamEvent.java Adds the generated event base.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​stream/​models/​TestStartedStreamEvent.java Wraps started-event payloads.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​stream/​models/​TestCompletedStreamEvent.java Wraps terminal-event payloads.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​stream/​implementation/​TestStreamEventConverter.java Converts fixture event payloads.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​SseClientBuilder.java Builds fixture clients.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​SseClient.java Demonstrates synchronous streaming APIs.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​SseAsyncClient.java Demonstrates asynchronous streaming APIs.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​package-info.java Documents the client package.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​models/​StartedPayload.java Adds the started payload model.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​models/​package-info.java Documents the payload package.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​models/​implementation/​sse/​ServerSentEventStreams.java Adds the generated runtime facade.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​models/​implementation/​sse/​ServerSentEventStreamResponse.java Adds generated response validation.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​models/​implementation/​sse/​ServerSentEventStream.java Adds the generated stream parser.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​models/​CompletedPayload.java Adds the completed payload model.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​implementation/​StreamOperationsImpl.java Implements fixture HTTP operations.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​implementation/​SseClientImpl.java Holds fixture client infrastructure.
packages/​http-client-java/​generator/​http-client-generator-test/​src/​main/​java/​tsptest/​sse/​implementation/​package-info.java Documents the implementation package.
packages/​http-client-java/​generator/​http-client-generator-test/​Generate.ps1 Selects the SSE fixture configuration.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​test/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​util/​SseNamingResolverTests.java Tests names and collisions.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​test/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​util/​SseMetadataRegistryTests.java Tests metadata deduplication and collisions.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​test/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​model/​javamodel/​JavaPackageSseTests.java Tests generated files and package placement.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​test/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​mapper/​ClientMethodMapperTests.java Tests SSE generation modes.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​resources/​ServerSentEventStreams.java Defines the runtime facade template.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​resources/​ServerSentEventStreamResponse.java Defines response validation and cleanup.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​resources/​ServerSentEventStream.java Defines incremental parsing and consumption.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​util/​TemplateUtil.java Marks SSE methods as collection-returning.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​util/​SseUtil.java Centralizes SSE package placement.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​util/​SseNamingResolver.java Resolves event and converter names.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​util/​SseMetadataRegistry.java Deduplicates streams and checks names.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​template/​SseEventModelTemplate.java Generates typed event wrappers.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​template/​SseEventConverterTemplate.java Generates JSON event converters.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​template/​ConvenienceSyncMethodTemplate.java Generates synchronous stream calls.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​template/​ConvenienceMethodTemplateBase.java Adds SSE helper imports.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​template/​ConvenienceAsyncMethodTemplate.java Generates asynchronous stream calls.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​model/​javamodel/​JavaPackage.java Emits SSE files with collision checks.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​model/​clientmodel/​GenericType.java Models closeable stream return types.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​model/​clientmodel/​ClientMethodType.java Adds SSE method kinds.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​model/​clientmodel/​ClientMethod.java Carries SSE metadata through methods.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​model/​clientmodel/​ClassType.java Registers the closeable stream class.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​mapper/​ClientMethodMapper.java Maps operations to SSE methods.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​extension/​plugin/​JavaSettings.java Stores the SSE enablement setting.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​extension/​model/​codemodel/​SseMetadata.java Represents stream metadata.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​extension/​model/​codemodel/​SseEventMetadata.java Represents individual event metadata.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​extension/​model/​codemodel/​Operation.java Attaches SSE metadata to operations.
packages/​http-client-java/​emitter/​test/​fixtures/​sse.tsp Covers supported and protocol-only operations.
packages/​http-client-java/​emitter/​test/​fixtures/​sse-unsupported.tsp Covers unsupported payload fallback.
packages/​http-client-java/​emitter/​test/​code-model.test.ts Tests opt-in metadata and fallback behavior.
packages/​http-client-java/​emitter/​src/​options.ts Defines the experimental SSE option.
packages/​http-client-java/​emitter/​src/​lib.ts Adds the unsupported-stream diagnostic.
packages/​http-client-java/​emitter/​src/​common/​operation.ts Defines TypeScript SSE metadata contracts.
packages/​http-client-java/​emitter/​src/​code-model-builder.ts Processes upstream SSE metadata.
.chronus/​changes/​xiaofeicao-implement-sse-naming-2026-9-20-15-3-28.md Records naming centralization.
.chronus/​changes/​http-client-java-experimental-sse-2026-10-20.md Documents the experimental feature.

Review effort: Balanced

Comment thread packages/http-client-java/emitter/src/code-model-builder.ts
Comment thread packages/http-client-java/emitter/src/code-model-builder.ts Outdated
Comment thread packages/http-client-java/generator/http-client-generator-test/Generate.ps1 Outdated
@azure-sdk-automation

azure-sdk-automation Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@JoshLove-msft

Copy link
Copy Markdown
Contributor

add opt-in Azure-flavor generation for named JSON server-sent event streams behind dev-options.enable-sse

Curious why this is opt-in rather than just enabled?

@XiaofeiCao

Copy link
Copy Markdown
Member Author

Curious why this is opt-in rather than just enabled?

Since we already had SSE customization code for Search GA Java SDK, my initial gut feeling is that we don't do major emitter changes before Search GA release.
Though current generated code is almost identical without customization, guess I could remove this opt-in once this PR's mature.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
@XiaofeiCao
Xiaofei Cao (XiaofeiCao) force-pushed the xiaofeicao-java-sse-experimental branch from f82f557 to c156bc1 Compare October 26, 2026 10:07
Copilot AI balanced review requested due to automatic review settings October 26, 2026 10:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread packages/http-client-java/emitter/src/code-model-builder.ts
Preserve internal visibility and sync-over-async protocol names, export SSE event packages, and generate valid event names and datetime imports.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
Copilot AI balanced review requested due to automatic review settings October 26, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

One or more issues must be addressed before approval.

2 open issues
2 previously missed issues

In code that hasn't changed since last review

Medium severity Reject named events with non-JSON payload content types

packages/​http-client-java/​emitter/​src/​code-model-builder.ts:1292

This accepts named events without checking event.payloadContentType, including string payloads explicitly marked @contentType("text/plain") (supported by packages/events/lib/decorators.tsp:41). Their unquoted SSE data is then passed to JsonProviders.createReader by SseEventConverterTemplate.java:146, so valid streams fail decoding; reject non-JSON payload content types through the existing unsupported-stream diagnostic and retain the raw APIs.

Medium severity Generate stream callbacks from wire types before client conversion

packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​template/​SseEventConverterTemplate.java:131

Calling getClientType() before generating the JSON callback discards wire encodings: a seconds-encoded duration maps to Duration and is decoded with Duration.parse(...) rather than reading the numeric seconds (PrimitiveMapper.java:113–126, ClassType.java:466), so valid payloads fail during iteration, including inside collections. Generate callbacks from the mapped wire type and then convert the decoded value to its client type, as StreamSerializationModelTemplate.java:1564–1599 does.

6 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
Copilot AI balanced review requested due to automatic review settings October 26, 2026 12:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

One or more issues must be addressed before approval.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve wire encodings during event deserialization

packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​template/​SseEventConverterTemplate.java:135

Calling getClientType() before building the JSON callback discards wire encodings: for example, a seconds-encoded duration becomes Duration and generates Duration.parse(reader.getString()), which fails on a valid numeric SSE payload such as 42. Deserialize using the wire type and then apply its client conversion (as WireTypeClientTypeConverter.java:105–120 does), recursively for collection elements, or retain the raw API for these encodings.

2 resolved since last review

Review effort: Balanced

Transport SSE definitions by union CID and bind canonical references before Java mapping. Emit only mapped definitions, preserve named output, and generate direct unnamed payloads or typed mixed and primitive-literal wrappers with strict matching and inclusive termination.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
Copilot AI balanced review requested due to automatic review settings October 26, 2026 17:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

One or more issues must be addressed before approval.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The changes require final human review because they are too complex or risky for automated approval.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The changes require final human review because they are too complex or risky for automated approval.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The changes require final human review because they are too complex or risky for automated approval.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
Copilot AI balanced review requested due to automatic review settings October 27, 2026 15:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

One or more issues must be addressed before approval.

3 open issues

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
Copilot AI balanced review requested due to automatic review settings October 27, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

One or more issues must be addressed before approval.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

Inline operation metadata and collect used SSE artifacts by CID.
Rename event converters to serializers, merge stream helpers, and use
ordinary Java imports. Strengthen metadata validation and coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
Copilot AI balanced review requested due to automatic review settings October 28, 2026 07:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Conflicting SSE type imports can make generated Java code fail compilation, while validation ordering can incorrectly abort generation for unsupported streams.

3 open issues

Review effort: Balanced

Comment on lines +712 to +716
if (m.getSseMetadata() != null) {
SseUtil.getSerializerType(m.getSseMetadata()).addImportsTo(methodImports, false);
SseUtil.getRuntimeType().addImportsTo(methodImports, false);
}
imports.addAll(methodImports);
String serializerName = names.getSerializerName();
Set<String> imports = new LinkedHashSet<>();
for (SseEventMetadata event : metadata.getEvents()) {
Mappers.getSchemaMapper().map(event.getPayload()).getClientType().addImportsTo(imports, false);
Comment on lines +1296 to +1299
const existingOwner = this.sseStreamOwners.get(id);
// Distinct generic union instantiations can share a TCGC CID while carrying different payloads.
if (existingOwner && existingOwner !== owner) {
throw new Error(`Distinct SSE unions claim cross-language definition ID '${id}'.`);
Compose inline synthetic base and event schemas in the emitter, consume their identities and relationships in Java, and remove obsolete wrapper naming plumbing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

private void createSseClientMethods(boolean isSync, Operation operation, ClientMethod baseMethod,
List<ClientMethod> methods, CreateMethodArgs createMethodArgs) {
IType eventType = SseUtil.getEventType(operation.getSseMetadata().getBaseSchema());
IType returnType = isSync ? GenericType.closeableIterableStream(eventType) : GenericType.flux(eventType);
Comment on lines +710 to +714
if (m.getSseMetadata() != null) {
SseUtil.getSerializerType(m.getSseMetadata()).addImportsTo(methodImports, false);
SseUtil.getRuntimeType().addImportsTo(methodImports, false);
}
imports.addAll(methodImports);
Comment on lines +37 to +40
for (SseEventMetadata event : metadata.getEvents()) {
Mappers.getSchemaMapper().map(SseUtil.getPayloadSchema(event)).getClientType().addImportsTo(imports, false);
}
SseUtil.getSerializerType(metadata).addImportsTo(imports, false);
Comment on lines +49 to +53
for (SseEventMetadata event : metadata.getEvents()) {
SseUtil.getEventType(event.getEventSchema()).addImportsTo(imports, false);
IType wirePayloadType = Mappers.getSchemaMapper().map(SseUtil.getPayloadSchema(event));
addPayloadImports(wirePayloadType, imports);
addPayloadImports(wirePayloadType.getClientType(), imports);

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants