mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 08:51:30 -05:00
add `datetime` format (note, not the built-in `date-time`) to our json schemas. this uses the iso8601 library to try and parse the string. also, move `strict-rfc3339` and `rfc3987` (used by jsonschema to validate `date-time` and `uri` formats respectively from test requirements to regular requirements. if they're not installed, validation silently succeeds, so validation wouldnt reject anything bad on prod, only in unit tests.
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
from app.schema_validation.definitions import uuid
|
|
from app.models import BroadcastStatusType
|
|
|
|
create_broadcast_message_schema = {
|
|
'$schema': 'http://json-schema.org/draft-04/schema#',
|
|
'description': 'POST create broadcast_message schema',
|
|
'type': 'object',
|
|
'title': 'Create broadcast_message',
|
|
'properties': {
|
|
'template_id': uuid,
|
|
'service_id': uuid,
|
|
'created_by': uuid,
|
|
'personalisation': {'type': 'object'},
|
|
'starts_at': {'type': 'string', 'format': 'datetime'},
|
|
'finishes_at': {'type': 'string', 'format': 'datetime'},
|
|
'areas': {"type": "array", "items": {"type": "string"}},
|
|
},
|
|
'required': ['template_id', 'service_id', 'created_by'],
|
|
'additionalProperties': False
|
|
}
|
|
|
|
update_broadcast_message_schema = {
|
|
'$schema': 'http://json-schema.org/draft-04/schema#',
|
|
'description': 'POST update broadcast_message schema',
|
|
'type': 'object',
|
|
'title': 'Update broadcast_message',
|
|
'properties': {
|
|
'personalisation': {'type': 'object'},
|
|
'starts_at': {'type': 'string', 'format': 'datetime'},
|
|
'finishes_at': {'type': 'string', 'format': 'datetime'},
|
|
'areas': {"type": "array", "items": {"type": "string"}},
|
|
},
|
|
'required': [],
|
|
'additionalProperties': False
|
|
}
|
|
|
|
update_broadcast_message_status_schema = {
|
|
'$schema': 'http://json-schema.org/draft-04/schema#',
|
|
'description': 'POST update broadcast_message status schema',
|
|
'type': 'object',
|
|
'title': 'Update broadcast_message',
|
|
'properties': {
|
|
'status': {'type': 'string', 'enum': BroadcastStatusType.STATUSES},
|
|
'created_by': uuid,
|
|
},
|
|
'required': ['status', 'created_by'],
|
|
'additionalProperties': False
|
|
}
|