{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Eventuate account manage example account-view service API",
    "license": {
      "name": "MIT"
    }
  },
  "servers": [
    {
      "url": "http://light-eventuate.swagger.io/v1"
    }
  ],
  "paths": {
    "/accounts": {
      "get": {
        "summary": "Return list of account object with customer Id",
        "operationId": "getAccountsByCustomerId",
        "tags": [
          "accounts"
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "query",
            "description": "customerId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "account_auth": [
              "read:account",
              "write:account"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAccountResponse"
                }
              }
            }
          },
          "201": {
            "description": "Null response"
          },
          "default": {
            "description": "unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/accounts/{accountId}": {
      "get": {
        "summary": "get an account by accountId",
        "operationId": "getAccountByAccpuntId",
        "tags": [
          "accounts"
        ],
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "description": "The id of the account",
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "account_auth": [
              "read:account",
              "write:account"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Expected response to a valid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAccountResponse"
                }
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/accounts/{accountId}/history": {
      "get": {
        "summary": "get Transactions History",
        "operationId": "getAccountTransactionHistory",
        "tags": [
          "accounts"
        ],
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "description": "accountId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "account_auth": [
              "read:account"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "List of accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AccountTransactionInfo"
                  }
                }
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "account_auth": {
        "type": "oauth2",
        "description": "This API uses OAuth 2 with the client credential grant flow.",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://localhost:6882/token",
            "scopes": {
              "write:account": "modify account",
              "read:account": "read account"
            }
          }
        }
      }
    },
    "schemas": {
      "AccountTransactionInfo": {
        "required": [
          "fromAccountId",
          "toAccountId"
        ],
        "properties": {
          "fromAccountId": {
            "type": "string"
          },
          "toAccountId": {
            "type": "string"
          },
          "transactionId": {
            "type": "string"
          },
          "amount": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "GetAccountResponse": {
        "required": [
          "accountId"
        ],
        "properties": {
          "accountId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "balance": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "CreateTodoRequest": {
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "type": "string"
          },
          "completed": {
            "type": "boolean"
          },
          "executionOrder": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "Error": {
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}