Installation
Installation
Installation
Install via Go
go install github.com/czemar/ng-openapi-gen/cmd/ng-openapi-gen@latestThis installs the ng-openapi-gen binary to your $GOPATH/bin (or $HOME/go/bin).
Note
Requires Go 1.21+. Verify with go version.
Download pre-built binary
Download the latest release from the releases page. Binaries are available for:
- Linux (amd64)
- macOS (amd64, arm64)
- Windows (amd64)
Extract the archive and add the binary to your PATH.
Build from source
git clone https://github.com/czemar/ng-openapi-gen.git
cd ng-openapi-gen
make buildThe binary is output as ng-openapi-gen in the project root.
Verify installation
ng-openapi-gen --helpYou should see the list of available CLI flags.
Quick start
1. Create a configuration file
Create ng-openapi-gen.json in your Angular project root:
{
"$schema": "ng-openapi-gen-schema.json",
"input": "path/to/openapi.yaml",
"output": "src/app/api"
}2. Generate the API code
ng-openapi-gen3. Import the generated Api service
See the generated code guide for how to use the output.
CI/CD integration
Add a script to your package.json to regenerate on each build:
{
"scripts": {
"generate:api": "ng-openapi-gen",
"start": "npm run generate:api && ng serve",
"build": "npm run generate:api && ng build"
}
}For multiple APIs:
{
"scripts": {
"generate:api": "npm run generate:api:a && npm run generate:api:b",
"generate:api:a": "ng-openapi-gen -c api-a.json",
"generate:api:b": "ng-openapi-gen -c api-b.json"
}
}