Skip to content

Conversation

@DurgaPrasad-54
Copy link
Contributor

@DurgaPrasad-54 DurgaPrasad-54 commented Feb 4, 2026

Summary by CodeRabbit

  • Documentation

    • Added DeepWiki badge to README.
  • New Features

    • Automated workflow to synchronize API documentation with the docs repository.
  • Infrastructure

    • Added H2 runtime support for development.
    • Added Swagger-profile configuration to support API documentation generation and related defaults.

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

Warning

Rate limit exceeded

@DurgaPrasad-54 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 45 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.

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
CI/CD Automation
​.github/workflows/swagger-json.yml
New workflow "Sync Swagger to AMRIT-Docs": checks out and builds the API (Java 17/Maven), runs it on port 9090 with swagger profile, polls /v3/api-docs, validates/pretty-prints with jq, stops the API, checks out AMRIT-Docs, copies hwc-api.json, and creates a PR via peter-evans/create-pull-request.
Configuration & Dependencies
pom.xml, src/main/resources/application-swagger.properties
Added runtime dependency com.h2database:h2. Added application-swagger.properties containing Swagger UI/service endpoints, H2 (in-memory) DB settings, Redis, CORS, JWT fallback, logging, and feature toggles for the swagger profile.
Documentation
README.md
Inserted a DeepWiki badge next to the GPLv3 license badge and adjusted spacing.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I hopped the build and fetched the spec,
Polished JSON tidy, neat and checked,
H2 tucked in for transient state,
A badge to wink at docs' new fate,
The rabbit stamps: "PR created—let's celebrate!" 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly relates to the main change—introducing GitHub Actions workflow automation for Swagger JSON generation and synchronization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🤖 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_id in the branch name (line 83) creates a unique branch for each workflow run. If multiple pushes to main occur before the PR is merged, this will result in multiple open PRs accumulating.

Consider using a static branch name like auto/swagger-update so 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 swagger

Also applies to: 83-83

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: 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.

Comment on lines 52 to 55
# Disable Redis if not needed for docs (optional)
spring.redis.host=localhost
spring.redis.port=6379

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

@sonarqubecloud
Copy link

@drtechie drtechie merged commit ca5dc75 into PSMRI:main Feb 11, 2026
2 checks passed
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.

2 participants