Show enum values and API types in resource command help#1501
Merged
bernerd-stripe merged 5 commits intomasterfrom Mar 23, 2026
Merged
Show enum values and API types in resource command help#1501bernerd-stripe merged 5 commits intomasterfrom
bernerd-stripe merged 5 commits intomasterfrom
Conversation
Extract enum values from standard JSON Schema `enum` arrays in the OpenAPI spec (in addition to the existing `x-stripeEnum` support) and display them in operation help output. Also extract enums from GET/DELETE query parameters, which were previously missing. Help output now shows: - Enum flags as literal values: --status complete|expired|open - Booleans as: --requested true|false - Typed params in angle brackets: --amount <integer> - Arrays as: --files <string> [can be specified multiple times] - Long enums truncated at 5 values: --type a|b|c|d|e|... The enum parameter type was simplified from map[string][]spec.StripeEnumValue to map[string][]string since the spec only provides plain value lists. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Committed-By-Agent: claude
Some OpenAPI spec enums include "" (empty string) to represent "clear/unset this field". This caused a rendering bug with a leading pipe in help output (e.g. --tax-exempt |exempt|none|reverse). Filter these out at code generation time. Affects: account_holder_type, tax_exempt, setup_future_usage Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Committed-By-Agent: claude
The generated addV1ResourcesCmds() was a 6,076-line function that caused a Go arm64 linker crash (go#77593) when building with CGO_ENABLED=1 (required for -race tests). The crash occurs in gensymlate when a function's compiled code/data exceeds internal limits. Restructure the template to generate one function per namespace instead of one mega-function per API version. This splits addV1ResourcesCmds into a coordinator calling ~17 per-namespace helpers, with the largest (root namespace) at ~3,768 lines — roughly 62% of the original size. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Committed-By-Agent: claude
Trim whitespace in the coordinator function template loop to prevent a blank line before the closing brace, which triggered golangci-lint "unnecessary trailing newline" errors. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Committed-By-Agent: claude
tomer-stripe
approved these changes
Mar 23, 2026
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.
Reviewers
r?
cc @stripe/developer-products
Summary
<string>,<integer>, etc.) for all request parameters in resource command helpactive|canceled)Before
Request parameters showed only flag names with no type information, accepted values, or usage hints:
After
Each parameter now shows its API type in angle brackets, enum values are displayed inline with
|, booleans showtrue|false, and arrays indicate repeatability.POST with enums (
stripe account_links create --help):GET with types and enums (
stripe checkout sessions list --help):Booleans, arrays, numbers, and enums (
stripe tax_rates create --help):Arrays (
stripe accounts create --help, excerpt):Short enums (
stripe customers create --help, excerpt):Details
Enum extraction from OpenAPI spec: The Stripe API spec supports an
x-stripeEnumextension with rich enum metadata (values + descriptions), but this extension is explicitly excluded from the CLI's version of the spec and has never been present in it. The generator already had code to readx-stripeEnumbut it was always empty. This change adds a fallback to the standard JSON Schemaenumarrays, which are present in the CLI spec. Enum extraction was also added for GET/DELETE query parameters, which was previously missing entirely.Display formatting: Types use angle brackets (
<string>) to visually distinguish them from literal enum values (active|canceled|expired). Enums with more than 5 values are truncated with|.... Empty string enum values (used in the Stripe API to mean "unset this field") are filtered out at code generation time.Simplified enum type: Since the CLI spec only provides plain
enumarrays (not the richerx-stripeEnum), the enum parameter was simplified frommap[string][]spec.StripeEnumValuetomap[string][]string. Enum values and API types are stored as flag annotations for the display layer.Linker crash fix: Adding enum data to the generated code pushed
addV1ResourcesCmds()to 6,076 lines with 570NewOperationCmdcalls, each containing inline map literals. This caused a Go 1.26 arm64 linker crash (go#77593) when building withCGO_ENABLED=1(required for-racetests). The fix restructures the code generation template to emit one function per namespace instead of one mega-function per API version. The coordinatoraddV1ResourcesCmds()now calls ~17 per-namespace helpers (e.g.addV1NsBillingResourcesCmds,addV1NsIssuingResourcesCmds), with the largest (root namespace) at ~3,768 lines — roughly 62% of the original.Test plan
go vet ./...passesgo test ./pkg/cmd/... ./pkg/stripe/...passesCGO_ENABLED=1 go test -race ./pkg/cmd/passes (previously crashed)stripe account_links create --help(POST with enums)stripe checkout sessions list --help(GET with enum)stripe accounts create --help(boolean, array, number types)stripe tax_rates create --help(long enum truncation)stripe customers create --help(no leading pipe on tax-exempt)stripe billing meters list --help(namespaced command still works)🤖 Generated with Claude Code