Use Zod Schemas to create OpenAPI v3.x documentation
MIT License
Published by samchungy about 1 year ago
.startsWith()
, .endsWith()
, .includes()
and multiple string patterns by @samchungy in https://github.com/samchungy/zod-openapi/pull/164
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.8.0...v2.9.0-beta.0
Published by samchungy about 1 year ago
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.4...v2.8.0
Published by samchungy over 1 year ago
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.3...v2.7.4
Published by samchungy over 1 year ago
Fix effectType
regression error by @samchungy in https://github.com/samchungy/zod-openapi/pull/147
Fixes a bug introduced in 2.7.2 where ZodEffects would throw errors around effectType
even if they were not used in components.
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.2...v2.7.3
Published by samchungy over 1 year ago
effectType
logic by @samchungy in https://github.com/samchungy/zod-openapi/pull/145
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.1...v2.7.2
Published by samchungy over 1 year ago
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.0...v2.7.1
Published by samchungy over 1 year ago
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.6.3...v2.7.0
Published by samchungy over 1 year ago
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.6.2...v2.6.3
Published by samchungy over 1 year ago
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.6.1...v2.6.2
Published by samchungy over 1 year ago
Export internal functions for fastify-zod-openapi by @samchungy in https://github.com/samchungy/zod-openapi/pull/127
Some internal functions are now available for consumption under the api
export.
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.6.0...v2.6.1
Published by samchungy over 1 year ago
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.5.1...v2.6.0
Published by samchungy over 1 year ago
required
value by @samchungy in https://github.com/samchungy/zod-openapi/pull/115
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.5.0...v2.5.1
Published by samchungy over 1 year ago
Optimise ZodLazy recursive error messaging by @jedwards1211 in https://github.com/samchungy/zod-openapi/pull/103
Enhance error messaging by @samchungy in https://github.com/samchungy/zod-openapi/pull/112
When you encounter an error with the library, there will now be an associated path with the error which will make debugging easier. For example:
`The schema at lazy schema > array items > property: foo needs to be registered because it's circularly referenced`,
Big thanks to @jedwards1211 for making this possible.
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.4.0...v2.4.1
Published by samchungy over 1 year ago
Enhance ZodLazy support by @samchungy in https://github.com/samchungy/zod-openapi/pull/102
This should allow you to write recursive ZodSchema like this:
const BasePost = z.object({
id: z.string(),
userId: z.string(),
});
type Post = z.infer<typeof BasePost> & {
user?: User;
};
const BaseUser = z.object({
id: z.string(),
});
type User = z.infer<typeof BaseUser> & {
posts?: Post[];
};
const PostSchema: ZodType<Post> = BasePost.extend({
user: z.lazy(() => UserSchema).optional(),
}).openapi({ ref: 'post' });
const UserSchema: ZodType<User> = BaseUser.extend({
posts: z.array(z.lazy(() => PostSchema)).optional(),
}).openapi({ ref: 'user' });
Fix type exports by @samchungy in https://github.com/samchungy/zod-openapi/pull/106
This change fixes an issue introduced in v2.3.1 and should resolve the following Typescript compilation error for any versions < 5.0.
TS1383: Only named exports may use 'export type'.
Please note: there may be a breaking change in the future to require Typescript 5.0.
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.3.3...v2.4.0
Published by samchungy over 1 year ago
Enhance ZodLazy support by @samchungy in https://github.com/samchungy/zod-openapi/pull/102
This should allow you to write recursive ZodSchema like this:
const BasePost = z.object({
id: z.string(),
userId: z.string(),
});
type Post = z.infer<typeof BasePost> & {
user?: User;
};
const BaseUser = z.object({
id: z.string(),
});
type User = z.infer<typeof BaseUser> & {
posts?: Post[];
};
const PostSchema: ZodType<Post> = BasePost.extend({
user: z.lazy(() => UserSchema).optional(),
}).openapi({ ref: 'post' });
const UserSchema: ZodType<User> = BaseUser.extend({
posts: z.array(z.lazy(() => PostSchema)).optional(),
}).openapi({ ref: 'user' });
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.3.3...v2.4.0-beta.1
Published by samchungy over 1 year ago
Fix optional default by @samchungy in https://github.com/samchungy/zod-openapi/pull/98
This fixes an issue where ZodDefault was incorrectly recognised as non optional
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.3.2...v2.3.3
Published by samchungy over 1 year ago
Avoid isOptional()
by @samchungy in https://github.com/samchungy/zod-openapi/pull/96
This should prevent the following error when using an asynchronous transform:
Error: Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.3.1...v2.3.2
Published by samchungy over 1 year ago
Export openapi3-ts folder as types by @samchungy in https://github.com/samchungy/zod-openapi/pull/94
This should fix the following compilation error
Import trace for requested module:
../node_modules/.pnpm/[email protected][email protected]/node_modules/zod-openapi/lib-es2015/openapi3-ts/dist/oas31.js
../node_modules/.pnpm/[email protected][email protected]/node_modules/zod-openapi/lib-es2015/openapi3-ts/dist/index.js
../node_modules/.pnpm/[email protected][email protected]/node_modules/zod-openapi/lib-es2015/index.js
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.3.0...v2.3.1
Published by samchungy over 1 year ago
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.2.3...v2.3.0
Published by samchungy over 1 year ago
Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.2.2...v2.2.3