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

Update swagger generation for 1.19 #2070

Merged
merged 9 commits into from
Jul 10, 2024
Merged

Update swagger generation for 1.19 #2070

merged 9 commits into from
Jul 10, 2024

Conversation

iramiller
Copy link
Member

@iramiller iramiller commented Jul 9, 2024

Description

This PR updates the swagger generation to use the new format that removes statik and switches to native go embed. It also updates the description, target version (from 1.13 to 1.19), and changes the tagging of method endpoints to they are grouped by module and Cosmos SDK instead of a large list of "Query" and "Service" endpoints.

closes: #2063


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

Summary by CodeRabbit

  • New Features

    • Enhanced Swagger API documentation with updated descriptions, version, and endpoint tags.
    • Introduced functionality to embed the swagger-ui directory.
  • Refactor

    • Updated RegisterSwaggerAPI function signature to include a swaggerEnabled parameter.
    • Modified script paths and processing in protoc-swagger-gen.sh.
  • Chores

    • Removed statik tool and related dependencies, simplifying project configuration.
    • Updated pre-commit hooks to streamline formatting checks.

@iramiller iramiller requested a review from a team as a code owner July 9, 2024 21:39
Copy link
Contributor

coderabbitai bot commented Jul 9, 2024

Walkthrough

The recent changes across multiple files improve the Swagger API documentation, replace the outdated statik tool with Go's native embed package, and refine the Go build process. These updates ensure better API method categorization, modern dependency handling, and an updated Swagger UI, enhancing the usability and maintainability of the codebase.

Changes

Files/Paths Summary of Changes
.golangci.yml Removed import of github.com/rakyll/statik/fs
CHANGELOG.md Added an update to the Swagger API documentation
Makefile Modified format target, removed update-swagger-docs target
app/app.go Refactored imports, function signature change in RegisterSwaggerAPI
client/docs/config.json Updated description, version, added tags
client/docs/embed.go Introduced embedding functionality using the embed package
client/docs/swagger-ui/oauth2-redirect.html Added <head> section, script modifications, improved error messages
contrib/devtools/Makefile Removed statik tool installation and logic
contrib/githooks/pre-commit Removed condition related to client/lcd/statik/ in formatting check
go.mod Removed github.com/rakyll/statik v0.1.7 dependency
scripts/protoc-swagger-gen.sh Modified output path, added steps to strip specific tags in swagger file
client/docs/README.md Replaced make update-swagger-docs with make proto-swagger-gen

Assessment against linked issues

