Command Line Interface
APIful provides a command line interface (CLI). Run the CLI with the --help
flag to see the available commands:
npx apiful --help
It will display the following output:
APIful CLI: Extensible, Typed API Tooling
USAGE apiful generate
COMMANDS
generate Generates TypeScript definitions from OpenAPI schemas
Use apiful <command> --help for more information about a command.
Commands
At the current development stage, the CLI provides only one command:
generate
Generates TypeScript definitions from OpenAPI schemas.
This command requires the openapi-typescript
package, which APIful does not include by default to keep its package size small. Install the package using your preferred package manager:
pnpm add -D openapi-typescript
yarn add -D openapi-typescript
npm install -D openapi-typescript
TIP
Read the OpenAPI extension documentation to learn how to build the type-safe API client.
By default, this command loads the APIful configuration from the apiful.config.{js,ts,mjs,cjs,json}
file in the current working directory. If it cannot find a configuration file based on the supported extensions, it will throw an error.
The generated TypeScript types are stored in the file apiful.d.ts
in the same directory. It augments the apiful/schema
module with the generated types, so that the OpenAPI extension and you can access the globally defined types.
✔ Generated apiful.d.ts types
Display all available options for the generate
command with the --help
flag:
npx apiful generate --help
It will display the following output:
Generates TypeScript definitions from OpenAPI schemas
USAGE apiful generate [OPTIONS]
OPTIONS
--outfile="apiful.d.ts" Path to the output file
--root Path to the project root
NOTE
Although it is recommended to create a apiful.config.ts
file with a defineApifulConfig
default export, you can also write plain JavaScript (.js
, .mjs
, .cjs
) or JSON (.json
, .json5
) configuration files.