Skip to content
Merged
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
33 changes: 25 additions & 8 deletions .github/workflows/regenerate-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,28 @@ jobs:
"${{ github.workspace }}/_generated" \
"${{ steps.version.outputs.sdk_version }}"

- name: Debug generated output
run: |
echo "Generated output structure:"
ls -la _generated/ 2>/dev/null || echo "ERROR: _generated/ does not exist!"
if [ "${{ inputs.language }}" = "node" ] || [ "${{ inputs.language }}" = "typescript" ]; then
ls -la _generated/src/generated/ 2>/dev/null || echo "ERROR: _generated/src/generated/ missing!"
elif [ "${{ inputs.language }}" = "php" ]; then
ls -la _generated/src/ 2>/dev/null || echo "ERROR: _generated/src/ missing!"
elif [ "${{ inputs.language }}" = "python" ]; then
ls -la _generated/shotstack_sdk/ 2>/dev/null || echo "ERROR: _generated/shotstack_sdk/ missing!"
elif [ "${{ inputs.language }}" = "ruby" ]; then
ls -la _generated/lib/shotstack/ 2>/dev/null || echo "ERROR: _generated/lib/shotstack/ missing!"
fi

- name: Copy generated files to SDK repo
run: |
# Remove previously generated files (but not .git, README, .github, etc.)
set -e
if [ "${{ inputs.language }}" = "node" ] || [ "${{ inputs.language }}" = "typescript" ]; then
rm -rf src/generated/ dist/
mkdir -p src/generated/
cp -r _generated/src/generated/* src/generated/
# Copy src/index.ts if generated
[ -f _generated/src/index.ts ] && cp _generated/src/index.ts src/index.ts
# Update package.json version only (preserve custom fields)
if [ -f _generated/package.json ]; then
node -e "
const pkg = JSON.parse(require('fs').readFileSync('package.json', 'utf-8'));
Expand All @@ -144,19 +156,24 @@ jobs:
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
fi
# Copy tsconfig if generated and none exists
[ -f _generated/tsconfig.json ] && [ ! -f tsconfig.json ] && cp _generated/tsconfig.json tsconfig.json
elif [ "${{ inputs.language }}" = "php" ]; then
rm -rf src/Api/ src/Model/ src/ApiException.php src/Configuration.php src/HeaderSelector.php src/ObjectSerializer.php
cp -r _generated/src/* src/ 2>/dev/null || true
cp -r _generated/lib/* src/ 2>/dev/null || true
cp -r _generated/src/* src/
elif [ "${{ inputs.language }}" = "python" ]; then
rm -rf shotstack_sdk/api/ shotstack_sdk/model/ shotstack_sdk/models/
cp -r _generated/shotstack_sdk/* shotstack_sdk/ 2>/dev/null || true
cp -r _generated/shotstack_sdk/* shotstack_sdk/
# Generator v5.4.0 outputs to models/ but SDK expects model/
if [ -d shotstack_sdk/models ] && [ ! -d shotstack_sdk/model ]; then
mv shotstack_sdk/models shotstack_sdk/model
mkdir -p shotstack_sdk/models
echo "from shotstack_sdk.model import *" > shotstack_sdk/models/__init__.py
fi
elif [ "${{ inputs.language }}" = "ruby" ]; then
rm -rf lib/shotstack/api/ lib/shotstack/models/
cp -r _generated/lib/shotstack/* lib/shotstack/ 2>/dev/null || true
cp -r _generated/lib/shotstack/* lib/shotstack/
fi
echo "Copy complete for ${{ inputs.language }}"

- name: Run post-generate script
if: hashFiles('scripts/post-generate.sh') != ''
Expand Down
10 changes: 6 additions & 4 deletions scripts/sdk/generate-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ echo "Generating Node/TypeScript SDK v${VERSION}..."

mkdir -p "${OUTPUT_DIR}/src/generated"

# hey-api resolves $ref from the spec's directory, so we must run from OAS root
# and point at the YAML source (not the bundled JSON) to resolve all refs.
# The bundled JSON has unresolved example $refs that hey-api tries to follow.
# hey-api resolves $ref from the spec's directory, so we pass the absolute path
# to the YAML source. The bundled JSON has unresolved example $refs that hey-api
# tries to follow, so we use the original YAML instead.
# Run npx from the OAS root so it finds the locally-installed hey-api package.
cd "${OAS_ROOT}"
npx @hey-api/openapi-ts \
--input "./api.oas3.yaml" \
--input "${OAS_ROOT}/api.oas3.yaml" \
--output "${OUTPUT_DIR}/src/generated" \
--plugins @hey-api/typescript @hey-api/sdk
cd -

# Write package.json for the generated SDK
cat > "${OUTPUT_DIR}/package.json" << EOF
Expand Down
1 change: 1 addition & 0 deletions scripts/sdk/generate-php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ npx @openapitools/openapi-generator-cli generate \
-g php \
-c "${CONFIGS_DIR}/php.yaml" \
-o "${OUTPUT_DIR}" \
--template-dir "${OAS_ROOT}/templates/php" \
--additional-properties=invokerPackage=Shotstack\\Client,licenseName="MIT",composerPackageName="shotstack/shotstack-sdk-php",srcBasePath="src",artifactVersion="${VERSION}",artifactUrl="https://shotstack.io",developerOrganization="Shotstack",developerOrganizationUrl="https://shotstack.io"

echo "PHP SDK generated at ${OUTPUT_DIR}"
3 changes: 2 additions & 1 deletion scripts/sdk/generate-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ echo "Using openapi-generator v${PYTHON_GENERATOR_VERSION} (Python requires lega

npx @openapitools/openapi-generator-cli version-manager set "${PYTHON_GENERATOR_VERSION}"

# cd to OAS root so config-relative paths (templateDir: templates/python) resolve
# cd to OAS root for consistent working directory
cd "${OAS_ROOT}"
npx @openapitools/openapi-generator-cli generate \
-i "${SPEC_FILE}" \
-g python \
-c "${CONFIGS_DIR}/python.yaml" \
-o "${OUTPUT_DIR}" \
--template-dir "${OAS_ROOT}/templates/python" \
--additional-properties=packageName="shotstack_sdk",projectName="shotstack-sdk",pythonAttrNoneIfUnset=true,packageVersion="${VERSION}",packageUrl="https://shotstack.io/product/sdk/python/",infoName="Shotstack",infoEmail="pypi@shotstack.io",licenseInfo="MIT"

echo "Python SDK generated at ${OUTPUT_DIR}"
1 change: 1 addition & 0 deletions scripts/sdk/generate-ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ npx @openapitools/openapi-generator-cli generate \
-g ruby \
-c "${CONFIGS_DIR}/ruby.yaml" \
-o "${OUTPUT_DIR}" \
--template-dir "${OAS_ROOT}/templates/ruby" \
--additional-properties=moduleName="Shotstack",gemAuthor="Shotstack",gemAuthorEmail="ruby@shotstack.io",gemHomepage="https://shotstack.io/product/sdk/ruby/",gemLicense="MIT",gemVersion="${VERSION}"

echo "Ruby SDK generated at ${OUTPUT_DIR}"
6 changes: 4 additions & 2 deletions scripts/sdk/generate-typescript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ echo "Generating TypeScript SDK v${VERSION}..."

mkdir -p "${OUTPUT_DIR}/src/generated"

# hey-api resolves $ref from the spec's directory, so we must run from OAS root
# hey-api resolves $ref from the spec's directory, so we pass the absolute path
# to the YAML source. Run npx from OAS root so it finds the locally-installed package.
cd "${OAS_ROOT}"
npx @hey-api/openapi-ts \
--input "./api.oas3.yaml" \
--input "${OAS_ROOT}/api.oas3.yaml" \
--output "${OUTPUT_DIR}/src/generated" \
--plugins @hey-api/typescript @hey-api/sdk
cd -

# Write package.json
cat > "${OUTPUT_DIR}/package.json" << EOF
Expand Down
Loading