Added definitions
DELETE
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-get-by-id.json
-{
- "title": "Get Charging Station Request",
- "type": "object",
- "properties": {
- "ID": {
- "$ref": "common.json#/definitions/id"
- }
- },
- "required": [
- "ID"
- ]
-}

DELETE
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-get-connector.json
-{
- "title": "Get Charging Station Connector Request",
- "type": "object",
- "properties": {
- "ChargeBoxID": {
- "$ref": "common.json#/definitions/id"
- },
- "ConnectorID": {
- "$ref": "common.json#/definitions/connectorID"
- }
- },
- "required": [
- "ChargeBoxID",
- "ConnectorID"
- ]
-}

DELETE
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-get-firmware.json
-{
- "title": "Get Charging Station Firmware Request",
- "type": "object",
- "properties": {
- "Filename": {
- "type": "string",
- "sanitize": "mongo"
- }
- },
- "required": ["Filename"]
-}

ADD
src/server/rest/v1/validator/ChargingStationValidation.ts
+import { HttpChargingStationCommandRequest, HttpDownloadQrCodeRequest } from '../../../../types/requests/HttpChargingStationRequest';
+
+import SchemaValidator from './SchemaValidator';
+import fs from 'fs';
+import global from '../../../../types/GlobalType';
+
+export default class ChargingStationValidator extends SchemaValidator {
+ private static _instance: ChargingStationValidator | undefined;
+ private _chargingStationDownloadQRCodePdf: any;
+ private _chargingStationAction: any;
+ private _chargingStationGetConnector: any;
+
+
+ private constructor() {
+ super('TenantValidator');
+ this._chargingStationDownloadQRCodePdf = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-download-qrcode-pdf.json`, 'utf8'));
+ this._chargingStationAction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action.json`, 'utf8'));
+ this._chargingStationGetById = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action.json`, 'utf8'));
+ }
+
+ public static getInstance(): ChargingStationValidator {
+ if (!ChargingStationValidator._instance) {
+ ChargingStationValidator._instance = new ChargingStationValidator();
+ }
+ return ChargingStationValidator._instance;
+ }
+
+ public validateChargingStationDownloadQRCodePdf(data: HttpDownloadQrCodeRequest): HttpDownloadQrCodeRequest {
+ // Validate schema
+ this.validate(this._chargingStationDownloadQRCodePdf, data);
+ // Validate deps between components
+ return data;
+ }
+
+ public validateChargingStationAction(data: HttpChargingStationCommandRequest): HttpChargingStationCommandRequest {
+ // Validate schema
+ this.validate(this._chargingStationAction, data);
+ // Validate deps between components
+ return data;
+ }
+}

MODIFY
src/server/rest/v1/validator/SchemaValidator.ts
src/server/rest/v1/validator/SchemaValidator.ts
@@ -15,6 +15,7 @@ export default class SchemaValidator {
private readonly ajv: Ajv.Ajv;
private _commonSchema: any = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/common/common.json`, 'utf8'));
private _tenantComponentSchema: any = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tenant/tenant-components.json`, 'utf8'));
+ private _chargingStationSchema: any = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation.json`, 'utf8'));
constructor(readonly moduleName: string,
config: {allErrors: boolean; removeAdditional: boolean|'all'|'failing'|undefined;
@@ -27,6 +28,7 @@ export default class SchemaValidator {
this.ajv = ajvSanitizer(new Ajv(config), extraSanitizers);
this.ajv.addSchema(this._commonSchema);
this.ajv.addSchema(this._tenantComponentSchema);
+ this.ajv.addSchema(this._chargingStationSchema);
}
public validate(schema: boolean|Record<string, unknown>, content: any): void {

Added definitions