{"repo":"asteasolutions/zod-to-openapi","free":true,"listed":false,"github":"https://github.com/asteasolutions/zod-to-openapi","clone":"git clone https://github.com/asteasolutions/zod-to-openapi.git","description":"A library that generates OpenAPI (Swagger) docs from Zod schemas","language":"TypeScript","stars":1610,"topics":["openapi","openapi3","schema","swagger","zod"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Zod to OpenAPI [!IMPORTANT] For Zod v3 support, please use the v7.3.4 version. However keep in mind that we do not intend to actively support that version going forward Install with: npm install @asteasolutions/zod-to-openapi@7.3.4 A library that uses zod schemas to generate an Open API Swagger documentation. 1. Purpose and quick example 2. Usage 1. Installation 2. The openapi method 3. The Registry 4. The Generator 5. Defining schemas 6. Defining routes & webhooks 7. Defining custom components 8. A full example 9. Adding it as part of your build 10. Using schemas vs a registry 11. Generation options 3. Zod schema types 1. Supported types 2. Unsupported types 4. Technologies We keep a changelog as part of the GitHub releases. Purpose and quick example We at Astea Solutions made this library because we use zod for validation in our APIs and are tired of the duplication to also support a separate OpenAPI definition that must be kept in sync. Using zod-to-openapi , we generate OpenAPI definitions directly from our zod schemas, thus having a single source of truth. Simply put, it turns this: into this: and you can still use UserSchema and the request.params object to validate the input of your API. Usage Installation The openapi method To keep openapi definitions natural, we add an openapi method to all Zod objects. Its idea is to provide a convenient way to provide OpenApi specific data. It has three overloads: 1. .openapi({ [key]: value }) - this way we can specify any OpenApi ","default_branch":null,"files":null,"tree":[],"storefront":"/r/asteasolutions","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/asteasolutions/zod-to-openapi/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}