Zod
Installโ
- npm
- yarn
- pnpm
npm install @basketry/zod
yarn add @basketry/zod
pnpm add @basketry/zod
Basic Usageโ
basketry.config.json
{
"source": "petstore.json",
"parser": "@basketry/openapi-3",
"generators": ["@basketry/zod"],
"output": "src"
}
File Structureโ
This generator will create Zod schemas for all the API schemas defined in the source file.
By default, the file will be nested within a directory named after the API major version. This behavior can be disabled by using the includeVersion
option from the Typescript Generator.
my-project/
โโโ node_modules/
โโโ src/
โ โโโ v1/ <-- generated
โ โ โโโ schemas.ts <-- generated
โ โโโ index.ts
โโโ .gitignore
โโโ basketry.config.json
โโโ package.json
โโโ petstore.json
โโโ README.md
Optionsโ
This generator depends on the @basketry/typescript
generator and all of their applied options will also apply to files emitted by this generator.
See:
@basketry/typescript
options
The @basketry/zod
generator does not accept any of its own options.
Dependenciesโ
The generated file contains code that depends on the zod
package that is not included by default. You will need to install it separately.
- npm
- yarn
- pnpm
npm install zod
yarn add zod
pnpm add zod