Refactored ChargingProfile schema
MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action.json
"enum": ["A", "W"]
},
"chargingProfilePurpose": {
- "$ref": "chargingstation.json#/definitions/chargingProfilePurpose"
+ "$ref": "chargingstation.json#/definitions/chargingProfile/properties/profile/properties/chargingProfilePurpose"
},
"stackLevel": {
"$ref": "chargingstation.json#/definitions/chargingProfile/properties/profile/properties/stackLevel"
},
"chargePointID": {
"$ref": "common.json#/definitions/id"
- },
- "profile": {
- "$ref": "chargingstation.json#/definitions/chargingProfile"
}
},
"required": [

MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstation.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstation.json
"type": "number",
"sanitize": "mongo"
},
- "profile": {
- "$ref": "#/definitions/profile"
- }
- },
- "required": [
- "chargingStationID",
- "profile"
- ]
- },
"profile": {
"type": "object",
"properties": {
"format": "date-time",
"sanitize": "mongo"
},
- "chargingSchedule": {
- "$ref": "#/definitions/chargingSchedule"
- }
- },
- "required": [
- "chargingProfileId",
- "stackLevel",
- "chargingProfilePurpose",
- "chargingProfileKind",
- "chargingSchedule"
- ]
- },
"chargingSchedule": {
"type": "object",
"properties": {
"chargingSchedulePeriod": {
"type": "array",
"items": {
- "$ref": "#/definitions/chargingSchedulePeriod"
- }
- },
- "minChargeRate": {
- "type": "number",
- "sanitize": "mongo"
- }
- },
- "required": [
- "chargingRateUnit",
- "chargingSchedulePeriod"
- ]
- },
- "chargingSchedulePeriod": {
"type": "object",
"properties": {
"startPeriod": {
"startPeriod",
"limit"
]
+ }
+ },
+ "minChargeRate": {
+ "type": "number",
+ "sanitize": "mongo"
+ }
+ },
+ "required": [
+ "chargingRateUnit",
+ "chargingSchedulePeriod"
+ ]
+ }
+ },
+ "required": [
+ "chargingProfileId",
+ "stackLevel",
+ "chargingProfilePurpose",
+ "chargingProfileKind",
+ "chargingSchedule"
+ ]
+ }
+ },
+ "required": [
+ "chargingStationID",
+ "profile"
+ ]
},
"connectorID": {
"type": "number",

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1222,7 +1222,12 @@ export default class ChargingStationService {
public static async handleAction(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter - Type is hacked because code below is. Would need approval to change code structure.
const command = action.slice(15) as Command;
- const filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionReq(req.body);
+ let filteredRequest;
+ try {
+ filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionReq(req.body);
+ } catch (e) {
+ const a = 5;
+ }
UtilsService.assertIdIsProvided(action, filteredRequest.chargeBoxID, MODULE_NAME, 'handleAction', req.user);
// Get the Charging station
const chargingStation = await ChargingStationStorage.getChargingStation(req.user.tenantID, filteredRequest.chargeBoxID);

Refactored ChargingProfile schema