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

Swagger: Add support for File Content #1085

Merged
merged 4 commits into from
Apr 26, 2024

Conversation

willfaught
Copy link
Contributor

@willfaught willfaught commented Apr 20, 2024

I need to be able to embed a swagger.json file into a Go program using the embed package. Config.FileContent enables that.

Summary by CodeRabbit

  • New Features
    • Enhanced API documentation capabilities by allowing Swagger file content to be provided directly, in addition to the traditional file path method.
  • Tests
    • Added comprehensive tests for new Swagger file handling configurations and multiple API documentation instances.

@willfaught willfaught requested a review from a team as a code owner April 20, 2024 20:12
@willfaught willfaught requested review from gaby, sixcolors, ReneWerner87 and efectn and removed request for a team April 20, 2024 20:12
Copy link

coderabbitai bot commented Apr 20, 2024

Walkthrough

The latest update enriches the Swagger middleware by enabling direct input of Swagger file content through FileContent, offering an alternative to FilePath when FileContentis provided. This enhancement ensures that the Swagger file is only read fromFilePathifFileContent` is empty, enhancing flexibility in managing the file.

Changes

File Change Summary
swagger/swagger.go Introduced support for supplying Swagger file content directly via FileContent.
swagger/swagger_test.go Enhanced logic to handle FileContent and expanded test coverage for various configurations.
swagger/README.md Updated swagger.Config declaration in the README to include FileContent []byte.

A Poem by CodeRabbit

🐇 In the realm of code, where ideas take flight,
📄 A new path emerges, shining bright.
🌟 Swagger evolves with a twist so fine,
🗂️ Content or path, now the choice is thine.
🎉 Celebrate the update, a leap so sly,
🚀 Towards API greatness, we joyfully fly!


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.

@willfaught
Copy link
Contributor Author

Synced my fork. Rebased on main.

@gaby gaby changed the title Add Config.FileContent swagger: Add support for FileContent Apr 20, 2024
@gaby gaby changed the title swagger: Add support for FileContent swagger: Add support for File Content Apr 20, 2024
@gaby gaby added the ✏️ Feature New feature or request label Apr 20, 2024
@gaby gaby changed the title swagger: Add support for File Content Swagger: Add support for File Content Apr 21, 2024
Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

Overall looks good, reorder the New() and add swagger.json to be used for FileContent testing that's different than the current one.

For example copy the current swagger.json, change the version # and make a new file. Use this file in the test verify the file returned has that version instead of the current one.

swagger/swagger.go Show resolved Hide resolved
swagger/swagger_test.go Show resolved Hide resolved
@sixcolors
Copy link
Member

@willfaught looks open to me....

@gaby
Copy link
Member

gaby commented Apr 21, 2024

@willfaught looks open to me....

Different PR, the previous one was closed

Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

LGTM

@gaby
Copy link
Member

gaby commented Apr 22, 2024

Ping @gofiber/maintainers

Copy link
Member

@ReneWerner87 ReneWerner87 left a comment

Choose a reason for hiding this comment

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

  • documentation missing

swagger/swagger.go Show resolved Hide resolved
@ReneWerner87
Copy link
Member

@willfaught can you please add a description for the new feature in the markdown files and maybe an example
otherwise hardly anyone will discover and use the feature

@willfaught
Copy link
Contributor Author

willfaught commented Apr 26, 2024

@ReneWerner87 f0070f2

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

Out of diff range and nitpick comments (1)
swagger/README.md (1)

118-122: ### Document the precedence of FileContent over FilePath
The documentation for FileContent in the Config structure does not explicitly mention that it takes precedence over FilePath if both are provided. This is a crucial piece of information that can affect how users configure their Swagger middleware. Consider adding a note here to clarify this behavior.

swagger/README.md Show resolved Hide resolved
@gaby gaby requested a review from ReneWerner87 April 26, 2024 04:07
@ReneWerner87 ReneWerner87 merged commit 75d4ee6 into gofiber:main Apr 26, 2024
59 checks passed
@willfaught willfaught deleted the filecontent branch April 28, 2024 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants