openapi: "3.0.3"
info:
  title: "Invoice schema for a keyword mapping table"
  version: "1.0.0"
  description: "This schema deliberately contains the four keywords that have no SQL equivalent, so the mapping table can show them. The metadata column carries the json keyword, which has no scalar equivalent. The unique constraint on number maps to a unique index rather than to a check. The currency length check maps to a CHECK constraint and not to a domain type."
paths: {}
x-domain-id: "spec_invoice"
x-dialect: "postgres"
components:
  schemas:
    invoices:
      type: "object"
      x-primary-key: "id"
      required: ["id", "number", "status", "total_cents", "issued_at", "currency", "metadata"]
      properties:
        id:
          type: "string"
          format: "uuid"
        number:
          type: "string"
          x-unique: true
        status:
          type: "string"
          enum: ["draft", "open", "paid"]
        total_cents:
          type: "integer"
          minimum: 0
        issued_at:
          type: "string"
          format: "date-time"
        currency:
          type: "string"
          minLength: 3
          maxLength: 3
        metadata:
          type: "object"
