feat: wire up --data/--file flags and flatten allOf for body flag generation#4
Open
joshuayoes wants to merge 3 commits intovercel-labs:mainfrom
Open
feat: wire up --data/--file flags and flatten allOf for body flag generation#4joshuayoes wants to merge 3 commits intovercel-labs:mainfrom
joshuayoes wants to merge 3 commits intovercel-labs:mainfrom
Conversation
…eration The --data and --file flags were documented in the README but never registered as Commander options. This wires them into the CLI by registering them in generated.ts and handling them in buildRequest(), using the existing but previously dead-code loadBody() from body.ts. Body field flag generation (--name, --address.city, etc.) failed for OpenAPI specs using allOf schema composition because generateBodyFlags() required direct type+properties on the schema. This adds flattenAllOf() to recursively merge allOf compositions before generating flags, fixing flag generation for specs like the YNAB API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fields with `type: ["string", "null"]` (OpenAPI 3.1 nullable syntax) 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. This fixes missing flags for fields like payee_name, memo, category_id, payee_id, and flag_color in specs like the YNAB API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a test that reproduces the exact schema shape that was broken: wrapper object -> allOf with empty object + object containing mixed scalar and nullable (["string", "null"]) properties. Verifies all 10 fields generate flags, including the 5 nullable ones that were previously silently dropped. Also add a --file happy path test that writes a temp file and verifies buildRequest reads it as the request body. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--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.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.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/--fileOperations with a
requestBodynow accept:--data <json>--file <path>These take priority over expanded body field flags. Using both is an error.
allOfflatteningBefore:
After:
OpenAPI 3.1 nullable types
Fields using
type: ["string", "null"](OpenAPI 3.1 nullable syntax) now generate flags. Previously only scalartype: "string"was recognized, causing fields likepayee_name,memo,category_id, andflag_colorto be silently dropped.Test plan
bun test)bun run typecheck)--dataand expanded body field flags🤖 Generated with Claude Code