Skip to content

Invalid OpenAPI schema for "store" property of "Purchase" and "Subscription" #1727

@elierotenberg

Description

@elierotenberg

Hi,

I wasn't too sure where to report this issue, as this is not strictly tied to a specific SDK but probably to the backend code implementing the RevenueCat API, but the "store" property of the "Purchase" and "Subscription" components are incorrect in the OpenAPI document for API v2:

components:
  schemas:
    # ...
    Purchase:
    properties:
      store:
        enum: # missing: test_store
          - amazon
          - app_store
          - mac_app_store
          - play_store
          - promotional
          - stripe
          - rc_billing
        description: Store the purchase belongs to
        nullable: false
        type: string
        example: amazon
    # ...
    Subscription:
      properties:
        store:
          enum: # missing: test_store
            - amazon
            - app_store
            - mac_app_store
            - play_store
            - promotional
            - stripe
            - rc_billing
          description: Store the subscription belongs to
          nullable: false
          type: string
          example: amazon

The 2 enums are missing the value test_store which, when used together with a strict schema validator, causes whole responses to be rejected (e.g. GET https://api.revenuecat.com/v2/projects/{project_id}/customers/{customer_id}/subscriptions) when called for a user having a subscription in a test_store.

Context: I am generating a strongly typed TypeScript SDK with Zod validation using the Hey API code generator for server-side (Node.js) usage.
I was able to circumvent the problem by monkey-patching the spec before running the generator:

  for (const schema of [`Purchase`, `Subscription`] as const) {
    if (
      !spec.components.schemas[schema].properties.store.enum.includes(
        `test_store`,
      )
    ) {
      spec.components.schemas[schema].properties.store.enum.push(`test_store`);
    }
  }

Please note that I am NOT reporting a bug in the client generation (this is on my side/my responsibility) but a bug in the OpenAPI spec provided in the RevenueCat docs. I am just sharing my workaround code for any fellow developers interested in the workaround.

Please don't hesitate to tell me if this is not the correct repo for reporting this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions