Skip to content

feat: enable swagger#1203

Merged
mergify[bot] merged 15 commits intomainfrom
rafilx/enable-swagger
Aug 4, 2022
Merged

feat: enable swagger#1203
mergify[bot] merged 15 commits intomainfrom
rafilx/enable-swagger

Conversation

@RafilxTenfen
Copy link
Copy Markdown
Contributor

Description

closes: #957


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@RafilxTenfen
Copy link
Copy Markdown
Contributor Author

@toteki @adamewozniak could you guys check if the module specifics seem correct?

Copy link
Copy Markdown
Collaborator

@adamewozniak adamewozniak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions - also @RafilxTenfen should we ignore the generated files here and maybe add it to make build, or something similar?

These files will likely become expired if they're not generated each time queries are updated

@@ -0,0 +1,26 @@
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move this into a folder swagger instead of client/docs maybe?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what other projects are using, but I agree - docs/swagger would be probably better place.

@RafilxTenfen
Copy link
Copy Markdown
Contributor Author

Just a few questions - also @RafilxTenfen should we ignore the generated files here and maybe add it to make build, or something similar?

These files will likely become expired if they're not generated each time queries are updated

Make sense, maybe we could put it together with proto-gen? since it will be modified it time the proto files change

Makefile Outdated
Comment on lines +278 to +279
echo "\033[91mSwagger docs are out of sync!!!\033[0m";\
exit 1;\
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we taking the approach where the swagger docs are always gitignored, or will they be committed?

And if they're being committed - this is most of the ingredients to a CI check that we could make, which would check it they're out of sync on any PR

toteki
toteki previously requested changes Aug 3, 2022
Copy link
Copy Markdown
Contributor

@toteki toteki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client/docs/statik/statik.go is so large that my git clone time for the repository seems to have doubled from this commit.

Because it's all in 13 lines, I also fear that it cannot diff efficiently, so our repo size would increase by the full 10+ MB every time it's generated.

Thus, we need to go the .gitignore route

RafilxTenfen and others added 2 commits August 3, 2022 11:06
Co-authored-by: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can check with the ecosystem if someone else has better setup rather than bundling the swagger docs into the chain app.

Makefile Outdated
runsim: $(RUNSIM)
$(RUNSIM):
@echo "Installing runsim..."
@go install github.com/cosmos/tools/cmd/runsim@v1.0.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think runsim nor statik is needed for swagger. Statik can be used to pack static files in a go library. Not sure if this is the best solution though. I know SDK and Regen are using Statik to serve doc files directly from the app. Ideally I would serve documentation from other app, rather than bundling it into the chain. What do you think?

@@ -0,0 +1,26 @@
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what other projects are using, but I agree - docs/swagger would be probably better place.

@RafilxTenfen
Copy link
Copy Markdown
Contributor Author

@adamewozniak @toteki @robert-zaremba
Okay, forget the first implementation, can you guys take a look again?
I used how Juno did to make ours

@toteki toteki dismissed their stale review August 3, 2022 15:03

To re-review later

Copy link
Copy Markdown
Collaborator

@adamewozniak adamewozniak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions but this looks much cleaner 🥳

Copy link
Copy Markdown
Contributor

@toteki toteki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc file size (swagger.yaml) is much more manageable now (80 kB) and its format would allow for efficient diff.

Remaining question is whether we should

  • .gitignore it anyway (so it's only generated locally when needed, and can't be out of sync)
  • commit it (and either manually or through CI, make sure it doesn't desync)

@RafilxTenfen
Copy link
Copy Markdown
Contributor Author

Doc file size (swagger.yaml) is much more manageable now (80 kB) and its format would allow for efficient diff.

Remaining question is whether we should

  • .gitignore it anyway (so it's only generated locally when needed, and can't be out of sync)
  • commit it (and either manually or through CI, make sure it doesn't desync)

In my opinion, we could commit that, in the same way we commit the generated structs from proto files

@adamewozniak
Copy link
Copy Markdown
Collaborator

adamewozniak commented Aug 3, 2022

Doc file size (swagger.yaml) is much more manageable now (80 kB) and its format would allow for efficient diff.
Remaining question is whether we should

  • .gitignore it anyway (so it's only generated locally when needed, and can't be out of sync)
  • commit it (and either manually or through CI, make sure it doesn't desync)

In my opinion, we could commit that, in the same way we commit the generated structs from proto files

Maybe we can add a CI task (later) where we check to see if swagger is out of date?
We could hash the existing swagger file & then compare that hash to a newly generated file.

@robert-zaremba
Copy link
Copy Markdown
Contributor

We could hash the existing swagger file & then compare that hash to a newly generated file.

Or check if proto was modified: whenever proto was modified, swagger should be checked if it should be modified as well.

},
"apis": [
{
"url": "./tmp-swagger-gen/umee/leverage/v1/query.swagger.json",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why tmp prefix? It looks weird.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is just the name of the temp dir /tmp-swagger-gen used in contrib/scripts/protoc-swagger-gen.sh to generate the ./swagger/swagger.yaml

Copy link
Copy Markdown
Contributor

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long term we should consider serving swagger docs not from the chain app.

@mergify mergify bot merged commit c09c9f1 into main Aug 4, 2022
@mergify mergify bot deleted the rafilx/enable-swagger branch August 4, 2022 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Swagger to Umeed

4 participants