From 93f82a5e194d5fcc49edab89439de4f658701f13 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 30 Sep 2019 11:28:19 -0700 Subject: [PATCH] Merge PR #5088: Swagger Auto Gen - Gov Updates --- .circleci/config.yml | 8 +- Makefile | 6 +- client/rest/docs/docs.go | 466 +++++++++++++++++++++++++++++----- client/rest/docs/swagger.json | 454 ++++++++++++++++++++++++++++----- client/rest/docs/swagger.yaml | 339 ++++++++++++++++++++----- contrib/devtools/Makefile | 4 +- x/gov/client/rest/query.go | 28 +- x/gov/client/rest/swagger.go | 75 ++++++ x/gov/client/rest/tx.go | 14 +- 9 files changed, 1173 insertions(+), 221 deletions(-) create mode 100644 x/gov/client/rest/swagger.go diff --git a/.circleci/config.yml b/.circleci/config.yml index 4cf730c697a6..5375e14dda29 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -162,18 +162,18 @@ jobs: name: upload command: bash <(curl -s https://codecov.io/bash) -f coverage.txt - update-swagger-docs: + verify-swagger-docs: executor: golang steps: - make: - target: update-swagger-docs - description: "Check if Swagger docs are up-to-date" + target: verify-swagger-docs + description: "Verify Swagger docs are up-to-date" workflows: version: 2 test-suite: jobs: - - update-swagger-docs: + - verify-swagger-docs: requires: - setup-dependencies - setup-dependencies: diff --git a/Makefile b/Makefile index 1cf88be98673..cf31c50586f8 100644 --- a/Makefile +++ b/Makefile @@ -24,9 +24,13 @@ build: go.sum .PHONY: build update-swagger-docs: swag - @scripts/swag.sh $(BINDIR)/swag + $(BINDIR)/swag init -g client/rest/root.go --output client/rest/docs .PHONY: update-swagger-docs +verify-swagger-docs: swag + @scripts/swag.sh $(BINDIR)/swag +.PHONY: verify-swagger-docs + mocks: $(MOCKS_DIR) mockgen -source=x/auth/types/account_retriever.go -package mocks -destination tests/mocks/account_retriever.go .PHONY: mocks diff --git a/client/rest/docs/docs.go b/client/rest/docs/docs.go index 45d5cd10e25a..d68d793f2362 100644 --- a/client/rest/docs/docs.go +++ b/client/rest/docs/docs.go @@ -1,12 +1,13 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2019-09-18 10:05:09.781608 -0400 EDT m=+0.358197733 +// 2019-09-30 14:20:00.263784 -0400 EDT m=+0.392590706 package docs import ( "bytes" "encoding/json" + "strings" "github.com/alecthomas/template" "github.com/swaggo/swag" @@ -27,7 +28,7 @@ var doc = `{ "paths": { "/gov/parameters/{type}": { "get": { - "description": "Query either (deposit | tallying | voting) parameters of the governance module.", + "description": "Query either (deposit | tallying | voting) parameters of the governance module", "produces": [ "application/json" ], @@ -54,21 +55,18 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", "$ref": "#/definitions/rest.ResponseWithHeight" } }, "400": { "description": "Returned if the request doesn't have a valid height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "404": { "description": "Returned if the type of parameter doesn't exist", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -115,28 +113,25 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryProposals" } }, "400": { "description": "Returned if the request doesn't have a valid parameters", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } } }, "post": { - "description": "Generate a proposal transaction that is ready for signing.", + "description": "Generate a proposal transaction that is ready for signing", "consumes": [ "application/json" ], @@ -149,8 +144,8 @@ var doc = `{ "summary": "Generate an unsigned proposal transaction", "parameters": [ { - "description": "The data required to construct a proposal message. The proposal_type can be text | parameter_change", - "name": "tx", + "description": "The data required to construct a proposal message, the proposal_type can be (text | parameter_change)", + "name": "body", "in": "body", "required": true, "schema": { @@ -163,14 +158,12 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/types.StdTx" + "$ref": "#/definitions/rest.postProposal" } }, "400": { "description": "Returned if the request is invalid", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -206,21 +199,18 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryProposal" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -229,7 +219,7 @@ var doc = `{ }, "/gov/proposals/{proposalID}/deposits": { "get": { - "description": "Query an individual governance proposal's deposits.\nNOTE: In order to query deposits for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history.", + "description": "Query an individual governance proposal's deposits.\nNOTE: In order to query deposits for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history", "produces": [ "application/json" ], @@ -256,21 +246,18 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryDeposits" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -298,7 +285,7 @@ var doc = `{ }, { "description": "The data required to construct a deposit message", - "name": "tx", + "name": "body", "in": "body", "required": true, "schema": { @@ -311,14 +298,12 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/types.StdTx" + "$ref": "#/definitions/rest.postDeposit" } }, "400": { "description": "Returned if the request is invalid", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -327,7 +312,7 @@ var doc = `{ }, "/gov/proposals/{proposalID}/deposits/{depositor}": { "get": { - "description": "Query an individual governance proposal's deposits.\nNOTE: In order to query a deposit for a passed proposal, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history.", + "description": "Query an individual governance proposal's deposits.\nNOTE: In order to query a deposit for a passed proposal, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history", "produces": [ "application/json" ], @@ -361,28 +346,24 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryDeposit" } }, "400": { "description": "Returned if the request doesn't have a valid proposalID or depositor", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "404": { "description": "Returned if the proposal is not found", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -418,21 +399,18 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryProposer" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -468,21 +446,18 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryTally" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -491,7 +466,7 @@ var doc = `{ }, "/gov/proposals/{proposalID}/votes": { "get": { - "description": "Query an individual governance proposal's votes.\nNOTE: In order to query deposits for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history.", + "description": "Query an individual governance proposal's votes.\nNOTE: In order to query deposits for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history", "produces": [ "application/json" ], @@ -518,21 +493,18 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryVotesOnProposal" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -560,7 +532,7 @@ var doc = `{ }, { "description": "The data required to construct a vote message", - "name": "tx", + "name": "body", "in": "body", "required": true, "schema": { @@ -573,14 +545,12 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/types.StdTx" + "$ref": "#/definitions/rest.postVote" } }, "400": { "description": "Returned if the request is invalid", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -589,7 +559,7 @@ var doc = `{ }, "/gov/proposals/{proposalID}/votes/{voter}": { "get": { - "description": "Query an individual governance proposal's vote.\nNOTE: In order to query votes for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history.", + "description": "Query an individual governance proposal's vote.\nNOTE: In order to query votes for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history", "produces": [ "application/json" ], @@ -623,28 +593,24 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryVote" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or voter address", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "404": { "description": "Returned if the proposal is not found", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -680,21 +646,18 @@ var doc = `{ "200": { "description": "OK", "schema": { - "type": "object", "$ref": "#/definitions/types.TxResponse" } }, "400": { "description": "Returned if the request is invalid.", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the transaction cannot be decoded.", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -703,6 +666,27 @@ var doc = `{ } }, "definitions": { + "auth.StdFee": { + "type": "object", + "properties": { + "amount": { + "type": "string" + }, + "gas": { + "type": "integer" + } + } + }, + "auth.StdSignature": { + "type": "object", + "properties": { + "signature": { + "type": "string", + "format": "base64", + "example": "U3dhZ2dlciByb2Nrcw==" + } + } + }, "rest.BaseReq": { "type": "object", "properties": { @@ -835,6 +819,178 @@ var doc = `{ } } }, + "rest.postDeposit": { + "type": "object", + "properties": { + "fee": { + "type": "object", + "$ref": "#/definitions/auth.StdFee" + }, + "memo": { + "type": "string" + }, + "msg": { + "type": "array", + "items": { + "$ref": "#/definitions/types.MsgDeposit" + } + }, + "signatures": { + "type": "array", + "items": { + "$ref": "#/definitions/auth.StdSignature" + } + } + } + }, + "rest.postProposal": { + "type": "object", + "properties": { + "fee": { + "type": "object", + "$ref": "#/definitions/auth.StdFee" + }, + "memo": { + "type": "string" + }, + "msg": { + "type": "array", + "items": { + "$ref": "#/definitions/types.MsgSubmitProposal" + } + }, + "signatures": { + "type": "array", + "items": { + "$ref": "#/definitions/auth.StdSignature" + } + } + } + }, + "rest.postVote": { + "type": "object", + "properties": { + "fee": { + "type": "object", + "$ref": "#/definitions/auth.StdFee" + }, + "memo": { + "type": "string" + }, + "msg": { + "type": "array", + "items": { + "$ref": "#/definitions/types.MsgVote" + } + }, + "signatures": { + "type": "array", + "items": { + "$ref": "#/definitions/auth.StdSignature" + } + } + } + }, + "rest.queryDeposit": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.Deposit" + } + } + }, + "rest.queryDeposits": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Deposit" + } + } + } + }, + "rest.queryProposal": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.Proposal" + } + } + }, + "rest.queryProposals": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Proposal" + } + } + } + }, + "rest.queryProposer": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/utils.Proposer" + } + } + }, + "rest.queryTally": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.TallyResult" + } + } + }, + "rest.queryVote": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.Vote" + } + } + }, + "rest.queryVotesOnProposal": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.Votes" + } + } + }, "types.ABCIMessageLog": { "type": "object", "properties": { @@ -887,6 +1043,115 @@ var doc = `{ } } }, + "types.Content": { + "type": "object" + }, + "types.Deposit": { + "type": "object", + "properties": { + "amount": { + "description": "Deposit amount", + "type": "string" + }, + "depositor": { + "description": "Address of the depositor", + "type": "string" + }, + "proposal_id": { + "description": "proposalID of the proposal", + "type": "integer" + } + } + }, + "types.MsgDeposit": { + "type": "object", + "properties": { + "amount": { + "description": "Coins to add to the proposal's deposit", + "type": "string" + }, + "depositor": { + "description": "Address of the depositor", + "type": "string" + }, + "proposal_id": { + "description": "ID of the proposal", + "type": "integer" + } + } + }, + "types.MsgSubmitProposal": { + "type": "object", + "properties": { + "content": { + "type": "object", + "$ref": "#/definitions/types.Content" + }, + "initial_deposit": { + "description": "Initial deposit paid by sender. Must be strictly positive", + "type": "string" + }, + "proposer": { + "description": "Address of the proposer", + "type": "string" + } + } + }, + "types.MsgVote": { + "type": "object", + "properties": { + "option": { + "description": "option from OptionSet chosen by the voter", + "type": "integer" + }, + "proposal_id": { + "description": "ID of the proposal", + "type": "integer" + }, + "voter": { + "description": "address of the voter", + "type": "string" + } + } + }, + "types.Proposal": { + "type": "object", + "properties": { + "deposit_end_time": { + "description": "Time that the Proposal would expire if deposit amount isn't met", + "type": "string" + }, + "final_tally_result": { + "description": "Result of Tallys", + "type": "object", + "$ref": "#/definitions/types.TallyResult" + }, + "id": { + "description": "ID of the proposal", + "type": "integer" + }, + "proposal_status": { + "description": "Status of the Proposal {Pending, Active, Passed, Rejected}", + "type": "integer" + }, + "submit_time": { + "description": "Time of the block where TxGovSubmitProposal was included", + "type": "string" + }, + "total_deposit": { + "description": "Current deposit on this proposal. Initial value is set at InitialDeposit", + "type": "string" + }, + "voting_end_time": { + "description": "Time that the VotingPeriod for this proposal will end and votes will be tallied", + "type": "string" + }, + "voting_start_time": { + "description": "Time of the block where MinDeposit was reached. -1 if MinDeposit is not reached", + "type": "string" + } + } + }, "types.StdFee": { "type": "object", "properties": { @@ -960,6 +1225,23 @@ var doc = `{ } } }, + "types.TallyResult": { + "type": "object", + "properties": { + "abstain": { + "type": "string" + }, + "no": { + "type": "string" + }, + "no_with_veto": { + "type": "string" + }, + "yes": { + "type": "string" + } + } + }, "types.Tx": { "type": "object" }, @@ -1010,6 +1292,54 @@ var doc = `{ "type": "string" } } + }, + "types.Vote": { + "type": "object", + "properties": { + "option": { + "description": "option from OptionSet chosen by the voter", + "type": "integer" + }, + "proposal_id": { + "description": "proposalID of the proposal", + "type": "integer" + }, + "voter": { + "description": "address of the voter", + "type": "string" + } + } + }, + "types.Votes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "option": { + "description": "option from OptionSet chosen by the voter", + "type": "integer" + }, + "proposal_id": { + "description": "proposalID of the proposal", + "type": "integer" + }, + "voter": { + "description": "address of the voter", + "type": "string" + } + } + } + }, + "utils.Proposer": { + "type": "object", + "properties": { + "proposal_id": { + "type": "integer" + }, + "proposer": { + "type": "string" + } + } } } }` @@ -1024,13 +1354,23 @@ type swaggerInfo struct { } // SwaggerInfo holds exported Swagger Info so clients can modify it -var SwaggerInfo = swaggerInfo{ Schemes: []string{}} +var SwaggerInfo = swaggerInfo{ + Version: "", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "", + Description: "", +} type s struct{} func (s *s) ReadDoc() string { + sInfo := SwaggerInfo + sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1) + t, err := template.New("swagger_info").Funcs(template.FuncMap{ - "marshal": func(v interface {}) string { + "marshal": func(v interface{}) string { a, _ := json.Marshal(v) return string(a) }, @@ -1040,7 +1380,7 @@ func (s *s) ReadDoc() string { } var tpl bytes.Buffer - if err := t.Execute(&tpl, SwaggerInfo); err != nil { + if err := t.Execute(&tpl, sInfo); err != nil { return doc } diff --git a/client/rest/docs/swagger.json b/client/rest/docs/swagger.json index defa394cde48..dc41b2d771e7 100644 --- a/client/rest/docs/swagger.json +++ b/client/rest/docs/swagger.json @@ -1,18 +1,13 @@ { "swagger": "2.0", "info": { - "description": "{{.Description}}", - "title": "{{.Title}}", "contact": {}, - "license": {}, - "version": "{{.Version}}" + "license": {} }, - "host": "{{.Host}}", - "basePath": "{{.BasePath}}", "paths": { "/gov/parameters/{type}": { "get": { - "description": "Query either (deposit | tallying | voting) parameters of the governance module.", + "description": "Query either (deposit | tallying | voting) parameters of the governance module", "produces": [ "application/json" ], @@ -39,21 +34,18 @@ "200": { "description": "OK", "schema": { - "type": "object", "$ref": "#/definitions/rest.ResponseWithHeight" } }, "400": { "description": "Returned if the request doesn't have a valid height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "404": { "description": "Returned if the type of parameter doesn't exist", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -100,28 +92,25 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryProposals" } }, "400": { "description": "Returned if the request doesn't have a valid parameters", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } } }, "post": { - "description": "Generate a proposal transaction that is ready for signing.", + "description": "Generate a proposal transaction that is ready for signing", "consumes": [ "application/json" ], @@ -134,8 +123,8 @@ "summary": "Generate an unsigned proposal transaction", "parameters": [ { - "description": "The data required to construct a proposal message. The proposal_type can be text | parameter_change", - "name": "tx", + "description": "The data required to construct a proposal message, the proposal_type can be (text | parameter_change)", + "name": "body", "in": "body", "required": true, "schema": { @@ -148,14 +137,12 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/types.StdTx" + "$ref": "#/definitions/rest.postProposal" } }, "400": { "description": "Returned if the request is invalid", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -191,21 +178,18 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryProposal" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -214,7 +198,7 @@ }, "/gov/proposals/{proposalID}/deposits": { "get": { - "description": "Query an individual governance proposal's deposits.\nNOTE: In order to query deposits for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history.", + "description": "Query an individual governance proposal's deposits.\nNOTE: In order to query deposits for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history", "produces": [ "application/json" ], @@ -241,21 +225,18 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryDeposits" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -283,7 +264,7 @@ }, { "description": "The data required to construct a deposit message", - "name": "tx", + "name": "body", "in": "body", "required": true, "schema": { @@ -296,14 +277,12 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/types.StdTx" + "$ref": "#/definitions/rest.postDeposit" } }, "400": { "description": "Returned if the request is invalid", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -312,7 +291,7 @@ }, "/gov/proposals/{proposalID}/deposits/{depositor}": { "get": { - "description": "Query an individual governance proposal's deposits.\nNOTE: In order to query a deposit for a passed proposal, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history.", + "description": "Query an individual governance proposal's deposits.\nNOTE: In order to query a deposit for a passed proposal, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history", "produces": [ "application/json" ], @@ -346,28 +325,24 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryDeposit" } }, "400": { "description": "Returned if the request doesn't have a valid proposalID or depositor", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "404": { "description": "Returned if the proposal is not found", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -403,21 +378,18 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryProposer" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -453,21 +425,18 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryTally" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -476,7 +445,7 @@ }, "/gov/proposals/{proposalID}/votes": { "get": { - "description": "Query an individual governance proposal's votes.\nNOTE: In order to query deposits for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history.", + "description": "Query an individual governance proposal's votes.\nNOTE: In order to query deposits for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history", "produces": [ "application/json" ], @@ -503,21 +472,18 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryVotesOnProposal" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or height", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -545,7 +511,7 @@ }, { "description": "The data required to construct a vote message", - "name": "tx", + "name": "body", "in": "body", "required": true, "schema": { @@ -558,14 +524,12 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/types.StdTx" + "$ref": "#/definitions/rest.postVote" } }, "400": { "description": "Returned if the request is invalid", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -574,7 +538,7 @@ }, "/gov/proposals/{proposalID}/votes/{voter}": { "get": { - "description": "Query an individual governance proposal's vote.\nNOTE: In order to query votes for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history.", + "description": "Query an individual governance proposal's vote.\nNOTE: In order to query votes for passed proposals, the transaction\nrecord must be available otherwise the query will fail. This requires a\nnode that is not pruning transaction history", "produces": [ "application/json" ], @@ -608,28 +572,24 @@ "200": { "description": "OK", "schema": { - "type": "object", - "$ref": "#/definitions/rest.ResponseWithHeight" + "$ref": "#/definitions/rest.queryVote" } }, "400": { "description": "Returned if the request doesn't have a valid proposal ID or voter address", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "404": { "description": "Returned if the proposal is not found", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the store query fails", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -665,21 +625,18 @@ "200": { "description": "OK", "schema": { - "type": "object", "$ref": "#/definitions/types.TxResponse" } }, "400": { "description": "Returned if the request is invalid.", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } }, "500": { "description": "Returned if the transaction cannot be decoded.", "schema": { - "type": "object", "$ref": "#/definitions/rest.ErrorResponse" } } @@ -688,6 +645,27 @@ } }, "definitions": { + "auth.StdFee": { + "type": "object", + "properties": { + "amount": { + "type": "string" + }, + "gas": { + "type": "integer" + } + } + }, + "auth.StdSignature": { + "type": "object", + "properties": { + "signature": { + "type": "string", + "format": "base64", + "example": "U3dhZ2dlciByb2Nrcw==" + } + } + }, "rest.BaseReq": { "type": "object", "properties": { @@ -820,6 +798,178 @@ } } }, + "rest.postDeposit": { + "type": "object", + "properties": { + "fee": { + "type": "object", + "$ref": "#/definitions/auth.StdFee" + }, + "memo": { + "type": "string" + }, + "msg": { + "type": "array", + "items": { + "$ref": "#/definitions/types.MsgDeposit" + } + }, + "signatures": { + "type": "array", + "items": { + "$ref": "#/definitions/auth.StdSignature" + } + } + } + }, + "rest.postProposal": { + "type": "object", + "properties": { + "fee": { + "type": "object", + "$ref": "#/definitions/auth.StdFee" + }, + "memo": { + "type": "string" + }, + "msg": { + "type": "array", + "items": { + "$ref": "#/definitions/types.MsgSubmitProposal" + } + }, + "signatures": { + "type": "array", + "items": { + "$ref": "#/definitions/auth.StdSignature" + } + } + } + }, + "rest.postVote": { + "type": "object", + "properties": { + "fee": { + "type": "object", + "$ref": "#/definitions/auth.StdFee" + }, + "memo": { + "type": "string" + }, + "msg": { + "type": "array", + "items": { + "$ref": "#/definitions/types.MsgVote" + } + }, + "signatures": { + "type": "array", + "items": { + "$ref": "#/definitions/auth.StdSignature" + } + } + } + }, + "rest.queryDeposit": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.Deposit" + } + } + }, + "rest.queryDeposits": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Deposit" + } + } + } + }, + "rest.queryProposal": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.Proposal" + } + } + }, + "rest.queryProposals": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Proposal" + } + } + } + }, + "rest.queryProposer": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/utils.Proposer" + } + } + }, + "rest.queryTally": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.TallyResult" + } + } + }, + "rest.queryVote": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.Vote" + } + } + }, + "rest.queryVotesOnProposal": { + "type": "object", + "properties": { + "height": { + "type": "integer" + }, + "result": { + "type": "object", + "$ref": "#/definitions/types.Votes" + } + } + }, "types.ABCIMessageLog": { "type": "object", "properties": { @@ -872,6 +1022,115 @@ } } }, + "types.Content": { + "type": "object" + }, + "types.Deposit": { + "type": "object", + "properties": { + "amount": { + "description": "Deposit amount", + "type": "string" + }, + "depositor": { + "description": "Address of the depositor", + "type": "string" + }, + "proposal_id": { + "description": "proposalID of the proposal", + "type": "integer" + } + } + }, + "types.MsgDeposit": { + "type": "object", + "properties": { + "amount": { + "description": "Coins to add to the proposal's deposit", + "type": "string" + }, + "depositor": { + "description": "Address of the depositor", + "type": "string" + }, + "proposal_id": { + "description": "ID of the proposal", + "type": "integer" + } + } + }, + "types.MsgSubmitProposal": { + "type": "object", + "properties": { + "content": { + "type": "object", + "$ref": "#/definitions/types.Content" + }, + "initial_deposit": { + "description": "Initial deposit paid by sender. Must be strictly positive", + "type": "string" + }, + "proposer": { + "description": "Address of the proposer", + "type": "string" + } + } + }, + "types.MsgVote": { + "type": "object", + "properties": { + "option": { + "description": "option from OptionSet chosen by the voter", + "type": "integer" + }, + "proposal_id": { + "description": "ID of the proposal", + "type": "integer" + }, + "voter": { + "description": "address of the voter", + "type": "string" + } + } + }, + "types.Proposal": { + "type": "object", + "properties": { + "deposit_end_time": { + "description": "Time that the Proposal would expire if deposit amount isn't met", + "type": "string" + }, + "final_tally_result": { + "description": "Result of Tallys", + "type": "object", + "$ref": "#/definitions/types.TallyResult" + }, + "id": { + "description": "ID of the proposal", + "type": "integer" + }, + "proposal_status": { + "description": "Status of the Proposal {Pending, Active, Passed, Rejected}", + "type": "integer" + }, + "submit_time": { + "description": "Time of the block where TxGovSubmitProposal was included", + "type": "string" + }, + "total_deposit": { + "description": "Current deposit on this proposal. Initial value is set at InitialDeposit", + "type": "string" + }, + "voting_end_time": { + "description": "Time that the VotingPeriod for this proposal will end and votes will be tallied", + "type": "string" + }, + "voting_start_time": { + "description": "Time of the block where MinDeposit was reached. -1 if MinDeposit is not reached", + "type": "string" + } + } + }, "types.StdFee": { "type": "object", "properties": { @@ -945,6 +1204,23 @@ } } }, + "types.TallyResult": { + "type": "object", + "properties": { + "abstain": { + "type": "string" + }, + "no": { + "type": "string" + }, + "no_with_veto": { + "type": "string" + }, + "yes": { + "type": "string" + } + } + }, "types.Tx": { "type": "object" }, @@ -995,6 +1271,54 @@ "type": "string" } } + }, + "types.Vote": { + "type": "object", + "properties": { + "option": { + "description": "option from OptionSet chosen by the voter", + "type": "integer" + }, + "proposal_id": { + "description": "proposalID of the proposal", + "type": "integer" + }, + "voter": { + "description": "address of the voter", + "type": "string" + } + } + }, + "types.Votes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "option": { + "description": "option from OptionSet chosen by the voter", + "type": "integer" + }, + "proposal_id": { + "description": "proposalID of the proposal", + "type": "integer" + }, + "voter": { + "description": "address of the voter", + "type": "string" + } + } + } + }, + "utils.Proposer": { + "type": "object", + "properties": { + "proposal_id": { + "type": "integer" + }, + "proposer": { + "type": "string" + } + } } } } \ No newline at end of file diff --git a/client/rest/docs/swagger.yaml b/client/rest/docs/swagger.yaml index 30fd7a9c8bb0..3a1c4cab1871 100644 --- a/client/rest/docs/swagger.yaml +++ b/client/rest/docs/swagger.yaml @@ -1,5 +1,18 @@ -basePath: '{{.BasePath}}' definitions: + auth.StdFee: + properties: + amount: + type: string + gas: + type: integer + type: object + auth.StdSignature: + properties: + signature: + example: U3dhZ2dlciByb2Nrcw== + format: base64 + type: string + type: object rest.BaseReq: properties: account_number: @@ -90,6 +103,120 @@ definitions: description: address of the voter type: string type: object + rest.postDeposit: + properties: + fee: + $ref: '#/definitions/auth.StdFee' + type: object + memo: + type: string + msg: + items: + $ref: '#/definitions/types.MsgDeposit' + type: array + signatures: + items: + $ref: '#/definitions/auth.StdSignature' + type: array + type: object + rest.postProposal: + properties: + fee: + $ref: '#/definitions/auth.StdFee' + type: object + memo: + type: string + msg: + items: + $ref: '#/definitions/types.MsgSubmitProposal' + type: array + signatures: + items: + $ref: '#/definitions/auth.StdSignature' + type: array + type: object + rest.postVote: + properties: + fee: + $ref: '#/definitions/auth.StdFee' + type: object + memo: + type: string + msg: + items: + $ref: '#/definitions/types.MsgVote' + type: array + signatures: + items: + $ref: '#/definitions/auth.StdSignature' + type: array + type: object + rest.queryDeposit: + properties: + height: + type: integer + result: + $ref: '#/definitions/types.Deposit' + type: object + type: object + rest.queryDeposits: + properties: + height: + type: integer + result: + items: + $ref: '#/definitions/types.Deposit' + type: array + type: object + rest.queryProposal: + properties: + height: + type: integer + result: + $ref: '#/definitions/types.Proposal' + type: object + type: object + rest.queryProposals: + properties: + height: + type: integer + result: + items: + $ref: '#/definitions/types.Proposal' + type: array + type: object + rest.queryProposer: + properties: + height: + type: integer + result: + $ref: '#/definitions/utils.Proposer' + type: object + type: object + rest.queryTally: + properties: + height: + type: integer + result: + $ref: '#/definitions/types.TallyResult' + type: object + type: object + rest.queryVote: + properties: + height: + type: integer + result: + $ref: '#/definitions/types.Vote' + type: object + type: object + rest.queryVotesOnProposal: + properties: + height: + type: integer + result: + $ref: '#/definitions/types.Votes' + type: object + type: object types.ABCIMessageLog: properties: events: @@ -129,6 +256,86 @@ definitions: value: type: string type: object + types.Content: + type: object + types.Deposit: + properties: + amount: + description: Deposit amount + type: string + depositor: + description: Address of the depositor + type: string + proposal_id: + description: proposalID of the proposal + type: integer + type: object + types.MsgDeposit: + properties: + amount: + description: Coins to add to the proposal's deposit + type: string + depositor: + description: Address of the depositor + type: string + proposal_id: + description: ID of the proposal + type: integer + type: object + types.MsgSubmitProposal: + properties: + content: + $ref: '#/definitions/types.Content' + type: object + initial_deposit: + description: Initial deposit paid by sender. Must be strictly positive + type: string + proposer: + description: Address of the proposer + type: string + type: object + types.MsgVote: + properties: + option: + description: option from OptionSet chosen by the voter + type: integer + proposal_id: + description: ID of the proposal + type: integer + voter: + description: address of the voter + type: string + type: object + types.Proposal: + properties: + deposit_end_time: + description: Time that the Proposal would expire if deposit amount isn't met + type: string + final_tally_result: + $ref: '#/definitions/types.TallyResult' + description: Result of Tallys + type: object + id: + description: ID of the proposal + type: integer + proposal_status: + description: Status of the Proposal {Pending, Active, Passed, Rejected} + type: integer + submit_time: + description: Time of the block where TxGovSubmitProposal was included + type: string + total_deposit: + description: Current deposit on this proposal. Initial value is set at InitialDeposit + type: string + voting_end_time: + description: Time that the VotingPeriod for this proposal will end and votes + will be tallied + type: string + voting_start_time: + description: Time of the block where MinDeposit was reached. -1 if MinDeposit + is not reached + type: string + type: object types.StdFee: properties: amount: @@ -177,6 +384,17 @@ definitions: type: string type: object type: array + types.TallyResult: + properties: + abstain: + type: string + "no": + type: string + no_with_veto: + type: string + "yes": + type: string + type: object types.Tx: type: object types.TxResponse: @@ -214,18 +432,47 @@ definitions: txhash: type: string type: object -host: '{{.Host}}' + types.Vote: + properties: + option: + description: option from OptionSet chosen by the voter + type: integer + proposal_id: + description: proposalID of the proposal + type: integer + voter: + description: address of the voter + type: string + type: object + types.Votes: + items: + properties: + option: + description: option from OptionSet chosen by the voter + type: integer + proposal_id: + description: proposalID of the proposal + type: integer + voter: + description: address of the voter + type: string + type: object + type: array + utils.Proposer: + properties: + proposal_id: + type: integer + proposer: + type: string + type: object info: contact: {} - description: '{{.Description}}' license: {} - title: '{{.Title}}' - version: '{{.Version}}' paths: /gov/parameters/{type}: get: description: Query either (deposit | tallying | voting) parameters of the governance - module. + module parameters: - description: Type of param (deposit | tallying | voting) in: path @@ -243,17 +490,14 @@ paths: description: OK schema: $ref: '#/definitions/rest.ResponseWithHeight' - type: object "400": description: Returned if the request doesn't have a valid height schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "404": description: Returned if the type of parameter doesn't exist schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Query governance parameters tags: - governance @@ -286,30 +530,27 @@ paths: "200": description: OK schema: - $ref: '#/definitions/rest.ResponseWithHeight' - type: object + $ref: '#/definitions/rest.queryProposals' "400": description: Returned if the request doesn't have a valid parameters schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "500": description: Returned if the store query fails schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Query for the list of governance proposals tags: - governance post: consumes: - application/json - description: Generate a proposal transaction that is ready for signing. + description: Generate a proposal transaction that is ready for signing parameters: - - description: The data required to construct a proposal message. The proposal_type - can be text | parameter_change + - description: The data required to construct a proposal message, the proposal_type + can be (text | parameter_change) in: body - name: tx + name: body required: true schema: $ref: '#/definitions/rest.PostProposalReq' @@ -320,13 +561,11 @@ paths: "200": description: OK schema: - $ref: '#/definitions/types.StdTx' - type: object + $ref: '#/definitions/rest.postProposal' "400": description: Returned if the request is invalid schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Generate an unsigned proposal transaction tags: - governance @@ -349,19 +588,16 @@ paths: "200": description: OK schema: - $ref: '#/definitions/rest.ResponseWithHeight' - type: object + $ref: '#/definitions/rest.queryProposal' "400": description: Returned if the request doesn't have a valid proposal ID or height schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "500": description: Returned if the store query fails schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Query a governance proposal by ID tags: - governance @@ -371,7 +607,7 @@ paths: Query an individual governance proposal's deposits. NOTE: In order to query deposits for passed proposals, the transaction record must be available otherwise the query will fail. This requires a - node that is not pruning transaction history. + node that is not pruning transaction history parameters: - description: The ID of the governance proposal in: path @@ -388,19 +624,16 @@ paths: "200": description: OK schema: - $ref: '#/definitions/rest.ResponseWithHeight' - type: object + $ref: '#/definitions/rest.queryDeposits' "400": description: Returned if the request doesn't have a valid proposal ID or height schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "500": description: Returned if the store query fails schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Query a governance proposal's deposits tags: - governance @@ -416,7 +649,7 @@ paths: type: integer - description: The data required to construct a deposit message in: body - name: tx + name: body required: true schema: $ref: '#/definitions/rest.DepositReq' @@ -427,13 +660,11 @@ paths: "200": description: OK schema: - $ref: '#/definitions/types.StdTx' - type: object + $ref: '#/definitions/rest.postDeposit' "400": description: Returned if the request is invalid schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Generate an unsigned deposit transaction tags: - governance @@ -443,7 +674,7 @@ paths: Query an individual governance proposal's deposits. NOTE: In order to query a deposit for a passed proposal, the transaction record must be available otherwise the query will fail. This requires a - node that is not pruning transaction history. + node that is not pruning transaction history parameters: - description: The ID of the governance proposal in: path @@ -465,24 +696,20 @@ paths: "200": description: OK schema: - $ref: '#/definitions/rest.ResponseWithHeight' - type: object + $ref: '#/definitions/rest.queryDeposit' "400": description: Returned if the request doesn't have a valid proposalID or depositor schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "404": description: Returned if the proposal is not found schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "500": description: Returned if the store query fails schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Query a governance proposal's individual deposit tags: - governance @@ -505,19 +732,16 @@ paths: "200": description: OK schema: - $ref: '#/definitions/rest.ResponseWithHeight' - type: object + $ref: '#/definitions/rest.queryProposer' "400": description: Returned if the request doesn't have a valid proposal ID or height schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "500": description: Returned if the store query fails schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Query a governance proposal's proposer tags: - governance @@ -540,19 +764,16 @@ paths: "200": description: OK schema: - $ref: '#/definitions/rest.ResponseWithHeight' - type: object + $ref: '#/definitions/rest.queryTally' "400": description: Returned if the request doesn't have a valid proposal ID or height schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "500": description: Returned if the store query fails schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Query a governance proposal's individual tally tags: - governance @@ -562,7 +783,7 @@ paths: Query an individual governance proposal's votes. NOTE: In order to query deposits for passed proposals, the transaction record must be available otherwise the query will fail. This requires a - node that is not pruning transaction history. + node that is not pruning transaction history parameters: - description: The ID of the governance proposal in: path @@ -579,19 +800,16 @@ paths: "200": description: OK schema: - $ref: '#/definitions/rest.ResponseWithHeight' - type: object + $ref: '#/definitions/rest.queryVotesOnProposal' "400": description: Returned if the request doesn't have a valid proposal ID or height schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "500": description: Returned if the store query fails schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Query a governance proposal's votes tags: - governance @@ -607,7 +825,7 @@ paths: type: integer - description: The data required to construct a vote message in: body - name: tx + name: body required: true schema: $ref: '#/definitions/rest.VoteReq' @@ -618,13 +836,11 @@ paths: "200": description: OK schema: - $ref: '#/definitions/types.StdTx' - type: object + $ref: '#/definitions/rest.postVote' "400": description: Returned if the request is invalid schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Generate an unsigned vote transaction tags: - governance @@ -634,7 +850,7 @@ paths: Query an individual governance proposal's vote. NOTE: In order to query votes for passed proposals, the transaction record must be available otherwise the query will fail. This requires a - node that is not pruning transaction history. + node that is not pruning transaction history parameters: - description: The ID of the governance proposal in: path @@ -656,24 +872,20 @@ paths: "200": description: OK schema: - $ref: '#/definitions/rest.ResponseWithHeight' - type: object + $ref: '#/definitions/rest.queryVote' "400": description: Returned if the request doesn't have a valid proposal ID or voter address schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "404": description: Returned if the proposal is not found schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "500": description: Returned if the store query fails schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Query a governance proposal's individual vote tags: - governance @@ -702,17 +914,14 @@ paths: description: OK schema: $ref: '#/definitions/types.TxResponse' - type: object "400": description: Returned if the request is invalid. schema: $ref: '#/definitions/rest.ErrorResponse' - type: object "500": description: Returned if the transaction cannot be decoded. schema: $ref: '#/definitions/rest.ErrorResponse' - type: object summary: Broadcast a signed transaction tags: - transactions diff --git a/contrib/devtools/Makefile b/contrib/devtools/Makefile index 19fe8c9d0cdd..874b86aa037f 100644 --- a/contrib/devtools/Makefile +++ b/contrib/devtools/Makefile @@ -56,8 +56,8 @@ $(GOLANGCI_LINT): $(mkfile_dir)/install-golangci-lint.sh swag: $(SWAG) $(SWAG): - @echo "Get swag" - @go get -u github.com/swaggo/swag/cmd/swag + @echo "Installing swag..." + @(cd /tmp && go get -u github.com/swaggo/swag/cmd/swag@v1.6.3) runsim: $(RUNSIM) $(RUNSIM): diff --git a/x/gov/client/rest/query.go b/x/gov/client/rest/query.go index dac8f476edd6..d9488af84ede 100644 --- a/x/gov/client/rest/query.go +++ b/x/gov/client/rest/query.go @@ -31,7 +31,7 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { // // @Summary Query governance parameters // @Tags governance -// @Description Query either (deposit | tallying | voting) parameters of the governance module. +// @Description Query either (deposit | tallying | voting) parameters of the governance module // @Produce json // @Param type path string true "Type of param (deposit | tallying | voting)" // @Param height query string false "Block height (defaults to chain tip)" @@ -69,7 +69,7 @@ func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // @Produce json // @Param proposalID path int true "The ID of the governance proposal" // @Param height query string false "Block height (defaults to chain tip)" -// @Success 200 {object} rest.ResponseWithHeight +// @Success 200 {object} rest.queryProposal // @Failure 400 {object} rest.ErrorResponse "Returned if the request doesn't have a valid proposal ID or height" // @Failure 500 {object} rest.ErrorResponse "Returned if the store query fails" // @Router /gov/proposals/{proposalID} [get] @@ -121,11 +121,11 @@ func queryProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // @Description Query an individual governance proposal's deposits. // @Description NOTE: In order to query deposits for passed proposals, the transaction // @Description record must be available otherwise the query will fail. This requires a -// @Description node that is not pruning transaction history. +// @Description node that is not pruning transaction history // @Produce json // @Param proposalID path int true "The ID of the governance proposal" // @Param height query string false "Block height (defaults to chain tip)" -// @Success 200 {object} rest.ResponseWithHeight +// @Success 200 {object} rest.queryDeposits // @Failure 400 {object} rest.ErrorResponse "Returned if the request doesn't have a valid proposal ID or height" // @Failure 500 {object} rest.ErrorResponse "Returned if the store query fails" // @Router /gov/proposals/{proposalID}/deposits [get] @@ -191,7 +191,7 @@ func queryDepositsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // @Produce json // @Param proposalID path int true "The ID of the governance proposal" // @Param height query string false "Block height (defaults to chain tip)" -// @Success 200 {object} rest.ResponseWithHeight +// @Success 200 {object} rest.queryProposer // @Failure 400 {object} rest.ErrorResponse "Returned if the request doesn't have a valid proposal ID or height" // @Failure 500 {object} rest.ErrorResponse "Returned if the store query fails" // @Router /gov/proposals/{proposalID}/proposer [get] @@ -221,19 +221,19 @@ func queryProposerHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { } // queryDepositHandlerFn implements a governance proposal deposit querying route -// for returning data on a governance proposal's individual deposits. +// for returning data on a governance proposal's individual deposits // // @Summary Query a governance proposal's individual deposit // @Tags governance // @Description Query an individual governance proposal's deposits. // @Description NOTE: In order to query a deposit for a passed proposal, the transaction // @Description record must be available otherwise the query will fail. This requires a -// @Description node that is not pruning transaction history. +// @Description node that is not pruning transaction history // @Produce json // @Param proposalID path int true "The ID of the governance proposal" // @Param depositor path string true "The address of the depositor" // @Param height query string false "Block height (defaults to chain tip)" -// @Success 200 {object} rest.ResponseWithHeight +// @Success 200 {object} rest.queryDeposit // @Failure 400 {object} rest.ErrorResponse "Returned if the request doesn't have a valid proposalID or depositor" // @Failure 404 {object} rest.ErrorResponse "Returned if the proposal is not found" // @Failure 500 {object} rest.ErrorResponse "Returned if the store query fails" @@ -328,12 +328,12 @@ func queryDepositHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // @Description Query an individual governance proposal's vote. // @Description NOTE: In order to query votes for passed proposals, the transaction // @Description record must be available otherwise the query will fail. This requires a -// @Description node that is not pruning transaction history. +// @Description node that is not pruning transaction history // @Produce json // @Param proposalID path int true "The ID of the governance proposal" // @Param voter path string true "The address of the voter" // @Param height query string false "Block height (defaults to chain tip)" -// @Success 200 {object} rest.ResponseWithHeight +// @Success 200 {object} rest.queryVote // @Failure 400 {object} rest.ErrorResponse "Returned if the request doesn't have a valid proposal ID or voter address" // @Failure 404 {object} rest.ErrorResponse "Returned if the proposal is not found" // @Failure 500 {object} rest.ErrorResponse "Returned if the store query fails" @@ -430,11 +430,11 @@ func queryVoteHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // @Description Query an individual governance proposal's votes. // @Description NOTE: In order to query deposits for passed proposals, the transaction // @Description record must be available otherwise the query will fail. This requires a -// @Description node that is not pruning transaction history. +// @Description node that is not pruning transaction history // @Produce json // @Param proposalID path int true "The ID of the governance proposal" // @Param height query string false "Block height (defaults to chain tip)" -// @Success 200 {object} rest.ResponseWithHeight +// @Success 200 {object} rest.queryVotesOnProposal // @Failure 400 {object} rest.ErrorResponse "Returned if the request doesn't have a valid proposal ID or height" // @Failure 500 {object} rest.ErrorResponse "Returned if the store query fails" // @Router /gov/proposals/{proposalID}/votes [get] @@ -511,7 +511,7 @@ func queryVotesOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // @Param status query string false "Filter proposals by proposal status (deposit_period | voting_period | passed | rejected)" // @Param depositor query string false "Filter proposals by depositor address" // @Param voter query string false "Filter proposals by voter address" -// @Success 200 {object} rest.ResponseWithHeight +// @Success 200 {object} rest.queryProposals // @Failure 400 {object} rest.ErrorResponse "Returned if the request doesn't have a valid parameters" // @Failure 500 {object} rest.ErrorResponse "Returned if the store query fails" // @Router /gov/proposals [get] @@ -591,7 +591,7 @@ func queryProposalsWithParameterFn(cliCtx context.CLIContext) http.HandlerFunc { // @Produce json // @Param proposalID path int true "The ID of the governance proposal" // @Param height query string false "Block height (defaults to chain tip)" -// @Success 200 {object} rest.ResponseWithHeight +// @Success 200 {object} rest.queryTally // @Failure 400 {object} rest.ErrorResponse "Returned if the request doesn't have a valid proposal ID or height" // @Failure 500 {object} rest.ErrorResponse "Returned if the store query fails" // @Router /gov/proposals/{proposalID}/tally [get] diff --git a/x/gov/client/rest/swagger.go b/x/gov/client/rest/swagger.go new file mode 100644 index 000000000000..e3b5324edf24 --- /dev/null +++ b/x/gov/client/rest/swagger.go @@ -0,0 +1,75 @@ +package rest + +import ( + auth "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/cosmos/cosmos-sdk/x/gov/client/utils" + "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +// Concrete Swagger types used to generate REST documentation. Note, these types +// are not actually used but since all queries return a generic JSON raw message, +// they enabled typed documentation. +// +//nolint:deadcode,unused +type ( + queryDeposits struct { + Height int64 `json:"height"` + Result []types.Deposit `json:"result"` + } + + queryProposal struct { + Height int64 `json:"height"` + Result types.Proposal `json:"result"` + } + + queryProposer struct { + Height int64 `json:"height"` + Result utils.Proposer `json:"result"` + } + + queryDeposit struct { + Height int64 `json:"height"` + Result types.Deposit `json:"result"` + } + + queryVote struct { + Height int64 `json:"height"` + Result types.Vote `json:"result"` + } + + queryVotesOnProposal struct { + Height int64 `json:"height"` + Result types.Votes `json:"result"` + } + + queryProposals struct { + Height int64 `json:"height"` + Result []types.Proposal `json:"result"` + } + + queryTally struct { + Height int64 `json:"height"` + Result types.TallyResult `json:"result"` + } + + postProposal struct { + Msgs []types.MsgSubmitProposal `json:"msg" yaml:"msg"` + Fee auth.StdFee `json:"fee" yaml:"fee"` + Signatures []auth.StdSignature `json:"signatures" yaml:"signatures"` + Memo string `json:"memo" yaml:"memo"` + } + + postDeposit struct { + Msgs []types.MsgDeposit `json:"msg" yaml:"msg"` + Fee auth.StdFee `json:"fee" yaml:"fee"` + Signatures []auth.StdSignature `json:"signatures" yaml:"signatures"` + Memo string `json:"memo" yaml:"memo"` + } + + postVote struct { + Msgs []types.MsgVote `json:"msg" yaml:"msg"` + Fee auth.StdFee `json:"fee" yaml:"fee"` + Signatures []auth.StdSignature `json:"signatures" yaml:"signatures"` + Memo string `json:"memo" yaml:"memo"` + } +) diff --git a/x/gov/client/rest/tx.go b/x/gov/client/rest/tx.go index d0f2f7a7799a..76b66ae0f515 100644 --- a/x/gov/client/rest/tx.go +++ b/x/gov/client/rest/tx.go @@ -29,12 +29,12 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router, phs []ProposalRE // is responsible for constructing a properly formatted proposal for signing. // // @Summary Generate an unsigned proposal transaction -// @Description Generate a proposal transaction that is ready for signing. +// @Description Generate a proposal transaction that is ready for signing // @Tags governance // @Accept json // @Produce json -// @Param tx body rest.PostProposalReq true "The data required to construct a proposal message. The proposal_type can be text | parameter_change" -// @Success 200 {object} types.StdTx +// @Param body body rest.PostProposalReq true "The data required to construct a proposal message, the proposal_type can be (text | parameter_change)" +// @Success 200 {object} rest.postProposal // @Failure 400 {object} rest.ErrorResponse "Returned if the request is invalid" // @Router /gov/proposals [post] func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { @@ -71,8 +71,8 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // @Accept json // @Produce json // @Param proposalID path int true "The ID of the governance proposal to deposit to" -// @Param tx body rest.DepositReq true "The data required to construct a deposit message" -// @Success 200 {object} types.StdTx +// @Param body body rest.DepositReq true "The data required to construct a deposit message" +// @Success 200 {object} rest.postDeposit // @Failure 400 {object} rest.ErrorResponse "Returned if the request is invalid" // @Router /gov/proposals/{proposalID}/deposits [post] func depositHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { @@ -120,8 +120,8 @@ func depositHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { // @Accept json // @Produce json // @Param proposalID path int true "The ID of the governance proposal to vote for" -// @Param tx body rest.VoteReq true "The data required to construct a vote message" -// @Success 200 {object} types.StdTx +// @Param body body rest.VoteReq true "The data required to construct a vote message" +// @Success 200 {object} rest.postVote // @Failure 400 {object} rest.ErrorResponse "Returned if the request is invalid" // @Router /gov/proposals/{proposalID}/votes [post] func voteHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {