DownloadByShPlugin
A core plugin — no configuration needed. It activates when a modules address starts with sh://.
Everything after sh:// is a script path. keq runs that script and treats its stdout as the OpenAPI document. It behaves exactly like DownloadByBashPlugin; the only difference is that it executes with /bin/sh, which suits environments that only have a POSIX shell.
.keqrc.ts
export default defineConfig({
outdir: "./src/apis",
modules: {
catService: "sh://./scripts/export-swagger.sh",
},
})scripts/export-swagger.sh
#!/usr/bin/env sh
curl -fsSL "$BACKEND_URL/v3/api-docs"How it runs
| Item | Behaviour |
|---|---|
| Script path | Relative paths resolve against keq's working directory (usually the project root) |
| Execution | /bin/sh <script path>, same working directory |
| Output | stdout, parsed as JSON first, then as YAML |
| Timeout | 30 seconds |
| Output limit | 50 MB |
| Cache | Keyed by script path; invalidated when the script's mtime changes |
Failures name the step that broke: script not found, script produced no output (with stderr attached), or script output is neither valid JSON nor YAML.
The cache only watches the script's
mtime. If the document changes while the script does not — a script that fetches from a remote endpoint on every run, for example — the build keeps reusing the old bytes. Clear it with keq cache clear, or bypass it for one run with keq build --no-cache.