Added OICP schemas validation
ADD
src/assets/schemas/oicp/oicp-endpoint.json
+{
+ "$id": "oicp-endpoint",
+ "definitions": {
+ "id": {
+ "$ref": "common#/definitions/id"
+ },
+ "name": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "role": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": [
+ "CPO",
+ "EMSP"
+ ]
+ },
+ "baseUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "countryCode": {
+ "type": "string",
+ "sanitize": "mongo",
+ "format": "country"
+ },
+ "partyId": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "backgroundPathJob": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ }
+ }
+}

ADD
src/assets/server/rest/v1/schemas/oicp/oicp-endpoint-by-id.json
+{
+ "$id": "oicp-endpoint-by-id",
+ "title": "OICP Endpoint by id Request",
+ "description": "",
+ "type": "object",
+ "properties": {
+ "ID": {
+ "$ref": "oicp-endpoint#/definitions/id"
+ }
+ },
+ "required": [
+ "ID"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/oicp/oicp-endpoint-create.json
+{
+ "$id": "oicp-endpoint-create",
+ "title": "OICP Endpoint creation Request",
+ "type": "object",
+ "properties": {
+ "name": {
+ "$ref": "oicp-endpoint#/definitions/name"
+ },
+ "role": {
+ "$ref": "oicp-endpoint#/definitions/role"
+ },
+ "baseUrl": {
+ "$ref": "oicp-endpoint#/definitions/baseUrl"
+ },
+ "countryCode": {
+ "$ref": "oicp-endpoint#/definitions/countryCode"
+ },
+ "partyId": {
+ "$ref": "oicp-endpoint#/definitions/partyId"
+ },
+ "backgroundPatchJob": {
+ "$ref": "oicp-endpoint#/definitions/name"
+ }
+ },
+ "required": [
+ "name",
+ "role",
+ "baseUrl"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/oicp/oicp-endpoint-get.json
+{
+ "$id": "oicp-endpoint-get",
+ "title": "Get OICP Endpoint Request",
+ "type": "object",
+ "properties": {
+ "ID": {
+ "$ref": "oicp-endpoint#/definitions/id"
+ }
+ },
+ "required": [
+ "ID"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/oicp/oicp-endpoint-ping.json
+{
+ "$id": "oicp-endpoint-ping",
+ "title": "OICP Endpoint ping Request",
+ "type": "object",
+ "properties": {
+ "name": {
+ "$ref": "oicp-endpoint#/definitions/name"
+ },
+ "role": {
+ "$ref": "oicp-endpoint#/definitions/role"
+ },
+ "baseUrl": {
+ "$ref": "oicp-endpoint#/definitions/baseUrl"
+ },
+ "countryCode": {
+ "$ref": "oicp-endpoint#/definitions/countryCode"
+ },
+ "partyId": {
+ "$ref": "oicp-endpoint#/definitions/partyId"
+ },
+ "backgroundPatchJob": {
+ "$ref": "oicp-endpoint#/definitions/name"
+ }
+ },
+ "required": [
+ "name",
+ "role",
+ "baseUrl"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/oicp/oicp-endpoint-update.json
+{
+ "$id": "oicp-endpoint-update",
+ "title": "OICP Endpoint update Request",
+ "type": "object",
+ "properties": {
+ "id": {
+ "$ref": "oicp-endpoint#/definitions/id"
+ },
+ "name": {
+ "$ref": "oicp-endpoint#/definitions/name"
+ },
+ "role": {
+ "$ref": "oicp-endpoint#/definitions/role"
+ },
+ "baseUrl": {
+ "$ref": "oicp-endpoint#/definitions/baseUrl"
+ },
+ "countryCode": {
+ "$ref": "oicp-endpoint#/definitions/countryCode"
+ },
+ "partyId": {
+ "$ref": "oicp-endpoint#/definitions/partyId"
+ },
+ "backgroundPatchJob": {
+ "$ref": "oicp-endpoint#/definitions/name"
+ }
+ },
+ "required": [
+ "id",
+ "name",
+ "role",
+ "baseUrl"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/oicp/oicp-endpoints-get.json
+{
+ "$id": "oicp-endpoints-get",
+ "title": "Get OICP Endpoints list Request",
+ "type": "object",
+ "properties": {
+ "Search": {
+ "$ref": "oicp-endpoint#/definitions/id"
+ },
+ "Limit": {
+ "$ref": "common#/definitions/limit"
+ },
+ "SortFields": {
+ "$ref": "common#/definitions/sortFields"
+ },
+ "Skip": {
+ "$ref": "common#/definitions/skip"
+ },
+ "OnlyRecordCount": {
+ "$ref": "common#/definitions/onlyRecordCount"
+ },
+ "ProjectFields": {
+ "$ref": "common#/definitions/projectFields"
+ }
+ },
+ "required": [
+ "Limit"
+ ]
+}

MODIFY
src/server/rest/v1/router/api/OICPEndpointRouter.ts
src/server/rest/v1/router/api/OICPEndpointRouter.ts
@@ -41,14 +41,14 @@ export default class OICPEndpointRouter {
private buildRouteOicpEndpointSendEvseStatuses(): void {
this.router.put(`/${ServerRoute.REST_OICP_ENDPOINT_SEND_EVSE_STATUSES}`, async (req: Request, res: Response, next: NextFunction) => {
- req.body.id = req.params.id;
+ req.params.ID = req.params.id;
await RouterUtils.handleServerAction(OICPEndpointService.handleSendEVSEStatusesOicpEndpoint.bind(this), ServerAction.OICP_ENDPOINT_SEND_EVSE_STATUSES, req, res, next);
});
}
private buildRouteOicpEndpointSendEvses(): void {
this.router.put(`/${ServerRoute.REST_OICP_ENDPOINT_SEND_EVSES}`, async (req: Request, res: Response, next: NextFunction) => {
- req.body.id = req.params.id;
+ req.params.ID = req.params.id;
await RouterUtils.handleServerAction(OICPEndpointService.handleSendEVSEsOicpEndpoint.bind(this), ServerAction.OICP_ENDPOINT_SEND_EVSES, req, res, next);
});
}
@@ -75,14 +75,14 @@ export default class OICPEndpointRouter {
private buildRouteOicpEndpointUnregister(): void {
this.router.put(`/${ServerRoute.REST_OICP_ENDPOINT_UNREGISTER}`, async (req: Request, res: Response, next: NextFunction) => {
- req.body.id = req.params.id;
+ req.params.ID = req.params.id;
await RouterUtils.handleServerAction(OICPEndpointService.handleUnregisterOicpEndpoint.bind(this), ServerAction.OICP_ENDPOINT_UNREGISTER, req, res, next);
});
}
private buildRouteOicpEndpointRegister(): void {
this.router.put(`/${ServerRoute.REST_OICP_ENDPOINT_REGISTER}`, async (req: Request, res: Response, next: NextFunction) => {
- req.body.id = req.params.id;
+ req.params.ID = req.params.id;
await RouterUtils.handleServerAction(OICPEndpointService.handleRegisterOicpEndpoint.bind(this), ServerAction.OICP_ENDPOINT_REGISTER, req, res, next);
});
}

MODIFY
src/server/rest/v1/service/OICPEndpointService.ts
src/server/rest/v1/service/OICPEndpointService.ts
@@ -9,8 +9,8 @@ import { HTTPAuthError } from '../../../../types/HTTPError';
import Logging from '../../../../utils/Logging';
import OICPClientFactory from '../../../../client/oicp/OICPClientFactory';
import OICPEndpoint from '../../../../types/oicp/OICPEndpoint';
-import OICPEndpointSecurity from './security/OICPEndpointSecurity';
import OICPEndpointStorage from '../../../../storage/mongodb/OICPEndpointStorage';
+import OICPEndpointValidator from '../validator/OICPEndpointValidator';
import { OICPRegistrationStatus } from '../../../../types/oicp/OICPRegistrationStatus';
import { OICPStatusCode } from '../../../../types/oicp/OICPStatusCode';
import { ServerAction } from '../../../../types/Server';
@@ -26,8 +26,7 @@ export default class OICPEndpointService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.OICP,
Action.DELETE, Entity.OICP_ENDPOINT, MODULE_NAME, 'handleDeleteOicpEndpoint');
// Filter
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointDeleteRequest(req.query);
- UtilsService.assertIdIsProvided(action, filteredRequest.ID, MODULE_NAME, 'handleDeleteOicpEndpoint', req.user);
+ const filteredRequest = OICPEndpointValidator.getInstance().validateOICPEndpointGetReq(req.query);
// Check auth
if (!await Authorizations.canDeleteOicpEndpoint(req.user)) {
throw new AppAuthError({
@@ -73,7 +72,7 @@ export default class OICPEndpointService {
});
}
// Filter
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointCreateRequest(req.body);
+ const filteredRequest = OICPEndpointValidator.getInstance().validateOICPEndpointCreateReq(req.body);
// Check Mandatory fields
UtilsService.checkIfOICPEndpointValid(filteredRequest, req);
const oicpEndpoint: OICPEndpoint = {
@@ -112,7 +111,7 @@ export default class OICPEndpointService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.OICP,
Action.UPDATE, Entity.OICP_ENDPOINT, MODULE_NAME, 'handleUpdateOicpEndpoint');
// Filter
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointUpdateRequest(req.body);
+ const filteredRequest = OICPEndpointValidator.getInstance().validateOICPEndpointUpdateReq(req.body);
// Check Mandatory fields
UtilsService.checkIfOICPEndpointValid(filteredRequest, req);
// Check auth
@@ -152,8 +151,7 @@ export default class OICPEndpointService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.OICP,
Action.READ, Entity.OICP_ENDPOINT, MODULE_NAME, 'handleGetOicpEndpoint');
// Filter
- const endpointID = OICPEndpointSecurity.filterOicpEndpointRequestByID(req.query);
- UtilsService.assertIdIsProvided(action, endpointID, MODULE_NAME, 'handleGetOicpEndpoint', req.user);
+ const endpointID = OICPEndpointValidator.getInstance().validateOICPEndpointGetReq(req.query).ID;
// Check auth
if (!await Authorizations.canReadOicpEndpoint(req.user)) {
throw new AppAuthError({
@@ -195,7 +193,7 @@ export default class OICPEndpointService {
userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName' ];
}
// Filter
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointsRequest(req.query);
+ const filteredRequest = OICPEndpointValidator.getInstance().validateOICPEndpointsGetReq(req.query);
// Get all oicpendpoints
const oicpEndpoints = await OICPEndpointStorage.getOicpEndpoints(req.tenant,
{
@@ -203,7 +201,7 @@ export default class OICPEndpointService {
}, {
limit: filteredRequest.Limit,
skip: filteredRequest.Skip,
- sort: filteredRequest.SortFields,
+ sort: UtilsService.httpSortFieldsToMongoDB(filteredRequest.SortFields),
onlyRecordCount: filteredRequest.OnlyRecordCount
},
[
@@ -232,11 +230,10 @@ export default class OICPEndpointService {
});
}
// Filter
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointSendEVSEStatusesRequest(req.body);
- UtilsService.assertIdIsProvided(action, filteredRequest.id, MODULE_NAME, 'handleSendEVSEStatusesOicpEndpoint', req.user);
+ const filteredRequest = OICPEndpointValidator.getInstance().validateOICPEndpointGetReq(req.params);
// Get oicpEndpoint
- const oicpEndpoint = await OICPEndpointStorage.getOicpEndpoint(req.tenant, filteredRequest.id);
- UtilsService.assertObjectExists(action, oicpEndpoint, `OICP Endpoint ID '${filteredRequest.id}' does not exist`,
+ const oicpEndpoint = await OICPEndpointStorage.getOicpEndpoint(req.tenant, filteredRequest.ID);
+ UtilsService.assertObjectExists(action, oicpEndpoint, `OICP Endpoint ID '${filteredRequest.ID}' does not exist`,
MODULE_NAME, 'handleSendEVSEStatusesOicpEndpoint', req.user);
// Build OICP Client
const oicpClient = await OICPClientFactory.getCpoOicpClient(req.tenant, oicpEndpoint);
@@ -263,11 +260,10 @@ export default class OICPEndpointService {
});
}
// Filter
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointSendEVSEsRequest(req.body);
- UtilsService.assertIdIsProvided(action, filteredRequest.id, MODULE_NAME, 'handleSendEVSEsOicpEndpoint', req.user);
+ const filteredRequest = OICPEndpointValidator.getInstance().validateOICPEndpointGetReq(req.params);
// Get oicpEndpoint
- const oicpEndpoint = await OICPEndpointStorage.getOicpEndpoint(req.tenant, filteredRequest.id);
- UtilsService.assertObjectExists(action, oicpEndpoint, `OICP Endpoint ID '${filteredRequest.id}' does not exist`,
+ const oicpEndpoint = await OICPEndpointStorage.getOicpEndpoint(req.tenant, filteredRequest.ID);
+ UtilsService.assertObjectExists(action, oicpEndpoint, `OICP Endpoint ID '${filteredRequest.ID}' does not exist`,
MODULE_NAME, 'handleSendEVSEsOicpEndpoint', req.user);
// Build OICP Client
const oicpClient = await OICPClientFactory.getCpoOicpClient(req.tenant, oicpEndpoint);
@@ -294,7 +290,7 @@ export default class OICPEndpointService {
});
}
// Filter
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointPingRequest(req.body);
+ const filteredRequest = OICPEndpointValidator.getInstance().validateOICPEndpointPingReq(req.params);
// Check Mandatory fields
UtilsService.checkIfOICPEndpointValid(filteredRequest, req);
// Get oicpEndpoint
@@ -309,7 +305,7 @@ export default class OICPEndpointService {
await Logging.logInfo({
tenantID: req.tenant.id,
user: req.user, module: MODULE_NAME, method: 'handlePingOicpEndpoint',
- message: `Oicp Endpoint '${filteredRequest.name}' can be reached successfully`,
+ message: `Oicp Endpoint '${oicpEndpoint.name}' can be reached successfully`,
action: action,
detailedMessages: { pingResult }
});
@@ -319,7 +315,7 @@ export default class OICPEndpointService {
await Logging.logError({
tenantID: req.tenant.id,
user: req.user, module: MODULE_NAME, method: 'handlePingOicpEndpoint',
- message: `Oicp Endpoint '${filteredRequest.name}' cannot be reached`,
+ message: `Oicp Endpoint '${oicpEndpoint.name}' cannot be reached`,
action: action,
detailedMessages: { pingResult }
});
@@ -342,11 +338,10 @@ export default class OICPEndpointService {
});
}
// Filter
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointRegisterRequest(req.body);
- UtilsService.assertIdIsProvided(action, filteredRequest.id, MODULE_NAME, 'handleUnregisterOicpEndpoint', req.user);
+ const filteredRequest = OICPEndpointValidator.getInstance().validateOICPEndpointGetReq(req.params);
// Get OicpEndpoint
- const oicpEndpoint = await OICPEndpointStorage.getOicpEndpoint(req.tenant, filteredRequest.id);
- UtilsService.assertObjectExists(action, oicpEndpoint, `OICP Endpoint ID '${filteredRequest.id}' does not exist`,
+ const oicpEndpoint = await OICPEndpointStorage.getOicpEndpoint(req.tenant, filteredRequest.ID);
+ UtilsService.assertObjectExists(action, oicpEndpoint, `OICP Endpoint ID '${filteredRequest.ID}' does not exist`,
MODULE_NAME, 'handleUnregisterOicpEndpoint', req.user);
// Build OICP Client
const oicpClient = await OICPClientFactory.getOicpClient(req.tenant, oicpEndpoint);
@@ -391,11 +386,10 @@ export default class OICPEndpointService {
});
}
// Filter
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointRegisterRequest(req.body);
- UtilsService.assertIdIsProvided(action, filteredRequest.id, MODULE_NAME, 'handleRegisterOicpEndpoint', req.user);
+ const filteredRequest = OICPEndpointValidator.getInstance().validateOICPEndpointGetReq(req.params);
// Get OicpEndpoint
- const oicpEndpoint = await OICPEndpointStorage.getOicpEndpoint(req.tenant, filteredRequest.id);
- UtilsService.assertObjectExists(action, oicpEndpoint, `OICP Endpoint ID '${filteredRequest.id}' does not exist`,
+ const oicpEndpoint = await OICPEndpointStorage.getOicpEndpoint(req.tenant, filteredRequest.ID);
+ UtilsService.assertObjectExists(action, oicpEndpoint, `OICP Endpoint ID '${filteredRequest.ID}' does not exist`,
MODULE_NAME, 'handleRegisterOicpEndpoint', req.user);
// Build OICP Client
const oicpClient = await OICPClientFactory.getOicpClient(req.tenant, oicpEndpoint);

DELETE
src/server/rest/v1/service/security/OICPEndpointSecurity.ts
-import { HttpOICPEndpointsRequest } from '../../../../../types/requests/HttpOICPEndpointRequest';
-import OICPEndpoint from '../../../../../types/oicp/OICPEndpoint';
-import UtilsSecurity from './UtilsSecurity';
-import sanitize from 'mongo-sanitize';
-
-export default class OICPEndpointSecurity {
- public static filterOicpEndpointDeleteRequest(request: any): HttpOICPEndpointsRequest {
- const filteredRequest: HttpOICPEndpointsRequest = {} as HttpOICPEndpointsRequest;
- // Set
- filteredRequest.ID = sanitize(request.ID);
- return filteredRequest;
- }
-
- public static filterOicpEndpointRequestByID(request: any): string {
- return sanitize(request.ID);
- }
-
- public static filterOicpEndpointUpdateRequest(request: any): Partial<OICPEndpoint> {
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointRequest(request);
- filteredRequest.id = sanitize(request.id);
- return filteredRequest;
- }
-
- public static filterOicpEndpointCreateRequest(request: any): Partial<OICPEndpoint> {
- return OICPEndpointSecurity.filterOicpEndpointRequest(request);
- }
-
- public static filterOicpEndpointsRequest(request: any): Partial<HttpOICPEndpointsRequest> {
- const filteredRequest: Partial<HttpOICPEndpointsRequest> = {
- Search: sanitize(request.Search)
- };
- UtilsSecurity.filterSkipAndLimit(request, filteredRequest);
- UtilsSecurity.filterSort(request, filteredRequest);
- return filteredRequest;
- }
-
- public static filterOicpEndpointPingRequest(request: any): Partial<OICPEndpoint> {
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointRequest(request);
- filteredRequest.id = sanitize(request.id);
- return filteredRequest;
- }
-
- public static filterOicpEndpointSendEVSEStatusesRequest(request: any): Partial<OICPEndpoint> {
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointRequest(request);
- filteredRequest.id = sanitize(request.id);
- return filteredRequest;
- }
-
- public static filterOicpEndpointSendEVSEsRequest(request: any): Partial<OICPEndpoint> {
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointRequest(request);
- filteredRequest.id = sanitize(request.id);
- return filteredRequest;
- }
-
- public static filterOicpEndpointRegisterRequest(request: any): Partial<OICPEndpoint> {
- const filteredRequest = OICPEndpointSecurity.filterOicpEndpointRequest(request);
- filteredRequest.id = sanitize(request.id);
- return filteredRequest;
- }
-
- private static filterOicpEndpointRequest(request: any): Partial<OICPEndpoint> {
- const filteredRequest: Partial<OICPEndpoint> = {};
- filteredRequest.name = sanitize(request.name);
- filteredRequest.role = sanitize(request.role);
- filteredRequest.baseUrl = sanitize(request.baseUrl);
- filteredRequest.countryCode = sanitize(request.countryCode);
- filteredRequest.partyId = sanitize(request.partyId);
- filteredRequest.backgroundPatchJob = sanitize(request.backgroundPatchJob);
- return filteredRequest;
- }
-}

ADD
src/server/rest/v1/validator/OICPEndpointValidator.ts
+import { HttpOICPEndpointRequest, HttpOICPEndpointsRequest } from '../../../../types/requests/HttpOICPEndpointRequest';
+
+import OICPEndpoint from '../../../../types/oicp/OICPEndpoint';
+import Schema from '../../../../types/validator/Schema';
+import SchemaValidator from '../../../../validator/SchemaValidator';
+import fs from 'fs';
+import global from '../../../../types/GlobalType';
+
+export default class OICPEndpointValidator extends SchemaValidator {
+ private static instance: OICPEndpointValidator|null = null;
+ private oicpEndpointCreate: Schema;
+ private oicpEndpointPing: Schema;
+ private oicpEndpointGet: Schema;
+ private oicpEndpointsGet: Schema;
+ private oicpEndpointUpdate: Schema;
+
+
+ private constructor() {
+ super('OICPEndpointValidator');
+ this.oicpEndpointCreate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/oicp/oicp-endpoint-create.json`, 'utf8'));
+ this.oicpEndpointPing = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/oicp/oicp-endpoint-ping.json`, 'utf8'));
+ this.oicpEndpointGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/oicp/oicp-endpoint-get.json`, 'utf8'));
+ this.oicpEndpointsGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/oicp/oicp-endpoints-get.json`, 'utf8'));
+ this.oicpEndpointUpdate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/oicp/oicp-endpoint-update.json`, 'utf8'));
+ }
+
+ public static getInstance(): OICPEndpointValidator {
+ if (!OICPEndpointValidator.instance) {
+ OICPEndpointValidator.instance = new OICPEndpointValidator();
+ }
+ return OICPEndpointValidator.instance;
+ }
+
+ public validateOICPEndpointCreateReq(data: Record<string, unknown>): OICPEndpoint {
+ return this.validate(this.oicpEndpointCreate, data);
+ }
+
+ public validateOICPEndpointPingReq(data: Record<string, unknown>): OICPEndpoint {
+ return this.validate(this.oicpEndpointPing, data);
+ }
+
+ public validateOICPEndpointGetReq(data: Record<string, unknown>): HttpOICPEndpointRequest {
+ return this.validate(this.oicpEndpointGet, data);
+ }
+
+ public validateOICPEndpointsGetReq(data: Record<string, unknown>): HttpOICPEndpointsRequest {
+ return this.validate(this.oicpEndpointsGet, data);
+ }
+
+ public validateOICPEndpointUpdateReq(data: Record<string, unknown>): OICPEndpoint {
+ return this.validate(this.oicpEndpointUpdate, data);
+ }
+}

MODIFY
src/types/requests/HttpOICPEndpointRequest.ts
src/types/requests/HttpOICPEndpointRequest.ts
+import HttpByIDRequest from './HttpByIDRequest';
import HttpDatabaseRequest from './HttpDatabaseRequest';
export interface HttpOICPEndpointsRequest extends HttpDatabaseRequest{
ID?: string;
Search?: string;
}
+
+export interface HttpOICPEndpointRequest extends HttpByIDRequest {
+ ID: string;
+}

MODIFY
src/validator/SchemaValidator.ts
src/validator/SchemaValidator.ts
@@ -29,6 +29,7 @@ export default class SchemaValidator {
private static assetSchema: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/schemas/asset/asset.json`, 'utf8'));
private static companySchema: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/schemas/company/company.json`, 'utf8'));
private static ocpiEndpointSchema: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/schemas/ocpi/ocpi-endpoint.json`, 'utf8'));
+ private static oicpEndpointSchema: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/schemas/oicp/oicp-endpoint.json`, 'utf8'));
private readonly ajv: Ajv;
constructor(readonly moduleName: string,
@@ -63,6 +64,7 @@ export default class SchemaValidator {
this.ajv.addSchema(SchemaValidator.assetSchema);
this.ajv.addSchema(SchemaValidator.companySchema);
this.ajv.addSchema(SchemaValidator.ocpiEndpointSchema);
+ this.ajv.addSchema(SchemaValidator.oicpEndpointSchema);
}
protected validate(schema: Schema, data: Record<string, unknown>): any {

Added OICP schemas validation