Preserve SSE data schema identifier in OpenAPI output - #2495
Closed
kitlangton wants to merge 4 commits into
Closed
Conversation
HttpApiSchema.StreamSse({ data }) encodes the SSE data field as a JSON
string. That string wrapper was claiming the data schema's identifier in
the generated OpenAPI spec, pushing the decoded schema to a suffixed name
(e.g. the string wrapper became MyEvent while the object became MyEvent1).
The wrapper now takes its own ${identifier}Stream name.
🦋 Changeset detectedLatest commit: e8cc112 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
tim-smart
reviewed
Jun 29, 2026
| } | ||
|
|
||
| const sseDataJsonSchema = (data: Schema.Constraint) => { | ||
| const json = Schema.fromJsonString(data) |
Collaborator
There was a problem hiding this comment.
Potentially the real issue is with Schema.fromJsonString transforming the schema but keeping the identifier.
I'll wait for @gcanti to weight in here.
Contributor
There was a problem hiding this comment.
Potentially the real issue is with
Schema.fromJsonStringtransforming the schema but keeping the identifier.
Agreed, we could add a synthetic identifier to the encoded side: #2512
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
HttpApiSchema.StreamSse({ data })encodes the SSEdatafield as a JSON string (Schema.fromJsonString(data)). In the generated OpenAPI spec, that string wrapper was claiming the data schema'sidentifier, pushing the decoded schema to a suffixed name.For a data schema with
identifier: "MyEvent":This inverts the names for OpenAPI codegen consumers: generated clients end up with
MyEvent = stringand the real type renamed toMyEvent1, breaking typed access to event payloads.Fix
StreamSsenow annotates the JSON-string transport wrapper with its own${identifier}Streamname (when the data schema has an identifier), leaving the data schema's identifier intact. This matches how identifiers are resolved/assigned elsewhere in the OpenAPI generator (SchemaAST.resolveIdentifier).The fix is scoped to the
StreamSseconstructor. OtherfromJsonStringusages (encoding/Sse,HttpApiClient,HttpApiBuilder) are runtime decode/encode codecs that are never rendered into an OpenAPI document, so they don't share the collision.Validation
pnpm lint-fixpnpm test packages/effect/test/unstable/httpapi/OpenApi.test.ts(added a regression test)pnpm check:tsgoA changeset is included.
Closes #2496