Skip to content

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.

At minimum, you need to specify the input specification and output path:

project.json
{
"targets": {
"generate-api": {
"executor": "@lambda-solutions/nx-plugin-openapi:generate-api",
"options": {
"inputSpec": "apps/my-app/swagger.json",
"outputPath": "libs/api-client/src"
}
}
}
}
OptionTypeDescription
inputSpecstringPath to the OpenAPI specification file (local file or URL)
outputPathstringOutput directory for the generated client
{
"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": true
}

Skip validation of the OpenAPI specification. Useful for faster generation when you’re confident your spec is valid.

{
"auth": "bearer:your-token-here"
}

Authentication configuration for accessing remote OpenAPI specifications.

{
"apiNameSuffix": "Client"
}

Suffix to append to generated API class names.

{
"apiPackage": "com.example.api"
}

Package name for API classes.

{
"packageName": "@my-org/api-client"
}

Package name for the generated client library.

{
"modelNamePrefix": "Api",
"modelNameSuffix": "Model",
"modelPackage": "com.example.models"
}
{
"artifactId": "my-api-client",
"artifactVersion": "1.0.0"
}
{
"groupId": "com.example"
}
{
"dryRun": true
}

Perform a dry run without actually generating files. Useful for testing configuration.

{
"enablePostProcessFile": true
}

Enable post-processing of generated files.

{
"minimalUpdate": true
}

Only update files that have actually changed.

{
"skipOverwrite": true
}

Skip overwriting existing files.

{
"removeOperationIdPrefix": true
}

Remove operation ID prefixes from generated method names.

{
"skipOperationExample": true
}

Skip generating operation examples in the code.

{
"strictSpec": true
}

Use strict specification validation.

{
"templateDirectory": "apps/my-app/templates"
}

Directory containing custom templates for code generation.

{
"ignoreFileOverride": "apps/my-app/.openapi-generator-ignore"
}

Path to a custom ignore file.

{
"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": "MyApp/1.0.0"
}

Custom HTTP user agent string.

{
"releaseNote": "Initial release of the API client"
}

Release notes for the generated code.

{
"inputSpecRootDirectory": "specs/"
}

Root directory for input specifications.

{
"invokerPackage": "com.example.invoker"
}

Package name for invoker classes.

{
"gitHost": "github.com",
"gitUserId": "my-username",
"gitRepoId": "my-api-client"
}
{
"logToStderr": true
}

Log output to stderr instead of stdout.

Instead of specifying all options in project.json, you can use a separate configuration file:

apps/my-app/openapi-config.json
{
"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:

project.json
{
"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"
}
}
}

You can use different configurations for different environments:

project.json
{
"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:

Terminal window
nx run my-app:generate-api:development