The openapi2aspida CLI allows you to generate aspida API clients from OpenAPI/Swagger specifications. You can provide configuration via a config file or by specifying input and output paths directly through CLI flags.
CLI Flags
| Flag | Alias | Type | Description |
|---|
--input | -i | string | The path to the OpenAPI/Swagger input file. If not provided, the CLI looks for openapi.inputFile in the configuration file. |
--outputdir | -o | string | The directory where the generated files will be placed. If not provided, the CLI looks for openapi.outputDir in the configuration file. |
--config | -c | string | The path to a configuration file. If multiple configurations are detected, the CLI will build all of them. |
--version | -v | string | Displays the current version of openapi2aspida and exits. |
Usage Patterns
1. Using a configuration file (Recommended)
If you have a configuration file defined, you can run the CLI simply by pointing to it:
openapi2aspida --config path/to/config.json
2. Overriding input/output via CLI
You can use a config file for general settings but override specific paths via flags:
openapi2aspida --config path/to/config.json --input ./spec.yaml --outputdir ./src/api
3. Running without a config file
If you are not using a config file, you must provide the input file path:
openapi2aspida --input ./spec.yaml --outputdir ./src/api
# Example: Using a config file with overrides
openapi2aspida --config path/to/config.json --input ./spec.yaml --outputdir ./src/api