Documentation
¶
Overview ¶
Command bodyclass answers, per operation, what a gopherstack service's restjson1/awsjson1.x response body actually is: wrapped (a genuine key-switch JSON object), flat/payload (the whole body collapses onto one Output member), header-only (no body, everything HTTP-header-bound), or void (no members beyond ResultMetadata).
It exists for gopherstack-cnhp: smithy-go emits, for restjson1 single-payload ops, BOTH a deserializeOpDocument<Op>Output helper that decodes named keys AND the deserializeOp<Op>.HandleDeserialize method that actually runs. For some ops the helper is dead code and the live path decodes the body flat onto one field instead. Trusting the helper's key-switch without checking whether HandleDeserialize calls it produces a confident, wrong "missing wrapper key" finding -- this happened twice (appmesh, glacier). Naming and call signature aren't reliable either: polly's deserializeOpDocumentSynthesizeSpeechOutput looks like an ordinary wrapped helper and is called normally, but its entire body is "v.AudioStream = body" -- no JSON decode at all.
bodyclass resolves the pinned aws-sdk-go-v2/service/<mod>@<version> for a services/<dir> from go.mod (module name resolved from the directory's own imports, not assumed equal to the directory name -- see resolve.go), parses deserializers.go with go/ast, and for each op AST-walks the BODY of whatever function actually consumes the HTTP response body in HandleDeserialize -- never the helper's name or its call site alone.
Usage:
go run ./cmd/bodyclass -service appmesh # every op, text go run ./cmd/bodyclass -service appmesh -op CreateMesh # one op go run ./cmd/bodyclass -service appmesh -json out.json # full JSON dump go run ./cmd/bodyclass -all # every service, ranked totals go run ./cmd/bodyclass -all -json out.json # every service, full JSON dump