docs: add OpenAPI docs

This commit is contained in:
Nex 2020-12-05 11:11:36 +08:00
parent a6d6428393
commit b256c1f80b
7 changed files with 579 additions and 2 deletions

View File

@ -0,0 +1,46 @@
{
"swagger": "2.0",
"info": {
"title": "bdware/bdledger/api/common.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@ -0,0 +1,46 @@
{
"swagger": "2.0",
"info": {
"title": "bdware/bdledger/api/error_details.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@ -0,0 +1,111 @@
{
"swagger": "2.0",
"info": {
"title": "bdware/bdledger/api/ledger.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"apiCreateLedgerResponse": {
"type": "object",
"properties": {
"ok": {
"type": "boolean",
"format": "boolean"
}
}
},
"apiGetLedgersResponse": {
"type": "object",
"properties": {
"ledgers": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"apiSendTransactionRequestTransaction": {
"type": "object",
"properties": {
"type": {
"$ref": "#/definitions/apiTransactionType"
},
"from": {
"type": "string",
"format": "byte"
},
"nonce": {
"type": "string",
"format": "uint64"
},
"to": {
"type": "string",
"format": "byte"
},
"data": {
"type": "string",
"format": "byte"
}
}
},
"apiSendTransactionResponse": {
"type": "object",
"properties": {
"hash": {
"type": "string",
"format": "byte"
}
}
},
"apiTransactionType": {
"type": "string",
"enum": [
"RECORD",
"MESSAGE",
"CONTRACT_CREATION",
"CONTRACT_INVOCATION",
"CONTRACT_STATUS"
],
"default": "RECORD",
"title": "事务类型"
},
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@ -0,0 +1,54 @@
{
"swagger": "2.0",
"info": {
"title": "bdware/bdledger/api/node.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"apiClientVersionResponse": {
"type": "object",
"properties": {
"version": {
"type": "string"
}
}
},
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@ -0,0 +1,310 @@
{
"swagger": "2.0",
"info": {
"title": "bdware/bdledger/api/query.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"apiBlock": {
"type": "object",
"properties": {
"hash": {
"type": "string",
"format": "byte"
},
"creator": {
"type": "string",
"format": "byte"
},
"nonce": {
"type": "string",
"format": "uint64"
},
"parentHashes": {
"type": "array",
"items": {
"type": "string",
"format": "byte"
}
},
"witnesses": {
"type": "array",
"items": {
"type": "string",
"format": "byte"
}
},
"timestamp": {
"type": "string",
"format": "int64"
},
"size": {
"type": "string",
"format": "uint64"
},
"transactionCount": {
"type": "integer",
"format": "int64"
},
"transactionsRoot": {
"type": "string",
"format": "byte"
},
"transactions": {
"type": "array",
"items": {
"$ref": "#/definitions/bdledgerapiTransaction"
}
},
"transactionHashes": {
"type": "array",
"items": {
"type": "string",
"format": "byte"
}
}
}
},
"apiBlockFilter": {
"type": "object",
"properties": {
"hash": {
"type": "string",
"format": "byte"
},
"timestamp": {
"type": "string",
"format": "int64"
}
}
},
"apiCountBlocksResponse": {
"type": "object",
"properties": {
"count": {
"type": "string",
"format": "uint64"
},
"startTimestamp": {
"type": "string",
"format": "int64"
},
"endTimestamp": {
"type": "string",
"format": "int64"
}
}
},
"apiCountTransactionsResponse": {
"type": "object",
"properties": {
"count": {
"type": "string",
"format": "uint64"
},
"startTimestamp": {
"type": "string",
"format": "int64"
},
"endTimestamp": {
"type": "string",
"format": "int64"
}
}
},
"apiGetBlockByHashResponse": {
"type": "object",
"properties": {
"block": {
"$ref": "#/definitions/apiBlock"
}
}
},
"apiGetBlocksResponse": {
"type": "object",
"properties": {
"blocks": {
"type": "array",
"items": {
"$ref": "#/definitions/apiBlock"
}
},
"startTimestamp": {
"type": "string",
"format": "int64"
},
"endTimestamp": {
"type": "string",
"format": "int64"
}
}
},
"apiGetTransactionByBlockHashAndIndexResponse": {
"type": "object",
"properties": {
"transaction": {
"$ref": "#/definitions/bdledgerapiTransaction"
}
}
},
"apiGetTransactionByHashResponse": {
"type": "object",
"properties": {
"transaction": {
"$ref": "#/definitions/bdledgerapiTransaction"
}
}
},
"apiGetTransactionsResponse": {
"type": "object",
"properties": {
"transactions": {
"type": "array",
"items": {
"$ref": "#/definitions/bdledgerapiTransaction"
}
},
"startTimestamp": {
"type": "string",
"format": "int64"
},
"endTimestamp": {
"type": "string",
"format": "int64"
}
}
},
"apiIncludeTransactions": {
"type": "string",
"enum": [
"NONE",
"HASH",
"FULL"
],
"default": "NONE"
},
"apiTransactionFilter": {
"type": "object",
"properties": {
"hash": {
"type": "string",
"format": "byte"
},
"from": {
"type": "string",
"format": "byte"
},
"to": {
"type": "string",
"format": "byte"
},
"timestamp": {
"type": "string",
"format": "byte"
}
},
"title": "repeated Transaction/BlockFilters are combined by \"\u0026\u0026\"(and) operator;"
},
"apiTransactionType": {
"type": "string",
"enum": [
"RECORD",
"MESSAGE",
"CONTRACT_CREATION",
"CONTRACT_INVOCATION",
"CONTRACT_STATUS"
],
"default": "RECORD",
"title": "事务类型"
},
"bdledgerapiTransaction": {
"type": "object",
"properties": {
"blockHash": {
"type": "string",
"format": "byte"
},
"blockTimestamp": {
"type": "string",
"format": "int64"
},
"index": {
"type": "integer",
"format": "int64"
},
"hash": {
"type": "string",
"format": "byte"
},
"type": {
"$ref": "#/definitions/apiTransactionType"
},
"from": {
"type": "string",
"format": "byte"
},
"nonce": {
"type": "string",
"format": "uint64"
},
"to": {
"type": "string",
"format": "byte"
},
"data": {
"type": "string",
"format": "byte"
},
"v": {
"type": "string",
"format": "byte"
},
"r": {
"type": "string",
"format": "byte"
},
"s": {
"type": "string",
"format": "byte"
}
}
},
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@ -32,7 +32,12 @@ for %%A in (%*) do (
if not exist !out! mkdir !out!
echo Generating Go HTTP code
!cmd! ^
--grpc-gateway_out=grpc_api_configuration=bdware/bdledger/api/grpc-gateway.yml,logtostderr=true:!out! ^
--grpc-gateway_out !out! ^
--grpc-gateway_opt grpc_api_configuration=bdware/bdledger/api/grpc-gateway.yml ^
--grpc-gateway_opt logtostderr=true ^
--openapiv2_out ..\..\docs\openapiv2 ^
--openapiv2_out grpc_api_configuration=bdware/bdledger/api/grpc-gateway.yml ^
--openapiv2_opt logtostderr=true ^
%pb_files%
)
if "%%A"=="nodejs" (

View File

@ -64,7 +64,12 @@ do
fi
echo "Generating Go HTTP code"
$cmd \
--grpc-gateway_out=grpc_api_configuration=bdware/bdledger/api/grpc-gateway.yml,logtostderr=true:$out \
--grpc-gateway_out $out \
--grpc-gateway_opt grpc_api_configuration=bdware/bdledger/api/grpc-gateway.yml \
--grpc-gateway_opt logtostderr=true \
--openapiv2_out ../../docs/openapiv2 \
--openapiv2_out grpc_api_configuration=bdware/bdledger/api/grpc-gateway.yml \
--openapiv2_opt logtostderr=true \
$pb_files \
$async_tag
fi