Skip to content

zod-openapi: infer parent Variables in defineOpenAPIRoute#1880

Open
SAY-5 wants to merge 1 commit into
honojs:mainfrom
SAY-5:say5/zod-openapi-1879-define-route-middleware-env
Open

zod-openapi: infer parent Variables in defineOpenAPIRoute#1880
SAY-5 wants to merge 1 commit into
honojs:mainfrom
SAY-5:say5/zod-openapi-1879-define-route-middleware-env

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented May 5, 2026

The author should do the following, if applicable

  • Add tests
  • Run tests
  • yarn changeset at the top of this repo and push the changeset
  • Follow the contribution guide

Fixes #1879. defineOpenAPIRoute's HandlerFromRoute/HookFromRoute previously dropped the route middleware's Variables, leaving c.var.* typed as any. They now use the same R['middleware'] extends MiddlewareHandler[] | MiddlewareHandler ? RouteMiddlewareParams<R>['env'] & E : E pattern that OpenAPIHono.openapi() already uses, and a new type test in handler.test-d.ts asserts the inferred handler env carries the middleware's Variables.

Signed-off-by: Sai Asish <saiasish.cnp@gmail.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

🦋 Changeset detected

Latest commit: d37e8d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/zod-openapi Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.00%. Comparing base (95c2039) to head (d37e8d3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1880   +/-   ##
=======================================
  Coverage   92.00%   92.00%           
=======================================
  Files         115      115           
  Lines        3925     3925           
  Branches     1005     1005           
=======================================
  Hits         3611     3611           
  Misses        282      282           
  Partials       32       32           
Flag Coverage Δ
zod-openapi 94.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

[zod-openapi] defineOpenAPIRoute does not infer handler Context variables from route middleware

1 participant