Added CS updateParameters validation
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"servers": [
{
"description": "Current server",
- "url": "/v1"
+ "url": "http://localhost:8080/v1"
}
],
"info": {
"schema": {
"type": "object",
"properties": {
+ "chargingStationUrl": {
+ "type": "string"
+ },
"maximumPower": {
"type": "number",
"example": 50000
"type": "boolean",
"example": false
},
+ "manualConfiguration": {
+ "type": "boolean"
+ },
"public": {
"type": "boolean",
"example": false
"items": {
"$ref": "#/components/schemas/Connector"
}
+ },
+ "chargePoints": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ChargePoint"
+ }
}
}
}
"type": "string"
},
"voltage": {
- "type": "number"
+ "type": "number",
+ "enum": [110, 230]
},
"amperage": {
"type": "number"
},
"currentType": {
- "type": "string"
+ "type": "string",
+ "enum": ["AC", "DC"]
},
"numberOfConnectedPhase": {
"type": "number"
"chargingSchedulePeriod"
]
},
+ "ChargePoint": {
+ "type": "object",
+ "properties": {
+ "chargePointID": {
+ "type": "string"
+ },
+ "currentType": {
+ "type": "string",
+ "enum": ["AC", "DC"]
+ },
+ "voltage": {
+ "type": "number",
+ "enum": [110, 230]
+ },
+ "amperage": {
+ "type": "number"
+ },
+ "numberOfConnectedPhase": {
+ "type": "number"
+ },
+ "cannotChargeInParallel": {
+ "type": "boolean"
+ },
+ "sharePowerToAllConnectors": {
+ "type": "boolean"
+ },
+ "excludeFromPowerLimitation": {
+ "type": "boolean"
+ },
+ "ocppParamForPowerLimitiation": {
+ "type": "boolean"
+ },
+ "power": {
+ "type": "number"
+ },
+ "efficiency": {
+ "type": "number"
+ },
+ "connectorIDs": {
+ "type": "array",
+ "items": {
+ "type": "number"
+ }
+ }
+ }
+ },
"Tag": {
"type": "object",
"required": ["id", "userID", "issuer", "active", "description"],

ADD
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-update-parameters.json
+{
+ "title": "Update Charging Station paramaters",
+ "type": "object",
+ "properties": {
+ "id": {
+ "$ref": "chargingstation.json#/definitions/id"
+ },
+ "chargingStationUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "maximumPower": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "excludeFromSmartCharging": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "forceInactive": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "manualConfiguration": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "public": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "siteAreaID": {
+ "$ref": "common.json#/definitions/id"
+ },
+ "coordinates": {
+ "$ref": "common.json#/definitions/address/properties/coordinates"
+ },
+ "connectors": {
+ "type": "array",
+ "items": {
+ "$ref": "chargingstation.json#/definitions/connector"
+ }
+ },
+ "chargePoints": {
+ "type": "array",
+ "items": {
+ "$ref": "chargingstation.json#/definitions/chargePoint"
+ }
+ }
+ },
+ "required": [
+ "id"
+ ]
+}

MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstation.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstation.json
"stackLevel": {
"type": "number",
"sanitize": "mongo"
+ },
+ "connector": {
+ "type": "object",
+ "properties": {
+ "connectorId": {
+ "$ref": "#/definitions/connectorID"
+ },
+ "power": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "voltage": {
+ "type": "number",
+ "enum": [110, 230],
+ "sanitize": "mongo"
+ },
+ "amperage": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "currentType": {
+ "type": "string",
+ "enum": ["AC", "DC"],
+ "sanitize": "mongo"
+ },
+ "numberOfConnectedPhase": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "phaseAssignmentToGrid": {
+ "type": "object",
+ "properties": {
+ "csPhaseL1": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "csPhaseL2": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "csPhaseL3": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ }
+ }
+ },
+ "chargePoint": {
+ "type": "object",
+ "properties": {
+ "chargePointID": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "currentType": {
+ "type": "string",
+ "enum": ["AC", "DC"],
+ "sanitize": "mongo"
+ },
+ "voltage": {
+ "type": "number",
+ "enum": [110, 230],
+ "sanitize": "mongo"
+ },
+ "amperage": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "numberOfConnectedPhase": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "cannotChargeInParallel": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "sharePowerToAllConnectors": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "excludeFromPowerLimitation": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "ocppParamForPowerLimitation": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "power": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "efficiency": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "connectorIDs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/connectorID"
+ }
+ }
+ }
}
}
}

MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstations-get.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstations-get.json
"type": "string",
"sanitize": "mongo"
},
- "ChargeBoxID": {
+ "ChargingStationID": {
"$ref": "chargingstation.json#/definitions/id"
},
"IncludeDeleted": {

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -49,7 +49,7 @@ const MODULE_NAME = 'ChargingStationService';
export default class ChargingStationService {
public static async handleUpdateChargingStationParams(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = ChargingStationSecurity.filterChargingStationParamsUpdateRequest({ ...req.params, ...req.body });
+ const filteredRequest = ChargingStationValidator.getInstance().validateChargingStationUpdateParametersReq({ ...req.params, ...req.body });
// Check the Charging Station
const chargingStation = await ChargingStationStorage.getChargingStation(req.user.tenantID, filteredRequest.id);
UtilsService.assertObjectExists(action, chargingStation, `Charging Station '${filteredRequest.id}' does not exist.`,

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
-import { HttpChargingStationCommandRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationsRequest } from '../../../../types/requests/HttpChargingStationRequest';
+import { HttpChargingStationCommandRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationsRequest } from '../../../../types/requests/HttpChargingStationRequest';
import HttpByIDRequest from '../../../../types/requests/HttpByIDRequest';
import Schema from './Schema';
@@ -13,6 +13,7 @@ export default class ChargingStationValidator extends SchemaValidator {
private chargingStationDelete: Schema;
private chargingStationAction: Schema;
private chargingStationRequestOCPPParameters: Schema;
+ private chargingStationUpdateParameters: Schema;
private constructor() {
@@ -22,6 +23,7 @@ export default class ChargingStationValidator extends SchemaValidator {
this.chargingStationDelete = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-delete.json`, 'utf8'));
this.chargingStationAction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action.json`, 'utf8'));
this.chargingStationRequestOCPPParameters = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-ocpp-request-parameters.json`, 'utf8'));
+ this.chargingStationUpdateParameters = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-update-parameters.json`, 'utf8'));
}
public static getInstance(): ChargingStationValidator {
@@ -60,4 +62,10 @@ export default class ChargingStationValidator extends SchemaValidator {
this.validate(this.chargingStationRequestOCPPParameters, data);
return data;
}
+
+ public validateChargingStationUpdateParametersReq(data: any): HttpChargingStationParamsUpdateRequest {
+ // Validate schema
+ this.validate(this.chargingStationUpdateParameters, data);
+ return data;
+ }
}

Added CS updateParameters validation