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
2 changes: 1 addition & 1 deletion .github/workflows/api-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

| | |
|---|---|
Expand Down
4 changes: 2 additions & 2 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# API contract

`openapi.yaml` is a snapshot of the Platform API's published contract,
<https://compositecode.github.io/substratalapps.com/openapi.yaml>. The C# client in
<https://docs.substratalapps.com/openapi.yaml>. The C# client in
`src/Substratal.Hub.Core/Api/Generated` is generated from it by `scripts/gen-api.sh`.

| | Current |
Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion scripts/gen-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Loading