This is a CLI tool that generates TypeScript types, Superstruct validators and type guards from an OpenAPI schema.
hdicli -u https://example.com/openapi.json -o ./output -t types.ts -s superstruct.ts -g guards.ts
Option | Alias | Description | Optional? |
---|---|---|---|
--url | -u | The URL to the OpenAPI schema. | ❌ |
--outdir | -o | The output directory for the generated files (Default: './') | ✅ |
--types | -t | The name for the generated types file. (Default: 'types.ts') | ✅ |
--superstruct | -s | The name for the generated superstruct file. (Default: 'superstruct.ts') | ✅ |
--guards | -g | The name for the generated guards file. (Default: 'guards.ts') | ✅ |
--help | -h | Show help | -- |
--version | -v | Show version number | -- |
npm install -g hdicli
hdicli -u https://example.com/openapi.json -o ./output -t types.ts -s superstruct.ts -g guards.ts
npx hdicli -u https://example.com/openapi.json -o ./output -t types.ts -s superstruct.ts -g guards.ts
-
types.ts
: Contains TypeScript types generated from the OpenAPI schema. -
superstruct.ts
: Contains Superstruct validators generated from the OpenAPI schema. -
guards.ts
: Contains type guards generated from the OpenAPI schema.