Releases: asteasolutions/zod-to-openapi
v8.2.0
v8.1.0
v8.0.0
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
- When extending registered schemas that are both registered and want the extended one to use
anyOfi.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- 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
getRefIdfunction (fixes #319)
Full Changelog: v7.3.4...v8.0.0
v7.3.4
v7.3.3
Full Changelog: v7.3.2...v7.3.3
Updated README.md
Updated README.md to point users to the 8.0.0-beta version for compatibility with zod v4
v7.3.2 - blank
No changes, but need this to be the latest version since we accidentally published a 7.3.1-beta-zod-v4-2.
Making this release so that people don't end up using the accidentally published one.
v7.3.1-beta-zod-v4-2
Release 7.3.1-beta-zod-v4-2
v7.3.1-beta-zod-v4
Beta release with support for zod v4