Skip to content

Releases: paolostyle/hono-zod-openapi

v0.3.0

11 Oct 22:29
Compare
Choose a tag to compare

0.3.0 (2024-10-11)

⚠ BREAKING CHANGES

  • rename Operation type to HonoOpenApiOperation - technically breaking as it was exported, but realistically you wouldn't use it without a good reason.

Features

  • rename Operation type to HonoOpenApiOperation, export HonoOpenApiRequestSchemas (e2bdda1)

v0.2.1

11 Oct 21:22
Compare
Choose a tag to compare

0.2.1 (2024-10-11)

Features

  • export some types that might be useful for users (5ecd9f8)

Bug Fixes

  • allow Hono instances with different Env type parameter than default (f77869c), closes #2

v0.2.0

06 Oct 21:15
Compare
Choose a tag to compare

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 to createOpenApiDocument

  • overrides field has been removed from the third argument of createOpenApi. The second argument accepts all the possible top-level OpenAPI fields (except openapi which is hardcoded to 3.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.