Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

OpenApi.fromApi drops the data schema of `HttpApiSchema.StreamSse({ data })`: `Schema.fromJsonString` no longer emits `contentSchema`

Open
#9,353 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@gcanti is already working on this.

Since Oct 20, 2026.

  • #9455 by @effect-bot — closed without merging
  • #9529 by @okarin1511 — closed without merging
  • #9613 by @gcanti — open

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Effect-TS/effect

All issues in Effect-TS/effect

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.