Skip to content

feat!: response headers, type-safe styles, multi-content-type#6

Merged
maxholman merged 1 commit intoblock65:masterfrom
maxholman:feat/openapi-headers-and-content-types
Apr 9, 2026
Merged

feat!: response headers, type-safe styles, multi-content-type#6
maxholman merged 1 commit intoblock65:masterfrom
maxholman:feat/openapi-headers-and-content-types

Conversation

@maxholman
Copy link
Copy Markdown
Contributor

Summary

  • Header construct: Full HeaderObject implementation with synth(), referenceObject(), components/headers registration, and export from package index
  • HTTP/2 lowercase enforcement: Header IDs, Parameter<_, 'header'> names, Response.headers keys, and ValidParameter all reject uppercase at compile time via Lowercase<string> constraints
  • Type-safe parameter styles: StyleForIn<TIn> constrains style values per OAS 3.1 location (e.g. query gets form | spaceDelimited | pipeDelimited | deepObject, header gets simple). Added missing explode field
  • Multi-content-type support: Response and RequestBody accept content as single value or array, enabling endpoints with multiple representations (e.g. JSON + binary)
  • Widened MIME types: MediaType.contentType accepts any string while preserving autocomplete for common types (application/json, application/octet-stream, text/plain, etc.)

Breaking changes

  • Response.headers type changed from Header[] to Record<Lowercase<string>, Header>
  • Parameter style field now constrained per in location (previously only accepted 'simple')
  • ValidParameter header variant now requires Lowercase<string> names

Test plan

  • tsc --noEmit passes
  • All vitest tests pass with updated snapshots
  • OpenAPI validation passes via @apidevtools/swagger-parser
  • Type tests verify lowercase header enforcement (positive + @ts-expect-error negative)
  • Example fixture exercises: reusable headers on responses, multi-content-type response (JSON + octet-stream), binary upload request body

…i-content-type responses

Implement the Header construct for OpenAPI 3.1 response headers with
components/headers registration and $ref support. Enforce lowercase
header names at the type level for HTTP/2 compliance (RFC 7540 §8.1.2).

Constrain parameter style values per location (path/query/header/cookie)
matching the OAS 3.1 style table, and add the missing explode field.

Widen MediaType contentType to accept any MIME string while preserving
autocomplete for common types. Allow Response and RequestBody to accept
arrays of content types for endpoints serving multiple representations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maxholman maxholman merged commit ed4c9ea into block65:master Apr 9, 2026
1 check passed
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