Add public ApiVersions constants for all known API versions#4
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
Add public ApiVersions constants for all known API versions#4devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
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>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Why?
The existing
ApiVersionclass is package-private and auto-generated, exposing onlyCURRENTandCURRENT_MAJOR. Users who need to reference a specific API version string — for example, when comparingevent.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_ACACIAinstead of"2024-09-30.acacia".Addresses stripe/stripe-java#2001.
What?
ApiVersions.java— public, final, non-instantiable class with:LATEST— alias forStripe.API_VERSION(delegates to the auto-generatedApiVersion.CURRENT)Stringconstants covering every known API version from2011-01-01through2026-03-25.dahlia, matching the versions inWebhookEndpointCreateParams.ApiVersionApiVersionsTest.java— 4 tests verifyingLATESTtracksStripe.API_VERSION, the current version constant matchesLATEST, spot-checked version strings are well-formed, and constants are non-nullNo existing code is modified.
Reviewer checklist:
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.ApiVersion.java, or whether a note/comment in the file would help future maintainers.WebhookEndpointCreateParamsbut doesn't actually use anyApiVersionsconstant — confirm this is acceptable or if a more illustrative example is needed.See Also
src/main/java/com/stripe/ApiVersion.javaWebhookEndpointCreateParams.ApiVersionenumLink to Devin session: https://app.devin.ai/sessions/c1b674151bf44bf5beb6dff50488e9d3
Requested by: @kllyjsn