Browse Source

deleted redundant code, md file, reverted some swagger properties for OtaPackageInfo fields

pull/14929/head
dashevchenko 7 months ago
parent
commit
a72a9c5174
  1. 13
      application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java
  2. 10
      common/data/src/main/java/org/thingsboard/server/common/data/OtaPackageInfo.java
  3. 2
      common/data/src/main/java/org/thingsboard/server/common/data/TbResourceInfo.java
  4. 32
      openapi_client_test_generation.md

13
application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java

@ -76,6 +76,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@ -308,7 +309,9 @@ public class SwaggerConfiguration {
Schema<?> errorCodeSchema = new Schema<>() Schema<?> errorCodeSchema = new Schema<>()
.type("integer") .type("integer")
.description("Platform error code") .description("Platform error code")
._enum(Arrays.asList(2, 10, 11, 15, 20, 30, 31, 32, 33, 34, 35, 40, 45, 46)); ._enum(Arrays.stream(ThingsboardErrorCode.values())
.map(ThingsboardErrorCode::getErrorCode)
.collect(Collectors.toList()));
openAPI.getComponents() openAPI.getComponents()
.addSchemas("LoginRequest", ModelConverters.getInstance().readAllAsResolvedSchema(new AnnotatedType().type(LoginRequest.class)).schema) .addSchemas("LoginRequest", ModelConverters.getInstance().readAllAsResolvedSchema(new AnnotatedType().type(LoginRequest.class)).schema)
.addSchemas("LoginResponse", ModelConverters.getInstance().readAllAsResolvedSchema(new AnnotatedType().type(LoginResponse.class)).schema) .addSchemas("LoginResponse", ModelConverters.getInstance().readAllAsResolvedSchema(new AnnotatedType().type(LoginResponse.class)).schema)
@ -536,14 +539,6 @@ public class SwaggerConfiguration {
}); });
} }
private Tag tagsCustomization(Map.Entry<String, PathItem> entry) {
var tagItem = tagItemFromPathItem(entry.getValue());
if (tagItem != null) {
return tagFromTagItem(tagItem);
}
return null;
}
private String tagItemFromPathItem(PathItem item) { private String tagItemFromPathItem(PathItem item) {
var operations = item.readOperationsMap().values(); var operations = item.readOperationsMap().values();
var operation = operations.stream().findAny(); var operation = operations.stream().findAny();

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

@ -41,7 +41,7 @@ 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.") @Schema(description = "JSON object with Tenant Id. Tenant Id of the ota package can't be changed.", accessMode = Schema.AccessMode.READ_ONLY)
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.") @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;
@ -67,16 +67,16 @@ public class OtaPackageInfo extends BaseDataWithAdditionalInfo<OtaPackageId> imp
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") @Schema(description = "OTA Package file name.", example = "fw_1.0", accessMode = Schema.AccessMode.READ_ONLY)
private String fileName; private String fileName;
@NoXss @NoXss
@Length(fieldName = "contentType") @Length(fieldName = "contentType")
@Schema(description = "OTA Package content type.", example = "APPLICATION_OCTET_STREAM") @Schema(description = "OTA Package content type.", example = "APPLICATION_OCTET_STREAM", accessMode = Schema.AccessMode.READ_ONLY)
private String contentType; private String contentType;
@Schema(description = "OTA Package checksum algorithm.", example = "CRC32") @Schema(description = "OTA Package checksum algorithm.", example = "CRC32", accessMode = Schema.AccessMode.READ_ONLY)
private ChecksumAlgorithm checksumAlgorithm; private ChecksumAlgorithm checksumAlgorithm;
@Length(fieldName = "checksum", max = 1020) @Length(fieldName = "checksum", max = 1020)
@Schema(description = "OTA Package checksum.", example = "0xd87f7e0c") @Schema(description = "OTA Package checksum.", example = "0xd87f7e0c", accessMode = Schema.AccessMode.READ_ONLY)
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;

2
common/data/src/main/java/org/thingsboard/server/common/data/TbResourceInfo.java

@ -40,7 +40,7 @@ public class TbResourceInfo extends BaseData<TbResourceId> implements HasName, H
@Serial @Serial
private static final long serialVersionUID = 7282664529021651736L; private static final long serialVersionUID = 7282664529021651736L;
@Schema(description = "JSON object with Tenant Id. Tenant Id of the resource can't be changed.") @Schema(description = "JSON object with Tenant Id. Tenant Id of the resource can't be changed.", accessMode = Schema.AccessMode.READ_ONLY)
private TenantId tenantId; private TenantId tenantId;
@NoXss @NoXss
@Length(fieldName = "title") @Length(fieldName = "title")

32
openapi_client_test_generation.md

@ -1,32 +0,0 @@
## To generate tests for generated OpenAPI client, use following prompt in Claude code cli:
Please add tests in `YourFileName` covering the following API client methods:
getDeviceById
getDeviceInfoById
saveDevice
saveDeviceWithCredentials
deleteDevice
assignDeviceToCustomer
unassignDeviceFromCustomer
assignDeviceToPublicCustomer
getDeviceCredentialsByDeviceId
updateDeviceCredentials
getTenantDevices
getTenantDeviceInfos
getTenantDevice
getTenantDeviceByName
getCustomerDevices
getCustomerDeviceInfos
getDevicesByIds
findByQuery
getDeviceTypes
claimDevice
reClaimDevice
getSecretKey
assignDeviceToTenant
assignDeviceToEdge
unassignDeviceFromEdge
getEdgeDevices
countByDeviceProfileAndEmptyOtaPackage
processDevicesBulkImport....
Loading…
Cancel
Save