Skip to content

feat: OpenAPI page#1853

Open
k-yang wants to merge 1335 commits into
mainfrom
scripts/swagger-gen
Open

feat: OpenAPI page#1853
k-yang wants to merge 1335 commits into
mainfrom
scripts/swagger-gen

Conversation

@k-yang

@k-yang k-yang commented Apr 23, 2024

Copy link
Copy Markdown
Collaborator

Purpose / Abstract

Creates an OpenAPI 2.0 (aka Swagger) page available at the LCD endpoint.

Screenshot 2024-04-23 at 3 05 40 PM

Summary by CodeRabbit

  • New Features

    • Introduced a new system for generating and updating Swagger documentation for the Nibiru Chain gRPC Gateway.
    • Added functionality to register Swagger routes using Gorilla mux for improved routing and static file serving.
  • Bug Fixes

    • Removed outdated imports and functions related to HTTP handling and Swagger API registration, ensuring cleaner and more efficient code.
  • Documentation

    • Updated Swagger documentation setup to support comprehensive REST interface documentation for various modules.

dependabot Bot and others added 30 commits July 1, 2023 23:44
)

* chore(deps): Bump bufbuild/buf-setup-action from 1.22.0 to 1.23.1

Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.22.0 to 1.23.1.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](bufbuild/buf-setup-action@v1.22.0...v1.23.1)

---
updated-dependencies:
- dependency-name: bufbuild/buf-setup-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
…1476)

bindings-perp contract + remove sudo permissioning
* fix(proto): use correct proto package

* fix(perp): check position changed event fields

* refactor: clean up code

* refactor: clean code

* chore: linter
* refactor(oracle)!: use typed events for exchange rate changes

* finish the move to typed events

* changelog

* refactor(oracle): rm unused constants file

* refactor(oracle)!: use ExchangeRateTuples instead of strings in event

* small typo in comments

* refactor(oracle)!: prefer "Price" to "ExchangeRate" in events
* fix(test): position changed event comparison

* refactor: use reflect.DeepEqual

* chore: linter
* feat(perp); add `MsgPartialClose`

* test(perp): partial close

* fix(test): position changed event comparison

* fix: margin to user assertion

* refactor: use reflect.DeepEqual

* chore: linter

* test(perp): partial close

* better error messaging

* add more descriptive error message

* test partial close with bad debt

* test(perp): partial close short positions

* feat(perp): partial close CLI

* Update CHANGELOG.md

* fix linter

* fix: tests
* fix some non conventional issues on sudo module

* linter

* remove old handler

* linter

* linter

* linter

* use constants

* linter
* add sudo root account cmd

* add sudo root command into cobra cli

* use make lint

* replace set validator as sudoer into script localnet

* add changelog
* ci: fix chaosnet for v0.21

* Update CHAOSNET.md

* use different mnemonics for liquidator, pricefeeder, and faucet

* Update chaosnet.sh
* chore(deps): Bump google.golang.org/grpc from 1.56.1 to 1.56.2

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.56.1 to 1.56.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.56.1...v1.56.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
* refactor: clean code

* refactor: clean code

* refactor: clean code

* refactor: clean code

* test(perp): fix RemoveMargin test

* fix(perp): allow closing positions with bad debt

* test(perp): close position tests

* test(perp): close short position

* test(perp): close long position with bad debt

* chore: remove redundant ClosePosition tests

* Update CHANGELOG.md

* refactor: clean code

* fix(perp): add bad debt check on partial close

* refactor: add context to error messages

* test(perp): partial close below maintenance margin ratio

* test(perp); partial close below mmr

* test(perp); partial close with bad debt

* test(perp): partial close short position with bad debt

* refactor: clean code

* fix: use updated AMM when calculating the margin ratio
* fix(spot): wire msg server to module

* chore(spot): remove handler

* test(spot): join pool cmd

* test(spot): create pool cmd

* test(spot): create pool errors

* refactor: rename testutil variables

* test(spot): create pool errors

