{
  "openapi": "3.0.0",
  "info": {
    "title": "Solar Category Schema",
    "description": "The API will be organized around REST. Our API will have predictable, resource-oriented URLs, and will use HTTP response codes to indicate API errors. ",
    "version": "1.0.0"
  },
  "domain": {
    "mconnect": {
      "authentication": [
        {
          "type": "basic",
          "key": ["Authorization"],
          "mode": "database",
          "storedKey": {
            "operation": "query",
            "queryType": "select",
            "table": "merchant_api_credentials",
            "clause": {
              "where": ["`key`", "status"],
              "queryParams": ["$auth.Authorization", 1],
              "logicalOperator": "AND"
            }
          }
        },
        {
          "type": "jwt",
          "key": "Authorization",
          "decodeKey": "$env.JWT_SECRET_KEY",
          "algorithm": "HS256",
          "verifyKey": {
            "operation": "query",
            "queryType": "select",
            "table": "merchant_api_credentials",
            "clause": {
              "where": ["`key`", "status"],
              "queryParams": ["$token.api_key", 1],
              "logicalOperator": "AND"
            }
          },
          "IPwhitelisting": false
        }
      ],
      "IPwhitelisting": {
        "operation": "query",
        "queryType": "raw",
        "dbRaw": "select m.ips from merchant m inner join merchant_api_credentials mac on m.id=mac.merchant_id where mac.`key` = %s",
        "queryParams": [
          "$auth.Authorization"
        ]
      },
      "response": {
        "basic": {
          "content": {
            "application/json": {
              "code": "invalid_auth",
              "description": "You are not authorized"
            },
            "status_code": 401
          }
        },
        "jwt": {
          "content": {
            "application/json": {
              "code": "invalid_header",
              "description": "Unable to find appropriate key"
            },
            "status_code": 401
          }
        }
      }
    }
  }
}