fix: allow null for SubscriptionModel.MaxPeriods in responses#2
Merged
Conversation
The CloudPayments subscription API returns "MaxPeriods": null for subscriptions created without a payment limit (unlimited recurring payments). The response model typed MaxPeriods as a non-nullable int32, so generated SDKs mistype a value the API actually returns as null. Mark MaxPeriods nullable on the response model only. The request models (SubscriptionCreateRequest / SubscriptionUpdateRequest) are intentionally left non-nullable: per the API docs maxPeriods is optional and "no limit" is expressed by omitting the field, not by sending null. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Problem
The CloudPayments subscription API returns
"MaxPeriods": nullfor subscriptions created without a payment limit (unlimited recurring payments). See the API reference: a subscription can be created with a max number of payments or with no limit at all, and the subscription object then carriesMaxPeriods: null.The response model
SubscriptionModel.MaxPeriodswas typed as a non-nullableint32, so generated SDKs mistype a value the API genuinely returns asnull(e.g. the Ruby SDK generatesoptional :max_periods, Integer, forcing consumers to fight a non-nilable type for a legitimately-null field).Change
models/subscription.tsp:SubscriptionModel.MaxPeriods?: int32→int32 | null.tsp-output/schema/openapi.1.0.0.yaml(make compile-openapi): the field becomesanyOf: [integer, "null"].Intentionally NOT changed
The request models
SubscriptionCreateRequestandSubscriptionUpdateRequestkeepMaxPeriods?: int32(non-nullable). Per the API docsmaxPeriodsis optional in requests, and "no limit" is expressed by omitting the field — sending an explicitnullin the request is not documented. Making the request param nullable would cause SDK serializers to emit"MaxPeriods": nullon the wire instead of omitting it.🤖 Generated with Claude Code