Repository navigation
Commit 7d63243
feat(api): generate --data/--data-file flags and body schema help (#156)
Reimplements PR #156 against the typed-client generator landed in #160
(6fd1f02). The original PR was authored against the pre-#160 generator,
whose entire schema parser, client signatures, and emit functions were
replaced — making a literal rebase impossible.
What
For every body-bearing endpoint the generator now emits two flags:
--data <json> Request body as a raw JSON string
--data-file <path> Read request body JSON from a file (- for stdin)
Body resolution precedence in the generated `RunE`:
--data wins; else --data-file (file, or os.Stdin for `-`); else fall
back to piped stdin so existing usage keeps working.
Each branch JSON-decodes directly into the typed `api.XInput` struct
(the post-#160 shape), so path/query overrides still win because they
populate `in` after.
The body schema is surfaced in the cobra `Long` help: sorted top-level
property names with JSON-style type hints, marking required fields,
looked up from `r.schemas[ep.BodySchema]`. Unknown / property-less
schemas fall back to a generic `Request body: raw JSON` note.
Regenerated `internal/commands/*` via `go run ./scripts/generate`. The
diff is large because every body-bearing command changed — expected.
`internal/api/*` is unchanged.
Verification
GOWORK=off CGO_ENABLED=0 go build ./... # OK
GOWORK=off go vet ./... # OK
GOWORK=off go test ./... # OK
go run ./cmd/cli api manager create-threat-investigations --help
→ Long now lists every field, --data / --data-file flags appear.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 31471af commit 7d63243
11 files changed
Lines changed: 4425 additions & 584 deletions
File tree
- internal/commands
- scripts/generate
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments