fix: parse nested JSON values for body flags#5
Merged
EvilFreelancer merged 1 commit intoEvilFreelancer:mainfrom Mar 17, 2026
Merged
fix: parse nested JSON values for body flags#5EvilFreelancer merged 1 commit intoEvilFreelancer:mainfrom
EvilFreelancer merged 1 commit intoEvilFreelancer:mainfrom
Conversation
Body flag values starting with `{` or `[` are now parsed as JSON objects/arrays
instead of being sent as raw strings. Boolean literals (`true`/`false`) and `null`
are also parsed into their JSON equivalents. Invalid JSON-like values throw a clear
error. Plain string values are preserved unchanged.
This fixes endpoints that expect nested JSON payloads (e.g. objects, arrays) in
request bodies assembled from CLI flags.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
EvilFreelancer
approved these changes
Mar 17, 2026
Owner
|
Hi! Thanks, good PR. |
Owner
|
Your fix in v0.1.9 |
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
openapi-to-cliassembles JSON request bodies from CLI flags, but nested values (objects, arrays) are sent as raw strings instead of parsed JSON. This makes endpoints expecting nested payloads unusable.Before (broken):
{ "revision": "main", "input": "{\"values\":[{\"name\":\"FOO\",\"value\":\"bar\"}]}" }After (fixed):
{ "revision": "main", "input": { "values": [{ "name": "FOO", "value": "bar" }] } }Root cause
In
runApiCommand(), unknown flags (body fields) are copied into the request body as-is. SinceparseArgs()treats all values as strings, JSON objects/arrays remain strings.Changes
parseBodyFlagValue()helper insrc/cli.tsthat:{or[as JSONtrue/false/nullliterals to JSON primitivestests/cli.test.tsIntentional limitations
"123"as a string)--helpand validationTest plan
true/false) → parsed as booleansnullbody flag → parsed as null🤖 Generated with Claude Code