Use Draft-07 and Draft7Validator everywhere

We were using the Draft4Validator in one place, so this updates it to
the Draft7Validator instead.

The schemas were mostly using draft 4 of the JSON schema, though there
were a couple of schemas that were already of version 7. This updates
them all to version 7, which is the latest version fully supported by
the jsonschema Python package. There are some breaking changes in the
newer version of the schema, but I could not see anywhere would these
affect us. Some of these schemas were not valid in version 4, but are
now valid in version 7 because `"required": []` was not valid in earlier
versions.
This commit is contained in:
Katie Smith
2022-04-08 17:05:59 +01:00
parent f17e01c90a
commit b440f3f904
30 changed files with 67 additions and 67 deletions

View File

@@ -1,7 +1,7 @@
from datetime import datetime
create_or_update_free_sms_fragment_limit_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST annual billing schema",
"type": "object",
"title": "Create",

View File

@@ -2,7 +2,7 @@ from app.models import BroadcastStatusType
from app.schema_validation.definitions import uuid
create_broadcast_message_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': 'POST create broadcast_message schema',
'type': 'object',
'title': 'Create broadcast_message',
@@ -32,7 +32,7 @@ create_broadcast_message_schema = {
}
update_broadcast_message_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': 'POST update broadcast_message schema',
'type': 'object',
'title': 'Update broadcast_message',
@@ -47,7 +47,7 @@ update_broadcast_message_schema = {
}
update_broadcast_message_status_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': 'POST update broadcast_message status schema',
'type': 'object',
'title': 'Update broadcast_message',

View File

@@ -1,6 +1,6 @@
complaint_count_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "complaint count request schema",
"type": "object",
"title": "Complaint count request",

View File

