一覧へ戻る
psulek/vscode-zodschema-generator(新しいタブで開きます)
主要言語: TypeScript
Typescript to Zod schema generator
- star 数
- 5
- watcher 数
- 1
- fork 数
- 1
- issue 数
- 0
- 最終更新
- 2023/07/30
主要言語: TypeScript
Typescript to Zod schema generator
A vscode extension which generates Zod schemas from typescript source code (using ts-to-zod package).
This extension will generate Zod schema together with inferred types into new vscode readonly panel.
Source typescript code:
export interface HeroContact { /** * The email of the hero. * * @format email */ email: string; /** * energy status of the hero */ energy: 'positive' | 'negative'; /** * Does the hero has super power? * * @default true */ hasSuperPower?: boolean; /** * The age of the hero * * @minimum 0 * @maximum 500 */ age: number; }
Generated Zod schema:
// Generated by ts-to-zod (https://www.npmjs.com/package/ts-to-zod) import { z } from "zod"; export const heroContactSchema = z.object({ /** * The email of the hero. * * @format email */ email: z.string(), /** * energy status of the hero */ energy: z.union([z.literal("positive"), z.literal("negative")]), /** * Does the hero has super power? * * @default true */ hasSuperPower: z.boolean().optional(), /** * The age of the hero * * @minimum 0 * @maximum 500 */ age: z.number() }); // inferred types: export type HeroContact = z.infer<typeof heroContactSchema>;
Available commands from command pallete:
| Command | Keybinding |
|---|---|
| Generate Zod schema from Typescript | none |
press
F1orCtrl+Shift+Pto openCommand palette
zodschema-generatorMarketplace extension page - Zod schema generator
Have a look at our CHANGELOG to get the details of all changes.
Initial release of Zod schema generator extension