Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the capability to alias resource names and aliases line_items -> invoice_line_items #1270

Merged
merged 8 commits into from
Nov 4, 2024

Conversation

fhats-stripe
Copy link
Contributor

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's invoice_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 the invoice_ 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 and invoice_line_items does:

image

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:

image

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.

…ename them while leaving the original resource hidden (but functional for backward compatibility)
…ith aliased names when an alias is defined. Also removes some unnecessary pointer returns
… aliased and principle resources hit the same underlying APIs
@fhats-stripe fhats-stripe requested a review from a team as a code owner November 1, 2024 23:39
@fhats-stripe fhats-stripe self-assigned this Nov 1, 2024
Copy link
Collaborator

@vcheung-stripe vcheung-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fhats-stripe fhats-stripe merged commit 7ffd100 into master Nov 4, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants