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-ui and bundle it directly #95

Conversation

uvulpos
Copy link
Contributor

@uvulpos uvulpos commented Jul 3, 2024

The upstream dependency https://github.com/swaggo/files seems unmaintained so I decided to bundle it directly into this gofiber packages so people can use newer versions of swagger.

Origin repo uses a submodule for this, I'm not too familiar with submodules and to automate this process, but this could be a good enhancement to run this periodically via github actions.

I ran the tests command but please test it yourself again please!

fixes #91
fixes #51

Summary by CodeRabbit

  • Documentation

    • Added instructions for setting up Swagger and Swagger UI in a Go project.
  • New Features

    • Introduced functionality to embed Swagger UI files in a Go package.
  • Refactor

    • Updated filesystem configuration for Swagger UI to use the new SwaggerFileSystem.

Copy link

coderabbitai bot commented Jul 3, 2024

Warning

Rate limit exceeded

@uvulpos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 20 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 74ce35d and d373a9a.

Walkthrough

The recent updates introduce Swagger and Swagger UI setup instructions for a Go project, explaining the installation of Swag, generating documentation, and configuring the Swagger UI. Additionally, they modify existing code to embed Swagger UI files into the Go application. These changes enhance the ability to document and visualize APIs within the application.

Changes

Files Change Summary
README.md Added instructions for setting up and accessing Swagger UI, including installing and running Swag.
files.go Introduced functionality to embed Swagger UI files through an embedded file system.
swagger.go Updated references from swaggerFiles to SwaggerFileSystem and modified import statements.

Poem

🌟 Amidst the codes where logic resides,
Swagger now flows, with joy it presides.
Documentation blooms, a map so clear,
Through embedded files, it's all right here.
Visions of APIs, in a UI so grand,
Celebrate the change, in this code-filled land. 🚀


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.

Copy link

@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: 1

Outside diff range and nitpick comments (6)
README.md (6)

15-15: Change 'by using' to 'to'.

The preposition ‘to’ seems more likely in this position.

- go get -u github.com/swaggo/swag/cmd/swag
+ go get -u github.com/swaggo/swag/cmd/swag
# 1.16 or newer
- go install github.com/swaggo/swag/cmd/swag@latest
+ go install github.com/swaggo/swag/cmd/swag@latest

34-34: Add 'the' before 'following'.

You might be missing the article “the” here.

- And import following in your code:
+ And import the following in your code:
Tools
LanguageTool

[uncategorized] ~34-~34: You might be missing the article “the” here.
Context: ...hub.com/gofiber/swagger And import following in your code: go import "github.com...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


86-86: Replace hard tab with spaces.

Hard tabs are used here; replace them with spaces for consistency.

-	_ "github.com/gofiber/swagger/example/docs"
+    _ "github.com/gofiber/swagger/example/docs"

87-87: Avoid bare URLs in Markdown.

Use Markdown syntax for links instead of bare URLs.

