#4
feat: wire up --data/--file flags and flatten allOf for body flag generation
Summary
- Register
--dataand--fileas CLI options for operations with request bodies. These were documented in the README but never wired into Commander. The existingloadBody()inbody.tswas dead code — this connects it tobuildRequest()in the request pipeline. - Flatten
allOfschema compositions before generating body field flags.generateBodyFlags()previously required directtype: "object"+propertieson the schema, which failed for specs usingallOf(e.g. the YNAB API'sExistingTransaction). AddedflattenAllOf()to recursively merge composed schemas. - Handle OpenAPI 3.1 nullable type arrays. Fields with
type: ["string", "null"]were silently skipped bycollectFlags()since it only matched scalar type strings. AddedresolveType()to extract the non-null type from array-style nullable types.
--data / --file
Operations with a requestBody now accept:
| Flag | Description |
|---|---|
--data <json> | Inline request body |
--file <path> | Read request body from file |
These take priority over expanded body field flags. Using both is an error.
allOf flattening
Before:
$ mycli update-item --help
# No body field flags shown for allOf-composed schemasAfter:
$ mycli update-item --help
Options:
--item.name <string>
--item.amount <integer>
...OpenAPI 3.1 nullable types
Fields using type: ["string", "null"] (OpenAPI 3.1 nullable syntax) now generate flags. Previously only scalar type: "string" was recognized, causing fields like payee_name, memo, category_id, and flag_color to be silently dropped.
Test plan
- 9 new unit tests (3 allOf, 2 nullable types, 4 --data/--file)
- All 282 tests pass (
bun test) - Typecheck passes (
bun run typecheck) - End-to-end: compiled a CLI from the YNAB OpenAPI spec and successfully updated a transaction using both
--dataand expanded body field flags
🤖 Generated with Claude Code