Adds the capability to alias resource names and aliases line_items -> invoice_line_items #1270
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? @vcheung-stripe
cc @stripe/developer-products
Summary
This change adds the ability to alias resources so that they are renamed in the CLI's resource list. This allows resources to effectively be renamed, while preserving backwards compatibility by supporting the "principle" (e.g. OpenAPI spec) name but hiding that name from help text output.
The first consumer of this feature is invoice line items. Today, the CLI supports these under the name
line_items
, which differs from how the same resource is accessed in the Stripe Shell and Workbench (there it'sinvoice_line_items
). It's also just not a very descriptive name -- there's the notion of line items in at least one other API (credit notes), and not having theinvoice_
prefix separates this resource from its other invoicing siblings in the help text output.As of this PR,
line_items
does not show up in the resource list andinvoice_line_items
does:The CLI generates two resources in the case of an alias: one for the principle/original resource (from the openapi spec), and one for the alias name. The principle resource is then hidden using post-processing but still works for compatibility. They hit the same underlying API:
I added a couple tests to ensure that aliased names show up and original names don't, and that original and aliased resources hit the same underlying API endpoint.