Skip to content

Conversation

@DurgaPrasad-54
Copy link
Contributor

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

Add Swagger Json Automation file swagger-json.yml and application-swagger.properties

Summary by CodeRabbit

  • New Features

    • Automated Swagger/OpenAPI extraction and sync to the docs repository via a workflow-triggered pull request.
    • Dedicated Swagger runtime profile and configuration to generate Swagger/OpenAPI docs during execution.
  • Chores

    • Added H2 database runtime support.
    • README updated with an additional badge.
    • Redis configuration excluded under the Swagger profile.

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow to build and run the API and sync its Swagger JSON to AMRIT-Docs; introduces a swagger profile properties file and H2 runtime dependency; marks RedisConfig to be disabled for the swagger profile; updates README badges.

Changes

Cohort / File(s) Summary
CI workflow
.github/workflows/swagger-json.yml
New workflow "Sync Swagger to AMRIT-Docs": checks out repo, sets up Java/Maven, builds and runs API (swagger profile), polls /v3/api-docs, validates JSON with jq, saves inventory-api.json into AMRIT-Docs, and creates a PR.
Swagger runtime properties
src/main/resources/application-swagger.properties
New properties file for running the app in a swagger profile (H2 in-memory config, Hibernate settings, CORS, logging, JWT placeholder, lookup URLs).
Build / Dependencies
pom.xml
Added runtime dependency com.h2database:h2.
Config profile change
src/main/java/com/iemr/inventory/config/RedisConfig.java
Annotated RedisConfig and its redisTemplate bean with @Profile("!swagger") to disable Redis beans when swagger profile is active.
Documentation
README.md
Added DeepWiki badge next to GPL v3 license badge in header.

Sequence Diagram(s)

sequenceDiagram
    participant GH as "GitHub Actions"
    participant Repo as "API repo"
    participant Maven as "Java 17 / Maven"
    participant API as "Local API (swagger profile)"
    participant Validator as "jq / HTTP"
    participant Docs as "AMRIT-Docs repo"
    participant GitHub as "GitHub (PR)"

    GH->>Repo: checkout code (full history)
    GH->>Maven: setup Java 17 & build (skip tests)
    GH->>API: start app on :9090 (background)
    API-->>GH: PID & logs
    loop poll up to 40 times (4s interval)
        GH->>API: GET /v3/api-docs
        API-->>GH: 200 + JSON or non-200
    end
    GH->>Validator: validate JSON (ensure non-empty paths)
    alt valid JSON
        GH->>Docs: checkout amrit-docs via token
        GH->>Docs: copy inventory-api.json -> docs/swagger/
        GH->>GitHub: commit branch & create PR (auto-delete branch)
    else invalid / timeout
        GH->>GH: dump logs, fail job
    end
    GH->>API: stop process (graceful then force)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

"I hopped through logs at crack of dawn,
I chased the JSON, fetched and drawn,
With tiny paws a PR I made—
Docs refreshed beneath the glade. 🐇"

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: automating Swagger JSON synchronization to the AMRIT-Docs repository via GitHub Actions workflow.

✏️ 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 6-9: The swagger profile currently sets
spring.data.redis.host/port but does not disable Redis auto-configuration;
update the application-swagger properties to explicitly exclude Redis
auto-configuration by adding the spring.autoconfigure.exclude property
referencing
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration (and
optionally
org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration)
so Spring Boot won't attempt to connect to Redis during the swagger profile.
🧹 Nitpick comments (2)
src/main/resources/application-swagger.properties (1)

15-16: Avoid committing a default JWT secret.

The fallback secret can be reused accidentally in shared environments. Prefer requiring JWT_SECRET_KEY (and set it in the workflow) or generate a per-run secret.

🔐 Suggested update
-jwt.secret=${JWT_SECRET_KEY:default-swagger-secret-change-me}
+jwt.secret=${JWT_SECRET_KEY}
.github/workflows/swagger-json.yml (1)

69-74: Prefer graceful shutdown before SIGKILL.

SIGKILL skips cleanup; a brief SIGTERM attempt is safer and still deterministic.

🛠️ Suggested change
-          if [ -f api_pid.txt ]; then
-            kill -9 $(cat api_pid.txt) || true
-          fi
+          if [ -f api_pid.txt ]; then
+            PID=$(cat api_pid.txt)
+            kill "$PID" || true
+            sleep 5
+            kill -9 "$PID" || true
+          fi

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/java/com/iemr/inventory/config/RedisConfig.java`:
- Around line 36-39: RoleMasterApplication.redisTemplate() is still being
created when the swagger profile is active, causing missing
LettuceConnectionFactory and injection failures for RedisTemplate in
JwtAuthenticationUtil and TokenDenylist; either annotate the redisTemplate()
method with `@Profile`("!swagger") or move its bean definition into RedisConfig so
the existing `@Profile`("!swagger") on RedisConfig covers it, ensuring the bean
depends on LettuceConnectionFactory and is excluded when swagger is active.

@sonarqubecloud
Copy link

@drtechie drtechie merged commit 152acd0 into PSMRI:main Feb 11, 2026
2 of 3 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