stopTransaction validation
ADD
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-stop-transaction.json
+{
+ "title": "Charging Station Action Request for Stop Transaction (endpoint)",
+ "type": "object",
+ "properties": {
+ "chargingStationID": {
+ "$ref": "chargingstation.json#/definitions/id"
+ },
+ "args": {
+ "type": "object",
+ "properties": {
+ "transactionId": {
+ "$ref": "transaction.json#/definitions/id"
+ }
+ },
+ "required": [
+ "transactionId"
+ ]
+ }
+ },
+ "required": [
+ "chargingStationID"
+ ]
+}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1144,7 +1144,7 @@ export default class ChargingStationService {
req.body.chargeBoxID && (req.body.chargingStationID = req.body.chargeBoxID);
// Filter - Type is hacked because code below is. Would need approval to change code structure.
const command = action.slice('RestChargingStation'.length) as Command;
- const filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionReq(req.body);
+ let filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionReq(req.body);
UtilsService.assertIdIsProvided(action, filteredRequest.chargingStationID, MODULE_NAME, 'handleAction', req.user);
// Get the Charging station
const chargingStation = await UtilsService.checkAndGetChargingStationAuthorization(
@@ -1153,6 +1153,7 @@ export default class ChargingStationService {
switch (command) {
// Remote Stop Transaction / Unlock Connector
case Command.REMOTE_STOP_TRANSACTION:
+ filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionStopTransactionReq(req.body);
result = await ChargingStationService.executeChargingStationStopTransaction(action, chargingStation, command, filteredRequest, req, res, next);
break;
// Remote Start Transaction

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
@@ -13,6 +13,7 @@ export default class ChargingStationValidator extends SchemaValidator {
private chargingStationGet: Schema;
private chargingStationDelete: Schema;
private chargingStationAction: Schema;
+ private chargingStationActionStopTransaction: Schema;
private chargingStationQRCodeGenerate: Schema;
private chargingStationQRCodeDownload: Schema;
private chargingStationOcppParametersGet: Schema;
@@ -34,6 +35,7 @@ export default class ChargingStationValidator extends SchemaValidator {
this.chargingStationGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-get.json`, 'utf8'));
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.chargingStationActionStopTransaction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-stop-transaction.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'));
@@ -81,6 +83,12 @@ export default class ChargingStationValidator extends SchemaValidator {
return data;
}
+ public validateChargingStationActionStopTransactionReq(data: any): HttpChargingStationCommandRequest {
+ // Validate schema for StopTransaction
+ this.validate(this.chargingStationActionStopTransaction, data);
+ return data;
+ }
+
public validateChargingStationQRCodeGenerateReq(data: any): HttpChargingStationConnectorRequest {
// Validate schema
this.validate(this.chargingStationQRCodeGenerate, data);

stopTransaction validation