Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .cursor/commands/build-sdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Build SDK and Run Validation Tests

## Overview

Build all API versions of the Python SDK from the OpenAPI specs and run the validation test suite. Use the same behavior as the GitHub action with default inputs: `api-specs-path=api-specs`, `skip-tests=false`.

## What to do

1. Run the build-and-validate script from the repository root:
- **Command:** `./scripts/build-and-validate-sdk.sh`
- Run from the workspace root directory.
2. Use default options (do not set `API_SPECS_PATH` or `SKIP_TESTS` unless the user asks otherwise).
3. Report the outcome: whether the build and validation tests completed successfully or any errors that occurred.

If the user provides extra instructions after the command (e.g. "skip tests" or a different api-specs path), follow those:

- To skip tests: run with `SKIP_TESTS=true ./scripts/build-and-validate-sdk.sh`
- Different api-specs path: run with `API_SPECS_PATH=<path> ./scripts/build-and-validate-sdk.sh`
67 changes: 67 additions & 0 deletions scripts/build-and-validate-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# Build the Python SDK and run validation tests.
# Uses default inputs: api-specs-path=api-specs, skip-tests=false.
#
# Prerequisites: Node.js, Python 3.x, Java 17+ on PATH.
# Optional: set API_SPECS_PATH to override api-specs location.

set -e

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$REPO_ROOT"

# Use project venv if present (so pip/python are available for install and tests)
if [ -f "$REPO_ROOT/.venv/bin/activate" ]; then
echo "Activating virtual environment..."
source "$REPO_ROOT/.venv/bin/activate"
fi

API_SPECS_PATH="${API_SPECS_PATH:-api-specs}"
SKIP_TESTS="${SKIP_TESTS:-false}"

echo "Building SDK (api-specs-path=$API_SPECS_PATH, skip-tests=$SKIP_TESTS)"

# Download OpenAPI Generator if not present
if [ ! -f openapi-generator-cli.jar ]; then
echo "Downloading OpenAPI Generator..."
wget -q https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.12.0/openapi-generator-cli-7.12.0.jar -O openapi-generator-cli.jar
fi

# Prescript
echo "Running prescript..."
node sdk-resources/prescript.js "$API_SPECS_PATH/idn"

build_sdk() {
local name=$1
local spec=$2
local config=$3
local out_dir=$4
echo "Building $name SDK..."
rm -rf "./sailpoint/$out_dir"
java -jar openapi-generator-cli.jar generate \
-i "$API_SPECS_PATH/idn/$spec" \
-g python -o . \
--global-property skipFormModel=false,apiDocs=true,modelDocs=true \
--config "sdk-resources/$config"
node sdk-resources/postscript.js "./sailpoint/$out_dir"
}

build_sdk "V3" "sailpoint-api.v3.yaml" "v3-config.yaml" "v3"
build_sdk "Beta" "sailpoint-api.beta.yaml" "beta-config.yaml" "beta"
build_sdk "V2024" "sailpoint-api.v2024.yaml" "v2024-config.yaml" "v2024"
build_sdk "V2025" "sailpoint-api.v2025.yaml" "v2025-config.yaml" "v2025"
build_sdk "V2026" "sailpoint-api.v2026.yaml" "v2026-config.yaml" "v2026"

# Install and test
echo "Installing dependencies and SDK..."
pip install -r requirements.txt
pip install -e .

if [ "$SKIP_TESTS" != "true" ]; then
echo "Running validation tests..."
python validation_test.py -v
else
echo "Skipping tests (SKIP_TESTS=$SKIP_TESTS)"
fi

echo "Done."