Browse Source

fixed some TB models for correct open-api json schema

pull/14929/head
dashevchenko 8 months ago
parent
commit
54a0f4e74e
  1. 28
      application/src/main/java/org/thingsboard/server/controller/DeviceConnectivityController.java
  2. 3
      common/data/src/main/java/org/thingsboard/server/common/data/BaseDataWithAdditionalInfo.java
  3. 20
      common/data/src/main/java/org/thingsboard/server/common/data/OtaPackageInfo.java

28
application/src/main/java/org/thingsboard/server/controller/DeviceConnectivityController.java

@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -75,6 +76,7 @@ public class DeviceConnectivityController extends BaseController {
description = "OK", description = "OK",
content = @Content( content = @Content(
mediaType = MediaType.APPLICATION_JSON_VALUE, mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(ref = "#/components/schemas/JsonNode"),
examples = { examples = {
@ExampleObject( @ExampleObject(
name = "http", name = "http",
@ -105,7 +107,18 @@ public class DeviceConnectivityController extends BaseController {
return deviceConnectivityService.findDevicePublishTelemetryCommands(baseUrl, device); return deviceConnectivityService.findDevicePublishTelemetryCommands(baseUrl, device);
} }
@ApiOperation(value = "Download server certificate using file path defined in device.connectivity properties (downloadServerCertificate)", notes = "Download server certificate.") @ApiOperation(value = "Download server certificate using file path defined in device.connectivity properties (downloadServerCertificate)",
notes = "Download server certificate.",
responses = {
@ApiResponse(
responseCode = "200",
description = "OK",
content = @Content(
mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE,
schema = @Schema(type = "string", format = "binary")
)
)
})
@RequestMapping(value = "/device-connectivity/{protocol}/certificate/download", method = RequestMethod.GET) @RequestMapping(value = "/device-connectivity/{protocol}/certificate/download", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public ResponseEntity<org.springframework.core.io.Resource> downloadServerCertificate(@Parameter(description = PROTOCOL_PARAM_DESCRIPTION) public ResponseEntity<org.springframework.core.io.Resource> downloadServerCertificate(@Parameter(description = PROTOCOL_PARAM_DESCRIPTION)
@ -122,7 +135,18 @@ public class DeviceConnectivityController extends BaseController {
.body(pemCert); .body(pemCert);
} }
@ApiOperation(value = "Download generated docker-compose.yml file for gateway (downloadGatewayDockerCompose)", notes = "Download generated docker-compose.yml for gateway.") @ApiOperation(value = "Download generated docker-compose.yml file for gateway (downloadGatewayDockerCompose)",
notes = "Download generated docker-compose.yml for gateway.",
responses = {
@ApiResponse(
responseCode = "200",
description = "OK",
content = @Content(
mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE,
schema = @Schema(type = "string", format = "binary")
)
)
})
@RequestMapping(value = "/device-connectivity/gateway-launch/{deviceId}/docker-compose/download", method = RequestMethod.GET) @RequestMapping(value = "/device-connectivity/gateway-launch/{deviceId}/docker-compose/download", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public ResponseEntity<org.springframework.core.io.Resource> downloadGatewayDockerCompose(@Parameter(description = DEVICE_ID_PARAM_DESCRIPTION) public ResponseEntity<org.springframework.core.io.Resource> downloadGatewayDockerCompose(@Parameter(description = DEVICE_ID_PARAM_DESCRIPTION)

3
common/data/src/main/java/org/thingsboard/server/common/data/BaseDataWithAdditionalInfo.java

@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.thingsboard.server.common.data.id.UUIDBased; import org.thingsboard.server.common.data.id.UUIDBased;
import org.thingsboard.server.common.data.validation.NoXss; import org.thingsboard.server.common.data.validation.NoXss;
@ -35,9 +36,11 @@ import java.util.function.Supplier;
* Created by ashvayka on 19.02.18. * Created by ashvayka on 19.02.18.
*/ */
@Slf4j @Slf4j
@Schema
public abstract class BaseDataWithAdditionalInfo<I extends UUIDBased> extends BaseData<I> implements HasAdditionalInfo { public abstract class BaseDataWithAdditionalInfo<I extends UUIDBased> extends BaseData<I> implements HasAdditionalInfo {
@NoXss @NoXss
@Schema(implementation = JsonNode.class)
private transient JsonNode additionalInfo; private transient JsonNode additionalInfo;
@JsonIgnore @JsonIgnore
private byte[] additionalInfoBytes; private byte[] additionalInfoBytes;

20
common/data/src/main/java/org/thingsboard/server/common/data/OtaPackageInfo.java

@ -41,19 +41,19 @@ public class OtaPackageInfo extends BaseDataWithAdditionalInfo<OtaPackageId> imp
@Serial @Serial
private static final long serialVersionUID = 3168391583570815419L; private static final long serialVersionUID = 3168391583570815419L;
@Schema(description = "JSON object with Tenant Id. Tenant Id of the ota package can't be changed.", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "JSON object with Tenant Id. Tenant Id of the ota package can't be changed.")
private TenantId tenantId; private TenantId tenantId;
@Schema(description = "JSON object with Device Profile Id. Device Profile Id of the ota package can't be changed.", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "JSON object with Device Profile Id. Device Profile Id of the ota package can't be changed.")
private DeviceProfileId deviceProfileId; private DeviceProfileId deviceProfileId;
@Schema(description = "OTA Package type.", example = "FIRMWARE", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "OTA Package type.", example = "FIRMWARE")
private OtaPackageType type; private OtaPackageType type;
@Length(fieldName = "title") @Length(fieldName = "title")
@NoXss @NoXss
@Schema(description = "OTA Package title.", example = "fw", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "OTA Package title.", example = "fw")
private String title; private String title;
@Length(fieldName = "version") @Length(fieldName = "version")
@NoXss @NoXss
@Schema(description = "OTA Package version.", example = "1.0", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "OTA Package version.", example = "1.0")
private String version; private String version;
@Length(fieldName = "tag") @Length(fieldName = "tag")
@NoXss @NoXss
@ -61,22 +61,22 @@ public class OtaPackageInfo extends BaseDataWithAdditionalInfo<OtaPackageId> imp
private String tag; private String tag;
@Length(fieldName = "url") @Length(fieldName = "url")
@NoXss @NoXss
@Schema(description = "OTA Package url.", example = "http://thingsboard.org/fw/1", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "OTA Package url.", example = "http://thingsboard.org/fw/1")
private String url; private String url;
@Schema(description = "Indicates OTA Package 'has data'. Field is returned from DB ('true' if data exists or url is set). If OTA Package 'has data' is 'false' we can not assign the OTA Package to the Device or Device Profile.", example = "true", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "Indicates OTA Package 'has data'. Field is returned from DB ('true' if data exists or url is set). If OTA Package 'has data' is 'false' we can not assign the OTA Package to the Device or Device Profile.", example = "true", accessMode = Schema.AccessMode.READ_ONLY)
private boolean hasData; private boolean hasData;
@Length(fieldName = "file name") @Length(fieldName = "file name")
@NoXss @NoXss
@Schema(description = "OTA Package file name.", example = "fw_1.0", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "OTA Package file name.", example = "fw_1.0")
private String fileName; private String fileName;
@NoXss @NoXss
@Length(fieldName = "contentType") @Length(fieldName = "contentType")
@Schema(description = "OTA Package content type.", example = "APPLICATION_OCTET_STREAM", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "OTA Package content type.", example = "APPLICATION_OCTET_STREAM")
private String contentType; private String contentType;
@Schema(description = "OTA Package checksum algorithm.", example = "CRC32", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "OTA Package checksum algorithm.", example = "CRC32")
private ChecksumAlgorithm checksumAlgorithm; private ChecksumAlgorithm checksumAlgorithm;
@Length(fieldName = "checksum", max = 1020) @Length(fieldName = "checksum", max = 1020)
@Schema(description = "OTA Package checksum.", example = "0xd87f7e0c", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "OTA Package checksum.", example = "0xd87f7e0c")
private String checksum; private String checksum;
@Schema(description = "OTA Package data size.", example = "8", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "OTA Package data size.", example = "8", accessMode = Schema.AccessMode.READ_ONLY)
private Long dataSize; private Long dataSize;

Loading…
Cancel
Save