Installation
Installation
Section titled “Installation”This guide will walk you through installing the Nx Plugin OpenAPI in your Nx workspace.
Prerequisites
Section titled “Prerequisites”Before installing the plugin, make sure you have:
- An existing Nx workspace (version 19+)
- Node.js and npm installed
Core Package Installation
Section titled “Core Package Installation”The recommended approach is to use the new modular package structure with the core package and your choice of generator plugin.
Step 1: Install the Core Package
Section titled “Step 1: Install the Core Package”nx add @nx-plugin-openapi/coreor
npm install --save-dev @nx-plugin-openapi/coreStep 2: Install a Generator Plugin
Section titled “Step 2: Install a Generator Plugin”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:
npm install --save-dev @nx-plugin-openapi/plugin-openapi @openapitools/openapi-generator-cliOption B: hey-api
Section titled “Option B: hey-api”For projects using hey-api/openapi-ts:
npm install --save-dev @nx-plugin-openapi/plugin-hey-api @hey-api/openapi-tsPackage Overview
Section titled “Package Overview”| Package | Purpose | Peer Dependencies |
|---|---|---|
@nx-plugin-openapi/core | Core executor and plugin system | @nx/devkit |
@nx-plugin-openapi/plugin-openapi | OpenAPI Generator plugin | @openapitools/openapi-generator-cli |
@nx-plugin-openapi/plugin-hey-api | hey-api plugin | @hey-api/openapi-ts |
Legacy Package Installation
Section titled “Legacy Package Installation”For backward compatibility, the original package is still available:
# Legacy package (OpenAPI Generator only)npm install --save-dev @lambda-solutions/nx-plugin-openapi @openapitools/openapi-generator-cliVerification
Section titled “Verification”After installation, verify the packages are installed correctly:
# Check core packagenx list @nx-plugin-openapi/coreYou 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 defaultsUsing the Generator
Section titled “Using the Generator”You can quickly add a generate-api target to an existing project:
nx generate @nx-plugin-openapi/core:add-generate-api-target --project=my-appThis interactive generator will guide you through the configuration options.
Next Steps
Section titled “Next Steps”Now that the plugin is installed, you can:
- Configure your first project to use the
generate-apiexecutor - Learn about advanced configuration options
- Explore examples for common use cases
If you encounter issues, please file an issue on GitHub.