Skip to content

chore(swagger): add env-driven servers to OpenAPI config#119

Open
DurgaPrasad-54 wants to merge 14 commits intoPSMRI:mainfrom
DurgaPrasad-54:main
Open

chore(swagger): add env-driven servers to OpenAPI config#119
DurgaPrasad-54 wants to merge 14 commits intoPSMRI:mainfrom
DurgaPrasad-54:main

Conversation

@DurgaPrasad-54
Copy link
Contributor

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

Adds Dev/UAT/Demo servers to OpenAPI config using env vars and avoids hardcoded live defaults.

Summary by CodeRabbit

Release Notes

  • Chores
    • Swagger API documentation now lists configurable Development, UAT, and Demo server URLs in the API docs.
    • CI automation for Swagger spec updates now uses a standardized branch name for update pull requests (removes per-run unique branch names).

@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 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 49 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

Updates fix the GitHub Actions PR branch name, change SwaggerConfig to accept an Environment parameter and populate OpenAPI servers from three environment variables, and add three API_*_URL properties to application-swagger.properties.

Changes

Cohort / File(s) Summary
CI/CD Workflow
.github/workflows/swagger-json.yml
Changed PR branch naming from dynamic auto/swagger-update-${{ github.run_id }}-${{ github.run_attempt }} to fixed auto/swagger-update-admin-api.
Swagger Configuration
src/main/java/com/iemr/admin/config/SwaggerConfig.java
Method signature updated to customOpenAPI(Environment env); imports updated (@Autowired, Environment); reads API_DEV_URL, API_UAT_URL, API_DEMO_URL and adds them to OpenAPI servers list.
Configuration Properties
src/main/resources/application-swagger.properties
Added properties: API_DEV_URL, API_UAT_URL, API_DEMO_URL for Swagger server URLs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibble at env keys, tidy and spry,
Three URLs hop in beneath the sky.
Swagger wakes, servers gleam anew,
Branch name fixed, the PR jumps too —
Hooray! A rabbit-approved deploy-by! 🎉

🚥 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 directly and clearly summarizes the main change: adding environment-driven servers to the OpenAPI configuration, which is the primary focus of the changeset.

✏️ 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: 2

🤖 Fix all issues with AI agents
In `@src/main/java/com/iemr/admin/config/SwaggerConfig.java`:
- Line 23: The Info() metadata in SwaggerConfig (the .info(new
Info().title("Admin API")...) call) has an incorrect description about "creation
and management of beneficiaries"; update the description string to accurately
describe the Admin API's purpose (e.g., administration, configuration, user/role
management or service-level operations for this microservice). Locate the
SwaggerConfig class and replace the description passed to
Info().description(...) with a concise, correct summary of the Admin API
responsibilities.
- Around line 18-31: customOpenAPI currently reads API_DEV_URL/ UAT/ DEMO into
devUrl/uatUrl/demoUrl and may pass nulls into new Server().url(...); update
customOpenAPI to guard against nulls by either supplying sensible defaults (e.g.
fallback to empty string or configured base URL) or by building the servers list
conditionally (only add a Server when its corresponding env property is
non-empty), and replace the inline fully-qualified class references with proper
imports for Arrays and io.swagger.v3.oas.models.servers.Server to improve
readability; ensure the OpenAPI.servers list is created from the
filtered/non-null URLs before returning the OpenAPI instance.
🧹 Nitpick comments (2)
src/main/resources/application-swagger.properties (1)

19-23: Hardcoded server URLs contradict the stated goal of removing hardcoded live defaults.

The PR description says it "removes hardcoded live defaults," but these properties embed real environment URLs directly. If the intent is truly env-driven configuration, use Spring property placeholders so these only serve as fallback defaults:

Proposed fix
-API_DEV_URL=https://amritwprdev.piramalswasthya.org
-API_UAT_URL=https://uatamrit.piramalswasthya.org
-API_DEMO_URL=https://amritdemo.piramalswasthya.org
+api.dev.url=${API_DEV_URL:https://amritwprdev.piramalswasthya.org}
+api.uat.url=${API_UAT_URL:https://uatamrit.piramalswasthya.org}
+api.demo.url=${API_DEMO_URL:https://amritdemo.piramalswasthya.org}

Using dot-notation keys with ${ENV_VAR:default} placeholders is more idiomatic for Spring and makes the env-override mechanism explicit. You'd then update SwaggerConfig to read api.dev.url, etc.

src/main/java/com/iemr/admin/config/SwaggerConfig.java (1)

5-5: Unused import: @Autowired is not used.

Environment is injected via the @Bean method parameter, so @Autowired is not needed.

-import org.springframework.beans.factory.annotation.Autowired;

@sonarqubecloud
Copy link

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.

1 participant