codegen: honor x-cli-description for surface-specific flag help (API-488) - #167
Closed
somanshreddy wants to merge 1 commit into
Closed
codegen: honor x-cli-description for surface-specific flag help (API-488)#167somanshreddy wants to merge 1 commit into
somanshreddy wants to merge 1 commit into
Conversation
…488) Generated CLI flag help reused the HTTP API field `description` verbatim, which is misleading when a field has a per-surface default override (e.g. `aspect_ratio` has API default 16:9 but CLI default `auto` via x-cli-default, so help still said "Defaults to 16:9"). Add an `x-cli-description` schema-property extension, parsed via a new `schemaCliHelp` helper that mirrors `schemaCliDefault`: the extension (when present and a string) wins over `description`, otherwise the API description is used unchanged. Applied at all three flag-help sites (query params, multipart fields, JSON body fields). The `--request-schema` output stays faithful to the raw API `description`. Proven via the codegen golden test: the mini_spec `color` property now carries x-cli-description and the regenerated golden shows the flag Help using the override while RequestSchema keeps the API description. Adds a unit test for schemaCliHelp precedence and documents the extension in CONTRIBUTING.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Closing in favor of #169. We decided the API spec (EF) will not own CLI-surface descriptions: surface framing belongs to the surface, and the source of truth in EF stays the API contract. #169 implements CLI-curated description overrides as a runtime overlay in cmd/heygen (the established columns.go/poll-config pattern), which is the chosen single mechanism. The 'x-cli-description' spec-extension consumer here would have no data source, so it's being dropped to avoid maintaining a second, unused override path. The default-value divergence (e.g. aspect_ratio 16:9 vs auto) remains owned by the existing x-cli-default mechanism. Salvaging the CONTRIBUTING doc for the existing x-cli-* extensions into #169. |
somanshreddy
added a commit
that referenced
this pull request
Jun 12, 2026
#167 (the x-cli-description spec-extension consumer) was closed: EF will not own CLI-surface descriptions, so that mechanism has no data source. This overlay is the single chosen mechanism. Salvage the CONTRIBUTING docs for the existing x-cli-visible/action/default extensions, and scrub the now-stale references to #167 / x-cli-description in the overlay docs and comments. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Scope
Surfaces: CLI (codegen) | Module: Codegen
Description
Generated CLI flag help currently reuses the HTTP API field
descriptionverbatim. This is misleading whenever a field has a per-surface default override. The canonical case isaspect_ratio: the HTTP API default is16:9but the CLI default isauto(via the existingx-cli-defaultextension), yet--helpstill reads "Defaults to 16:9," misleading both humans and agents.This teaches codegen to honor a surface-specific help override on a schema property. When the property carries the extension, codegen uses it as the flag's
Help; when absent, it falls back to the existingdescription(current behavior, unchanged).Extension name:
x-cli-description. This mirrors the siblingx-cli-*extensions the codegen already reads (x-cli-default,x-cli-visible,x-cli-action,x-cli-category) and keeps the samex-cli-<concept>naming style. The parsing/lookup follows the exact pattern ofschemaCliDefault: a smallschemaCliHelphelper that readss.Extensions["x-cli-description"], type-asserts tostring, and otherwise returnss.Description. It is wired into all three flag-help sites (query params, multipart fields, JSON body fields).The override applies only to flag help. The
--request-schema/--response-schemaoutput stays faithful to the raw APIdescription, since those expose the actual API contract.The production OpenAPI spec (in experiment-framework) does not yet carry
x-cli-description; adding it there is a separate EF-side change. This PR is the CLI-repo half only.Testing
codegen/testdata/mini_spec.json): thecolorproperty now carries both adescriptionand anx-cli-descriptionoverride. The regenerated golden (codegen/testdata/golden/widget.go) shows the flagHelpusing the override whileRequestSchemakeeps the raw APIdescription, proving both override and faithful-schema behavior.TestSchemaCliHelpcovering precedence: extension wins over description, fallback to description when absent, non-string extension falls back, and unrelated extensions are ignored.make buildandmake test(golden + unit suites) pass.