Skip to main content

CLI: Updated SDK Generation Input Flag and Path Semantics

· 2 min read

We are updating the SDK generation CLI command to make inputs for SDK and Portal generation CLI commands consistent. Now Portals and SDKs can be generated using the same input, simplifying CI/CD scripts.

What's Changed

  1. The --spec flag for the apimatic sdk generate CLI command has been renamed to --input.
  2. Default input path changed from ./src/spec to ./.
  3. The input path now points to the parent directory containing the src directory that contains all the configurations along with the API specification files.
  4. Added optional --api-version flag to allow selecting the API version for multi-versioned builds.

The following example shows the directory structure required for --spec and --input flags.

apimatic sdk generate --langauge=php --input=./build
build
└─ src
├─ spec # Required; Contains all API definition files
| ├─ APIMATIC-META.json # Defines customization for SDK generation
| └─ openapi.json
├── APIMATIC-BUILD.json # Optional; Defines configurations for Portal generation
├── static # Optional; Contains all static files for the Portal
└── content # Optional; Contains custom documentation pages for the Portal

API Version Selection

When generating SDKs for multi-versioned builds, you can now specify which API version to use with the --api-version flag. If not provided, you will be prompted to select from all available versions.

Example:

apimatic sdk generate --language=csharp --input=./build --api-version=v2

This generates the SDK using the specification for v2. The specified version must exist within the versioned build.

Migration Guidance

If you are upgrading from a CLI version that only supports the --spec flag (for example, 1.1.0-beta.6) to a version that supports the newer --input flag:

  1. No change is required in CI workflows if you are not using the --spec flag.
  2. Replace --spec with --input in scripts and CI workflows and point --input to the project root (or other parent directory that contains src).

Replace:

apimatic sdk generate --language=csharp --spec="/path/to/spec/dir"

With:

apimatic sdk generate --language=csharp --input="path/to/root/dir/of/src"