Skip to content

Installation

This guide will walk you through installing the Nx Plugin OpenAPI in your Nx workspace.

Before installing the plugin, make sure you have:

  • An existing Nx workspace (version 19+)
  • Node.js and npm installed

The recommended approach is to use the new modular package structure with the core package and your choice of generator plugin.

Terminal window
nx add @nx-plugin-openapi/core

or

Terminal window
npm install --save-dev @nx-plugin-openapi/core

Choose and install one or more generator plugins based on your needs:

Option A: OpenAPI Generator (openapi-tools)

Section titled “Option A: OpenAPI Generator (openapi-tools)”

For projects using OpenAPI Generator:

Terminal window
npm install --save-dev @nx-plugin-openapi/plugin-openapi @openapitools/openapi-generator-cli

For projects using hey-api/openapi-ts:

Terminal window
npm install --save-dev @nx-plugin-openapi/plugin-hey-api @hey-api/openapi-ts
PackagePurposePeer Dependencies
@nx-plugin-openapi/coreCore executor and plugin system@nx/devkit
@nx-plugin-openapi/plugin-openapiOpenAPI Generator plugin@openapitools/openapi-generator-cli
@nx-plugin-openapi/plugin-hey-apihey-api plugin@hey-api/openapi-ts

For backward compatibility, the original package is still available:

Terminal window
# Legacy package (OpenAPI Generator only)
npm install --save-dev @lambda-solutions/nx-plugin-openapi @openapitools/openapi-generator-cli

After installation, verify the packages are installed correctly:

Terminal window
# Check core package
nx list @nx-plugin-openapi/core

You should see output similar to:

@nx-plugin-openapi/core
Executors:
- generate-api : Generate API code using a selected generator plugin
Generators:
- add-generate-api-target : Add a generate-api target using the core executor
- init : Initialize core plugin defaults

You can quickly add a generate-api target to an existing project:

Terminal window
nx generate @nx-plugin-openapi/core:add-generate-api-target --project=my-app

This interactive generator will guide you through the configuration options.

Now that the plugin is installed, you can:

  1. Configure your first project to use the generate-api executor
  2. Learn about advanced configuration options
  3. Explore examples for common use cases

If you encounter issues, please file an issue on GitHub.