Added CS getOcppParameters validation
ADD
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-ocpp-parameters-get.json
+{
+ "title": "Get Charging Station OCPP parameters",
+ "type": "object",
+ "properties": {
+ "ChargeBoxID": {
+ "$ref": "chargingstation.json#/definitions/id"
+ }
+ },
+ "required": [
+ "ChargeBoxID"
+ ]
+}

MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-qrcode-download.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-qrcode-download.json
{
- "title": "Generate QRCode for Charging Station",
+ "title": "Download QRCode of Charging Stations",
"type": "object",
"properties": {
"ChargingStationID": {

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -724,7 +724,7 @@ export default class ChargingStationService {
public static async handleGetChargingStationOcppParameters(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = ChargingStationSecurity.filterChargingStationOcppParametersRequest(req.query);
+ const filteredRequest = ChargingStationValidator.getInstance().validateChargingStationOcppParametersGetReq(req.query);
// Check
UtilsService.assertIdIsProvided(action, filteredRequest.ChargeBoxID, MODULE_NAME, 'handleGetChargingStationOcppParameters', req.user);
// Get the Charging Station`

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
-import { HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest } from '../../../../types/requests/HttpChargingStationRequest';
+import { HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest } 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 chargingStationQRCodeGenerate: Schema;
private chargingStationQRCodeDownload: Schema;
+ private chargingStationOcppParametersGet: 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.chargingStationQRCodeGenerate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-qrcode-generate.json`, 'utf8'));
this.chargingStationQRCodeDownload = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-qrcode-download.json`, 'utf8'));
+ this.chargingStationOcppParametersGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-ocpp-parameters-get.json`, 'utf8'));
}
public static getInstance(): ChargingStationValidator {
@@ -68,4 +70,10 @@ export default class ChargingStationValidator extends SchemaValidator {
this.validate(this.chargingStationQRCodeDownload, data);
return data;
}
+
+ public validateChargingStationOcppParametersGetReq(data: any): HttpChargingStationOcppRequest {
+ // Validate schema
+ this.validate(this.chargingStationOcppParametersGet, data);
+ return data;
+ }
}

Added CS getOcppParameters validation