-
Notifications
You must be signed in to change notification settings - Fork 202
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
feat: OpenAPI page #1853
base: main
Are you sure you want to change the base?
feat: OpenAPI page #1853
Conversation
WalkthroughThe recent updates represent a significant restructuring of Swagger documentation and routing mechanisms in the application. The changes involve removing outdated HTTP and Swagger setup from the main app components, while introducing new scripts and configurations for generating and handling Swagger documentation for the Nibiru Chain gRPC Gateway. Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional comments not posted (1)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
// RegisterSwaggerAPI registers swagger route with API Server | ||
func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) { | ||
statikFS, err := fs.New() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
staticServer := http.FileServer(statikFS) | ||
rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider handling the error more gracefully instead of using panic
. It's generally better to return an error and let the caller handle it, which could improve the robustness of the application.
- if err != nil {
- panic(err)
- }
+ if err != nil {
+ return fmt.Errorf("failed to create statikFS: %w", err)
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
// RegisterSwaggerAPI registers swagger route with API Server | |
func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) { | |
statikFS, err := fs.New() | |
if err != nil { | |
panic(err) | |
} | |
staticServer := http.FileServer(statikFS) | |
rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer)) | |
} | |
// RegisterSwaggerAPI registers swagger route with API Server | |
func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) error { | |
statikFS, err := fs.New() | |
if err != nil { | |
return fmt.Errorf("failed to create statikFS: %w", err) | |
} | |
staticServer := http.FileServer(statikFS) | |
rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer)) | |
return nil | |
} |
for dir in $proto_dirs; do | ||
# generate swagger files (filter query files) | ||
query_file=$(find "${dir}" -maxdepth 1 \( -name 'query.proto' -o -name 'service.proto' \)) | ||
if [[ ! -z "$query_file" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve the condition check by using -n
instead of ! -z
for clarity and consistency in bash scripting.
- if [[ ! -z "$query_file" ]]; then
+ if [[ -n "$query_file" ]]; then
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if [[ ! -z "$query_file" ]]; then | |
if [[ -n "$query_file" ]]; then |
query_file=$(find "${dir}" -maxdepth 1 \( -name 'query.proto' -o -name 'service.proto' \)) | ||
if [[ ! -z "$query_file" ]]; then | ||
# echo $query_file | ||
buf generate --template buf.gen.swagger.yaml $query_file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure variables are double-quoted to prevent globbing and word splitting, which can lead to unexpected behavior or security issues.
- buf generate --template buf.gen.swagger.yaml $query_file
+ buf generate --template buf.gen.swagger.yaml "$query_file"
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
buf generate --template buf.gen.swagger.yaml $query_file | |
buf generate --template buf.gen.swagger.yaml "$query_file" |
ifeq ($(GO),) | ||
$(error could not find go. Is it in PATH? $(GO)) | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that the error message is clear and helpful. Consider adding more details about how to resolve the issue if Go is not found in the PATH.
- $(error could not find go. Is it in PATH? $(GO))
+ $(error Could not find the Go executable. Please ensure that Go is installed and available in your PATH.)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
ifeq ($(GO),) | |
$(error could not find go. Is it in PATH? $(GO)) | |
endif | |
ifeq ($(GO),) | |
$(error Could not find the Go executable. Please ensure that Go is installed and available in your PATH.) | |
endif |
Purpose / Abstract
Creates an OpenAPI 2.0 (aka Swagger) page available at the LCD endpoint.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation