zod-openapi

Use Zod Schemas to create OpenAPI v3.x documentation

MIT License

Downloads
192.7K
Stars
180
zod-openapi - v2.9.0-beta.0

Published by samchungy about 1 year ago

What's Changed

New Features 🎉

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.8.0...v2.9.0-beta.0

zod-openapi - v2.8.0

Published by samchungy about 1 year ago

What's Changed

New Features 🎉

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.4...v2.8.0

zod-openapi - v2.7.4

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.3...v2.7.4

zod-openapi - v2.7.3

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.2...v2.7.3

zod-openapi - v2.7.2

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.1...v2.7.2

zod-openapi - v2.7.1

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.7.0...v2.7.1

zod-openapi - v2.7.0

Published by samchungy over 1 year ago

What's Changed

New Features 🎉

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.6.3...v2.7.0

zod-openapi - v2.6.3

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.6.2...v2.6.3

zod-openapi - v2.6.2

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.6.1...v2.6.2

zod-openapi - v2.6.1

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.6.0...v2.6.1

zod-openapi - v2.6.0

Published by samchungy over 1 year ago

What's Changed

New Features 🎉

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.5.1...v2.6.0

zod-openapi - v2.5.1

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.5.0...v2.5.1

zod-openapi - v2.5.0

Published by samchungy over 1 year ago

What's Changed

  • 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.

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.4.0...v2.4.1

zod-openapi - v2.4.0

Published by samchungy over 1 year ago

What's Changed

New Features 🎉

  • 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' });
    

Other Changes

  • 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

zod-openapi - v2.4.0-beta.1

Published by samchungy over 1 year ago

What's Changed

New Features 🎉

  • 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

zod-openapi - v2.3.3

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.3.2...v2.3.3

zod-openapi - v2.3.2

Published by samchungy over 1 year ago

What's Changed

Other Changes

  • 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

zod-openapi - v2.3.1

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.3.0...v2.3.1

zod-openapi - v2.3.0

Published by samchungy over 1 year ago

What's Changed

New Features 🎉

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.2.3...v2.3.0

zod-openapi - v2.2.3

Published by samchungy over 1 year ago

What's Changed

Other Changes

Full Changelog: https://github.com/samchungy/zod-openapi/compare/v2.2.2...v2.2.3