From cbfc436678112eee1c5e1e27a4dfd102a6545453 Mon Sep 17 00:00:00 2001 From: Adron Hall Date: Mon, 30 Nov 2026 12:48:13 -0800 Subject: [PATCH] Fetch the API contract from docs.substratalapps.com The API docs moved from compositecode.github.io/substratalapps.com to docs.substratalapps.com, and the old URL now answers 301. curl -fsS doesn't follow redirects, so api-sync.yml saved nginx's redirect page as api/openapi.yaml and Kiota failed on it, every day since. - gen-api.sh fetches https://docs.substratalapps.com/openapi.yaml (OPENAPI_URL overrides it), follows redirects, and refuses a download that isn't an OpenAPI 3 document instead of overwriting the snapshot. - ci.yml's live-contract comparison and api-sync.yml's changelog link use the new host; so do README.md and api/README.md. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/api-sync.yml | 2 +- .github/workflows/ci.yml | 2 +- README.md | 2 +- api/README.md | 4 ++-- scripts/gen-api.sh | 16 +++++++++++++++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/api-sync.yml b/.github/workflows/api-sync.yml index 82c5ea0..e1f5f16 100644 --- a/.github/workflows/api-sync.yml +++ b/.github/workflows/api-sync.yml @@ -61,7 +61,7 @@ jobs: git push --force origin "$branch" body="Regenerated \`src/Substratal.Hub.Core/Api/Generated\` from the published \`openapi.yaml\` ($VERSION). - Check the API [Changelog](https://compositecode.github.io/substratalapps.com/changelog/) for what changed. If it adds a new \`Substratal-Version\`, bump \`ApiVersion.Current\` in this pull request." + Check the API [Changelog](https://docs.substratalapps.com/changelog/) for what changed. If it adds a new \`Substratal-Version\`, bump \`ApiVersion.Current\` in this pull request." if gh pr view "$branch" --json state -q .state 2>/dev/null | grep -q OPEN; then gh pr edit "$branch" --title "Sync the API client with openapi.yaml $VERSION" --body "$body" else diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63b3c59..e4c6f9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: # A newer published contract isn't a failure here: api-sync.yml opens a pull request for it. - name: Compare with the live contract run: | - curl -fsS https://compositecode.github.io/substratalapps.com/openapi.yaml -o /tmp/live.yaml + curl -fsSL https://docs.substratalapps.com/openapi.yaml -o /tmp/live.yaml if ! cmp -s /tmp/live.yaml api/openapi.yaml; then echo "::notice::The published openapi.yaml differs from api/openapi.yaml. api-sync.yml will open a pull request." fi diff --git a/README.md b/README.md index 6aad156..b0fcd7a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Substratal Hub for Windows -The Windows edition of the **Substratal Hub**, the client for the [Substratal Apps Platform API](https://compositecode.github.io/substratalapps.com/). It's built management-first: the Administration and Developer sections (users, access, roles, audit, Applications, API keys, webhooks, tenants) come before the personal ones. +The Windows edition of the **Substratal Hub**, the client for the [Substratal Apps Platform API](https://docs.substratalapps.com/). It's built management-first: the Administration and Developer sections (users, access, roles, audit, Applications, API keys, webhooks, tenants) come before the personal ones. | | | |---|---| diff --git a/api/README.md b/api/README.md index 275ebd9..a6ba035 100644 --- a/api/README.md +++ b/api/README.md @@ -1,7 +1,7 @@ # API contract `openapi.yaml` is a snapshot of the Platform API's published contract, -. The C# client in +. The C# client in `src/Substratal.Hub.Core/Api/Generated` is generated from it by `scripts/gen-api.sh`. | | Current | @@ -12,7 +12,7 @@ ## Two version numbers -- **`Substratal-Version`** is the API version, a whole number sent as a request header on every call. It changes only for a breaking change. The old version keeps working for at least 6 months, and responses to it carry `Deprecation` and `Sunset` headers. See [Conventions → Versioning](https://compositecode.github.io/substratalapps.com/api-reference/conventions/#versioning). +- **`Substratal-Version`** is the API version, a whole number sent as a request header on every call. It changes only for a breaking change. The old version keeps working for at least 6 months, and responses to it carry `Deprecation` and `Sunset` headers. See [Conventions → Versioning](https://docs.substratalapps.com/api-reference/conventions/#versioning). - **`info.version`** in `openapi.yaml` is the contract revision. It moves with every additive change: new endpoints, new optional fields, new enum values. None of those need a new `Substratal-Version`. ## Updating diff --git a/scripts/gen-api.sh b/scripts/gen-api.sh index 965b68b..edf91c6 100755 --- a/scripts/gen-api.sh +++ b/scripts/gen-api.sh @@ -9,8 +9,22 @@ set -euo pipefail cd "$(dirname "$0")/.." +# The published contract. Override with OPENAPI_URL (for example a local API checkout's docs/openapi.yaml served over +# HTTP). Redirects are followed: the docs moved hosts once already (GitHub Pages → docs.substratalapps.com). +OPENAPI_URL="${OPENAPI_URL:-https://docs.substratalapps.com/openapi.yaml}" + if [[ "${1:-}" == "--fetch" ]]; then - curl -fsS https://compositecode.github.io/substratalapps.com/openapi.yaml -o api/openapi.yaml + tmp=$(mktemp) + trap 'rm -f "$tmp"' EXIT + curl -fsSL --max-redirs 5 "$OPENAPI_URL" -o "$tmp" + # Refuse anything that isn't an OpenAPI 3 document (an HTML error or redirect page, say) rather than overwrite + # the snapshot with it and fail later inside Kiota. + if ! head -c 4096 "$tmp" | grep -qE '^openapi: *["'\'']?3\.'; then + echo "error: $OPENAPI_URL didn't return an OpenAPI 3 document. First bytes:" >&2 + head -c 300 "$tmp" >&2; echo >&2 + exit 1 + fi + mv "$tmp" api/openapi.yaml fi dotnet tool run kiota generate \