#4

feat: wire up --data/--file flags and flatten allOf for body flag generation

Openjoshuayoeswants to merge intofrom

Summary

  • Register --data and --file as CLI options for operations with request bodies. These were documented in the README but never wired into Commander. The existing loadBody() in body.ts was dead code — this connects it to buildRequest() in the request pipeline.
  • Flatten allOf schema compositions before generating body field flags. generateBodyFlags() previously required direct type: "object" + properties on the schema, which failed for specs using allOf (e.g. the YNAB API's ExistingTransaction). Added flattenAllOf() to recursively merge composed schemas.
  • Handle OpenAPI 3.1 nullable type arrays. Fields with type: ["string", "null"] were silently skipped by collectFlags() since it only matched scalar type strings. Added resolveType() to extract the non-null type from array-style nullable types.

--data / --file

Operations with a requestBody now accept:

FlagDescription
--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 schemas

After:

$ 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 --data and expanded body field flags

🤖 Generated with Claude Code