openapi: "3.0.3"
info:
  title: "Insurance claims API"
  version: "1.0.0"
  description: "A claim without its policy row is rejected by the foreign key, and claim_items are rejected without their claim. The amount check constraints are strictly positive, so a zero-value claim line is an invalid instance rather than a valid one. The denied status is a legitimate row value, so a fixture that only fills approved claims hides half the state machine. The active flag on the policy is an integer constrained to zero or one."
paths: {}
x-domain-id: "claims"
x-dialect: "postgres"
components:
  schemas:
    policies:
      type: "object"
      x-primary-key: "id"
      required: ["id", "holder_name", "premium_cents", "active"]
      properties:
        id:
          type: "string"
          format: "uuid"
        holder_name:
          type: "string"
        premium_cents:
          type: "integer"
          minimum: 0
        active:
          type: "integer"
          minimum: 0
          maximum: 1
    claims:
      type: "object"
      x-primary-key: "id"
      required: ["id", "policy_id", "amount_cents", "status", "filed_at"]
      properties:
        id:
          type: "string"
          format: "uuid"
        policy_id:
          $ref: "#/components/schemas/policies"
        amount_cents:
          type: "integer"
          minimum: 1
        status:
          type: "string"
          enum: ["submitted", "approved", "denied"]
        filed_at:
          type: "string"
          format: "date-time"
    claim_items:
      type: "object"
      x-primary-key: "id"
      required: ["id", "claim_id", "category", "amount_cents"]
      properties:
        id:
          type: "string"
          format: "uuid"
        claim_id:
          $ref: "#/components/schemas/claims"
        category:
          type: "string"
        amount_cents:
          type: "integer"
          minimum: 1
