Skip to content

Releases: asteasolutions/zod-to-openapi

v8.4.1

14 Feb 23:42

Choose a tag to compare

What's Changed

  • Fix memory leak in generateDocument() when using request parameters (fixes #361)

Full Changelog: v8.4.0...v8.4.1

v8.4.0

04 Jan 11:32

Choose a tag to compare

What's Changed

  • Added support for z.json (#353)
  • Added support for template literals (#352)
  • Fixed a bug in some nested structures when using isAnyZodType with null/undefined #343
  • Exported OpenApiOptions to resolve a problem when extending an object schema. For more information see: #341

Full Changelog: v8.3.3...v8.4.0

v8.3.3

03 Jan 19:25

Choose a tag to compare

What's Changed

  • use correct date-time instead of date when using z.date
  • fix: add null option for nullable enum

Full Changelog: v8.3.2...v8.3.3

v8.3.2

03 Jan 19:05

Choose a tag to compare

Testing Trusted Publishers setup again

Full Changelog: v8.3.1...v8.3.2

v8.3.1

03 Jan 18:56

Choose a tag to compare

Testing the Trusted Publihsers setup

Full Changelog: v8.3.0...v8.3.1

v8.3.0

03 Jan 18:46

Choose a tag to compare

What's Changed

  • 🎉 FINALLY added support for zod lazy (and recursive schemas with getters). Closes: #247, #300 and the discussion in #191
  • Bump js-yaml from 3.14.1 to 3.14.2
  • Setup Trusted Publishsers for NPM

Full Changelog: v8.2.0...v8.3.0

v8.2.0

05 Dec 15:20

Choose a tag to compare

What's Changed

  • (#327 ) feat: support zodv4 prefault new type

Full Changelog: v8.1.0...v8.2.0

v8.1.0

01 Aug 13:06

Choose a tag to compare

What's Changed

  • Improve Zod v4 type compatibility in module augmentation (fixes #321 ) thanks to @YeeP79
  • Add option to sort schemas and parameters (fixes: #312) See more details on how to use it here

Full Changelog: v8.0.0...v8.1.0

v8.0.0

15 Jul 20:37

Choose a tag to compare

Added Zod v4 support 🚀

Support for properties from .meta

With zod's new option for generating JSON schemas and maintaining registries we've added a pretty much seamless support for all metadata information coming from .meta calls as if that was metadata passed into .openapi.

So the following 2 schemas produce exactly the same results:

const schema = z
  .string()
  .openapi('Schema', { description: 'Name of the user', example: 'Test' });

const schema2 = z
  .string()
  .meta({ id: 'Schema2', description: 'Name of the user', example: 'Test' });

Removing extendZodWithOpenApi

This also means that unless you are using some of our more complicated scenarios you could even generate a schema without using extendZodWithOpenApi in your codebase and only rely on .meta to provide additional metadata information and schema names (using the id property).

Where would you still need to use extendZodWithOpenApi and .openapi

  1. When extending registered schemas that are both registered and want the extended one to use anyOf i.e:
const schema = z.object({ name: z.string() }).openapi('Schema');

const schema2 = schema.extend({ age: z.number() }).openapi('Schema2'); // this one would have anyOf and a reference to the first one
  1. Defining parameter metadata. So for example when doing:
registry.registerPath({
  // ...
  request: {
    query: z.object({
      name: z.string().openapi({
        description: 'Schema level description',
        param: { description: 'Param level description' }, 
      }),
    }),
  },
});

the result would be:

  "parameters": [
      {
        "schema": {
          "type": "string",
          "description": "Schema level description" // comes directly from description
        },
        "required": true,
        "description": "Param level description", // comes from param.description
        "name": "name",
        "in": "query"
      }
  ],

What's Changed as well

  • Added support for required modifier (fixes #305)*
  • Added support for conditional oneOf instead of anyOf for unions (fixes #236 and #227). Read more about in the README
  • Exposed a getRefId function (fixes #319)

Full Changelog: v7.3.4...v8.0.0

v7.3.4

13 Jun 14:38

Choose a tag to compare

What's Changed

  • check for missing _internal when extending a non registered schema by @AGalabov in #309 (fixes #297 and #276 )
  • remove omit checks for null and leave only undefined by @AGalabov in #310 (fixes: #283)

Full Changelog: v7.3.3...v7.3.4