From 43377fe686d1fad32526177eabfd0533670ceac5 Mon Sep 17 00:00:00 2001 From: RogerLamTd Date: Thu, 30 Nov 2023 20:42:21 +0800 Subject: [PATCH] fixed swagger autogen --- docs/docs.go | 56 +++++++++++++++++++++++++++++++++++++++++++- docs/swagger.json | 56 +++++++++++++++++++++++++++++++++++++++++++- docs/swagger.yaml | 37 ++++++++++++++++++++++++++++- prover/server/api.go | 3 ++- 4 files changed, 148 insertions(+), 4 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index cd322bd2f..6de82f426 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -33,7 +33,6 @@ const docTemplate = `{ "application/json" ], "summary": "Try to accept a block proof assignment", - "operationId": "create-assignment", "parameters": [ { "description": "assignment request body", @@ -61,6 +60,29 @@ const docTemplate = `{ } } }, + "/signedBlocks": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get signed blocks", + "operationId": "get-signed-blocks", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/prover_server.SignedBlock" + } + } + } + } + } + }, "/status": { "get": { "consumes": [ @@ -123,6 +145,12 @@ const docTemplate = `{ "prover_server.ProposeBlockResponse": { "type": "object", "properties": { + "maxBlockID": { + "type": "integer" + }, + "maxProposedIn": { + "type": "integer" + }, "prover": { "type": "string" }, @@ -134,12 +162,35 @@ const docTemplate = `{ } } }, + "prover_server.SignedBlock": { + "type": "object", + "properties": { + "blockHash": { + "type": "string" + }, + "blockID": { + "type": "integer" + }, + "proverAddress": { + "type": "string" + }, + "signature": { + "type": "string" + } + } + }, "prover_server.Status": { "type": "object", "properties": { "currentCapacity": { "type": "integer" }, + "heartBeatSignature": { + "type": "array", + "items": { + "type": "integer" + } + }, "maxExpiry": { "type": "integer" }, @@ -151,6 +202,9 @@ const docTemplate = `{ }, "minSgxTierFee": { "type": "integer" + }, + "prover": { + "type": "string" } } } diff --git a/docs/swagger.json b/docs/swagger.json index e0db39db9..157ede6dd 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -24,7 +24,6 @@ "application/json" ], "summary": "Try to accept a block proof assignment", - "operationId": "create-assignment", "parameters": [ { "description": "assignment request body", @@ -52,6 +51,29 @@ } } }, + "/signedBlocks": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get signed blocks", + "operationId": "get-signed-blocks", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/prover_server.SignedBlock" + } + } + } + } + } + }, "/status": { "get": { "consumes": [ @@ -114,6 +136,12 @@ "prover_server.ProposeBlockResponse": { "type": "object", "properties": { + "maxBlockID": { + "type": "integer" + }, + "maxProposedIn": { + "type": "integer" + }, "prover": { "type": "string" }, @@ -125,12 +153,35 @@ } } }, + "prover_server.SignedBlock": { + "type": "object", + "properties": { + "blockHash": { + "type": "string" + }, + "blockID": { + "type": "integer" + }, + "proverAddress": { + "type": "string" + }, + "signature": { + "type": "string" + } + } + }, "prover_server.Status": { "type": "object", "properties": { "currentCapacity": { "type": "integer" }, + "heartBeatSignature": { + "type": "array", + "items": { + "type": "integer" + } + }, "maxExpiry": { "type": "integer" }, @@ -142,6 +193,9 @@ }, "minSgxTierFee": { "type": "integer" + }, + "prover": { + "type": "string" } } } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 348f3bf08..e6d809428 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -25,6 +25,10 @@ definitions: type: object prover_server.ProposeBlockResponse: properties: + maxBlockID: + type: integer + maxProposedIn: + type: integer prover: type: string signedPayload: @@ -32,10 +36,25 @@ definitions: type: integer type: array type: object + prover_server.SignedBlock: + properties: + blockHash: + type: string + blockID: + type: integer + proverAddress: + type: string + signature: + type: string + type: object prover_server.Status: properties: currentCapacity: type: integer + heartBeatSignature: + items: + type: integer + type: array maxExpiry: type: integer minOptimisticTierFee: @@ -44,6 +63,8 @@ definitions: type: integer minSgxTierFee: type: integer + prover: + type: string type: object info: contact: @@ -61,7 +82,6 @@ paths: post: consumes: - application/json - operationId: create-assignment parameters: - description: assignment request body in: body @@ -81,6 +101,21 @@ paths: schema: type: string summary: Try to accept a block proof assignment + /signedBlocks: + get: + consumes: + - application/json + operationId: get-signed-blocks + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/prover_server.SignedBlock' + type: array + summary: Get signed blocks /status: get: consumes: diff --git a/prover/server/api.go b/prover/server/api.go index f3b9db554..e6b158100 100644 --- a/prover/server/api.go +++ b/prover/server/api.go @@ -218,6 +218,7 @@ func (srv *ProverServer) CreateAssignment(c echo.Context) error { }) } +// SignedBlock represents a signed block. type SignedBlock struct { BlockID uint64 `json:"blockID"` BlockHash string `json:"blockHash"` @@ -231,7 +232,7 @@ type SignedBlock struct { // @ID get-signed-blocks // @Accept json // @Produce json -// @Success 200 {object} []SignedBlocks +// @Success 200 {object} []SignedBlock // @Router /signedBlocks [get] func (srv *ProverServer) GetSignedBlocks(c echo.Context) error { latestBlock, err := srv.rpc.L2.BlockByNumber(c.Request().Context(), nil)