A powerful CLI tool to generate TypeScript API client code from OpenAPI/Swagger specifications, built on top of openapi-generator-cli.
- 🚀 Fast generation: Uses openapi-generator-cli under the hood for reliable and efficient code generation
- 📦 TypeScript first: Generates fully typed TypeScript API clients
- 🎨 Custom templates: Supports custom Mustache templates for API and model generation
- 📝 OpenAPI/Swagger support: Works with both OpenAPI 2.0 (Swagger) and OpenAPI 3.0 specifications
- 🔧 Easy to use: Simple CLI interface for quick generation
npm install -g openapi-generator-clientnpm install --save-dev openapi-generator-clientopenapi-generator-client <directory-path># Process OpenAPI in the current directory
openapi-generator-client .
# Process OpenAPI in a specific directory
openapi-generator-client ./src/apiopenapi-generator-client --helpThe tool expects the following structure in the target directory:
<target-directory>/
├── swagger.json # Your OpenAPI/Swagger specification file
└── openapiconfig.json # Configuration file for the generator
{
"swagger": {
"url": "./swagger.json",
"originalPath": "__swagger-download.json",
"processedPath": "__swagger-processed.json"
},
"filter": {
"includePaths": [],
"extractCodeResult": true,
"codeFieldName": "code",
"messageFieldName": "message",
"dataFieldName": "data"
},
"openapiGenerator": {
"generator": "typescript-axios",
"useDocker": false,
"apiPackage": "api",
"modelPackage": "models",
"additionalProperties": "withSeparateModelsAndApi=true,skipFormModel=true",
"ignoreList": [
"docs/",
"git_push.sh",
"index.ts",
"api.ts",
"common.ts",
"configuration.ts",
".gitignore",
".npmignore"
]
}
}openapi-generator-client/
├── src/
│ ├── cli.js # CLI entry point
│ └── generate.js # Core generation logic
├── templates/ # Custom Mustache templates
│ ├── apiInner.mustache
│ ├── baseApi.mustache
│ └── model.mustache
├── package.json
└── README.md
The tool includes custom Mustache templates in the templates/ directory. You can modify these templates to customize the generated code:
apiInner.mustache: Template for API endpoint methodsbaseApi.mustache: Template for the base API classmodel.mustache: Template for data models
You can specify a custom template directory in your openapiconfig.json:
{
"templateDir": "./your-custom-templates"
}- Node.js 14.x or higher
- npm or yarn
- Docker (required by openapi-generator-cli)
Contributions are welcome! Please feel free to submit a Pull Request.
ISC
- Initial release
- Basic OpenAPI client generation
- Custom template support
- CLI interface