Configuration
Configuration
Section titled “Configuration”See OpenApiTools docs for all options.
The generate-api
executor offers extensive configuration options to customize the generated API client code. This page covers all available configuration options and how to use them effectively.
Basic Configuration
Section titled “Basic Configuration”At minimum, you need to specify the input specification and output path:
{ "targets": { "generate-api": { "executor": "@lambda-solutions/nx-plugin-openapi:generate-api", "options": { "inputSpec": "apps/my-app/swagger.json", "outputPath": "libs/api-client/src" } } }}
Required Options
Section titled “Required Options”Option | Type | Description |
---|---|---|
inputSpec | string | Path to the OpenAPI specification file (local file or URL) |
outputPath | string | Output directory for the generated client |
Core Options
Section titled “Core Options”configFile
Section titled “configFile”{ "configFile": "apps/my-app/openapi-config.json"}
Path to an OpenAPI Generator configuration file. This allows you to specify detailed generation options in a separate file.
skipValidateSpec
Section titled “skipValidateSpec”{ "skipValidateSpec": true}
Skip validation of the OpenAPI specification. Useful for faster generation when you’re confident your spec is valid.
Authentication & Security
Section titled “Authentication & Security”{ "auth": "bearer:your-token-here"}
Authentication configuration for accessing remote OpenAPI specifications.
Naming & Organization
Section titled “Naming & Organization”apiNameSuffix
Section titled “apiNameSuffix”{ "apiNameSuffix": "Client"}
Suffix to append to generated API class names.
apiPackage
Section titled “apiPackage”{ "apiPackage": "com.example.api"}
Package name for API classes.
packageName
Section titled “packageName”{ "packageName": "@my-org/api-client"}
Package name for the generated client library.
Model Naming
Section titled “Model Naming”{ "modelNamePrefix": "Api", "modelNameSuffix": "Model", "modelPackage": "com.example.models"}
Project Information
Section titled “Project Information”artifactId
& artifactVersion
Section titled “artifactId & artifactVersion”{ "artifactId": "my-api-client", "artifactVersion": "1.0.0"}
groupId
Section titled “groupId”{ "groupId": "com.example"}
Generation Behavior
Section titled “Generation Behavior”dryRun
Section titled “dryRun”{ "dryRun": true}
Perform a dry run without actually generating files. Useful for testing configuration.
enablePostProcessFile
Section titled “enablePostProcessFile”{ "enablePostProcessFile": true}
Enable post-processing of generated files.
minimalUpdate
Section titled “minimalUpdate”{ "minimalUpdate": true}
Only update files that have actually changed.
skipOverwrite
Section titled “skipOverwrite”{ "skipOverwrite": true}
Skip overwriting existing files.
removeOperationIdPrefix
Section titled “removeOperationIdPrefix”{ "removeOperationIdPrefix": true}
Remove operation ID prefixes from generated method names.
skipOperationExample
Section titled “skipOperationExample”{ "skipOperationExample": true}
Skip generating operation examples in the code.
strictSpec
Section titled “strictSpec”{ "strictSpec": true}
Use strict specification validation.
Templates & Customization
Section titled “Templates & Customization”templateDirectory
Section titled “templateDirectory”{ "templateDirectory": "apps/my-app/templates"}
Directory containing custom templates for code generation.
ignoreFileOverride
Section titled “ignoreFileOverride”{ "ignoreFileOverride": "apps/my-app/.openapi-generator-ignore"}
Path to a custom ignore file.
Advanced Options
Section titled “Advanced Options”globalProperties
Section titled “globalProperties”{ "globalProperties": { "supportsES6": "true", "npmName": "@my-org/api-client", "npmVersion": "1.0.0", "providedInRoot": "true", "withInterfaces": "true", "useSingleRequestParameter": "true" }}
Global properties passed to the OpenAPI Generator.
httpUserAgent
Section titled “httpUserAgent”{ "httpUserAgent": "MyApp/1.0.0"}
Custom HTTP user agent string.
releaseNote
Section titled “releaseNote”{ "releaseNote": "Initial release of the API client"}
Release notes for the generated code.
inputSpecRootDirectory
Section titled “inputSpecRootDirectory”{ "inputSpecRootDirectory": "specs/"}
Root directory for input specifications.
invokerPackage
Section titled “invokerPackage”{ "invokerPackage": "com.example.invoker"}
Package name for invoker classes.
Git Integration
Section titled “Git Integration”Git Repository Information
Section titled “Git Repository Information”{ "gitHost": "github.com", "gitUserId": "my-username", "gitRepoId": "my-api-client"}
Logging & Debugging
Section titled “Logging & Debugging”logToStderr
Section titled “logToStderr”{ "logToStderr": true}
Log output to stderr instead of stdout.
Configuration File Example
Section titled “Configuration File Example”Instead of specifying all options in project.json
, you can use a separate configuration file:
{ "npmName": "@my-org/api-client", "npmVersion": "1.0.0", "ngVersion": "17.0.0", "providedInRoot": true, "withInterfaces": true, "useSingleRequestParameter": true, "supportsES6": true, "modelPropertyNaming": "camelCase", "enumPropertyNaming": "UPPERCASE"}
Then reference it:
{ "generate-api": { "executor": "@lambda-solutions/nx-plugin-openapi:generate-api", "options": { "inputSpec": "apps/my-app/swagger.json", "outputPath": "libs/api-client/src", "configFile": "apps/my-app/openapi-config.json" } }}
Environment-Specific Configuration
Section titled “Environment-Specific Configuration”You can use different configurations for different environments:
{ "generate-api": { "executor": "@lambda-solutions/nx-plugin-openapi:generate-api", "options": { "inputSpec": "apps/my-app/swagger.json", "outputPath": "libs/api-client/src" }, "configurations": { "development": { "inputSpec": "http://localhost:3000/api/swagger.json", "skipValidateSpec": true }, "production": { "inputSpec": "https://api.prod.example.com/swagger.json", "strictSpec": true } } }}
Run with specific configuration:
nx run my-app:generate-api:development
Next Steps
Section titled “Next Steps”- View Examples for common configuration patterns
- API Reference for complete option details
- Nx Integration for advanced Nx workspace setup