Added CS limitPower 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": "http://localhost:8080/v1"
+ "url": "/v1"
}
],
"info": {

MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action.json
"sanitize": "mongo"
},
"connectorId": {
- "$ref": "chargingstation.json#/definitions/connectorID"
+ "$ref": "chargingstation.json#/definitions/connector/properties/connectorId"
},
"duration": {
"type": "number",

ADD
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-limit-power.json
+{
+ "title": "Limit Charging Station power",
+ "type": "object",
+ "properties": {
+ "chargeBoxID": {
+ "$ref": "chargingstation.json#/definitions/id"
+ },
+ "chargePointID": {
+ "$ref": "chargingstation.json#/definitions/chargePoint/properties/chargePointID"
+ },
+ "connectorId": {
+ "$ref": "chargingstation.json#/definitions/connector/properties/connectorId"
+ },
+ "ampLimitValue": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "forceUpdateChargingPlan": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ }
+ },
+ "required": [
+ "chargeBoxID", "chargePointID", "connectorId", "ampLimitValue"
+ ]
+}

MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstation.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstation.json
},
"required": ["startPeriod", "limit"]
},
- "connectorID": {
- "type": "number",
- "sanitize": "mongo"
- },
"chargingProfilePurpose": {
"type": "string",
"sanitize": "mongo"
"type": "object",
"properties": {
"connectorId": {
- "$ref": "#/definitions/connectorID"
+ "type": "number",
+ "sanitize": "mongo"
},
"power": {
"type": "number",
"type": "object",
"properties": {
"chargePointID": {
- "type": "string",
+ "type": "number",
"sanitize": "mongo"
},
"currentType": {
"connectorIDs": {
"type": "array",
"items": {
- "$ref": "#/definitions/connectorID"
+ "$ref": "#/definitions/connector/properties/connectorId"
}
}
}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -313,7 +313,7 @@ export default class ChargingStationService {
public static async handleChargingStationLimitPower(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = ChargingStationSecurity.filterChargingStationLimitPowerRequest(req.body);
+ const filteredRequest = ChargingStationValidator.getInstance().validateChargingStationLimitPowerReq(req.body);
// Check
if (!filteredRequest.chargePointID) {
throw new AppError({

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
-import { HttpChargingStationCommandRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationsRequest } from '../../../../types/requests/HttpChargingStationRequest';
+import { HttpChargingStationCommandRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationsRequest } from '../../../../types/requests/HttpChargingStationRequest';
import HttpByIDRequest from '../../../../types/requests/HttpByIDRequest';
import Schema from './Schema';
@@ -14,6 +14,7 @@ export default class ChargingStationValidator extends SchemaValidator {
private chargingStationAction: Schema;
private chargingStationRequestOCPPParameters: Schema;
private chargingStationUpdateParameters: Schema;
+ private chargingStationLimitPower: Schema;
private constructor() {
@@ -24,6 +25,7 @@ export default class ChargingStationValidator extends SchemaValidator {
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'));
+ this.chargingStationLimitPower = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-limit-power.json`, 'utf8'));
}
public static getInstance(): ChargingStationValidator {
@@ -68,4 +70,10 @@ export default class ChargingStationValidator extends SchemaValidator {
this.validate(this.chargingStationUpdateParameters, data);
return data;
}
+
+ public validateChargingStationLimitPowerReq(data: any): HttpChargingStationLimitPowerRequest {
+ // Validate schema
+ this.validate(this.chargingStationLimitPower, data);
+ return data;
+ }
}

Added CS limitPower validation