From d8fa7d08b71c9a54f02e88a7475ef299f5b6e875 Mon Sep 17 00:00:00 2001
From: Michal Zander <mzander@syncad.com>
Date: Mon, 3 Mar 2025 14:22:12 +0000
Subject: [PATCH] Fix openapi examples

---
 .../account-balances/get_account_balances.sql |  45 ++++----
 .../get_account_delegations.sql               |   3 +-
 .../account-balances/get_balance_history.sql  |   3 +-
 endpoints/endpoint_schema.sql                 | 108 +++++++++---------
 4 files changed, 76 insertions(+), 83 deletions(-)

diff --git a/endpoints/account-balances/get_account_balances.sql b/endpoints/account-balances/get_account_balances.sql
index 3ed83bd..42c682c 100644
--- a/endpoints/account-balances/get_account_balances.sql
+++ b/endpoints/account-balances/get_account_balances.sql
@@ -156,28 +156,29 @@ CREATE TYPE btracker_endpoints.balances AS (
           application/json:
             schema:
               $ref: '#/components/schemas/btracker_endpoints.balances'
-            example:
-              - hbd_balance: 77246982
-                hive_balance: 29594875
-                vesting_shares: "8172549681941451"
-                vesting_balance_hive: 2720696229
-                post_voting_power_vests: "8172549681941451"
-                delegated_vests: "0"
-                received_vests: "0"
-                curation_rewards: "196115157"
-                posting_rewards: "65916519"
-                hbd_rewards: 0
-                hive_rewards: 0
-                vests_rewards: "0"
-                hive_vesting_rewards: 0
-                hbd_savings: 0
-                hive_savings: 0
-                savings_withdraw_requests: 0
-                vesting_withdraw_rate: "80404818220529"
-                to_withdraw: "8362101094935031"
-                withdrawn: "804048182205290"
-                withdraw_routes: 4
-                delayed_vests: "0"
+            example: {
+              "hbd_balance": 77246982,
+              "hive_balance": 29594875,
+              "vesting_shares": "8172549681941451",
+              "vesting_balance_hive": 2720696229,
+              "post_voting_power_vests": "8172549681941451",
+              "delegated_vests": "0",
+              "received_vests": "0",
+              "curation_rewards": "196115157",
+              "posting_rewards": "65916519",
+              "hbd_rewards": 0,
+              "hive_rewards": 0,
+              "vests_rewards": "0",
+              "hive_vesting_rewards": 0,
+              "hbd_savings": 0,
+              "hive_savings": 0,
+              "savings_withdraw_requests": 0,
+              "vesting_withdraw_rate": "80404818220529",
+              "to_withdraw": "8362101094935031",
+              "withdrawn": "804048182205290",
+              "withdraw_routes": 4,
+              "delayed_vests": "0"
+            }
       '404':
         description: No such account in the database
  */
diff --git a/endpoints/account-balances/get_account_delegations.sql b/endpoints/account-balances/get_account_delegations.sql
index 602467c..d5cb64d 100644
--- a/endpoints/account-balances/get_account_delegations.sql
+++ b/endpoints/account-balances/get_account_delegations.sql
@@ -31,8 +31,7 @@ SET ROLE btracker_owner;
             schema:
               type: string
               x-sql-datatype: JSON
-            example: 
-              - {
+            example: {
                   "outgoing_delegations": [],
                   "incoming_delegations": []
                 }
diff --git a/endpoints/account-balances/get_balance_history.sql b/endpoints/account-balances/get_balance_history.sql
index f0e75a0..45ad345 100644
--- a/endpoints/account-balances/get_balance_history.sql
+++ b/endpoints/account-balances/get_balance_history.sql
@@ -116,8 +116,7 @@ CREATE TYPE btracker_endpoints.balance_history AS (
             schema:
               type: string
               x-sql-datatype: JSON
-            example: 
-              - {
+            example: {
                   "total_operations": 188291,
                   "total_pages": 94146,
                   "operations_result": [
diff --git a/endpoints/endpoint_schema.sql b/endpoints/endpoint_schema.sql
index abcaed9..88bb3f4 100644
--- a/endpoints/endpoint_schema.sql
+++ b/endpoints/endpoint_schema.sql
@@ -216,31 +216,29 @@ declare
                 "schema": {
                   "$ref": "#/components/schemas/btracker_endpoints.balances"
                 },
-                "example": [
-                  {
-                    "hbd_balance": 77246982,
-                    "hive_balance": 29594875,
-                    "vesting_shares": "8172549681941451",
-                    "vesting_balance_hive": 2720696229,
-                    "post_voting_power_vests": "8172549681941451",
-                    "delegated_vests": "0",
-                    "received_vests": "0",
-                    "curation_rewards": "196115157",
-                    "posting_rewards": "65916519",
-                    "hbd_rewards": 0,
-                    "hive_rewards": 0,
-                    "vests_rewards": "0",
-                    "hive_vesting_rewards": 0,
-                    "hbd_savings": 0,
-                    "hive_savings": 0,
-                    "savings_withdraw_requests": 0,
-                    "vesting_withdraw_rate": "80404818220529",
-                    "to_withdraw": "8362101094935031",
-                    "withdrawn": "804048182205290",
-                    "withdraw_routes": 4,
-                    "delayed_vests": "0"
-                  }
-                ]
+                "example": {
+                  "hbd_balance": 77246982,
+                  "hive_balance": 29594875,
+                  "vesting_shares": "8172549681941451",
+                  "vesting_balance_hive": 2720696229,
+                  "post_voting_power_vests": "8172549681941451",
+                  "delegated_vests": "0",
+                  "received_vests": "0",
+                  "curation_rewards": "196115157",
+                  "posting_rewards": "65916519",
+                  "hbd_rewards": 0,
+                  "hive_rewards": 0,
+                  "vests_rewards": "0",
+                  "hive_vesting_rewards": 0,
+                  "hbd_savings": 0,
+                  "hive_savings": 0,
+                  "savings_withdraw_requests": 0,
+                  "vesting_withdraw_rate": "80404818220529",
+                  "to_withdraw": "8362101094935031",
+                  "withdrawn": "804048182205290",
+                  "withdraw_routes": 4,
+                  "delayed_vests": "0"
+                }
               }
             }
           },
@@ -337,32 +335,30 @@ declare
                   "type": "string",
                   "x-sql-datatype": "JSON"
                 },
-                "example": [
-                  {
-                    "total_operations": 188291,
-                    "total_pages": 94146,
-                    "operations_result": [
-                      {
-                        "block_num": 4999992,
-                        "operation_id": "21474802120262208",
-                        "op_type_id": 64,
-                        "balance": "8172549681941451",
-                        "prev_balance": "8172546678091286",
-                        "balance_change": "3003850165",
-                        "timestamp": "2016-09-15T19:46:57"
-                      },
-                      {
-                        "block_num": 4999959,
-                        "operation_id": "21474660386343488",
-                        "op_type_id": 64,
-                        "balance": "8172546678091286",
-                        "prev_balance": "8172543674223181",
-                        "balance_change": "3003868105",
-                        "timestamp": "2016-09-15T19:45:12"
-                      }
-                    ]
-                  }
-                ]
+                "example": {
+                  "total_operations": 188291,
+                  "total_pages": 94146,
+                  "operations_result": [
+                    {
+                      "block_num": 4999992,
+                      "operation_id": "21474802120262208",
+                      "op_type_id": 64,
+                      "balance": "8172549681941451",
+                      "prev_balance": "8172546678091286",
+                      "balance_change": "3003850165",
+                      "timestamp": "2016-09-15T19:46:57"
+                    },
+                    {
+                      "block_num": 4999959,
+                      "operation_id": "21474660386343488",
+                      "op_type_id": 64,
+                      "balance": "8172546678091286",
+                      "prev_balance": "8172543674223181",
+                      "balance_change": "3003868105",
+                      "timestamp": "2016-09-15T19:45:12"
+                    }
+                  ]
+                }
               }
             }
           },
@@ -495,12 +491,10 @@ declare
                   "type": "string",
                   "x-sql-datatype": "JSON"
                 },
-                "example": [
-                  {
-                    "outgoing_delegations": [],
-                    "incoming_delegations": []
-                  }
-                ]
+                "example": {
+                  "outgoing_delegations": [],
+                  "incoming_delegations": []
+                }
               }
             }
           },
-- 
GitLab