feat(standard-json-openapi): add package for Standard JSON Schema OpenAPI - #2044
feat(standard-json-openapi): add package for Standard JSON Schema OpenAPI#2044gusanthiago wants to merge 10 commits into
Conversation
🦋 Changeset detectedLatest commit: 981c521 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
KTrain5169
left a comment
There was a problem hiding this comment.
Please just don't try and force Zod into the package here
|
Hey @KTrain5169, thanks for the review
Let me know if it is okay now |
KTrain5169
left a comment
There was a problem hiding this comment.
I haven't been able to take a proper look at the code myself yet as I don't really have time to experiment to the level required to have a thorough code review
|
|
||
| ## Limitations | ||
|
|
||
| - **Request header arrays are documentation only.** `request.headers` accepts an array of schemas so several can be described, but only a single schema is validated at runtime. |
There was a problem hiding this comment.
Any reason why this is the case?
There was a problem hiding this comment.
No reason; that was gap — the array never reached a validator, so nothing was validated. Now each schema validates. Only the typing stays limited, since Hono has a single header target. Adjusted the Limitation and added a test.
| "main": "./dist/index.cjs", | ||
| "module": "./dist/index.mjs", | ||
| "types": "./dist/index.d.cts", |
There was a problem hiding this comment.
@yusukebe Should middlewares be published as ESM-only?
…penapi
* Added missing schema libraries sample like zod mini / zod 4 / arktype / validbot
* Fixed gap of validate('header', route.request?,headers)
* Added valibot + valibot/to-json-schema in devDeps
|
I did adjustments mentioned in the PR. Let me know if I need to work on anything more. Thanks for the review |
Hey everyone, this supersedes #2042 based on the review there, and should close #1763.
Summary
@hono/zod-openapitakes Zod and nothing else today. This new package,@hono/standard-json-openapi, takes schemas from any library implementing Standard JSON Schema — ArkType, Valibot once wrapped withtoStandardJsonSchema(), and Zod 4, which ships it natively. A route can mix them.Solution
@asteasolutions/zod-to-openapireads Zod internals, so a foreign schema cannot go to it directly. Non-Zod schemas are hidden inside a Zod carrier (z.string().openapi(jsonSchema)) — the generator merges.openapi()metadata over whatever it generated, so the output comes entirely from~standard.jsonSchema. Zod schemas are never converted and behave exactly as before.Test
pnpm testinpackages/standard-json-openapi— 18 pass. They cover ArkType and mixed routes: validation, parameters, input vs output, response headers and sub-apps.The author should do the following, if applicable
pnpm changesetat the top of this repo and push the changeset