{
  "openapi": "3.1.0",
  "info": {
    "title": "Cedar Parcel API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://sandbox.api.cedar-parcel.example/v1",
      "description": "Sandbox"
    },
    {
      "url": "https://api.cedar-parcel.example/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ServiceBearer": []
    },
    {
      "ParcelKey": []
    }
  ],
  "tags": [
    {
      "name": "Legacy",
      "description": "Older routes retained for migration testing."
    }
  ],
  "paths": {
    "/legacy/parcels/{parcelId}": {
      "get": {
        "tags": [
          "Legacy"
        ],
        "summary": "Get a parcel through the old route",
        "operationId": "getLegacyParcel",
        "parameters": [
          {
            "name": "parcelId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Parcel found. Use the current lookup route for new integrations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Parcel"
                }
              }
            }
          }
        },
        "deprecated": true
      }
    }
  },
  "components": {
    "schemas": {
      "Parcel": {
        "type": "object",
        "required": [
          "parcelId",
          "status",
          "declaredValue",
          "recipient"
        ],
        "properties": {
          "parcelId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "label_created",
              "in_transit",
              "delivered",
              "exception"
            ]
          },
          "declaredValue": {
            "type": "number",
            "minimum": 0,
            "multipleOf": 0.01,
            "description": "Value in currency units, to the nearest cent."
          },
          "recipient": {
            "$ref": "#/components/schemas/Recipient"
          },
          "events": {
            "type": "array",
            "description": "Tracking history in chronological order.",
            "items": {
              "type": "object",
              "required": [
                "kind",
                "at"
              ],
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "pickup",
                    "scan",
                    "delivery"
                  ]
                },
                "at": {
                  "type": "string",
                  "format": "date-time"
                },
                "details": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "Recipient": {
        "type": "object",
        "required": [
          "city",
          "postalCode"
        ],
        "properties": {
          "city": {
            "type": "string"
          },
          "postalCode": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "ParcelKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Parcel-Key",
        "description": "Long-lived account key."
      },
      "ServiceBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Short-lived service token."
      }
    }
  }
}
