
Announcing Nx OpenAPI Plugin
We are thrilled to announce the release of the Nx Plugin for integrating the popular OpenAPI Generator seamless into your Nx workspace.
Prerequisites
The plugin requires a minimum version of Nx 19.
Let’s get started
Integrating the Plugin could not be easier:
nx add @lambda-solutions/nx-plugin-openapi
The command will install the plugin itself as well as the @openapitools/openapi-generator-cli
package, if not already installed.
Also it will update your nx.json
file with the recommended configuration for caching.
Additionally you might want to make any build
-target dependent on the generate-api
target, so that the OpenAPI Generator runs before the build. You can do this by adding the following to your project.json
:
"targets": {
"build": {
"dependsOn": ["generate-api", "^generate-api"]
}
}
Last but not least to to generate any API client for a project, you will need to add a generate-api
target to your project.json
:
nx generate @lambda-solutions/nx-plugin-openapi:generate-api
This command will guide you through the process of setting up an executor which will do the heavy lifting to generate the API client for you.
Usage
Once the generate-api
target is set up, you can run it using:
nx run my-app:generate-api
Of course we make usage of any cool Nx feature like caching, so the next time you run the command, it will only regenerate the API client if the OpenAPI specification has changed.
This will also work when you provide an endpoint to the OpenAPI specification file.
Some last words
Today we are releasing the first early version of the plugin in version 0.2.0. You can already use it and it should not have any major issues. However it is not feature complete yet.
Any feedback and / or contributions are very welcome.