Initial commit: Check-My-IRVE SaaS (OCPP 1.6, Audit, Diagnostics)
This commit is contained in:
commit
192be86487
44 changed files with 2070 additions and 0 deletions
39
backend/app/core/ocpp_schemas.py
Normal file
39
backend/app/core/ocpp_schemas.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import jsonschema
|
||||
|
||||
# Schémas simplifiés pour la démo (basés sur la spec OCPP 1.6)
|
||||
SCHEMAS = {
|
||||
"BootNotification": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"chargePointVendor": {"type": "string", "maxLength": 20},
|
||||
"chargePointModel": {"type": "string", "maxLength": 20}
|
||||
},
|
||||
"required": ["chargePointVendor", "chargePointModel"]
|
||||
},
|
||||
"Authorize": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"idTag": {"type": "string", "maxLength": 20}
|
||||
},
|
||||
"required": ["idTag"]
|
||||
},
|
||||
"StartTransaction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"connectorId": {"type": "integer"},
|
||||
"idTag": {"type": "string"},
|
||||
"meterStart": {"type": "integer"},
|
||||
"timestamp": {"type": "string"}
|
||||
},
|
||||
"required": ["connectorId", "idTag", "meterStart", "timestamp"]
|
||||
}
|
||||
}
|
||||
|
||||
def validate_payload(action, payload):
|
||||
if action in SCHEMAS:
|
||||
try:
|
||||
jsonschema.validate(instance=payload, schema=SCHEMAS[action])
|
||||
return None
|
||||
except jsonschema.ValidationError as e:
|
||||
return e.message
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue