Skip to content

Add public ApiVersions constants for all known API versions#4

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
feature/api-version-constants
Open

Add public ApiVersions constants for all known API versions#4
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
feature/api-version-constants

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 12, 2026

Why?

The existing ApiVersion class is package-private and auto-generated, exposing only CURRENT and CURRENT_MAJOR. Users who need to reference a specific API version string — for example, when comparing event.getApiVersion() or documenting which version their integration targets — must resort to magic strings scattered through their code.

This adds a public constants class so users can write ApiVersions.VERSION_2024_09_30_ACACIA instead of "2024-09-30.acacia".

Addresses stripe/stripe-java#2001.

What?

  • New ApiVersions.java — public, final, non-instantiable class with:
    • LATEST — alias for Stripe.API_VERSION (delegates to the auto-generated ApiVersion.CURRENT)
    • 99 individual String constants covering every known API version from 2011-01-01 through 2026-03-25.dahlia, matching the versions in WebhookEndpointCreateParams.ApiVersion
  • New ApiVersionsTest.java — 4 tests verifying LATEST tracks Stripe.API_VERSION, the current version constant matches LATEST, spot-checked version strings are well-formed, and constants are non-null

No existing code is modified.

Reviewer checklist:

  • Completeness: Verify the 99 constants match 1:1 with the entries in WebhookEndpointCreateParams.ApiVersion — any missing or extra entry would be a bug. A quick diff of the constant names against that enum is the fastest way to check.
  • Maintenance burden: This file is hand-written, not auto-generated. Each new API version release will require a manual addition here. Consider whether this should eventually be generated alongside ApiVersion.java, or whether a note/comment in the file would help future maintainers.
  • Javadoc example: The code example in the class Javadoc shows building a WebhookEndpointCreateParams but doesn't actually use any ApiVersions constant — confirm this is acceptable or if a more illustrative example is needed.

See Also

  • stripe/stripe-java#2001 — original feature request
  • Existing auto-generated class: src/main/java/com/stripe/ApiVersion.java
  • Version source of truth: WebhookEndpointCreateParams.ApiVersion enum

Link to Devin session: https://app.devin.ai/sessions/c1b674151bf44bf5beb6dff50488e9d3
Requested by: @kllyjsn


Open with Devin

The existing ApiVersion class is package-private and auto-generated,
containing only CURRENT and CURRENT_MAJOR. There is no public API for
users to reference specific API version strings as constants.

This adds ApiVersions (public, final, non-instantiable) with:
- LATEST: alias for Stripe.API_VERSION (the SDK's built-in version)
- Individual constants for all 99 known API versions from 2011-01-01
  through 2026-03-25.dahlia, matching the versions in
  WebhookEndpointCreateParams.ApiVersion

Use cases:
- Comparing event.getApiVersion() against a known constant
- Documenting which API version a codebase targets
- Avoiding magic strings scattered through application code

Also adds ApiVersionsTest with 4 tests verifying:
- LATEST matches Stripe.API_VERSION
- Current version constant matches LATEST
- Version strings are well-formed (spot checks across eras)
- Constants are non-null

Addresses stripe#2001

Co-Authored-By: Jason Kelley <kllyjsn@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant