Use dedicated schema for asset delete
ADD
src/assets/server/rest/v1/schemas/asset/asset-delete.json
+{
+ "$id": "asset-delete",
+ "title": "Delete Asset by ID Request",
+ "type": "object",
+ "properties": {
+ "ID": {
+ "$ref": "asset#/definitions/id"
+ }
+ },
+ "required": [
+ "ID"
+ ]
+}

MODIFY
src/server/rest/v1/service/AssetService.ts
src/server/rest/v1/service/AssetService.ts
@@ -286,7 +286,7 @@ export default class AssetService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ASSET,
Action.DELETE, Entity.ASSET, MODULE_NAME, 'handleDeleteAsset');
// Filter
- const filteredRequest = AssetValidator.getInstance().validateAssetGetReq(req.query);
+ const filteredRequest = AssetValidator.getInstance().validateAssetDeleteReq(req.query);
// Check and get Asset
const asset = await UtilsService.checkAndGetAssetAuthorization(req.tenant, req.user, filteredRequest.ID,
Action.DELETE, action, null, { withSiteArea: filteredRequest.WithSiteArea });

MODIFY
src/server/rest/v1/validator/AssetValidator.ts
src/server/rest/v1/validator/AssetValidator.ts
@@ -12,6 +12,7 @@ export default class AssetValidator extends SchemaValidator {
private assetConsumptionCreate: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-consumption-create.json`, 'utf8'));
private assetGet: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-get.json`, 'utf8'));
private assetsGet: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/assets-get.json`, 'utf8'));
+ private assetsDelete: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-delete.json`, 'utf8'));
private assetCreate: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-create.json`, 'utf8'));
private assetUpdate: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-update.json`, 'utf8'));
private assetConsumptionsGet: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-consumptions-get.json`, 'utf8'));
@@ -37,6 +38,10 @@ export default class AssetValidator extends SchemaValidator {
return this.validate(this.assetGet, data);
}
+ public validateAssetDeleteReq(data: Record<string, unknown>): HttpAssetRequest {
+ return this.validate(this.assetsDelete, data);
+ }
+
public validateAssetsGetReq(data: Record<string, unknown>): HttpAssetsRequest {
return this.validate(this.assetsGet, data);
}

Use dedicated schema for asset delete