#
Getting Started
In your project, you can install the create-schemas
CLI using:
pnpm add @workleap/create-schemas
npm install @workleap/create-schemas
yarn add @workleap/create-schemas
Create a create-schemas.config.ts
file this this:
create-schemas.config.ts
import { defineConfig } from "@workleap/create-schemas";
export default defineConfig({
input: "https://petstore3.swagger.io/api/v3/openapi.json", // replace with your own OpenAPI schema
outdir: "src/codegen",
});
Then, run the create-schemas
CLI in your terminal:
pnpm create-schemas
npx create-schemas
yarn create-schemas
The src/codegen/types.ts
file should be created.
#
Watch mode
During development, you can regenerate the types whenever your input file changes or configuration changes.
To enable watch mode, add the --watch
flag to the CLI command or add watch: true
to the configuration file.
pnpm create-schemas --watch
npx create-schemas --watch
yarn create-schemas --watch
or
create-schemas.config.ts
import { defineConfig } from "@workleap/create-schemas";
export default defineConfig({
input: "./openapi.json",
watch: true,
});
#
Advanced usage
If you have a more complex use case that isn't supported by
@workleap/create-schemas
you can try extending the behavior of the library by
Creating a Plugin or using the JavaScript API.
If you think many users would benefit from a use case being officially supported, we encourage you to open an issue on Github.