- Run it, and browser to http://localhost:8080/swagger, you can see Swagger 2.0 Api documents.
+ Run it, and browse to [http://localhost:8080/swagger](http://localhost:8080/swagger), you can see Swagger 2.0 API documents.
Tools
Markdownlint

87-87: null
Bare URL used

(MD034, no-bare-urls)


89-89: Remove trailing punctuation in heading.

Trailing punctuation in the heading should be removed.

- ### Version Note:
+ ### Version Note
Tools
Markdownlint

89-89: Punctuation: ':'
Trailing punctuation in heading

(MD026, no-trailing-punctuation)


91-91: Fix typo and improve readability.

There is a typo in 'specifications' and the format can be improved for readability.

- Swagger-UI currently runs on version 5.0.0 and supports OpenAPI sepcifications from
+ Swagger-UI currently runs on version 5.0.0 and supports OpenAPI specifications from:
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fce41f4 and 74ce35d.

Files ignored due to path filters (20)
  • dist/favicon-16x16.png is excluded by !**/dist/**, !**/*.png, !dist/**, !**/*.png
  • dist/favicon-32x32.png is excluded by !**/dist/**, !**/*.png, !dist/**, !**/*.png
  • dist/index.css is excluded by !**/dist/**, !dist/**
  • dist/index.html is excluded by !**/dist/**, !dist/**
  • dist/oauth2-redirect.html is excluded by !**/dist/**, !dist/**
  • dist/swagger-initializer.js is excluded by !**/dist/**, !dist/**
  • dist/swagger-ui-bundle.js is excluded by !**/dist/**, !dist/**
  • dist/swagger-ui-bundle.js.map is excluded by !**/dist/**, !**/*.map, !dist/**, !**/*.map
  • dist/swagger-ui-es-bundle-core.js is excluded by !**/dist/**, !dist/**
  • dist/swagger-ui-es-bundle-core.js.map is excluded by !**/dist/**, !**/*.map, !dist/**, !**/*.map
  • dist/swagger-ui-es-bundle.js is excluded by !**/dist/**, !dist/**
  • dist/swagger-ui-es-bundle.js.map is excluded by !**/dist/**, !**/*.map, !dist/**, !**/*.map
  • dist/swagger-ui-standalone-preset.js is excluded by !**/dist/**, !dist/**
  • dist/swagger-ui-standalone-preset.js.map is excluded by !**/dist/**, !**/*.map, !dist/**, !**/*.map
  • dist/swagger-ui.css is excluded by !**/dist/**, !dist/**
  • dist/swagger-ui.css.map is excluded by !**/dist/**, !**/*.map, !dist/**, !**/*.map
  • dist/swagger-ui.js is excluded by !**/dist/**, !dist/**
  • dist/swagger-ui.js.map is excluded by !**/dist/**, !**/*.map, !dist/**, !**/*.map
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
Files selected for processing (3)
  • README.md (2 hunks)
  • files.go (1 hunks)
  • swagger.go (2 hunks)
Additional context used
LanguageTool
README.md

[uncategorized] ~14-~14: The preposition ‘to’ seems more likely in this position.
Context: ... Swag for Go by using: ```sh go get -u github.co...

(AI_HYDRA_LEO_REPLACE_FOR_TO)


[uncategorized] ~34-~34: You might be missing the article “the” here.
Context: ...hub.com/gofiber/swagger And import following in your code: go import "github.com...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

Markdownlint
README.md

83-83: Column: 1
Hard tabs

(MD010, no-hard-tabs)


89-89: Punctuation: ':'
Trailing punctuation in heading

(MD026, no-trailing-punctuation)


87-87: null
Bare URL used

(MD034, no-bare-urls)

Additional comments not posted (2)
files.go (1)

1-1: LGTM!

The package declaration and imports look correct and appropriate for embedding files.

swagger.go (1)

Line range hint 1-1:
LGTM!

The package declaration, imports, and constants look correct. The New function has been updated to use the embedded Swagger files.

files.go Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@gaby
Copy link
Member

gaby commented Jul 3, 2024

@uvulpos The dependency is not unmaintained, probably worth doing a PR there instead of merging all this code here.

@uvulpos
Copy link
Contributor Author

uvulpos commented Jul 4, 2024

@gaby I made a ping comment to the abandoned pr to merge a newer version see here. Also there was just one feature pr merged last year

And also by merging it to our own code, we could solve the google font api request. Should be fine in most countries, but in europe this could be an issue. There were incidents where companies and individual website hosts got fined for requesting google fonts before asking because of the GDPR. This way it would be more safety regarding legal issues

@uvulpos
Copy link
Contributor Author

uvulpos commented Jul 4, 2024

Since swaggo/files updated their repo, this is obsolet

@uvulpos uvulpos closed this Jul 4, 2024
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.

Go fiber swagger Swag v2 support
2 participants