Skip to content

feat: generate typed header parameters with valibot validation#13

Merged
maxholman merged 5 commits intoblock65:masterfrom
maxholman:feat/header-params
Apr 9, 2026
Merged

feat: generate typed header parameters with valibot validation#13
maxholman merged 5 commits intoblock65:masterfrom
maxholman:feat/header-params

Conversation

@maxholman
Copy link
Copy Markdown
Contributor

Summary

  • Generate *Header type aliases for operations with in: "header" parameters, with lowercase keys (HTTP/2 compliant)
  • Generate non-strict v.object() valibot schemas for header validation, allowing extra HTTP headers to pass through
  • Use native types (not stringish) for integer/boolean header params since valibot parses them from strings
  • Exclude header schemas from hono middleware array (Hono lacks c.req.valid("header"))
  • Fix openai test to use mock agent instead of hitting the network

Test plan

  • Snapshot test for header type generation (required, optional, enum, integer)
  • Snapshot test for valibot header schema using v.object() (not v.strictObject())
  • Snapshot test for hono middleware excluding header entries
  • All 7 tests pass

🤖 Generated with Claude Code

maxholman and others added 5 commits April 2, 2026 12:32
Consumers need iterable enum values at runtime (e.g. for dropdown
options) but TypeScript union types are erased. Generate an enums.ts
file with `as const` arrays for each enum schema. Skip writing the
file when no enums exist.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
type: ["string", "null"] (valid in OAS 3.1) fell through to v.unknown()
because neither the type nor valibot codegen handled array-form types.
const schemas were ignored in valibot output entirely, and only handled
for strings in type generation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collect header params from operations and generate:
- Exported *Header type aliases with lowercase keys (HTTP/2 compliant)
- Non-strict v.object() valibot schemas allowing extra HTTP headers
- Integer/boolean types as native (not stringish) since valibot parses them

Header schemas are excluded from hono middleware (no c.req.valid("header")
support) but exported from valibot.ts for manual validation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maxholman maxholman merged commit 9b50329 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