openapi: "3.0.3"
info:
  title: "Shipment schema for a worked conversion"
  version: "1.0.0"
  description: "This schema is used for the worked conversion that turns one definition into three ordered inserts. The ordering rule is the point of the worked example, because the carrier insert has to come first. The tracking uniqueness means the second shipment cannot reuse the first tracking value. The status enum has three members and the delivered one is the terminal state."
paths: {}
x-domain-id: "spec_shipment"
x-dialect: "postgres"
components:
  schemas:
    carriers:
      type: "object"
      x-primary-key: "id"
      required: ["id", "code", "name"]
      properties:
        id:
          type: "string"
          format: "uuid"
        code:
          type: "string"
          x-unique: true
        name:
          type: "string"
    shipments:
      type: "object"
      x-primary-key: "id"
      required: ["id", "carrier_id", "tracking", "status", "weight_grams"]
      properties:
        id:
          type: "string"
          format: "uuid"
        carrier_id:
          $ref: "#/components/schemas/carriers"
        tracking:
          type: "string"
          x-unique: true
        status:
          type: "string"
          enum: ["label_created", "in_transit", "delivered"]
        weight_grams:
          type: "integer"
          minimum: 1
