mirror of
https://github.com/zitadel/zitadel.git
synced 2026-07-25 18:28:00 +00:00
# Which Problems Are Solved 1. `oneOf` variant sub-schemas generated from proto `oneof` fields missing `type: "object"`. This causes fumadocs to skip rendering the properties within each variant. Example: https://zitadel.com/docs/reference/api/internal_permission/zitadel.internal_permission.v2.InternalPermissionService.CreateAdministrator [Before](https://zitadel.com/docs/reference/api/internal_permission/zitadel.internal_permission.v2.InternalPermissionService.CreateAdministrator): <img width="977" height="823" alt="Screenshot 2026-03-06 at 09 56 38" src="https://github.com/user-attachments/assets/54ddbbbb-f36b-4a2a-96af-13b3da41de3b" /> [After](https://docs-git-bump-protoc-gen-connect-openapi-version-zitadel.vercel.app/docs/reference/api/internal_permission/zitadel.internal_permission.v2.InternalPermissionService.CreateAdministrator): <img width="964" height="1021" alt="Screenshot 2026-03-06 at 09 56 47" src="https://github.com/user-attachments/assets/a461c4b5-44fe-487b-b4d2-8af47d407d3e" /> 2. missing requestBody for messages with oneOf and path params. Example: https://zitadel.com/docs/reference/api/user/zitadel.user.v2.UserService.UpdateUser [Before](https://zitadel.com/docs/reference/api/user/zitadel.user.v2.UserService.UpdateUser): <img width="994" height="883" alt="Screenshot 2026-03-06 at 09 59 03" src="https://github.com/user-attachments/assets/824f4154-3270-45d7-9af7-a28c7bdc7c44" /> [After](https://docs-git-bump-protoc-gen-connect-openapi-version-zitadel.vercel.app/docs/reference/api/user/zitadel.user.v2.UserService.UpdateUser): <img width="978" height="1293" alt="Screenshot 2026-03-06 at 09 59 25" src="https://github.com/user-attachments/assets/330c1204-ccce-402c-bccb-b27076198dcd" /> (https://github.com/fuma-nama/fumadocs/issues/3063 will also be updated with improved `oneOf` visualization in this case.) # How the Problems Are Solved By fixing `protoc-gen-connect-openapi` to correctly generate the OpenAPI docs. # Additional Changes n/a # Additional Context https://github.com/sudorandom/protoc-gen-connect-openapi/pull/233 https://github.com/sudorandom/protoc-gen-connect-openapi/pull/234
85 lines
3.9 KiB
Bash
Executable File
85 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Downloads protoc-gen-connect-openapi for docs OpenAPI generation.
|
|
# Must be run from the workspace root.
|
|
# Supports Linux (including WSL2) and macOS only.
|
|
#
|
|
# WHY a binary download instead of "go install":
|
|
# This script runs as an Nx target that docs/generate-proto-docs depends on.
|
|
# Docs OpenAPI generation happens both in CI (has Go) and on Vercel
|
|
# (Node.js-only, no Go). Using a pre-built binary means Vercel never needs a
|
|
# Go toolchain. Nx remote cache means the download is skipped on repeated runs.
|
|
#
|
|
# WHY uname instead of "go env GOOS/GOARCH":
|
|
# Same reason — this script must work without Go present.
|
|
set -euo pipefail
|
|
|
|
# ── VERSIONS & CHECKSUMS ────────────────────────────────────────────────────
|
|
# To upgrade: update VERSION and the SHA256_<os>_<arch> vars below.
|
|
# Note: macOS ships a universal binary, so darwin_amd64 and darwin_arm64 share
|
|
# the same tarball and checksum.
|
|
|
|
CONNECT_OPENAPI_VERSION="0.25.5"
|
|
# checksums from upstream checksums.txt
|
|
CONNECT_OPENAPI_SHA256_linux_amd64="a9cbf821d42bc12a91b853d1fc8c3ffbea19bd8a6096d8db8b39263f1f67da74"
|
|
CONNECT_OPENAPI_SHA256_linux_arm64="287575b705cdd4a037baef75adcd8813566c4fda2eba5399483a9cbad8be7422"
|
|
CONNECT_OPENAPI_SHA256_darwin_amd64="07af8e3adbac202a0d09b97d281dcdb24949d642e43c101ea2a1a0d09aff7bd0"
|
|
CONNECT_OPENAPI_SHA256_darwin_arm64="07af8e3adbac202a0d09b97d281dcdb24949d642e43c101ea2a1a0d09aff7bd0"
|
|
|
|
# ── HELPERS ──────────────────────────────────────────────────────────────────
|
|
|
|
verify_sha256() {
|
|
local file="$1" expected="$2"
|
|
local actual
|
|
if command -v sha256sum &>/dev/null; then
|
|
actual=$(sha256sum "$file" | cut -d' ' -f1)
|
|
else
|
|
actual=$(shasum -a 256 "$file" | cut -d' ' -f1)
|
|
fi
|
|
if [ "$actual" != "$expected" ]; then
|
|
echo "ERROR: SHA256 mismatch for $(basename "$file")" >&2
|
|
echo " expected: $expected" >&2
|
|
echo " actual: $actual" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# ── PLATFORM DETECTION ───────────────────────────────────────────────────────
|
|
|
|
_uname_os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
_uname_arch=$(uname -m)
|
|
case "$_uname_os" in
|
|
linux) GOOS="linux" ;;
|
|
darwin) GOOS="darwin" ;;
|
|
*) echo "Unsupported OS: $_uname_os" >&2; exit 1 ;;
|
|
esac
|
|
case "$_uname_arch" in
|
|
x86_64) GOARCH="amd64" ;;
|
|
aarch64 | arm64) GOARCH="arm64" ;;
|
|
*) echo "Unsupported arch: $_uname_arch" >&2; exit 1 ;;
|
|
esac
|
|
|
|
BIN_DIR="${PWD}/.artifacts/bin/${GOOS}/${GOARCH}"
|
|
mkdir -p "$BIN_DIR"
|
|
|
|
TMP=$(mktemp -d "${TMPDIR:-/tmp}/zitadel-docs-proto-plugins.XXXXXX")
|
|
trap 'rm -rf "$TMP"' EXIT
|
|
|
|
# ── INSTALL ───────────────────────────────────────────────────────────────────
|
|
|
|
# ----- protoc-gen-connect-openapi (sudorandom/protoc-gen-connect-openapi) -----
|
|
# macOS ships a single universal ("all") tarball for both amd64 and arm64.
|
|
case "$GOOS" in
|
|
linux) OAI_ARCH="$GOARCH" ;;
|
|
darwin) OAI_ARCH="all" ;;
|
|
esac
|
|
sha256_var="CONNECT_OPENAPI_SHA256_${GOOS}_${GOARCH}"
|
|
echo "Downloading protoc-gen-connect-openapi v${CONNECT_OPENAPI_VERSION} (${GOOS}/${OAI_ARCH})..."
|
|
curl -fsSL \
|
|
"https://github.com/sudorandom/protoc-gen-connect-openapi/releases/download/v${CONNECT_OPENAPI_VERSION}/protoc-gen-connect-openapi_${CONNECT_OPENAPI_VERSION}_${GOOS}_${OAI_ARCH}.tar.gz" \
|
|
-o "${TMP}/oai.tar.gz"
|
|
verify_sha256 "${TMP}/oai.tar.gz" "${!sha256_var}"
|
|
tar -xzf "${TMP}/oai.tar.gz" -C "${TMP}" protoc-gen-connect-openapi
|
|
install -m 755 "${TMP}/protoc-gen-connect-openapi" "${BIN_DIR}/protoc-gen-connect-openapi"
|
|
|
|
echo "protoc-gen-connect-openapi installed to ${BIN_DIR}"
|