|
1 | 1 | #!/usr/bin/env bash |
2 | | -# Generate OpenAPI specs from both engine and service apps. |
3 | | -# Output: docs/openapi/engine.json, docs/openapi/service.json |
| 2 | +# Generate OpenAPI specs from engine, service, and webhook apps. |
| 3 | +# Output: docs/openapi/{engine,service,webhook}.json |
4 | 4 | set -euo pipefail |
5 | 5 |
|
6 | 6 | cd "$(dirname "$0")/.." |
@@ -36,11 +36,20 @@ node -e " |
36 | 36 | process.stdout.write(JSON.stringify(spec, null, 2) + '\n'); |
37 | 37 | " > "$outdir/service.json" |
38 | 38 |
|
39 | | -pnpm prettier --write "$outdir/engine.json" "$outdir/service.json" --log-level warn |
| 39 | +echo "Generating webhook OpenAPI spec..." |
| 40 | +node -e " |
| 41 | + import { createWebhookApp } from './apps/service/dist/api/webhook-app.js'; |
| 42 | + const app = createWebhookApp({ push_event: () => {} }); |
| 43 | + const res = await app.request('/openapi.json'); |
| 44 | + const spec = await res.json(); |
| 45 | + process.stdout.write(JSON.stringify(spec, null, 2) + '\n'); |
| 46 | +" > "$outdir/webhook.json" |
| 47 | + |
| 48 | +pnpm prettier --write "$outdir/engine.json" "$outdir/service.json" "$outdir/webhook.json" --log-level warn |
40 | 49 |
|
41 | 50 | if $check_mode; then |
42 | 51 | drift=false |
43 | | - for spec in engine.json service.json; do |
| 52 | + for spec in engine.json service.json webhook.json; do |
44 | 53 | if ! diff -q "$outdir/$spec" "docs/openapi/$spec" > /dev/null 2>&1; then |
45 | 54 | echo "DRIFT: docs/openapi/$spec is out of date" |
46 | 55 | diff --unified "$outdir/$spec" "docs/openapi/$spec" || true |
|
57 | 66 | echo "Done:" |
58 | 67 | echo " docs/openapi/engine.json ($(wc -l < docs/openapi/engine.json) lines)" |
59 | 68 | echo " docs/openapi/service.json ($(wc -l < docs/openapi/service.json) lines)" |
| 69 | + echo " docs/openapi/webhook.json ($(wc -l < docs/openapi/webhook.json) lines)" |
60 | 70 | fi |
0 commit comments