fix: parse object and array params from JSON strings#19
Conversation
When OpenAPI spec defines a parameter as type "object" or "array", CLI string values are now JSON.parse()'d before sending to the API. Previously they were sent as raw strings, causing 400 errors from APIs expecting structured data. Falls back to the original string if JSON parsing fails. Closes #15 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@claude Review This PR |
|
Claude finished @lucianfialho's task in 1m 15s —— View job PR Review: fix: parse object and array params from JSON stringsTodo:
SummaryThe fix correctly solves the core bug: object/array params passed as CLI strings are now JSON-parsed before being sent to the API. Implementation is clean and tests pass. A few notes below. What's Good
Issues & Suggestions1. Duplicated logic across two code paths (design concern)The same JSON-parse logic lives in both The two builders appear to coexist ( 2. Silent fallback may hide user mistakes (
|
Highlights since v0.5.0: - feat: multi-header auth for VTEX-style APIs (#20, PR #21) - --header / -H flag, repeatable, works inline and via `auth login` profiles - $VAR / ${VAR} expansion per header value with empty-var warning - --agent-help now suggests multi-header usage on specs with 2+ apiKey schemes - fix: mask all auth header values in --verbose output (not just Authorization) - fix: reject CR/LF in header names/values (RFC 7230 injection guard) - fix: parse object and array params from JSON strings (#15, PR #19) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
object/arraytype params are now parsed into proper objects before sending to the APIindex.ts(main flow) andcommander-builder.ts(alternate flow)Changes
src/index.ts— Addedobject/arraycase to param type coercion in action handlersrc/executor/commander-builder.ts— Added sameobject/arraycase tocollectParams()switchsrc/executor/commander-builder.test.ts— 3 new tests: object parsing, array parsing, invalid JSON fallbackTest plan
--content '{"text":"hello"}'sends parsed object, not string--tags '["a","b"]'sends parsed array--data "not-json"falls back to string without errorCloses #15
🤖 Implemented by Claude Code dev-pipeline