Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Swagger Doc Generation #5038

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
be78cd9
Start prototype of auto swagger gen
alexanderbez Sep 12, 2019
5c879bd
Cleanup
alexanderbez Sep 12, 2019
0ec8c59
Merge branch 'master' into bez/2179-auto-swagger
alexanderbez Sep 16, 2019
6f2f40a
Rename and remove LCD notion
alexanderbez Sep 16, 2019
b7ebdc8
Remove TODO
alexanderbez Sep 17, 2019
5a49b28
Update build
alexanderbez Sep 17, 2019
c36d0b0
Update format make target
alexanderbez Sep 17, 2019
d322068
Update circle CI description
alexanderbez Sep 17, 2019
c450c18
Add initial swagger docs
alexanderbez Sep 17, 2019
a6070a5
Add swagger build vars
alexanderbez Sep 17, 2019
f9f1cdb
Add doc.go
alexanderbez Sep 17, 2019
10e0697
Add changelog entry
alexanderbez Sep 17, 2019
92d1793
Merge branch 'master' into bez/2179-auto-swagger
alexanderbez Sep 17, 2019
cb477e2
Merge PR #5059: Swagger Auto Gen - Gov
jackzampolin Sep 18, 2019
a4d280c
Update swagger docs
alexanderbez Sep 18, 2019
1fa0c61
Fix update-swagger-docs by using a script
alexanderbez Sep 18, 2019
4dd2bbf
Fix script
alexanderbez Sep 18, 2019
f63e1a6
Merge branch 'master' into bez/2179-auto-swagger
alexanderbez Sep 18, 2019
93f82a5
Merge PR #5088: Swagger Auto Gen - Gov Updates
jackzampolin Sep 30, 2019
b5654cb
Merge branch 'master' into bez/2179-auto-swagger
alexanderbez Sep 30, 2019
bdb878e
Bump swag version to 1.6.3
alexanderbez Sep 30, 2019
965134a
Merge branch 'master' into bez/2179-auto-swagger
alexanderbez Oct 1, 2019
352820c
Swagger Auto Gen - Bank (#5181)
tac0turtle Oct 11, 2019
63feb02
Swagger Auto Gen - Supply (#5184)
tac0turtle Oct 11, 2019
f132da5
Merge branch 'master' into bez/2179-auto-swagger
alexanderbez Oct 11, 2019
e991b2a
Fix changelog merge conflict
alexanderbez Oct 11, 2019
9d6ea39
Merge branch 'master' into bez/2179-auto-swagger
alexanderbez Oct 11, 2019
b71d571
Update x/bank swagger annotations
alexanderbez Oct 11, 2019
74aad45
Merge branch 'bez/2179-auto-swagger' of github.com:cosmos/cosmos-sdk …
alexanderbez Oct 11, 2019
0bf9525
Update x/supply swagger annotations
alexanderbez Oct 11, 2019
1e204a1
fix: check exit status of swag command
alexanderbez Oct 11, 2019
235dc49
Merge PR #5061: Swagger Auto Gen - Staking
jackzampolin Oct 11, 2019
bc30c0a
Merge PR #5185: Swagger Auto Gen - Mint
tac0turtle Oct 14, 2019
f392923
Swagger Auto Gen - Slashing (#5183)
tac0turtle Oct 15, 2019
7224acf
swagger: fix x/mint annotations
alexanderbez Oct 15, 2019
91f4b0b
swagger: update docs
alexanderbez Oct 15, 2019
48ee92a
swagger: update slashing query docs
alexanderbez Oct 15, 2019
6b6517b
swagger: update slashing tx docs
alexanderbez Oct 15, 2019
cf9a9c5
swagger: update docs
alexanderbez Oct 15, 2019
b68e9c0
Merge PR #5182: Add CreateValidator and EditValidator in REST
preminem Oct 16, 2019
30223df
docs: update swagger docs
alexanderbez Oct 16, 2019
6505188
Merge PR #5197: Swagger Auto Gen - Auth
tac0turtle Oct 16, 2019
71bee87
docs: update swagger docs
alexanderbez Oct 16, 2019
9539e1a
Merge branch 'master' into bez/2179-auto-swagger
tac0turtle Nov 2, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 statik.go is 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:
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
client/lcd/swagger-ui/* linguist-vendored
client/rest/docs/* linguist-vendored
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ have this method perform a no-op.
* Update gov keys to use big endian encoding instead of little endian
* (modules) [\#5017](https://github.com/cosmos/cosmos-sdk/pull/5017) The `x/genaccounts` module has been
deprecated and all components removed except the `legacy/` package.
* (rest) [\#5038](https://github.com/cosmos/cosmos-sdk/pull/5038) RESTful Swagger documentation is
now mounted under `/swagger/` instead of `/swagger-ui/`.
* [\#4486](https://github.com/cosmos/cosmos-sdk/issues/4486) Vesting account types decoupled from the `x/auth` module and
now live under `x/auth/vesting`. Applications wishing to use vesting account types must be sure to register types via
`RegisterCodec` under the new vesting package.
Expand Down Expand Up @@ -130,7 +132,12 @@ that allows for arbitrary vesting periods.

### Improvements


* (rest) [\#5038](https://github.com/cosmos/cosmos-sdk/pull/5038) RESTful Swagger documentation is
now handled automatically via handler annotations using the [Swag](https://github.com/swaggo/swag) library instead of a static
configuration.
* (tendermint) Bump Tendermint version to [v0.32.7](https://github.com/tendermint/tendermint/releases/tag/v0.32.7)

* (server) [\#4215](https://github.com/cosmos/cosmos-sdk/issues/4215) The `--pruning` flag
has been moved to the configuration file, to allow easier node configuration.
* (cli) [\#5116](https://github.com/cosmos/cosmos-sdk/issues/5116) The `CLIContext` now supports multiple verifiers
Expand Down Expand Up @@ -329,6 +336,7 @@ that error is that the account doesn't exist.
* [\#4843](https://github.com/cosmos/cosmos-sdk/issues/4843) Add RegisterEvidences function in the codec package to register
Tendermint evidence types with a given codec.
* (rest) [\#3867](https://github.com/cosmos/cosmos-sdk/issues/3867) Allow querying for genesis transaction when height query param is set to zero.
* (rest) [\#5113](https://github.com/cosmos/cosmos-sdk/issues/5113) Implement create and edit validator REST endpoints through POST and PUT `/staking/validators/{validatorAddr}` respectively.
* [\#2020](https://github.com/cosmos/cosmos-sdk/issues/2020) New keys export/import command line utilities to export/import private keys in ASCII format
that rely on Keybase's new underlying ExportPrivKey()/ImportPrivKey() API calls.
* [\#3565](https://github.com/cosmos/cosmos-sdk/issues/3565) Implement parameter change proposal support.
Expand Down
20 changes: 9 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ build: go.sum
@go build -mod=readonly ./...
.PHONY: build

update-swagger-docs: statik
$(BINDIR)/statik -src=client/lcd/swagger-ui -dest=client/lcd -f -m
@if [ -n "$(git status --porcelain)" ]; then \
echo "\033[91mSwagger docs are out of sync!!!\033[0m";\
exit 1;\
else \
echo "\033[92mSwagger docs are in sync\033[0m";\
fi
update-swagger-docs: 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
Expand Down Expand Up @@ -180,9 +178,9 @@ lint: golangci-lint
.PHONY: lint

format: tools
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/cosmos/cosmos-sdk
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/rest/docs/docs.go" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/rest/docs/docs.go" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/rest/docs/docs.go" | xargs goimports -w -local github.com/cosmos/cosmos-sdk
.PHONY: format

benchmark:
Expand Down
9 changes: 4 additions & 5 deletions client/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// ALIASGEN: github.com/cosmos/cosmos-sdk/client/context
// ALIASGEN: github.com/cosmos/cosmos-sdk/client/flags
// ALIASGEN: github.com/cosmos/cosmos-sdk/client/keys
// ALIASGEN: github.com/cosmos/cosmos-sdk/client/lcd
// ALIASGEN: github.com/cosmos/cosmos-sdk/client/rest
// ALIASGEN: github.com/cosmos/cosmos-sdk/client/rpc
// ALIASGEN: github.com/cosmos/cosmos-sdk/client/tx
Expand All @@ -17,7 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/input"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rest"
"github.com/cosmos/cosmos-sdk/client/rpc"
)

Expand Down Expand Up @@ -87,8 +86,8 @@ var (
NewKeyBaseFromHomeFlag = keys.NewKeyBaseFromHomeFlag
NewKeyBaseFromDir = keys.NewKeyBaseFromDir
NewInMemoryKeyBase = keys.NewInMemoryKeyBase
NewRestServer = lcd.NewRestServer
ServeCommand = lcd.ServeCommand
NewRestServer = rest.NewRestServer
ServeCommand = rest.ServeCommand
BlockCommand = rpc.BlockCommand
GetChainHeight = rpc.GetChainHeight
BlockRequestHandlerFn = rpc.BlockRequestHandlerFn
Expand Down Expand Up @@ -119,7 +118,7 @@ type (
RecoverKey = keys.RecoverKey
UpdateKeyReq = keys.UpdateKeyReq
DeleteKeyReq = keys.DeleteKeyReq
RestServer = lcd.RestServer
RestServer = rest.RestServer
ValidatorOutput = rpc.ValidatorOutput
ResultValidatorsOutput = rpc.ResultValidatorsOutput
)
3 changes: 0 additions & 3 deletions client/lcd/statik/init.go

This file was deleted.

13 changes: 0 additions & 13 deletions client/lcd/statik/statik.go

This file was deleted.

Binary file removed client/lcd/swagger-ui/favicon-16x16.png
Binary file not shown.
Binary file removed client/lcd/swagger-ui/favicon-32x32.png
Binary file not shown.
60 changes: 0 additions & 60 deletions client/lcd/swagger-ui/index.html

This file was deleted.

67 changes: 0 additions & 67 deletions client/lcd/swagger-ui/oauth2-redirect.html

This file was deleted.

Loading