Objective Addressed Explanation
Update the swagger/openapi build flow with additional documentation (Issue #2063)
Move to the go embed flow from the existing statik compiled resource approach (Issue #2063)
Update to current versions of the swagger bundled css/javascript (Issue #2063)

Poem

In the code, a change was clear,
Swagger docs, now with cheer.
Goodbye statik, embed took reign,
APIs neat, no more pain.
Rabbit hops, in joy so true,
For clean and tidy, code anew.
🌟🐇✨


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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.

scirner22
scirner22 previously approved these changes Jul 9, 2024
@iramiller iramiller marked this pull request as draft July 9, 2024 21:43
@iramiller iramiller marked this pull request as ready for review July 9, 2024 21:48
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 770401f and b0d1782.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (11)
  • .golangci.yml (1 hunks)
  • CHANGELOG.md (1 hunks)
  • Makefile (2 hunks)
  • app/app.go (6 hunks)
  • client/docs/config.json (3 hunks)
  • client/docs/embed.go (1 hunks)
  • client/docs/swagger-ui/oauth2-redirect.html (4 hunks)
  • contrib/devtools/Makefile (4 hunks)
  • contrib/githooks/pre-commit (1 hunks)
  • go.mod (1 hunks)
  • scripts/protoc-swagger-gen.sh (1 hunks)
Files skipped from review due to trivial changes (2)
  • .golangci.yml
  • go.mod
Additional comments not posted (17)
client/docs/embed.go (1)

1-6: LGTM! The use of Go embed is appropriate.

The Go embed package is correctly used to embed the swagger-ui directory.

contrib/githooks/pre-commit (1)

28-30: LGTM! The exclusion of generated files is appropriate.

The changes ensure that generated files are not formatted, which is a good practice.

scripts/protoc-swagger-gen.sh (1)

32-38: LGTM! The changes to the swagger generation process are appropriate.

The updates to combine swagger files and strip specific tags improve the organization of the generated files.

client/docs/swagger-ui/oauth2-redirect.html (2)

3-5: LGTM! The addition of the <head> section is appropriate.

Adding the <head> section is a good practice for HTML documents.


16-27: LGTM! The improvements to the script conditions are appropriate.

The changes enhance the JavaScript logic and improve readability.

contrib/devtools/Makefile (1)

53-53: Approved: Removal of statik tool installation logic.

The removal aligns with the PR objectives. Ensure no additional dependencies on statik remain.

client/docs/config.json (4)

5-5: Approved: Update of description.

The description change to "Provenance Blockchain Protocol API" aligns with the PR objectives.


6-6: Approved: Update of version.

The version update to "1.19.0" aligns with the PR objectives.


11-15: Approved: Addition of tags for endpoints.

The addition of tags improves the organization of the Swagger documentation.

Also applies to: 23-28, 32-36, 44-49, 52-57, 60-65, 69-73, 81-86, 90-94, 104-109, 113-117, 126-131, 135-139, 147-152, 156-160, 168-173, 176-181, 184-189, 193-197, 205-210, 213-218, 221-226, 229-234, 237-242, 245-258


249-257: Approved: Addition of "Cosmos SDK" tag and exclusion of "cosmos/nft/.*" path.

These changes align with the PR objectives of improving method grouping and documentation.

Makefile (2)

290-290: Approved: Update of formatting command.

The changes align with the PR objectives of updating the build process and excluding specific paths.


292-292: Approved: Update of goimports command.

The changes improve the formatting process and align with the PR objectives.

app/app.go (4)

6-6: Import statement for io/fs looks good.

The addition of io/fs is necessary for the new implementation of the RegisterSwaggerAPI function.


140-140: Import statement for github.com/provenance-io/provenance/client/docs looks good.

The addition of client/docs is necessary for embedding the Swagger UI files.


1322-1323: Function signature change looks good.

The function signature of RegisterSwaggerAPI was modified to include a swaggerEnabled boolean parameter and return an error. This change is necessary for the new Swagger generation process.


1324-1336: New implementation of RegisterSwaggerAPI looks good.

The function now conditionally registers the Swagger API based on the swaggerEnabled parameter and handles errors appropriately. The use of io/fs and client/docs is correct for embedding the Swagger UI files.

CHANGELOG.md (1)

48-48: Changelog entry looks good.

The entry for updating the Swagger API documentation is clear and follows the existing format.

Makefile Show resolved Hide resolved
app/app.go Show resolved Hide resolved
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 b0d1782 and d0d0379.

Files selected for processing (2)
  • Makefile (3 hunks)
  • client/docs/README.md (1 hunks)
Files skipped from review due to trivial changes (1)
  • client/docs/README.md
Files skipped from review as they are similar to previous changes (1)
  • Makefile

@iramiller iramiller merged commit fae7a8b into main Jul 10, 2024
32 checks passed
@iramiller iramiller deleted the 2063-update-swagger branch July 10, 2024 18:01
SpicyLemon added a commit that referenced this pull request Jul 11, 2024
* Mark v1.19.0-rc1. (#2051)

* Mark v1.19.0-rc1 in the changelog.

* Create release changelog.

* remove statik for go:embed

* updated swagger-ui components

* updated swagger gen to filter extra tags

* fix changelog

* remove release changelog that should not be on main

* fix spelling error in comment

* update swagger makefile generation references

---------

Co-authored-by: Daniel Wedul <[email protected]>
SpicyLemon added a commit that referenced this pull request Jul 11, 2024
* Mark v1.19.0-rc1. (#2051)

* Mark v1.19.0-rc1 in the changelog.

* Create release changelog.

* remove statik for go:embed

* updated swagger-ui components

* updated swagger gen to filter extra tags

* fix changelog

* remove release changelog that should not be on main

* fix spelling error in comment

* update swagger makefile generation references

---------

Co-authored-by: Ira Miller <[email protected]>
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.

Update swagger documentation
4 participants