Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#9,353 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@gcanti ci sta già lavorando.

Dal 20/10/2026.

  • #9455 di @effect-bot — chiusa senza merge
  • #9529 di @okarin1511 — chiusa senza merge
  • #9613 di @gcanti — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
openapi, typescript
Ambito
api

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
12h 7m
PR unite (30g)
844

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.