Skip to content

feat!: emit sequential media commands from itemSchema, read documents as OAS 3.2 - #25

Merged
maxholman[bot] merged 6 commits into
masterfrom
feat/event-stream-output
Sep 27, 2026
Merged

maxholman[bot] merged 6 commits into
masterfrom
feat/event-stream-output

Conversation

@maxholman

@maxholman maxholman Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Requires @block65/rest-client 16. This stays a draft until that's published, then the peer and dev ranges move to ^16.0.0 and the local link comes out.

  • Sequential media: a 2xx response whose media type has an OAS 3.2 itemSchema becomes a sequential command. text/event-stream extends EventStreamCommand<Input, Output>, where Output is the union of the variants' data contentSchema.
    • Both the base class and the data decoding are table-driven. JSON is the default, and text/plain sets dataTransformer = textDataTransformer.
    • AllOutputs carries ParsedStreamEvent<Output>.
    • A construct outside those tables fails codegen and names the operation.
    • An itemSchema in a document older than 3.2 is refused.
    • Without an itemSchema, text/event-stream is a plain Command. It is no longer typed as Uint8Array chunks.
  • Validated commands: they set instance responseSchema / dataSchema fields, which rest-client's parse hooks read, in place of static responseSchema.
  • Void outputs: a bodiless success is Command<Input, undefined>, and an operation with no documented 2xx is never.
  • OAS 3.2 types: documents are typed with openapi3-ts oas32, replacing the local 3.2 shims.
    • Boolean schemas become JsonValue / never (jsonValueSchema / v.never()).
    • $ref'd media types are resolved.
    • The test helpers move to __tests__/helpers.ts, and snapshots are named by test file and test name.
  • Non-JSON bodies: a command's non-JSON body input widens only the parameters beside the body.
  • Formatting: the blank line after the valibot import is kept.

Stacked on #28.

@maxholman maxholman Bot changed the title feat: type text/event-stream responses as Uint8Array chunks feat: type event-stream responses as Uint8Array; key records by string Sep 26, 2026
@maxholman
maxholman Bot force-pushed the feat/event-stream-output branch from 3b7c389 to 05e93a8 Compare September 26, 2026 07:27
@maxholman maxholman Bot changed the title feat: type event-stream responses as Uint8Array; key records by string fix: key additionalProperties records by string Sep 26, 2026
@maxholman
maxholman Bot force-pushed the feat/event-stream-output branch from 05e93a8 to 124102c Compare September 27, 2026 06:44
@maxholman maxholman Bot changed the title fix: key additionalProperties records by string feat!: emit sequential media commands from itemSchema, read documents as OAS 3.2 Sep 27, 2026
@maxholman
maxholman Bot changed the base branch from master to fix/schema-types September 27, 2026 06:45
@maxholman
maxholman Bot marked this pull request as draft September 27, 2026 06:45
maxholman Bot and others added 5 commits September 27, 2026 16:44
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
maxholman Bot force-pushed the feat/event-stream-output branch from 124102c to 3c90444 Compare September 27, 2026 11:14
@maxholman
maxholman Bot changed the base branch from fix/schema-types to master September 27, 2026 11:14
@maxholman maxholman Bot closed this Sep 27, 2026
@maxholman maxholman Bot reopened this Sep 27, 2026
Co-Authored-By: LLM <noreply@maxholman.dev>
@maxholman
maxholman Bot marked this pull request as ready for review September 27, 2026 11:45
@maxholman
maxholman Bot merged commit 38fcce1 into master Sep 27, 2026
4 checks passed
@maxholman
maxholman Bot deleted the feat/event-stream-output branch September 27, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant