`HttpApiSchema` streams: declare every media type a stream can be sent as
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
Problem
Some APIs send one stream under one of several media types, depending on the resource or the API version:
- Docker's container logs answer
200withapplication/vnd.docker.raw-streamwhen the container has a TTY, and withapplication/vnd.docker.multiplexed-streamotherwise. - Docker's
GET /eventsis NDJSON sent asapplication/jsonup to API 1.51, and asapplication/jsonlfrom API 1.52 (measured on Docker 29).
OpenAPI describes this directly: a response's content maps each media type to its schema, and Docker's own API document lists both stream types under the logs' 200. A stream schema has exactly one contentType, though. So the generated OpenAPI document lists one media type the API may not send. For logs, declared as StreamUint8Array, it lists application/octet-stream, which the API never sends:
HttpApiEndpoint.get("logs", "/containers/:id/logs", {
params: { id: Schema.String },
success: HttpApiSchema.WithHeaders(HttpApiSchema.StreamUint8Array(), {
"content-type": Schema.Literals([
"application/vnd.docker.raw-stream",
"application/vnd.docker.multiplexed-stream"
])
})
})
// OpenAPI: 200 → content: { "application/octet-stream": … }
Declaring two stream successes instead isn't allowed ("Multiple streaming success responses are not supported", HttpApiEndpoint.ts L1403), and would need a way for a handler to pick one.
Proposal
Let StreamUint8Array and StreamNdjson take a list of media types:
success: HttpApiSchema.WithHeaders(
HttpApiSchema.StreamUint8Array({
contentType: ["application/vnd.docker.raw-stream", "application/vnd.docker.multiplexed-stream"]
}),
{
"content-type": Schema.Literals(["application/vnd.docker.raw-stream", "application/vnd.docker.multiplexed-stream"])
}
)
HttpApiSchema.StreamNdjson({ schema: EventMessage, contentType: ["application/jsonl", "application/json"] })
- OpenAPI: each media type is listed under the status, with the same stream schema.
- Client: unchanged. A status with one stream alternative is decoded whatever its
Content-Typetoday, so any of the listed types is read the same way. - Server: the first media type is the default. A handler that sets a
content-typedeclared withWithHeaderssends that one. This already works today: a handler's header replaces the stream's defaultContent-Type(tested withNodeHttpServer). - Payloads: a streaming request payload with several media types accepts any of them.
It's still one stream per status, so there's no new handler API and no union of stream types.
Scope
In scope: StreamUint8Array and StreamNdjson, as successes and as payloads.
Out of scope: StreamSse (always text/event-stream), and several stream schemas for one status.
Open questions
- Should the server check that a handler's
content-typeis one of the listed types, or leave that to the declared header's schema?
- 主要言語
- TypeScript
- スター
- 16.7k
- フォーク
- 808
- 平均マージ
- 11時間 3分
- マージ済み PR(30日)
- 840
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Effect-TS/effect のほかの issue
-
PgClient: withTransaction dies instead of failing with SqlError when the server ends the session対応中かも @effect-bot が今日担当しました。 オープン
Effect-TS/effect#10290 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
shorthand for mapping over tagged union schema対応中かも @effect-bot が今日担当しました。 オープンenhancement
Effect-TS/effect#10286 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Cluster: A way to remove processed requests from storage対応中かも @effect-bot が 1 日前に担当しました。 オープンenhancement
Effect-TS/effect#10239 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 47/100
メンテナーはふだん 1 日以内に返信
Effect-TS/effect の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
kunchenguid/gh-axi#247 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
lidge-jun/opencodex#8101 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
effort:S P3 refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nightscout/nocturne#3243 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
JuliusBrussee/caveman#1449 ·
メンテナーはふだん 1 日以内に返信