Releases: paolostyle/hono-zod-openapi
v0.5.0
v0.4.2
v0.4.1
v0.4.0
v0.3.1
v0.3.0
v0.2.1
v0.2.0
This release contains quite a lot of breaking changes and can be considered a rewrite of the previous API (I warned you). I do believe this should cover 98% of the cases and I think I'm aware of at least some part of these 2%, but I'm definitely looking for more feedback.
Refer to README to learn about the new API.
Breaking changes
-
openApi
now accepts just a single argument, consolidating previous 3 arguments into one object.
Before:openApi( z.object({ hello: z.string() }), { json: z.object({ name: z.string() }) }, { tags: ['User'] }, );
After:
openApi({ tags: ['User'], request: { json: z.object({ name: z.string() }), }, response: { 200: z.object({ hello: z.string() }), }, });
It might look a bit more verbose now, but in majority of cases this will actually result in less code. You can also use
defineOpenApiOperation
function to define this object outside of the middleware and import it. -
createOpenApi
has been renamed tocreateOpenApiDocument
-
overrides
field has been removed from the third argument ofcreateOpenApi
. The second argument accepts all the possible top-level OpenAPI fields (exceptopenapi
which is hardcoded to3.1.0
) instead, so you need to change e.g.:createOpenApi(app, { title: 'Example API', version: '1.0.0', });
to
createOpenApi(app, { info: { title: 'Example API', version: '1.0.0', }, });
Again, this looks like a bit more code here, but in majority of cases users would've added more fields than
info
anyway. -
Response validation has been removed. I really doubt in usefulness of this feature and it horribly complicates everything on TypeScript level.