Skip to content

fix: allow null for SubscriptionModel.MaxPeriods in responses#2

Merged
mokevnin merged 1 commit into
mainfrom
fix/subscription-maxperiods-nullable
Jun 26, 2026
Merged

fix: allow null for SubscriptionModel.MaxPeriods in responses#2
mokevnin merged 1 commit into
mainfrom
fix/subscription-maxperiods-nullable

Conversation

@mokevnin

Copy link
Copy Markdown
Member

Problem

The CloudPayments subscription API returns "MaxPeriods": null for 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 carries MaxPeriods: null.

The response model SubscriptionModel.MaxPeriods was typed as a non-nullable int32, so generated SDKs mistype a value the API genuinely returns as null (e.g. the Ruby SDK generates optional :max_periods, Integer, forcing consumers to fight a non-nilable type for a legitimately-null field).

Change

  • models/subscription.tsp: SubscriptionModel.MaxPeriods?: int32int32 | null.
  • Regenerated tsp-output/schema/openapi.1.0.0.yaml (make compile-openapi): the field becomes anyOf: [integer, "null"].

Intentionally NOT changed

The request models SubscriptionCreateRequest and SubscriptionUpdateRequest keep MaxPeriods?: int32 (non-nullable). Per the API docs maxPeriods is optional in requests, and "no limit" is expressed by omitting the field — sending an explicit null in the request is not documented. Making the request param nullable would cause SDK serializers to emit "MaxPeriods": null on the wire instead of omitting it.

🤖 Generated with Claude Code

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]>
@mokevnin mokevnin merged commit bcdaf61 into main Jun 26, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant