Repository navigation
feat: show request body examples in generated command help - #966
aengelberg wants to merge 1 commit into
Conversation
5b810bc to
642df58
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 642df58. Configure here.
| for _, ex := range op.Examples { | ||
| data := strings.ReplaceAll(ex.Data, "'", `'\''`) | ||
| data = strings.ReplaceAll(data, "\n", "\n ") | ||
| example := fmt.Sprintf(" %s --%s '%s'", cmdLine, cliflags.DataFlag, data) |
There was a problem hiding this comment.
Help examples omit semantic-patch flag
Medium Severity
buildExample builds a copy-paste command from path flags and --data only, and never adds --semantic-patch. Several generated help examples use an instructions body that the API accepts only with the semantic-patch content type, so those commands fail when run as shown.
Reviewed by Cursor Bugbot for commit 642df58. Configure here.
The generator now reads the request body examples of each operation in the OpenAPI spec. Each generated command shows them in the Examples section of its help, as a full command with the required flags and the example JSON in --data. The generator uses the media type example and the named examples. It does not use schema examples. 53 commands now have help examples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
642df58 to
5d99cbc
Compare
|
bumping @btesfamariam @nieblara |
|
running also, running |


Context
The help for a generated command that takes
--datasays only "Input data in JSON". It does not show the JSON that the endpoint accepts.Why I care: I'm concerned that commands that are
--data-heavy (specifically the newenvironment-releases-beta) are going to be really hard for agents to use because there's no info about what the data needs to look like.The OpenAPI spec already has request body examples for many of these endpoints. For example,
startEnvironmentReleasehas four named examples, one for each type of release.With these changes
The generator reads the request body examples of each operation, and each command shows them in the
Examplessection of its help:exampleand the namedexamples, with the summary of each named example as a comment line. It does not use schema examples, because many of them are generated placeholder values such as"metricKey": "metricKey".Testing
go test ./...passes. A new test gets the example fromldcli teams create --help, runs it with a mock client, and checks that the command sends the example JSON.environment-releases-beta startexamples throughsh. Each one parsed and sent its request to the correct URL.🤖 Generated with Claude Code
Note
Overview
Generated resource commands now surface copy-pasteable
--dataexamples in each subcommand’s Examples section instead of only describing JSON generically.The OpenAPI generator pulls
application/jsonrequest bodyexampleand namedexamples(summaries become#comment lines), stores them onOperationData.Examples, andbuildExampleturns them into full commands with required/path flags, indented JSON, and shell-safe single-quote escaping. The codegen template embeds examples intoresource_cmds.gofor dozens of body-bearing operations (including multi-example flows like environment releases).Tests cover
buildExampleformatting/escaping and verifyteams create --helpexample JSON is accepted by a mock client.Reviewed by Cursor Bugbot for commit 5d99cbc. Bugbot is set up for automated code reviews on this repo. Configure here.