openapi: "3.0.3"
info:
  title: "Polymorphic payment schema"
  version: "1.0.0"
  description: "The oneOf table on this page compares three table designs for a polymorphic schema. The kind discriminator column is the design that keeps one table and two nullable columns. The card_last4 column is only meaningful for the card branch, so it stays nullable. The iban column is only meaningful for the bank transfer branch."
paths: {}
x-domain-id: "spec_oneof"
x-dialect: "postgres"
components:
  schemas:
    payments:
      type: "object"
      x-primary-key: "id"
      required: ["id", "kind", "amount_cents", "reference"]
      properties:
        id:
          type: "string"
          format: "uuid"
        kind:
          type: "string"
          enum: ["card", "bank_transfer"]
        amount_cents:
          type: "integer"
          minimum: 1
        card_last4:
          type: "string"
          nullable: true
        iban:
          type: "string"
          nullable: true
        reference:
          type: "string"
