Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
a8b17d4
chore(swagger): automate swagger sync to amrit-docs
DurgaPrasad-54 Feb 2, 2026
91485fb
chore(swagger): automate swagger sync to amrit-docs
DurgaPrasad-54 Feb 3, 2026
40087b7
chore(swagger): automate swagger sync to amrit-docs
DurgaPrasad-54 Feb 4, 2026
b10ba86
fix(swagger): update the workflow and fix the running issue
DurgaPrasad-54 Feb 11, 2026
a4ea98c
Merge branch 'main' into main
DurgaPrasad-54 Feb 11, 2026
54a79e1
fix(swagger): fix the swagger json workflow
DurgaPrasad-54 Feb 11, 2026
21c6a84
Merge branch 'main' of https://github.com/DurgaPrasad-54/Common-API
DurgaPrasad-54 Feb 11, 2026
e4bc1ac
chore(swagger): add fixed branch name in workflow
DurgaPrasad-54 Feb 11, 2026
f8d94ed
chore(ci): prevent multiple swagger sync PRs by using fixed branch
DurgaPrasad-54 Feb 11, 2026
452be06
chore(swagger): add Dev/UAT/Demo servers to OpenAPI config
DurgaPrasad-54 Feb 12, 2026
4ef377f
chore(swagger): avoid default server URLs
DurgaPrasad-54 Feb 12, 2026
e9eb39e
chore(swagger): remove field injection and inject URLs into OpenAPI bean
DurgaPrasad-54 Feb 12, 2026
587d45e
Merge branch 'PSMRI:main' into main
DurgaPrasad-54 Feb 22, 2026
5e9de59
feat(health,version): update version and health endpoints and add adv…
DurgaPrasad-54 Feb 23, 2026
bfe5ab3
fix(health): normalize severity and fix slow query false positives
DurgaPrasad-54 Feb 23, 2026
d43d892
fix(health): avoid false CRITICAL on single long-running MySQL transa…
DurgaPrasad-54 Feb 23, 2026
d549ad5
fix(health): enforce 3s DB connection timeout via HikariCP
DurgaPrasad-54 Feb 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,32 @@
<build>
<finalName>${artifactId}-${version}</finalName>
<plugins>
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>9.0.2</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<property>^git.branch$</property>
<property>^git.commit.id.abbrev$</property>
<property>^git.build.version$</property>
<property>^git.build.time$</property>
</includeOnlyProperties>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@
/**
* REST controller exposing application version and build metadata.
* <p>
* Provides the <code>/version</code> endpoint which returns the
* Git commit hash and build timestamp in a standardized JSON format.
* Provides the <code>/version</code> endpoint which returns Git metadata
* in a standardized JSON format consistent across all AMRIT APIs.
* </p>
*
* @author Vaishnav Bhosale
*/
package com.iemr.common.controller.version;

import java.io.InputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -46,28 +50,39 @@ public class VersionController {

private final Logger logger =
LoggerFactory.getLogger(this.getClass().getSimpleName());

private static final String UNKNOWN_VALUE = "unknown";

@Operation(summary = "Get version")
@RequestMapping(value = "/version", method = { RequestMethod.GET })
public VersionInfo versionInformation() {
@Operation(summary = "Get version information")
@GetMapping(value = "/version", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, String>> versionInformation() {
Map<String, String> response = new LinkedHashMap<>();
try {
logger.info("version Controller Start");
Properties gitProperties = loadGitProperties();
response.put("buildTimestamp", gitProperties.getProperty("git.build.time", UNKNOWN_VALUE));
response.put("version", gitProperties.getProperty("git.build.version", UNKNOWN_VALUE));
response.put("branch", gitProperties.getProperty("git.branch", UNKNOWN_VALUE));
response.put("commitHash", gitProperties.getProperty("git.commit.id.abbrev", UNKNOWN_VALUE));
} catch (Exception e) {
logger.error("Failed to load version information", e);
response.put("buildTimestamp", UNKNOWN_VALUE);
response.put("version", UNKNOWN_VALUE);
response.put("branch", UNKNOWN_VALUE);
response.put("commitHash", UNKNOWN_VALUE);
}
logger.info("version Controller End");
return ResponseEntity.ok(response);
}

private Properties loadGitProperties() throws IOException {
Properties properties = new Properties();

try (InputStream is = getClass()
.getClassLoader()
try (InputStream input = getClass().getClassLoader()
.getResourceAsStream("git.properties")) {

if (is != null) {
properties.load(is);
if (input != null) {
properties.load(input);
}

} catch (Exception e) {
logger.error("Error reading git.properties", e);
}

return new VersionInfo(
properties.getProperty("git.commit.id.abbrev", "unknown"),
properties.getProperty("git.build.time", "unknown")
);
return properties;
}
}
Loading
Loading