{
  "$import": {
    "common": "file:///common.json"
  },
  "definitions": {
    "App": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "userId": {
          "type": "integer"
        },
        "status": {
          "type": "integer"
        },
        "name": {
          "type": "string",
          "pattern": "^[A-z0-9\\-\\_]{3,64}$"
        },
        "url": {
          "type": "string",
          "minLength": 8
        },
        "appKey": {
          "type": "string"
        },
        "appSecret": {
          "type": "string"
        },
        "date": {
          "type": "string"
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "App_Collection": {
      "$ref": "common:Collection",
      "$template": {
        "T": "App"
      }
    },
    "App_Create": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[A-z0-9\\-\\_]{3,64}$"
        },
        "url": {
          "type": "string",
          "minLength": 8
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": ["name", "url", "scopes"]
    },
    "App_Update": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[A-z0-9\\-\\_]{3,64}$"
        },
        "url": {
          "type": "string",
          "minLength": 8
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": ["name", "url", "scopes"]
    },
    "Authorize_Meta": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "scopes": {
          "type": "array",
          "items": {
            "$ref": "Scope"
          }
        }
      }
    },
    "Authorize_Request": {
      "type": "object",
      "properties": {
        "responseType": {
          "type": "string"
        },
        "clientId": {
          "type": "string"
        },
        "redirectUri": {
          "type": "string"
        },
        "scope": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "allow": {
          "type": "boolean"
        }
      },
      "required": ["responseType", "clientId", "scope", "allow"]
    },
    "Authorize_Response": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        },
        "token": {
          "$ref": "Authorize_Response_Token"
        },
        "code": {
          "type": "string"
        },
        "redirectUri": {
          "type": "string"
        }
      }
    },
    "Authorize_Response_Token": {
      "type": "object",
      "properties": {
        "access_token": {
          "type": "string"
        },
        "token_type": {
          "type": "string"
        },
        "expires_in": {
          "type": "string"
        },
        "scope": {
          "type": "string"
        }
      }
    },
    "Event": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      }
    },
    "Event_Collection": {
      "$ref": "common:Collection",
      "$template": {
        "T": "Event"
      }
    },
    "Event_Subscription": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "status": {
          "type": "integer"
        },
        "event": {
          "type": "string"
        },
        "endpoint": {
          "type": "string"
        },
        "responses": {
          "type": "array",
          "items": {
            "$ref": "Event_Subscription_Response"
          }
        }
      }
    },
    "Event_Subscription_Response": {
      "type": "object",
      "properties": {
        "status": {
          "type": "integer"
        },
        "code": {
          "type": "integer"
        },
        "attempts": {
          "type": "string"
        },
        "executeDate": {
          "type": "string"
        }
      }
    },
    "Event_Subscription_Collection": {
      "$ref": "common:Collection",
      "$template": {
        "T": "Event_Subscription"
      }
    },
    "Event_Subscription_Create": {
      "type": "object",
      "properties": {
        "event": {
          "type": "string"
        },
        "endpoint": {
          "type": "string"
        }
      },
      "required": ["event", "endpoint"]
    },
    "Event_Subscription_Update": {
      "type": "object",
      "properties": {
        "event": {
          "type": "string"
        },
        "endpoint": {
          "type": "string"
        }
      },
      "required": ["event", "endpoint"]
    },
    "Log": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "appId": {
          "type": "integer"
        },
        "ip": {
          "type": "string"
        },
        "userAgent": {
          "type": "string"
        },
        "method": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "header": {
          "type": "string"
        },
        "body": {
          "type": "string"
        },
        "date": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "Log_Collection": {
      "$ref": "common:Collection",
      "$template": {
        "T": "Log"
      }
    },
    "Grant": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "app": {
          "$ref": "App"
        },
        "createDate": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "Grant_Collection": {
      "$ref": "common:Collection",
      "$template": {
        "T": "Grant"
      }
    },
    "Page": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "title": {
          "type": "string"
        },
        "slug": {
          "type": "string"
        },
        "content": {
          "type": "string"
        }
      }
    },
    "Page_Collection": {
      "$ref": "common:Collection",
      "$template": {
        "T": "Page"
      }
    },
    "Plan": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "price": {
          "type": "number"
        },
        "points": {
          "type": "integer"
        }
      }
    },
    "Plan_Collection": {
      "$ref": "common:Collection",
      "$template": {
        "T": "Plan"
      }
    },
    "Payment_Checkout_Request": {
      "type": "object",
      "properties": {
        "planId": {
          "type": "integer"
        },
        "returnUrl": {
          "type": "string"
        }
      }
    },
    "Payment_Checkout_Response": {
      "type": "object",
      "properties": {
        "approvalUrl": {
          "type": "string"
        }
      }
    },
    "Payment_Portal_Response": {
      "type": "object",
      "properties": {
        "redirectUrl": {
          "type": "string"
        }
      }
    },
    "Scope": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string",
          "pattern": "^[A-z0-9\\-\\_]{3,64}$"
        },
        "description": {
          "type": "string"
        }
      }
    },
    "Scope_Collection": {
      "$ref": "common:Collection",
      "$template": {
        "T": "Scope"
      }
    },
    "Transaction": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "status": {
          "type": "integer"
        },
        "transactionId": {
          "type": "string"
        },
        "amount": {
          "type": "number"
        },
        "updateDate": {
          "type": "integer",
          "format": "date-time"
        },
        "insertDate": {
          "type": "integer",
          "format": "date-time"
        }
      }
    },
    "Transaction_Collection": {
      "$ref": "common:Collection",
      "$template": {
        "T": "Transaction"
      }
    },
    "User_Attributes": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "User_Account": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "planId": {
          "type": "integer"
        },
        "status": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "points": {
          "type": "integer"
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "attributes": {
          "$ref": "User_Attributes"
        },
        "date": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "User_Activate": {
      "type": "object",
      "properties": {
        "token": {
          "type": "string"
        }
      },
      "required": ["token"]
    },
    "User_Email": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string"
        },
        "captcha": {
          "type": "string"
        }
      },
      "required": ["email"]
    },
    "User_JWT": {
      "type": "object",
      "properties": {
        "token": {
          "type": "string"
        },
        "expires_in": {
          "type": "string"
        },
        "refresh_token": {
          "type": "string"
        }
      }
    },
    "User_Login": {
      "type": "object",
      "properties": {
        "username": {
          "type": "string"
        },
        "password": {
          "type": "string"
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "User_PasswordReset": {
      "type": "object",
      "properties": {
        "token": {
          "type": "string"
        },
        "newPassword": {
          "type": "string"
        }
      },
      "required": ["token", "newPassword"]
    },
    "User_Provider": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "clientId": {
          "type": "string"
        },
        "redirectUri": {
          "type": "string"
        }
      }
    },
    "User_Refresh": {
      "type": "object",
      "properties": {
        "refresh_token": {
          "type": "string"
        }
      }
    },
    "User_Register": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "password": {
          "type": "string"
        },
        "captcha": {
          "type": "string"
        }
      },
      "required": ["name", "email", "password"]
    }
  }
}
