ocpp icon indicating copy to clipboard operation
ocpp copied to clipboard

Allow to provide JSON schemas manually

Open OrangeTux opened this issue 2 years ago • 1 comments

The OCA doesn't allow to share the JSON schemas for OCPP 2.1 outside it's members. Thus this library can't include these schemas.

This commit introduces the SchemaValidator: a structure that loads schemas located at inprovide folder and validates payload against those schemas. The file names of the schema must follow the format 'Request' or 'Response'. E.g.: "HeartbeatRequest" or "BootNotificationResponse".

The file names for the schemas of OCPP 1.6 and OCPP 2.0 have been adjusted to follow this pattern.

Users relying on ocpp.v16, ocpp.v20 or ocpp.v201 shouldn't be affected by introduction of SchemaValidator. These modules create a default instance of Validator to include the right set of schemas.

Users of ocpp.v21 can create a custom validator and pass it to the construct of ocpp.v21.ChargePoint. See also the two examples in examples/v21/.

Fixes: #453

OrangeTux avatar Jul 21 '23 14:07 OrangeTux