From e6b98476247e68476b1fecbdacf073909f6e55b2 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Thu, 5 Nov 2026 13:25:27 +0200 Subject: [PATCH] Document GET /api/system/info in the OpenAPI spec The endpoint is available to every authenticated user, but the whole SystemInfoController was hidden, so generated REST clients had no call for it and could only read the version from the sysadmin-only /api/admin/updates. Show the endpoint and return a SystemVersionInfo record that serializes to the same JSON as the hand-built ObjectNode. The other two endpoints of the controller stay hidden. --- .../controller/SystemInfoController.java | 27 +++++++++---------- .../server/common/data/SystemVersionInfo.java | 23 ++++++++++++++++ 2 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 common/data/src/main/java/org/thingsboard/server/common/data/SystemVersionInfo.java diff --git a/application/src/main/java/org/thingsboard/server/controller/SystemInfoController.java b/application/src/main/java/org/thingsboard/server/controller/SystemInfoController.java index c072b6b09d..f10009830c 100644 --- a/application/src/main/java/org/thingsboard/server/controller/SystemInfoController.java +++ b/application/src/main/java/org/thingsboard/server/controller/SystemInfoController.java @@ -3,7 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1 package org.thingsboard.server.controller; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import io.swagger.v3.oas.annotations.Hidden; import jakarta.annotation.PostConstruct; @@ -21,6 +20,7 @@ import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.DashboardInfo; import org.thingsboard.server.common.data.EntityType; import org.thingsboard.server.common.data.SystemParams; +import org.thingsboard.server.common.data.SystemVersionInfo; import org.thingsboard.server.common.data.exception.ThingsboardException; import org.thingsboard.server.common.data.id.CustomerId; import org.thingsboard.server.common.data.id.TenantId; @@ -34,6 +34,7 @@ import org.thingsboard.server.common.data.settings.UserSettings; import org.thingsboard.server.common.data.settings.UserSettingsType; import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration; import org.thingsboard.server.common.msg.edqs.EdqsService; +import org.thingsboard.server.config.annotations.ApiOperation; import org.thingsboard.server.dao.mobile.QrCodeSettingService; import org.thingsboard.server.dao.subscription.PlatformFeature; import org.thingsboard.server.dao.subscription.SubscriptionService; @@ -52,7 +53,8 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -@Hidden +import static org.thingsboard.server.controller.ControllerConstants.SYSTEM_OR_TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH; + @RestController @TbCoreComponent @RequestMapping("/api") @@ -117,23 +119,26 @@ public class SystemInfoController extends BaseController { @PostConstruct public void init() { - JsonNode info = buildInfoObject(); - log.info("System build info: {}", info); + log.info("System build info: {}", JacksonUtil.toString(buildInfoObject())); } + @ApiOperation(value = "Get platform version (getSystemVersionInfo)", + notes = "Returns the version and edition of the platform build." + SYSTEM_OR_TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH) @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") @RequestMapping(value = "/system/info", method = RequestMethod.GET) @ResponseBody - public JsonNode getSystemVersionInfo() { + public SystemVersionInfo getSystemVersionInfo() { return buildInfoObject(); } + @Hidden @RequestMapping(value = "/noauth/system/development", method = RequestMethod.GET) @ResponseBody public Boolean isDevelopment() { return subscriptionService.isDevelopment(TenantId.SYS_TENANT_ID); } + @Hidden @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") @RequestMapping(value = "/system/params", method = RequestMethod.GET) @ResponseBody @@ -230,17 +235,11 @@ public class SystemInfoController extends BaseController { currentUser.getAdditionalInfo().get("defaultDashboardFullscreen").booleanValue()); } - private JsonNode buildInfoObject() { - ObjectNode infoObject = JacksonUtil.newObjectNode(); + private SystemVersionInfo buildInfoObject() { if (buildProperties != null) { - infoObject.put("version", buildProperties.getVersion()); - infoObject.put("artifact", buildProperties.getArtifact()); - infoObject.put("name", buildProperties.getName()); - } else { - infoObject.put("version", "unknown"); + return new SystemVersionInfo(buildProperties.getVersion(), buildProperties.getArtifact(), buildProperties.getName(), "PE"); } - infoObject.put("type", "PE"); - return infoObject; + return new SystemVersionInfo("unknown", null, null, "PE"); } } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/SystemVersionInfo.java b/common/data/src/main/java/org/thingsboard/server/common/data/SystemVersionInfo.java new file mode 100644 index 0000000000..c202c7c695 --- /dev/null +++ b/common/data/src/main/java/org/thingsboard/server/common/data/SystemVersionInfo.java @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +package org.thingsboard.server.common.data; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "Version and edition of the platform build") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"version", "artifact", "name", "type"}) +public record SystemVersionInfo( + @Schema(requiredMode = Schema.RequiredMode.REQUIRED, example = "4.4.1", + description = "Platform version, or 'unknown' when the build information is not available") + String version, + @Schema(example = "application", description = "Build artifact; absent when the build information is not available") + String artifact, + @Schema(example = "ThingsBoard Server Application", description = "Build name; absent when the build information is not available") + String name, + @Schema(requiredMode = Schema.RequiredMode.REQUIRED, example = "PE", description = "Platform edition") + String type +) { +}