* test(spot): create pool cmd

* test(spot): join stable pool

* test(spot): swap assets

* test(spot): swap stable assets cmd

* test(spot): exit pool cmd

* test(spot): exit stable pool cmd

* Update CHANGELOG.md

* refactor(epoch): remove unused methods

* refactor(inflation): remove unnecessary methods

* refactor(perp): clean up module

* refactor(spot): clean up module

* refactor(stablecoin): clean up module

* refactor(sudo): clean up module
* create msg change root proto

* use test keeper only for tests

* move convenience wrapper

* move convenience wrapper

* remove pb folder

* move files where convention rules

* split msg server from keeper

* split querier from keeper

* add message server change root command

* change root cli command

* add change root command

* add changelog

* add test trick for ordering
* remove commented code

* test(perp): reverse market order with bad debt

* test(perp): reverse market order with short position

* test(perp): more test cases

* Update CHANGELOG.md
* feat(proto): python buf template

* docs: comments to help with running proto gen in python

* feat(proto): python buf generation

* feat(localnet.sh): (1) Makes script run while offline. (2) Adds
--no-build option for external usage

* changelog
Bumps [github.com/holiman/uint256](https://github.com/holiman/uint256) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/holiman/uint256/releases)
- [Commits](holiman/uint256@v1.2.2...v1.2.3)

---
updated-dependencies:
- dependency-name: github.com/holiman/uint256
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

* chore(deps): Bump bufbuild/buf-setup-action from 1.23.1 to 1.24.0

Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.23.1 to 1.24.0.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](bufbuild/buf-setup-action@v1.23.1...v1.24.0)

---
updated-dependencies:
- dependency-name: bufbuild/buf-setup-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
* feat: add wasm oracle exchange rate query

* chore: changelog

* feat: let wasm contracts query exchange rates

* wip

* feat: adapt bindings types for the oracle price query

---------

Co-authored-by: Unique-Divine <realuniquedivine@gmail.com>
* add ledger build suppport

* update changelog
* chore(deps): Bump github.com/CosmWasm/wasmvm from 1.2.4 to 1.3.0

