feat!: emit sequential media commands from itemSchema, read documents as OAS 3.2 - #25
Merged
Merged
Conversation
maxholman
Bot
force-pushed
the
feat/event-stream-output
branch
from
September 26, 2026 07:27
3b7c389 to
05e93a8
Compare
maxholman
approved these changes
Sep 27, 2026
maxholman
Bot
force-pushed
the
feat/event-stream-output
branch
from
September 27, 2026 06:44
05e93a8 to
124102c
Compare
A 2xx response whose media type has an OAS 3.2 itemSchema, and appears in the sequentialMediaTypes table, becomes a sequential command. For text/event-stream it extends rest-client's EventStreamCommand<Input, Output>. Output is the union of the item variants' `data` contentSchema. The contentMediaType picks a decoding from the dataDecodings table: JSON is rest-client's default, and text/plain sets `dataTransformer = textDataTransformer`. Constructs that don't fit throw at codegen and name the operation. AllOutputs carries ParsedStreamEvent<Output>, so client.stream() accepts the command. Validated subclasses now set an instance field, `responseSchema` or `dataSchema`, in place of `static responseSchema`, as rest-client's parse hooks read it. A text/event-stream response with no itemSchema is a plain Command again. It is no longer typed as Uint8Array chunks. A command with a non-JSON body now widens only the parameters beside the body, in place of Except/Pick around the whole input. Co-Authored-By: LLM <noreply@block65.dev>
A 2xx response without content, a 204 or otherwise, gives the command an output of undefined, which rest-client's json() and send() resolve with, and undefined stays in AllOutputs. An operation documenting no 2xx response at all gets never, which drops out of AllOutputs. Both used to fall back to unknown, which the generated client's AllOutputs constraint rejects. Co-Authored-By: LLM <noreply@block65.dev>
The generator took oas31 types and patched in what 3.2 added (itemSchema, contentSchema, `in: querystring`) with local shims and casts. It now takes oas32.OpenAPIObject, which types all of them, and reads a 3.1 document unchanged. Two 3.2 rules the old types hid are handled: a schema may be true or false, which becomes JsonValue/never and jsonValueSchema/v.never(), and a media type may be a $ref, which resolves before use. The test helpers move into __tests__/helpers.ts, with names that say what each does in place of a `For` suffix, and expectGenerated writes each snapshot under the test file and test names as written. Co-Authored-By: LLM <noreply@block65.dev>
itemSchema arrived in OAS 3.2, so a document declaring an earlier version cannot state one. Codegen used to accept it silently, and now stops and names the operation. Co-Authored-By: LLM <noreply@block65.dev>
The JSON value schema was declared in every valibot module and removed where unused, and the removal took the blank line after the imports with it. It is now declared only in a module that uses it. Co-Authored-By: LLM <noreply@block65.dev>
maxholman
Bot
force-pushed
the
feat/event-stream-output
branch
from
September 27, 2026 11:14
124102c to
3c90444
Compare
Co-Authored-By: LLM <noreply@maxholman.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requires
@block65/rest-client16. This stays a draft until that's published, then the peer and dev ranges move to^16.0.0and the local link comes out.itemSchemabecomes a sequential command.text/event-streamextendsEventStreamCommand<Input, Output>, where Output is the union of the variants'datacontentSchema.text/plainsetsdataTransformer = textDataTransformer.AllOutputscarriesParsedStreamEvent<Output>.itemSchemain a document older than 3.2 is refused.itemSchema,text/event-streamis a plainCommand. It is no longer typed asUint8Arraychunks.responseSchema/dataSchemafields, which rest-client's parse hooks read, in place ofstatic responseSchema.Command<Input, undefined>, and an operation with no documented 2xx isnever.oas32, replacing the local 3.2 shims.JsonValue/never(jsonValueSchema/v.never()).$ref'd media types are resolved.__tests__/helpers.ts, and snapshots are named by test file and test name.Stacked on #28.