Generator plugin for OpenAPI Generator. This plugin integrates with @nx-plugin-openapi/core to provide code generation capabilities using the OpenAPI Generator CLI.
npm install --save-dev @nx-plugin-openapi/core @nx-plugin-openapi/plugin-openapi @openapitools/openapi-generator-cliConfigure 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"
}
}
}
}- 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
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 |
{
"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"
}
}
}
}
}{
"npmName": "@my-org/api-client",
"npmVersion": "1.0.0",
"ngVersion": "17.0.0",
"providedInRoot": true,
"withInterfaces": true,
"useSingleRequestParameter": true,
"supportsES6": true
}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"
}
}@openapitools/openapi-generator-cli(^2.20.2)
MIT