-
Notifications
You must be signed in to change notification settings - Fork 25
refactor(docs): extract Swagger UI into template #85
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
base: main
Are you sure you want to change the base?
refactor(docs): extract Swagger UI into template #85
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📒 Files selected for processing (2)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughThis PR refactors Swagger UI documentation rendering from hard-coded inline HTML to an external embedded template file. The Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
4 files reviewed, 1 comment
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: 1
🤖 Fix all issues with AI agents
In `@gateway/main.go`:
- Around line 141-152: The /docs handler currently calls
swaggerTmpl.Execute(c.Writer, data) which can leave Content-Type unset and may
write partial output before an error; update the handler that uses
getSwaggerUIVersion() and swaggerTmpl to render into a bytes.Buffer first, check
Execute error before writing to the gin.ResponseWriter, set the Content-Type
header to "text/html; charset=utf-8" on the gin.Context (c.Header or
c.Writer.Header) and only write the buffered content to c.Writer if Execute
succeeded, otherwise return a proper 500 response without sending partial HTML.
🧹 Nitpick comments (1)
gateway/templates/swagger.html (1)
1-18: LGTM! Clean Swagger UI template.The template correctly uses Go's template syntax for version injection, and the version is validated by regex in
main.gopreventing injection attacks.Consider these optional enhancements for better HTML standards compliance:
📝 Optional: Add charset and lang attribute
<!DOCTYPE html> -<html> +<html lang="en"> <head> + <meta charset="UTF-8"> <title>MicroAI Paygate API Docs</title>
4518952 to
4b16ea5
Compare
|
@Vaishnavi-Iyer67 what are the uses of this? |
What this PR does
main.gointo a dedicated templatego:embedSWAGGER_UI_VERSION5.11.0) when env var is missing or invalidWhy this change
How to test
Context used:
dashboard- AGENTS.md (source)