OpenApi.fromApi drops the data schema of `HttpApiSchema.StreamSse({ data })`: `Schema.fromJsonString` no longer emits `contentSchema`
I maintainer di solito rispondono entro 1 giorno
@gcanti ci sta già lavorando.
Dal 20/10/2026.
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Effect-TS/effect
-
Support {self: this} for fnUntracedForse già presa @ArjunCodess l’ha presa 33 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Effect-TS/effect#8101 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
HttpApiClient: a path parameter of `.` or `..` changes the request pathForse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#9766 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Effect 3: add `~standard.jsonSchema` to `Schema.standardSchemaV1`Forse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#9765 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
wontfix
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
`Schema.toStandardJSONSchemaV1` output has no `$schema`Forse già presa @gcanti l’ha presa oggi. Aperta
Effect-TS/effect#9763 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Effect-TS/effect
Issue simili
-
native
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
prime-radiant-inc/evener#4839 ·
I maintainer di solito rispondono entro 1 giorno
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
processone/fluux-messenger#1790 ·
I maintainer di solito rispondono entro 1 giorno
-
🛣️ Infrastructure
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
opencrvs/opencrvs-core#14232 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
kunchenguid/gh-axi#220 ·
I maintainer di solito rispondono entro 1 giorno