-
Notifications
You must be signed in to change notification settings - Fork 45
Swagger json Automation #186
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
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. 📝 WalkthroughWalkthroughAdds a GitHub Actions workflow to build the API, run it with a Swagger profile, extract and validate OpenAPI JSON, and open a PR to sync that JSON into the AMRIT-Docs repo. Also adds H2 runtime dependency, a swagger configuration properties file, and a README badge change. Changes
Sequence Diagram(s)sequenceDiagram
participant GHA as GitHub Actions
participant Checkout as Checkout API Repo
participant Build as Maven Build (skip tests)
participant API as API Service (swagger profile, port 9090)
participant Endpoint as /v3/api-docs
participant Docs as AMRIT-Docs Repo
participant PR as Create Pull Request
GHA->>Checkout: checkout api repo
GHA->>Build: build (Java 17, Maven, skip tests)
GHA->>API: start service (swagger profile)
loop poll for up to ~30 attempts
GHA->>Endpoint: GET /v3/api-docs
Endpoint-->>GHA: HTTP 200/other
end
GHA->>GHA: validate & pretty-print JSON (jq)
GHA->>API: stop service (kill PID)
GHA->>Docs: checkout amrit-docs (token)
GHA->>Docs: copy hwc-api.json -> docs/swagger/
GHA->>PR: create PR branch auto/swagger-update-${run_id}
PR-->>Docs: PR opened
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/main/resources/application-swagger.properties`:
- Around line 59-64: Duplicate property jwt.secret is defined twice; remove the
redundant literal definition "jwt.secret=JWT_SECRET" and keep the
environment-backed entry
"jwt.secret=${JWT_SECRET_KEY:default-swagger-secret-change-me}" so the file only
contains the single environment-variable-based jwt.secret configuration; update
any comments if needed and ensure no other occurrences of jwt.secret remain
duplicated in this resource.
🧹 Nitpick comments (3)
src/main/resources/application-swagger.properties (1)
18-19: Dummy credentials are acceptable for swagger profile, but consider adding a comment.The dummy values (
dummyAuthKey,dummyAuthSecret) are appropriate for a documentation-only profile. Consider adding a brief comment similar to lines 39-46 to clarify these are intentional placeholders for the swagger profile..github/workflows/swagger-json.yml (2)
38-57: Consider checking if the API process is still alive during the polling loop.The polling loop waits up to 150 seconds (30 iterations × 5 seconds), but if the API crashes during startup, the loop continues waiting unnecessarily. You could check if the process is still running and fail fast:
♻️ Proposed improvement
- name: Wait for API & fetch Swagger run: | for i in {1..30}; do + # Check if API process is still running + if [ -f api_pid.txt ] && ! kill -0 $(cat api_pid.txt) 2>/dev/null; then + echo "API process died unexpectedly" + cat app.log || true + exit 1 + fi CODE=$(curl --connect-timeout 2 --max-time 5 -s -o swagger_raw.json -w "%{http_code}" http://localhost:9090/v3/api-docs || true) if [ "$CODE" = "200" ]; then if jq . swagger_raw.json > hwc-api.json; then
3-6: Consider using a static branch name to update existing PRs instead of creating new ones.Using
github.run_idin the branch name (line 83) creates a unique branch for each workflow run. If multiple pushes tomainoccur before the PR is merged, this will result in multiple open PRs accumulating.Consider using a static branch name like
auto/swagger-updateso subsequent runs update the existing PR rather than creating new ones:♻️ Proposed fix
- name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.DOCS_REPO_TOKEN }} path: amrit-docs - branch: auto/swagger-update-${{ github.run_id }} + branch: auto/swagger-update base: main commit-message: Auto-update HWC-API swagger title: Auto-update HWC-API swaggerAlso applies to: 83-83
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: 2
🤖 Fix all issues with AI agents
In `@src/main/resources/application-swagger.properties`:
- Around line 18-19: Replace hard-coded secrets with environment-backed property
placeholders: change authKey, authSecret, and foetalMonitorAPIKey to use
Spring-style placeholders like authKey=${AUTH_KEY:}, authSecret=${AUTH_SECRET:},
foetalMonitorAPIKey=${FOETAL_MONITOR_API_KEY:} (or provide a non-secret safe
default) so values come from environment variables; update any code/config that
expects these exact property names to continue using authKey, authSecret, and
foetalMonitorAPIKey but no longer rely on literal secret strings.
- Around line 52-55: The swagger profile comments claim Redis is disabled but
only sets spring.redis.host and spring.redis.port, which can still trigger Redis
auto-configuration; remove or blank out spring.redis.host/port and explicitly
disable Redis auto-configuration by adding
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
(or set spring.redis.enabled=false if your Spring Boot version supports it) in
the same application-swagger.properties so the Redis auto-config won't attempt a
connection during swagger runs.
| # Disable Redis if not needed for docs (optional) | ||
| spring.redis.host=localhost | ||
| spring.redis.port=6379 | ||
|
|
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.
Redis isn’t actually disabled for the swagger profile.
The comment says “Disable Redis,” but only host/port are set. This may still trigger Redis auto-configuration and connection attempts during swagger runs.
🔧 Suggested change
# Disable Redis if not needed for docs (optional)
-spring.redis.host=localhost
-spring.redis.port=6379
+spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration🤖 Prompt for AI Agents
In `@src/main/resources/application-swagger.properties` around lines 52 - 55, The
swagger profile comments claim Redis is disabled but only sets spring.redis.host
and spring.redis.port, which can still trigger Redis auto-configuration; remove
or blank out spring.redis.host/port and explicitly disable Redis
auto-configuration by adding
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
(or set spring.redis.enabled=false if your Spring Boot version supports it) in
the same application-swagger.properties so the Redis auto-config won't attempt a
connection during swagger runs.
|



Summary by CodeRabbit
Documentation
New Features
Infrastructure