@@ -1,7 +1,7 @@
from app.models import BRANDING_TYPES
post_create_email_branding_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST schema for getting email_branding",
"type": "object",
"properties": {
@@ -15,7 +15,7 @@ post_create_email_branding_schema = {
}
post_update_email_branding_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST schema for getting email_branding",
"type": "object",
"properties": {

View File

@@ -1,5 +1,5 @@
get_inbound_sms_for_service_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "schema for parameters allowed when searching for to field=",
"type": "object",
"properties": {

View File

@@ -1,5 +1,5 @@
post_letter_branding_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST schema for creating or updating a letter brand",
"type": "object",
"properties": {

View File

@@ -1,5 +1,5 @@
letter_references = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "list of letter notification references",
"type": "object",
"title": "references",

View File

@@ -17,7 +17,7 @@ register_errors(letter_callback_blueprint)
dvla_sns_callback_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "sns callback received on s3 update",
"type": "object",
"title": "dvla internal sns callback",

View File

@@ -2,7 +2,7 @@ from app.models import INVITED_USER_STATUS_TYPES, ORGANISATION_TYPES
from app.schema_validation.definitions import uuid
post_create_organisation_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST organisation schema",
"type": "object",
"properties": {
@@ -15,7 +15,7 @@ post_create_organisation_schema = {
}
post_update_organisation_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST organisation schema",
"type": "object",
"properties": {
@@ -28,7 +28,7 @@ post_update_organisation_schema = {
}
post_link_service_to_organisation_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST link service to organisation schema",
"type": "object",
"properties": {
@@ -39,7 +39,7 @@ post_link_service_to_organisation_schema = {
post_create_invited_org_user_status_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST create organisation invite schema",
"type": "object",
"properties": {
@@ -52,7 +52,7 @@ post_create_invited_org_user_status_schema = {
post_update_invited_org_user_status_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST update organisation invite schema",
"type": "object",
"properties": {

View File

@@ -1,5 +1,5 @@
performance_dashboard_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Performance dashboard request schema",
"type": "object",
"title": "Performance dashboard request",

View File

@@ -1,5 +1,5 @@
platform_stats_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "platform stats request schema",
"type": "object",
"title": "Platform stats request",

View File

@@ -1,5 +1,5 @@
send_pdf_letter_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST send uploaded pdf letter",
"type": "object",
"title": "Send an uploaded pdf letter",

View File

@@ -1,5 +1,5 @@
service_broadcast_settings_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Set a services broadcast settings",
"type": "object",
"title": "Set a services broadcast settings",

View File

@@ -1,7 +1,7 @@
from app.schema_validation.definitions import https_url, uuid
create_service_callback_api_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST service callback/inbound api schema",
"type": "object",
"title": "Create service callback/inbound api",
@@ -14,7 +14,7 @@ create_service_callback_api_schema = {
}
update_service_callback_api_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST service callback/inbound api schema",
"type": "object",
"title": "Create service callback/inbound api",

View File

@@ -1,7 +1,7 @@
from app.schema_validation.definitions import uuid
create_service_contact_list_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST create service contact list schema",
"type": "object",
"title": "Create service contact list",

View File

@@ -1,5 +1,5 @@
add_service_data_retention_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST service data retention schema",
"title": "Add service data retention for notification type api",
"type": "object",
@@ -12,7 +12,7 @@ add_service_data_retention_request = {
update_service_data_retention_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST service data retention schema",
"title": "Update service data retention for notification type api",
"type": "object",

View File

@@ -1,7 +1,7 @@
from app.schema_validation.definitions import uuid
add_service_email_reply_to_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST service email reply to address",
"type": "object",
"title": "Add new email reply to address for service",
@@ -14,7 +14,7 @@ add_service_email_reply_to_request = {
add_service_letter_contact_block_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST service letter contact block",
"type": "object",
"title": "Add new letter contact block for service",
@@ -27,7 +27,7 @@ add_service_letter_contact_block_request = {
add_service_sms_sender_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST add service SMS sender",
"type": "object",
"title": "Add new SMS sender for service",

View File

@@ -1,7 +1,7 @@
from app.schema_validation.definitions import nullable_uuid, uuid
post_create_template_folder_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST schema for getting template_folder",
"type": "object",
"properties": {
@@ -12,7 +12,7 @@ post_create_template_folder_schema = {
}
post_update_template_folder_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST schema for updating template_folder",
"type": "object",
"properties": {
@@ -23,7 +23,7 @@ post_update_template_folder_schema = {
}
post_move_template_folder_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST schema for renaming template_folder",
"type": "object",
"properties": {

View File

@@ -1,5 +1,5 @@
post_verify_code_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': 'POST schema for verifying a 2fa code',
'type': 'object',
'properties': {
@@ -12,7 +12,7 @@ post_verify_code_schema = {
post_verify_webauthn_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': 'POST schema for verifying a webauthn login attempt',
'type': 'object',
'properties': {
@@ -24,7 +24,7 @@ post_verify_webauthn_schema = {
post_send_user_email_code_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': (
'POST schema for generating a 2fa email - "to" is required for legacy purposes. '
'"next" is an optional url to redirect to on sign in'
@@ -43,7 +43,7 @@ post_send_user_email_code_schema = {
post_send_user_sms_code_schema = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': 'POST schema for generating a 2fa sms',
'type': 'object',
'properties': {

View File

@@ -1,7 +1,7 @@
from app.schema_validation.definitions import uuid
get_inbound_sms_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "schema for query parameters allowed when getting list of received text messages",
"type": "object",
"properties": {
@@ -12,7 +12,7 @@ get_inbound_sms_request = {
get_inbound_sms_single_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET inbound sms schema response",
"type": "object",
"title": "GET response v2/inbound_sms",
@@ -36,7 +36,7 @@ get_inbound_sms_single_response = {
}
get_inbound_sms_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET list of inbound sms response schema",
"type": "object",
"properties": {

View File

@@ -7,7 +7,7 @@ from app.models import (
from app.schema_validation.definitions import personalisation, uuid
template = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "template schema",
"type": "object",
"title": "notification content",
@@ -20,7 +20,7 @@ template = {
}
notification_by_id = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET notification response schema",
"type": "object",
"title": "response v2/notification",
@@ -32,7 +32,7 @@ notification_by_id = {
get_notification_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET notification response schema",
"type": "object",
"title": "response v2/notification",
@@ -67,7 +67,7 @@ get_notification_response = {
}
get_notifications_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "schema for query parameters allowed when getting list of notifications",
"type": "object",
"properties": {
@@ -92,7 +92,7 @@ get_notifications_request = {
}
get_notifications_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET list of notifications response schema",
"type": "object",
"properties": {
@@ -126,7 +126,7 @@ get_notifications_response = {
}
post_sms_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST sms notification schema",
"type": "object",
"title": "POST v2/notifications/sms",
@@ -143,7 +143,7 @@ post_sms_request = {
}
sms_content = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "content schema for SMS notification response schema",
"type": "object",
"title": "notification content",
@@ -155,7 +155,7 @@ sms_content = {
}
post_sms_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST sms notification response schema",
"type": "object",
"title": "response v2/notifications/sms",
@@ -172,7 +172,7 @@ post_sms_response = {
post_email_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST email notification schema",
"type": "object",
"title": "POST v2/notifications/email",
@@ -189,7 +189,7 @@ post_email_request = {
}
email_content = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Email content for POST email notification",
"type": "object",
"title": "notification email content",
@@ -202,7 +202,7 @@ email_content = {
}
post_email_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST email notification response schema",
"type": "object",
"title": "response v2/notifications/email",
@@ -218,7 +218,7 @@ post_email_response = {
}
post_letter_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST letter notification schema",
"type": "object",
"title": "POST v2/notifications/letter",
@@ -232,7 +232,7 @@ post_letter_request = {
}
post_precompiled_letter_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST precompiled letter notification schema",
"type": "object",
"title": "POST v2/notifications/letter",
@@ -246,7 +246,7 @@ post_precompiled_letter_request = {
}
letter_content = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Letter content for POST letter notification",
"type": "object",
"title": "notification letter content",
@@ -258,7 +258,7 @@ letter_content = {
}
post_letter_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST sms notification response schema",
"type": "object",
"title": "response v2/notifications/letter",

View File

@@ -2,7 +2,7 @@ from app.models import TEMPLATE_TYPES
from app.schema_validation.definitions import personalisation, uuid
get_template_by_id_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "schema for parameters allowed when getting template by id",
"type": "object",
"properties": {
@@ -14,7 +14,7 @@ get_template_by_id_request = {
}
get_template_by_id_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET template by id schema response",
"type": "object",
"title": "reponse v2/template",
@@ -42,7 +42,7 @@ get_template_by_id_response = {
}
post_template_preview_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST template schema",
"type": "object",
"title": "POST v2/template/{id}/preview",
@@ -54,7 +54,7 @@ post_template_preview_request = {
}
post_template_preview_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST template preview schema response",
"type": "object",
"title": "reponse v2/template/{id}/preview",

View File

@@ -4,7 +4,7 @@ from app.v2.template.template_schemas import (
)
get_all_template_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "request schema for parameters allowed when getting all templates",
"type": "object",
"properties": {
@@ -14,7 +14,7 @@ get_all_template_request = {
}
get_all_template_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET response schema when getting all templates",
"type": "object",
"properties": {

View File

@@ -2,7 +2,7 @@ import os
import jsonschema
from flask import json
from jsonschema import Draft4Validator
from jsonschema import Draft7Validator
def return_json_from_response(response):
@@ -22,5 +22,5 @@ def validate_v0(json_to_validate, schema_filename):
def validate(json_to_validate, schema):
validator = Draft4Validator(schema)
validator = Draft7Validator(schema)
validator.validate(json_to_validate, schema)

View File

@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET notification return schema - for email notifications",
"type" : "object",
"properties": {

View File

@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET notification return schema - for sms notifications",
"type" : "object",
"properties": {

View File

@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET notification return schema - for sms notifications",
"type" : "object",
"properties": {

View File

@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST notification return schema - for email notifications",
"type" : "object",
"properties": {

View File

@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST notification return schema - for sms notifications",
"type" : "object",
"properties": {

View File

@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Common definitions - usage example: {'$ref': 'definitions.json#/uuid'} (swap quotes for double quotes)",
"uuid": {
"type": "string",