{ "schemes": [ "http", "https" ], "swagger": "2.0", "info": { "description": "RESTful API for managing assets on Hyperledger Fabric blockchain", "title": "Hyperledger Fabric Asset Transfer API", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "API Support", "url": "http://www.swagger.io/support", "email": "support@swagger.io" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0" }, "host": "localhost:8888", "basePath": "/api/v1", "paths": { "/assets": { "get": { "description": "Retrieve all assets from the blockchain ledger", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "assets" ], "summary": "Get all assets", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/models.Response" }, { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/definitions/models.Asset" } } } } ] } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } }, "post": { "description": "Create a new asset on the blockchain ledger with auto-generated UUID if ID not provided", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "assets" ], "summary": "Create a new asset", "parameters": [ { "description": "Asset data (ID is optional and will be auto-generated)", "name": "asset", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.CreateAssetRequest" } } ], "responses": { "201": { "description": "Created", "schema": { "allOf": [ { "$ref": "#/definitions/models.Response" }, { "type": "object", "properties": { "data": { "type": "object", "properties": { "asset": { "$ref": "#/definitions/models.Asset" }, "transactionId": { "type": "string" } } } } } ] } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/assets/{id}": { "get": { "description": "Retrieve a specific asset by its ID from the blockchain ledger", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "assets" ], "summary": "Get asset by ID", "parameters": [ { "type": "string", "description": "Asset ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/models.Response" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/models.Asset" } } } ] } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } }, "put": { "description": "Update an existing asset's information on the blockchain", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "assets" ], "summary": "Update an existing asset", "parameters": [ { "type": "string", "description": "Asset ID", "name": "id", "in": "path", "required": true }, { "description": "Updated asset data", "name": "asset", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.CreateAssetRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/models.Response" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/models.Asset" } } } ] } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/assets/{id}/transfer": { "put": { "description": "Transfer ownership of an asset to a new owner", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "assets" ], "summary": "Transfer asset ownership", "parameters": [ { "type": "string", "description": "Asset ID", "name": "id", "in": "path", "required": true }, { "description": "Transfer request", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.TransferAssetRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.Response" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/blockchain/height": { "get": { "description": "Get the current block height of the blockchain", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "blockchain" ], "summary": "Get block height", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/models.Response" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/models.BlockHeightResponse" } } } ] } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/blockchain/info": { "get": { "description": "Get detailed information about the blockchain including block height", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "blockchain" ], "summary": "Get chain information", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/models.Response" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/models.ChainInfoResponse" } } } ] } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/health": { "get": { "description": "Check the health status of the API", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "health" ], "summary": "Health check", "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.HealthResponse" } } } } }, "/ledger/init": { "post": { "description": "Initialize the blockchain ledger with a set of assets", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "ledger" ], "summary": "Initialize ledger", "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.Response" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/transactions/{txid}": { "get": { "description": "Retrieve detailed information about a specific transaction by its ID", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "transactions" ], "summary": "Get transaction details by ID", "parameters": [ { "type": "string", "description": "Transaction ID", "name": "txid", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/models.Response" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/models.TransactionDetail" } } } ] } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } } }, "definitions": { "models.Asset": { "type": "object", "properties": { "ID": { "type": "string", "example": "asset123" }, "appraisedValue": { "type": "string", "example": "2000" }, "color": { "type": "string", "example": "red" }, "owner": { "type": "string", "example": "Alice" }, "size": { "type": "string", "example": "10" } } }, "models.BlockHeightResponse": { "type": "object", "properties": { "height": { "type": "integer", "example": 12345 } } }, "models.ChainInfoResponse": { "type": "object", "properties": { "blockHash": { "type": "string", "example": "a1b2c3d4e5f6..." }, "chainName": { "type": "string", "example": "mychannel" }, "height": { "type": "integer", "example": 12345 } } }, "models.CreateAssetRequest": { "type": "object", "properties": { "appraisedValue": { "type": "string", "example": "2000" }, "color": { "type": "string", "example": "red" }, "id": { "description": "Optional - will be auto-generated if not provided", "type": "string", "example": "asset123" }, "owner": { "type": "string", "example": "Alice" }, "size": { "type": "string", "example": "10" } } }, "models.ErrorResponse": { "type": "object", "properties": { "message": { "type": "string" }, "success": { "type": "boolean" } } }, "models.HealthResponse": { "type": "object", "properties": { "status": { "type": "string", "example": "healthy" } } }, "models.Response": { "type": "object", "properties": { "data": {}, "message": { "type": "string" }, "success": { "type": "boolean" } } }, "models.TransactionDetail": { "type": "object", "properties": { "arguments": { "type": "array", "items": { "type": "string" }, "example": [ "asset1", "red", "10", "Alice", "1000" ] }, "blockHash": { "type": "string", "example": "a1b2c3d4e5f6..." }, "blockNumber": { "type": "integer", "example": 123 }, "chaincodeId": { "type": "string", "example": "basic" }, "channelId": { "type": "string", "example": "mychannel" }, "creatorId": { "type": "string", "example": "User1@org1.example.com" }, "creatorMspId": { "type": "string", "example": "Org1MSP" }, "endorsers": { "type": "array", "items": { "type": "string" }, "example": [ "peer0.org1.example.com", "peer0.org2.example.com" ] }, "function": { "type": "string", "example": "CreateAsset" }, "rawTransaction": { "type": "object", "additionalProperties": true }, "response": { "$ref": "#/definitions/models.TransactionResponse" }, "timestamp": { "type": "string", "example": "2024-01-15T10:30:00Z" }, "transactionId": { "type": "string", "example": "f973e40540e3b629b7dffd0b91b87aa3474bc31de89e11b01f749bbc5e6d5add" }, "validationCode": { "type": "string", "example": "VALID" } } }, "models.TransactionResponse": { "type": "object", "properties": { "message": { "type": "string", "example": "Transaction completed successfully" }, "payload": { "type": "string", "example": "" }, "status": { "type": "integer", "example": 200 } } }, "models.TransferAssetRequest": { "type": "object", "properties": { "newOwner": { "type": "string", "example": "Bob" } } } } }