@nx-plugin-openapi/plugin-openapi
v0.1.0
Published
Generator plugin for [OpenAPI Generator](https://openapi-generator.tech). This plugin integrates with `@nx-plugin-openapi/core` to provide code generation capabilities using the OpenAPI Generator CLI.
Readme
@nx-plugin-openapi/plugin-openapi
Generator plugin for OpenAPI Generator. This plugin integrates with @nx-plugin-openapi/core to provide code generation capabilities using the OpenAPI Generator CLI.
Installation
npm install --save-dev @nx-plugin-openapi/core @nx-plugin-openapi/plugin-openapi @openapitools/openapi-generator-cliUsage
Configure the generate-api executor with generator: "openapi-tools":
{
"targets": {
"generate-api": {
"executor": "@nx-plugin-openapi/core:generate-api",
"options": {
"generator": "openapi-tools",
"inputSpec": "apps/my-app/swagger.json",
"outputPath": "libs/api-client/src"
}
}
}
}Features
- TypeScript Angular Generation: Generate Angular services and models
- Multiple Languages: Support for 50+ languages via OpenAPI Generator
- Custom Templates: Use custom Mustache templates
- Configuration Files: External configuration via JSON files
- Retry Mechanism: Automatic retry on transient failures
Options
All OpenAPI Generator CLI options are supported. Common options include:
| Option | Type | Description |
|--------|------|-------------|
| configFile | string | Path to configuration file |
| skipValidateSpec | boolean | Skip spec validation |
| globalProperties | object | Global generator properties |
| apiNameSuffix | string | Suffix for API class names |
| modelNamePrefix | string | Prefix for model class names |
| modelNameSuffix | string | Suffix for model class names |
Example with Options
{
"targets": {
"generate-api": {
"executor": "@nx-plugin-openapi/core:generate-api",
"options": {
"generator": "openapi-tools",
"inputSpec": "apps/my-app/swagger.json",
"outputPath": "libs/api-client/src",
"configFile": "apps/my-app/openapi-config.json",
"globalProperties": {
"supportsES6": "true",
"npmName": "@my-org/api-client",
"providedInRoot": "true",
"withInterfaces": "true"
}
}
}
}
}Configuration File Example
{
"npmName": "@my-org/api-client",
"npmVersion": "1.0.0",
"ngVersion": "17.0.0",
"providedInRoot": true,
"withInterfaces": true,
"useSingleRequestParameter": true,
"supportsES6": true
}Multiple Specifications
Generate clients for multiple APIs:
{
"options": {
"generator": "openapi-tools",
"inputSpec": {
"users-api": "apis/users.yaml",
"products-api": "apis/products.yaml"
},
"outputPath": "libs/api-clients/src"
}
}Peer Dependencies
@openapitools/openapi-generator-cli(^2.20.2)
Documentation
License
MIT
