Releases: asteasolutions/zod-to-openapi
Releases · asteasolutions/zod-to-openapi
v8.4.1
v8.4.0
What's Changed
- Added support for z.json (#353)
- Added support for template literals (#352)
- Fixed a bug in some nested structures when using
isAnyZodTypewith 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
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
Testing Trusted Publishers setup again
Full Changelog: v8.3.1...v8.3.2
v8.3.1
Testing the Trusted Publihsers setup
Full Changelog: v8.3.0...v8.3.1
v8.3.0
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