Bumps [github.com/CosmWasm/wasmvm](https://github.com/CosmWasm/wasmvm) from 1.2.4 to 1.3.0.
- [Release notes](https://github.com/CosmWasm/wasmvm/releases)
- [Changelog](https://github.com/CosmWasm/wasmvm/blob/main/CHANGELOG.md)
- [Commits](CosmWasm/wasmvm@v1.2.4...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/CosmWasm/wasmvm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

* chore(build): update wasmvm static lib version to download

* deps(build.mk): read the WASMVM_VERSION programattically with 'go list'

* fix merge conflict

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: Helder M <helder.moreira@voluzi.com>
Co-authored-by: Unique-Divine <realuniquedivine@gmail.com>
* test: add test for perp amm types

* test: simplify oneint onedec and add change reason and genesis tests

* test: more cleaning of mustnewdecfromstr(1)

* fix: revert removal of used functions

* test: add market test

* test: add msg tests

* chore: changelog

* test: add positions tests

* test: add snapshot test

* test: fix tests

* test: more tests for msgs

* test: fix tests for snapshot_test

* test: add more position test for validate

* test: remove bad test

* test: add more amm tests
…gh maps in x/oracle (#1506)

* refactor(oracle): Implement OrderedMap and use it for iterating through maps in x/oracle

* doc comments fix

* implement indexOf

* chore(deps): Bump github.com/CosmWasm/wasmvm from 1.2.4 to 1.3.0

Bumps [github.com/CosmWasm/wasmvm](https://github.com/CosmWasm/wasmvm) from 1.2.4 to 1.3.0.
- [Release notes](https://github.com/CosmWasm/wasmvm/releases)
- [Changelog](https://github.com/CosmWasm/wasmvm/blob/main/CHANGELOG.md)
- [Commits](CosmWasm/wasmvm@v1.2.4...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/CosmWasm/wasmvm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

* chore(build): update wasmvm static lib version to download

* deps(build.mk): read the WASMVM_VERSION programattically with 'go list'

* deps(build.mk): read the WASMVM_VERSION programattically with 'go list'

* fix merge conflict

* refactor: simplify data structure

* typo

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: Helder M <helder.moreira@voluzi.com>
* update post genesis commands

* temp commit

* add genmsg module

* add genmsg module

* bind genmsg into app.go

* remove script

* add init after wasm

* revert localnet

* add changelog

---------

Co-authored-by: Matthias <97468149+matthiasmatt@users.noreply.github.com>
helder-moreira and others added 21 commits March 5, 2024 22:54
* feat(inflation): add burn method

* Update CHANGELOG.md
* test(inflation): add negative burn tests

* test(inflation): add total supply check to burn tests
)

* chore(deps): Bump bufbuild/buf-setup-action from 1.29.0 to 1.30.0

Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.29.0 to 1.30.0.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](bufbuild/buf-setup-action@v1.29.0...v1.30.0)

---
updated-dependencies:
- dependency-name: bufbuild/buf-setup-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
* refactor: move Burn rpc method to x/tokenfactory

* Update tx_msgs.go

* feat: add burn native method to tokenfactory msg server

* feat: add cli cmd

* fix: validate msg

* feat: add v1.2.0 upgrade handler

* Update CHANGELOG.md

* fix: register codec for MsgBurnNative

* fix: test

---------

Co-authored-by: Unique-Divine <realuniquedivine@gmail.com>
* feat: rest in peace

* fix: fix e2e wasm test

* fix: fix justfile and deplyo-wasm

---------

Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
)

* chore(deps): Bump bufbuild/buf-setup-action from 1.30.0 to 1.30.1

Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.30.0 to 1.30.1.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](bufbuild/buf-setup-action@v1.30.0...v1.30.1)

---
updated-dependencies:
- dependency-name: bufbuild/buf-setup-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

---------

Signed-off-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
* feat(eth): protos, eth types, and evm module types

* chore: changelog

* feat(eth): unit tests for types, crypto, encoding (#1838)

* feat(eth): unit tests for types, crypto, encoding

## Impl `go-ethereum`

Adds `go-ethereum` fork with an `Interpreter` interface for running smart
contracts in integration tests.

```go
type Interpreter interface {
	// Run loops and evaluates the contract's code with the given input data and returns
	// the return byte-slice and an error if one occurred.
	Run(contract *Contract, input []byte, static bool) ([]byte, error)
}
```

An `Interpreter` is used to run Ethereum based contracts and will utilize the
passed environment to query external sources for state information.
The Interpreter will run the byte code VM based on the passed
configuration.

Changes from go-ethereum v1.11:

* Set `callcode` to use `readOnly` mode for precompiled calls.
* Remove `IsStateful` function from the `PrecompiledContract` interface, as this remains unused.
* Support stateful precompiled contracts.
* Add `Address` function to `PrecompiledContract` interface.
* Implement custom active precompiles for the EVM.
* Define `Interpreter` interface for the EVM.
* Move the `JumpTable` defaults to a separate function.
* Refactor `Stack` implementation

* chore: linter

* docs(sample.go): PrivKeyEth

* refactor: fix copyright lines and LICENSE entity

* feat(eth): Collections encoders for bytes, Ethereum addresses, and Ethereum hashes (#1841)
* fix(docker-chaosnet): add copy step for geth dependency

* chore: changelog

* ci: conditional workflows should account for other go.mod and go.sum files

* ci: changing docker changes the build, so it should be a dep

* fix(docker): test builds locally with 'docker build -d nibi-test .'
* feat: rest in peace

* fix: fix e2e wasm test

* fix: fix justfile and deplyo-wasm

* fix: update localnet

* feat: rest in peace

* fix(localnet.sh): change order of operations in genesis config

* fix(localnet.sh): change order of operations in genesis config

* rm unused file

---------

Co-authored-by: Unique-Divine <realuniquedivine@gmail.com>
Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
* chore(deps): Bump golang.org/x/net from 0.20.0 to 0.23.0

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.20.0 to 0.23.0.
- [Commits](golang/net@v0.20.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20210921155107-089bfa567519 to 0.17.0.
- [Commits](https://github.com/golang/crypto/commits/v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
...

Signed-off-by: Unique Divine <realuniquedivine@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
…001d to 0.23.0 in /geth (#1849)

* chore(deps): Bump golang.org/x/crypto in /geth

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20210921155107-089bfa567519 to 0.17.0.
- [Commits](https://github.com/golang/crypto/commits/v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): Bump golang.org/x/net in /geth

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.0.0-20220607020251-c690dde0001d to 0.23.0.
- [Commits](https://github.com/golang/net/commits/v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
Co-authored-by: Unique-Divine <realuniquedivine@gmail.com>
…154634-513d2456b344 to 0.3.11 in /geth (#1851)

* chore(deps): Bump github.com/supranational/blst in /geth

Bumps [github.com/supranational/blst](https://github.com/supranational/blst) from 0.3.8-0.20220526154634-513d2456b344 to 0.3.11.
- [Release notes](https://github.com/supranational/blst/releases)
- [Commits](https://github.com/supranational/blst/commits/v0.3.11)

---
updated-dependencies:
- dependency-name: github.com/supranational/blst
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
* chore(deps): Bump robinraju/release-downloader from 1.9 to 1.10

Bumps [robinraju/release-downloader](https://github.com/robinraju/release-downloader) from 1.9 to 1.10.
- [Release notes](https://github.com/robinraju/release-downloader/releases)
- [Commits](robinraju/release-downloader@v1.9...v1.10)

---
updated-dependencies:
- dependency-name: robinraju/release-downloader
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated changelog - dependabot

---------

Signed-off-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com>
Co-authored-by: Unique-Divine <Unique-Divine@users.noreply.github.com>
* ICA Host / Controller integration. Added upgrade constants. Added make format command

* Fixed required message URLs

* Code import fix

* Fixed upgrade name

* Fixed upgrade target

* Changed version number

* Update CHANGELOG.md

---------

Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: Kevin Yang <5478483+k-yang@users.noreply.github.com>
@k-yang
k-yang marked this pull request as ready for review April 23, 2024 20:06
@k-yang
k-yang requested a review from a team as a code owner April 23, 2024 20:06
@coderabbitai

coderabbitai Bot commented Apr 23, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The 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

File Pattern Change Summary
app/app.go Removed HTTP and Swagger-related imports and functions.
app/keepers.go Removed import related to static Swagger files.
app/swagger.go, contrib/... Added mechanisms for Swagger route registration and documentation generation and handling.
proto/buf.gen.swagger.yaml Added configuration for generating Swagger documentation from protobuf.

🐇✨
In the code's garden, changes bloom,
Docs sprout up, clearing the gloom.
Swagger paths, now neatly laid,
With protobuf tales, the docs are made.
Hoppily crafting, on we zoom! 🚀
🐇💻


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 6aff6ad and 79ad315.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments not posted (1)
CHANGELOG.md (1)

52-52: The changelog entry for the addition of Swagger documentation is clear and well-formatted.


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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 4

Comment thread app/swagger.go
Comment on lines +13 to +22
// 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))
}

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.

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.

Suggested change
// 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

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.

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.

Suggested change
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

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.

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.

Suggested change
buf generate --template buf.gen.swagger.yaml $query_file
buf generate --template buf.gen.swagger.yaml "$query_file"

Comment thread contrib/make/swagger.mk
Comment on lines +14 to +16
ifeq ($(GO),)
$(error could not find go. Is it in PATH? $(GO))
endif

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.

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.

Suggested change
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

@Unique-Divine
Unique-Divine force-pushed the main branch 4 times, most recently from 22fb261 to ac05154 Compare July 2, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants