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

fix: fix swagger page and ci #1333

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

fix: fix swagger page and ci #1333

wants to merge 3 commits into from

Conversation

dadamu
Copy link
Contributor

@dadamu dadamu commented May 8, 2024

Description

Closes: #XXXX
This PR fixes swagger page to show proper frontend and includes cosmos-sdk queries and services to swagger file.


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
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • 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 ! in the type prefix if API or client breaking change
  • 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)

Summary by CodeRabbit

  • New Features
    • Enhanced Swagger documentation generation with new automated dependency downloads for Cosmos SDK and IBC protocols.
    • Introduced new HTML and JavaScript files to support OAuth2 redirection and enhance the Swagger UI experience.
  • Bug Fixes
    • Fixed issues in the Swagger frontend to include third-party API methods.
  • Refactor
    • Updated operations and parameter naming across various Swagger JSON files to improve clarity and consistency.
  • Chores
    • Improved the automation process for generating Swagger files by modifying the Makefile and associated scripts.

@dadamu dadamu requested a review from a team as a code owner May 8, 2024 10:24
Copy link
Contributor

coderabbitai bot commented May 8, 2024

Walkthrough

The recent changes focus on enhancing the management of Protobuf dependencies and Swagger file generation for Cosmos SDK and IBC protocols. This includes updates to the Makefile for dependency downloads and Swagger file cleanup, renaming parameters in various Swagger JSON files for clarity, introducing new HTML files for better Swagger UI integration, and refining the script for Swagger generation to adapt to new directory structures and setup requirements.

Changes

File(s) Change Summary
Makefile Added proto-download-deps, updated proto-swagger-gen
app/app.go Added import statement for desmos client docs
client/docs/config.json Renamed various Params across multiple Swagger JSON files
client/docs/swagger-ui/index.html
client/docs/swagger-ui/oauth2-redirect.html
Added new HTML files for Swagger UI
scripts/protoc-swagger-gen.sh Updated to include new steps and directory adjustments for Swagger generation

🐇✨
In the burrows of code, beneath the digital sky,
A rabbit hops along, patches flying high.
Protos fetched, and Swagger swirled,
In the Makefile's embrace, a new world unfurled.
Cheers to the bytes, in harmony they lay,
For every line refined, a brighter day! 🌟📜
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added x/CLI kind/build Related to the build of the project labels May 8, 2024
SWAGGER_THIRD_PARTY_DIR=$(SWAGGER_PROTO_DIR)/third_party
SWAGGER_COSMOS_SDK_BRANCH=release/v0.47.x
SWAGGER_IBC_BRANCH=release/v7.4.x
proto-download-deps:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To include cosmos-sdk and other third party queries and services into swagger, it requires download the raw proto files for generating proper swagger files.

@@ -110,6 +110,8 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

_ "github.com/desmos-labs/desmos/v7/client/docs/statik"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Overwrite the swagger static files.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Out of diff range and nitpick comments (1)
scripts/protoc-swagger-gen.sh (1)

Line range hint 22-27: Consider simplifying the condition check and ensure proper handling of variables to prevent issues like word splitting.

- if [[ ! -z "$query_file" ]]; then
+ if [[ -n "$query_file" ]]; then
- buf generate --template buf.gen.swagger.yaml $query_file
+ buf generate --template buf.gen.swagger.yaml "$query_file"
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between fdd752f and f7db28d.
Files ignored due to path filters (9)
  • client/docs/swagger-ui/favicon-16x16.png is excluded by !**/*.png
  • client/docs/swagger-ui/favicon-32x32.png is excluded by !**/*.png
  • client/docs/swagger-ui/swagger-ui-bundle.js.map is excluded by !**/*.map
  • client/docs/swagger-ui/swagger-ui-es-bundle-core.js.map is excluded by !**/*.map
  • client/docs/swagger-ui/swagger-ui-es-bundle.js.map is excluded by !**/*.map
  • client/docs/swagger-ui/swagger-ui-standalone-preset.js.map is excluded by !**/*.map
  • client/docs/swagger-ui/swagger-ui.css.map is excluded by !**/*.map
  • client/docs/swagger-ui/swagger-ui.js.map is excluded by !**/*.map
  • proto/buf.lock is excluded by !**/*.lock
Files selected for processing (6)
  • Makefile (1 hunks)
  • app/app.go (1 hunks)
  • client/docs/config.json (1 hunks)
  • client/docs/swagger-ui/index.html (1 hunks)
  • client/docs/swagger-ui/oauth2-redirect.html (1 hunks)
  • scripts/protoc-swagger-gen.sh (2 hunks)
Files not reviewed due to errors (3)
  • client/docs/swagger-ui/oauth2-redirect.html (no review received)
  • client/docs/config.json (no review received)
  • Makefile (no review received)
Files skipped from review due to trivial changes (1)
  • client/docs/swagger-ui/index.html
Additional Context Used
ShellCheck (2)
scripts/protoc-swagger-gen.sh (2)

[style] 26-26: Use -n instead of ! -z.


[info] 27-27: Double quote to prevent globbing and word splitting.

Additional comments not posted (7)
scripts/protoc-swagger-gen.sh (6)

6-10: LGTM! Preparation steps for Swagger generation are well-structured.


11-15: LGTM! Copying proto files to a new directory ensures isolation during Swagger generation.


16-16: LGTM! Using a temporary folder for intermediate results is a good practice.


32-32: LGTM! Cleaning up after generation prevents issues with stale files.


32-32: LGTM! Effective finalization of the Swagger generation process.


Line range hint 6-32: The script is well-structured and effectively supports the enhancements to Swagger documentation.

app/app.go (1)

114-114: Ensure the imported Swagger documentation is utilized within the application.

Verification successful

The search results indicate that the import statement for the statik package appears only once in app/app.go, and that is the import line itself. There is no further evidence from the provided output that the imported package is being utilized elsewhere in the file. This could suggest that the import might be unnecessary unless it is implicitly used by the Go toolchain (which is common for packages that embed static files).

To confirm whether this package is indeed used implicitly (which is a common pattern for packages that serve static files or documentation), I will need to check if there is any reference in the build scripts or other parts of the application where this package's content is accessed indirectly.


The search results from the scripts provide clear evidence that the statik package is indeed used within the project, particularly in the build process as specified in the Makefile. The references to statik in the Makefile and other related files indicate that it is used to embed Swagger UI assets into the Go binary. This is a common practice for serving static files directly from a Go application, which aligns with the purpose of enhancing Swagger documentation as mentioned in the PR.

Additionally, the presence of a statik.go file in the client/docs/statik directory, which is generated by the statik tool and contains static assets, confirms that the statik package is not only imported but actively used to serve embedded content.

Given this information, the import statement in app/app.go is justified and necessary for the application's functionality related to serving Swagger documentation. Therefore, the review comment questioning the utilization of the imported Swagger documentation is addressed, and the usage is verified as correct.

Ensure the imported Swagger documentation is utilized within the application.

  • The statik package is used in the build scripts to embed Swagger UI assets into the Go binary.
  • The generated statik.go file in the client/docs/statik directory confirms the active use of the statik package for serving embedded content.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of the imported Swagger documentation package.

# Test: Search for the usage of the `statik` package. Expect: At least one occurrence.
rg --type go $'github.com/desmos-labs/desmos/v7/client/docs/statik' app/app.go

Length of output: 134



Script:

#!/bin/bash
# Description: Check for implicit usage of the `statik` package in build scripts or other Go files.

# Search for any reference to the `statik` package in all Go files and build scripts.
rg --type go --type make --type sh 'statik' .

Length of output: 1571

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between f7db28d and 0f91043.
Files selected for processing (1)
  • .changeset/entries/9769bdf3cddefa33b7cbb5e13147c6b1f7a0d4193acb78e6904a7c1734fa5e68.yaml (1 hunks)
Files skipped from review due to trivial changes (1)
  • .changeset/entries/9769bdf3cddefa33b7cbb5e13147c6b1f7a0d4193acb78e6904a7c1734fa5e68.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/build Related to the build of the project x/CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant