Allow to provide JSON schemas manually #459
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
orocpp.v201
shouldn't be affected by introduction ofSchemaValidator
. These modules create a default instance ofValidator
to include the right set of schemas.Users of
ocpp.v21
can create a custom validator and pass it to the construct ofocpp.v21.ChargePoint
. See also the two examples inexamples/v21/
.Fixes: #453