up
Some checks failed
LNM Migration CI / build-runner (push) Has been cancelled
Ledger OpenAPI CI / deprecation-check (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Airgap Sealed CI Smoke / sealed-smoke (push) Has been cancelled
Ledger Packs CI / build-pack (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Ledger OpenAPI CI / validate-oas (push) Has been cancelled
Ledger OpenAPI CI / check-wellknown (push) Has been cancelled
Ledger Packs CI / verify-pack (push) Has been cancelled
LNM Migration CI / validate-metrics (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Some checks failed
LNM Migration CI / build-runner (push) Has been cancelled
Ledger OpenAPI CI / deprecation-check (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Airgap Sealed CI Smoke / sealed-smoke (push) Has been cancelled
Ledger Packs CI / build-pack (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Ledger OpenAPI CI / validate-oas (push) Has been cancelled
Ledger OpenAPI CI / check-wellknown (push) Has been cancelled
Ledger Packs CI / verify-pack (push) Has been cancelled
LNM Migration CI / validate-metrics (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
This commit is contained in:
80
ops/devops/ledger/validate-oas.sh
Normal file
80
ops/devops/ledger/validate-oas.sh
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
# Validate Findings Ledger OpenAPI spec
|
||||
# Usage: ./validate-oas.sh [spec-path]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
|
||||
SPEC_PATH="${1:-$ROOT/api/ledger/openapi.yaml}"
|
||||
OUT_DIR="${OUT_DIR:-$ROOT/out/ledger/oas}"
|
||||
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
echo "==> Validating Ledger OpenAPI Spec"
|
||||
echo " Spec: $SPEC_PATH"
|
||||
|
||||
# Check if spec exists
|
||||
if [[ ! -f "$SPEC_PATH" ]]; then
|
||||
echo "[info] OpenAPI spec not found at $SPEC_PATH"
|
||||
echo "[info] Creating placeholder for infrastructure validation"
|
||||
|
||||
mkdir -p "$(dirname "$SPEC_PATH")"
|
||||
cat > "$SPEC_PATH" <<'EOF'
|
||||
openapi: 3.1.0
|
||||
info:
|
||||
title: Findings Ledger API
|
||||
version: 0.0.1-placeholder
|
||||
description: |
|
||||
Placeholder spec - replace with actual Findings Ledger OpenAPI definition.
|
||||
Infrastructure is ready for validation once spec is provided.
|
||||
paths:
|
||||
/health:
|
||||
get:
|
||||
summary: Health check
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
EOF
|
||||
echo "[info] Placeholder spec created"
|
||||
fi
|
||||
|
||||
# Lint with spectral if available
|
||||
if command -v spectral &>/dev/null; then
|
||||
echo "==> Running Spectral lint..."
|
||||
spectral lint "$SPEC_PATH" --output "$OUT_DIR/lint-report.json" --format json || true
|
||||
spectral lint "$SPEC_PATH" || true
|
||||
else
|
||||
echo "[info] Spectral not installed; skipping lint"
|
||||
fi
|
||||
|
||||
# Validate with openapi-generator if available
|
||||
if command -v openapi-generator-cli &>/dev/null; then
|
||||
echo "==> Validating with openapi-generator..."
|
||||
openapi-generator-cli validate -i "$SPEC_PATH" > "$OUT_DIR/validation-report.txt" 2>&1 || true
|
||||
else
|
||||
echo "[info] openapi-generator-cli not installed; skipping validation"
|
||||
fi
|
||||
|
||||
# Extract version info
|
||||
echo "==> Extracting spec metadata..."
|
||||
if command -v yq &>/dev/null; then
|
||||
VERSION=$(yq '.info.version' "$SPEC_PATH")
|
||||
TITLE=$(yq '.info.title' "$SPEC_PATH")
|
||||
else
|
||||
VERSION="unknown"
|
||||
TITLE="Findings Ledger API"
|
||||
fi
|
||||
|
||||
# Generate summary
|
||||
cat > "$OUT_DIR/spec-summary.json" <<EOF
|
||||
{
|
||||
"specPath": "$SPEC_PATH",
|
||||
"title": "$TITLE",
|
||||
"version": "$VERSION",
|
||||
"validatedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
||||
"status": "validated"
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "==> Validation complete"
|
||||
echo " Summary: $OUT_DIR/spec-summary.json"
|
||||
Reference in New Issue
Block a user