OpenApi.fromApi drops the data schema of `HttpApiSchema.StreamSse({ data })`: `Schema.fromJsonString` no longer emits `contentSchema`
Maintainers usually reply within 1 day
@gcanti is already working on this.
Since Oct 20, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- openapi, typescript
- Domain
- api
Research direction
Start in packages/effect/src/Schema.ts around fromJsonString (L9795-L9837), where contentSchema was removed in #6424, then HttpApiSchema.ts L406-L409 for StreamSse's data field. Check how OpenApi.ts (L763-L820) selects reachable components, and run the reproduction test in packages/effect/test/httpapi/OpenApi.test.ts. Done means the data schema appears in components.schemas, or SCHEMA.md and the affected snapshot tests are updated to match an intentional decision. Confirm the intended behavior with maintainers first.
Written by the indexing model from the issue text.
Description
What version of Effect is running?
[email protected], Node 26.11.1. The code involved is unchanged on main (c9a1e72). 4.0.0-beta.101 still emitted the data schema; it is missing from 4.0.0-beta.102 on.
What steps can reproduce the bug?
When an endpoint returns HttpApiSchema.StreamSse({ data }), OpenApi.fromApi leaves the data schema out of the document: the event's data is a JSON string with no contentSchema, and the data schema is not in components.schemas. The same schema as a plain JSON success is documented.
This test, added to packages/effect/test/httpapi/OpenApi.test.ts, fails on main:
it("documents the data schema of a StreamSse({ data }) response", () => {
const MyEvent = Schema.Struct({
kind: Schema.String,
payload: Schema.String
}).annotate({ identifier: "MyEvent" })
const Api = HttpApi.make("Api").add(
HttpApiGroup.make("test").add(
HttpApiEndpoint.get("stream", "/stream", {
success: HttpApiSchema.StreamSse({ data: MyEvent })
})
)
)
assert.deepStrictEqual(OpenApi.fromApi(Api).components.schemas, {
MyEvent: {
type: "object",
properties: { kind: { type: "string" }, payload: { type: "string" } },
required: ["kind", "payload"],
additionalProperties: false
},
MyEventEncoded: {
type: "string",
contentMediaType: "application/json",
contentSchema: { $ref: "#/components/schemas/MyEvent" }
}
})
})
What is the expected behavior?
data points to the data schema through contentSchema, and the data schema is in components.schemas, as 4.0.0-beta.101 produced (the wrapper was then named MyEventJsonString). SCHEMA.md still documents this for fromJsonString: "the generated schema uses contentSchema to embed the JSON Schema of the decoded value" (SCHEMA.md#L5731-L5772).
What do you see instead?
{ MyEventEncoded: { type: "string", contentMediaType: "application/json" } }
MyEvent, and any schema only it references, is missing, so the document describes each event's data only as a JSON string. The SCHEMA.md example, Schema.toJsonSchemaDocument(Schema.fromJsonString(Schema.Struct({ a: Schema.String }))), likewise returns no contentSchema.
Additional information
fromJsonString encodes through a String annotated only with expected and contentMediaType (Schema.ts#L9795-L9798, #L9837). StreamSse({ data }) builds data with it (HttpApiSchema.ts#L406-L409). OpenApi compiles stream.events (OpenApi.ts#L472) on the encoded side (toRepresentation.ts#L113), where nothing refers to the data schema, so the reachable-only component selection (OpenApi.ts#L763-L820) never includes it. A Schema.fromJsonString used directly in an endpoint schema is documented the same way.
#6424 (first in 4.0.0-beta.102) removed contentSchema from fromJsonString, together with the test added for this case in Effect-TS/effect-smol#2512. It also rewrote that PR's toJsonSchemaDocument test to expect no contentSchema (toJsonSchemaDocument.test.ts#L3954-L3973), and the SSE case in OpenApiRepresentation.test.ts (#L47-L84) now pins the output without the data schema. If dropping contentSchema is intended, the SCHEMA.md section is out of date.
An explicit contentSchema: { $ref: "#/components/schemas/MyEvent" } annotation on the encoded string is emitted, but it does not bring MyEvent into components.schemas: the $ref dangles unless MyEvent is also passed through HttpApi.AdditionalSchemas.
- Dominant language
- TypeScript
- Stars
- 16.7k
- Forks
- 808
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 848
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Effect-TS/effect
-
Support {self: this} for fnUntracedPossibly taken @ArjunCodess claimed this 34 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Effect-TS/effect#8101 · 1 comment ·
Maintainers usually reply within 1 day
-
HttpApiClient: a path parameter of `.` or `..` changes the request pathPossibly taken @effect-bot claimed this 1 day ago. Open
Effect-TS/effect#9766 · 1 assignee ·
Maintainers usually reply within 1 day
-
Effect 3: add `~standard.jsonSchema` to `Schema.standardSchemaV1`Possibly taken @effect-bot claimed this 1 day ago. Open
Effect-TS/effect#9765 · 1 assignee ·
Maintainers usually reply within 1 day
-
Support the `openapi-3.0` target in `Schema.toStandardJSONSchemaV1`Possibly taken A pull request linked to this issue is open or already merged. Openwontfix
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
`Schema.toStandardJSONSchemaV1` output has no `$schema`Possibly taken @gcanti claimed this today. Open
Effect-TS/effect#9763 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in Effect-TS/effect
Similar issues
-
area:agent-view area:tui bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
anthropics/claude-code#104558 ·
Maintainers usually reply within 1 day
-
updater
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
UniversityOfHelsinkiCS/oodikone#5141 ·
-
maintanance
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
inmanta/web-console#7606 ·
Maintainers usually reply within 1 day
-
bug skills
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
equinor/fusion-framework#5846 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 74/100