{
  "openapi": "3.0.3",
  "info": {
    "title": "Demo Rentals API",
    "version": "1.0.0",
    "description": "Lab car rental booking API for Cloudflare API Shield schema validation"
  },
  "servers": [
    {
      "url": "https://demo.virtuous-huntsman.sxpdemo.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "Credentials": {
        "type": "object",
        "required": [
          "username",
          "password"
        ],
        "additionalProperties": false,
        "properties": {
          "username": {
            "type": "string",
            "maxLength": 64
          },
          "password": {
            "type": "string",
            "maxLength": 128
          }
        }
      },
      "Transfer": {
        "type": "object",
        "required": [
          "fromAccount",
          "toAccount",
          "amount",
          "currency"
        ],
        "additionalProperties": false,
        "properties": {
          "fromAccount": {
            "type": "string",
            "pattern": "^ACC-[0-9]{6}$"
          },
          "toAccount": {
            "type": "string",
            "pattern": "^ACC-[0-9]{6}$"
          },
          "amount": {
            "type": "number",
            "minimum": 1,
            "maximum": 50000
          },
          "currency": {
            "type": "string",
            "enum": [
              "SAR"
            ]
          },
          "reference": {
            "type": "string",
            "maxLength": 140
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/auth/token": {
      "post": {
        "operationId": "issueToken",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Credentials"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JWT issued"
          },
          "401": {
            "description": "Invalid credentials"
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}": {
      "get": {
        "operationId": "getAccount",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^ACC-[0-9]{6}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account"
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/transactions": {
      "get": {
        "operationId": "listTransactions",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^ACC-[0-9]{6}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transactions"
          }
        }
      }
    },
    "/api/v1/transfers": {
      "post": {
        "operationId": "createTransfer",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Transfer"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Transfer accepted"
          }
        }
      }
    }
  }
}