From e70e389f3f66fd7f19cbc3563ec6fd426b218500 Mon Sep 17 00:00:00 2001 From: Laura Ghiorghisor Date: Wed, 7 Aug 2024 09:58:15 +0100 Subject: [PATCH 1/2] Add mock finder --- content_schemas/allowed_document_types.yml | 1 + .../dist/formats/generic/frontend/schema.json | 1 + .../formats/generic/notification/schema.json | 1 + .../formats/generic/publisher_v2/schema.json | 1 + .../frontend/schema.json | 1 + .../notification/schema.json | 1 + .../publisher_v2/schema.json | 1 + .../specialist_document/frontend/schema.json | 30 +++++++++++++++++++ .../notification/schema.json | 30 +++++++++++++++++++ .../publisher_v2/schema.json | 30 +++++++++++++++++++ .../definitions/_specialist_document.jsonnet | 29 ++++++++++++++++++ .../formats/specialist_document.jsonnet | 1 + 12 files changed, 127 insertions(+) diff --git a/content_schemas/allowed_document_types.yml b/content_schemas/allowed_document_types.yml index 520a1a91ff..5af4274dba 100644 --- a/content_schemas/allowed_document_types.yml +++ b/content_schemas/allowed_document_types.yml @@ -98,6 +98,7 @@ - ministerial_role - ministers_index - modern_slavery_statement +- mock_spike_finder_document - national - national_statistics - national_statistics_announcement diff --git a/content_schemas/dist/formats/generic/frontend/schema.json b/content_schemas/dist/formats/generic/frontend/schema.json index f098dd0743..74a5b64706 100644 --- a/content_schemas/dist/formats/generic/frontend/schema.json +++ b/content_schemas/dist/formats/generic/frontend/schema.json @@ -134,6 +134,7 @@ "ministerial_role", "ministers_index", "modern_slavery_statement", + "mock_spike_finder_document", "national", "national_statistics", "national_statistics_announcement", diff --git a/content_schemas/dist/formats/generic/notification/schema.json b/content_schemas/dist/formats/generic/notification/schema.json index ccc471a053..1f0c2bbab1 100644 --- a/content_schemas/dist/formats/generic/notification/schema.json +++ b/content_schemas/dist/formats/generic/notification/schema.json @@ -158,6 +158,7 @@ "ministerial_role", "ministers_index", "modern_slavery_statement", + "mock_spike_finder_document", "national", "national_statistics", "national_statistics_announcement", diff --git a/content_schemas/dist/formats/generic/publisher_v2/schema.json b/content_schemas/dist/formats/generic/publisher_v2/schema.json index ab2dfbde0a..07a215fcd8 100644 --- a/content_schemas/dist/formats/generic/publisher_v2/schema.json +++ b/content_schemas/dist/formats/generic/publisher_v2/schema.json @@ -144,6 +144,7 @@ "ministerial_role", "ministers_index", "modern_slavery_statement", + "mock_spike_finder_document", "national", "national_statistics", "national_statistics_announcement", diff --git a/content_schemas/dist/formats/generic_with_external_related_links/frontend/schema.json b/content_schemas/dist/formats/generic_with_external_related_links/frontend/schema.json index a8687c39f2..2a99d679a4 100644 --- a/content_schemas/dist/formats/generic_with_external_related_links/frontend/schema.json +++ b/content_schemas/dist/formats/generic_with_external_related_links/frontend/schema.json @@ -134,6 +134,7 @@ "ministerial_role", "ministers_index", "modern_slavery_statement", + "mock_spike_finder_document", "national", "national_statistics", "national_statistics_announcement", diff --git a/content_schemas/dist/formats/generic_with_external_related_links/notification/schema.json b/content_schemas/dist/formats/generic_with_external_related_links/notification/schema.json index ab5927e1ba..475d3143f2 100644 --- a/content_schemas/dist/formats/generic_with_external_related_links/notification/schema.json +++ b/content_schemas/dist/formats/generic_with_external_related_links/notification/schema.json @@ -158,6 +158,7 @@ "ministerial_role", "ministers_index", "modern_slavery_statement", + "mock_spike_finder_document", "national", "national_statistics", "national_statistics_announcement", diff --git a/content_schemas/dist/formats/generic_with_external_related_links/publisher_v2/schema.json b/content_schemas/dist/formats/generic_with_external_related_links/publisher_v2/schema.json index 4351122329..5c6ace094b 100644 --- a/content_schemas/dist/formats/generic_with_external_related_links/publisher_v2/schema.json +++ b/content_schemas/dist/formats/generic_with_external_related_links/publisher_v2/schema.json @@ -144,6 +144,7 @@ "ministerial_role", "ministers_index", "modern_slavery_statement", + "mock_spike_finder_document", "national", "national_statistics", "national_statistics_announcement", diff --git a/content_schemas/dist/formats/specialist_document/frontend/schema.json b/content_schemas/dist/formats/specialist_document/frontend/schema.json index 5fc842bfc3..6474c713d2 100644 --- a/content_schemas/dist/formats/specialist_document/frontend/schema.json +++ b/content_schemas/dist/formats/specialist_document/frontend/schema.json @@ -57,6 +57,7 @@ "marine_equipment_approved_recommendation", "marine_notice", "medical_safety_alert", + "mock_spike_finder_document", "product_safety_alert_report_recall", "protected_food_drink_name", "raib_report", @@ -707,6 +708,9 @@ { "$ref": "#/definitions/medical_safety_alert_metadata" }, + { + "$ref": "#/definitions/mock_spike_finder_document_metadata" + }, { "$ref": "#/definitions/product_safety_alert_report_recall_metadata" }, @@ -2713,6 +2717,32 @@ } } }, + "mock_spike_finder_document_metadata": { + "type": "object", + "additionalProperties": false, + "properties": { + "bulk_published": { + "type": "boolean" + }, + "mock_spike_finder_document_facet_one": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "facet_one_value_one", + "facet_one_value_two" + ] + } + }, + "mock_spike_finder_document_facet_two": { + "type": "string", + "enum": [ + "facet_two_value_one", + "facet_two_value_two" + ] + } + } + }, "nested_headers": { "type": "array", "items": { diff --git a/content_schemas/dist/formats/specialist_document/notification/schema.json b/content_schemas/dist/formats/specialist_document/notification/schema.json index 713b0383a5..8f1ad6328c 100644 --- a/content_schemas/dist/formats/specialist_document/notification/schema.json +++ b/content_schemas/dist/formats/specialist_document/notification/schema.json @@ -81,6 +81,7 @@ "marine_equipment_approved_recommendation", "marine_notice", "medical_safety_alert", + "mock_spike_finder_document", "product_safety_alert_report_recall", "protected_food_drink_name", "raib_report", @@ -795,6 +796,9 @@ { "$ref": "#/definitions/medical_safety_alert_metadata" }, + { + "$ref": "#/definitions/mock_spike_finder_document_metadata" + }, { "$ref": "#/definitions/product_safety_alert_report_recall_metadata" }, @@ -2814,6 +2818,32 @@ } } }, + "mock_spike_finder_document_metadata": { + "type": "object", + "additionalProperties": false, + "properties": { + "bulk_published": { + "type": "boolean" + }, + "mock_spike_finder_document_facet_one": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "facet_one_value_one", + "facet_one_value_two" + ] + } + }, + "mock_spike_finder_document_facet_two": { + "type": "string", + "enum": [ + "facet_two_value_one", + "facet_two_value_two" + ] + } + } + }, "multiple_content_types": { "type": "array", "items": { diff --git a/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json b/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json index 6495aafaf5..60a2801a4a 100644 --- a/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json +++ b/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json @@ -67,6 +67,7 @@ "marine_equipment_approved_recommendation", "marine_notice", "medical_safety_alert", + "mock_spike_finder_document", "product_safety_alert_report_recall", "protected_food_drink_name", "raib_report", @@ -631,6 +632,9 @@ { "$ref": "#/definitions/medical_safety_alert_metadata" }, + { + "$ref": "#/definitions/mock_spike_finder_document_metadata" + }, { "$ref": "#/definitions/product_safety_alert_report_recall_metadata" }, @@ -2511,6 +2515,32 @@ } } }, + "mock_spike_finder_document_metadata": { + "type": "object", + "additionalProperties": false, + "properties": { + "bulk_published": { + "type": "boolean" + }, + "mock_spike_finder_document_facet_one": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "facet_one_value_one", + "facet_one_value_two" + ] + } + }, + "mock_spike_finder_document_facet_two": { + "type": "string", + "enum": [ + "facet_two_value_one", + "facet_two_value_two" + ] + } + } + }, "multiple_content_types": { "type": "array", "items": { diff --git a/content_schemas/formats/shared/definitions/_specialist_document.jsonnet b/content_schemas/formats/shared/definitions/_specialist_document.jsonnet index 5337b2fc99..9e1b3476bc 100644 --- a/content_schemas/formats/shared/definitions/_specialist_document.jsonnet +++ b/content_schemas/formats/shared/definitions/_specialist_document.jsonnet @@ -71,6 +71,9 @@ { "$ref": "#/definitions/medical_safety_alert_metadata", }, + { + "$ref": "#/definitions/mock_spike_finder_document_metadata", + }, { "$ref": "#/definitions/product_safety_alert_report_recall_metadata", }, @@ -2169,6 +2172,32 @@ }, }, }, + mock_spike_finder_document_metadata: { + type: "object", + additionalProperties: false, + properties: { + bulk_published: { + type: "boolean", + }, + mock_spike_finder_document_facet_one: { + type: "array", + items: { + type: "string", + enum: [ + "facet_one_value_one", + "facet_one_value_two" + ], + }, + }, + mock_spike_finder_document_facet_two: { + type: "string", + enum: [ + "facet_two_value_one", + "facet_two_value_two" + ] + }, + }, + }, product_safety_alert_report_recall_metadata: { type: "object", additionalProperties: false, diff --git a/content_schemas/formats/specialist_document.jsonnet b/content_schemas/formats/specialist_document.jsonnet index 122513ad97..e0eda4e3bd 100644 --- a/content_schemas/formats/specialist_document.jsonnet +++ b/content_schemas/formats/specialist_document.jsonnet @@ -23,6 +23,7 @@ "marine_equipment_approved_recommendation", "marine_notice", "medical_safety_alert", + "mock_spike_finder_document", "product_safety_alert_report_recall", "protected_food_drink_name", "raib_report", From 04cd2606d3204fe973e845833cfe497941408fb5 Mon Sep 17 00:00:00 2001 From: Minno Dang Date: Thu, 22 Aug 2024 17:46:22 +0100 Subject: [PATCH 2/2] PROOF OF CONCEPT: relaxing of specialist document schema validation At the moment it is incredibly tedious to maintain the vast amount of document types and their facets for specialist documents. Unsure there is a lot of value in having these strict schema validations when a more relaxed one that doesn't check "valid values" for each field should be enough. This proof of concept works for publishing a specialist document. NOTE: for the sake of spike, the schemas have been directly manipulated to remove the enum for "document_type". if build schemas is rerun, we will lose this configuration. NOTE 2: another option is to remove enums entirely for document type across all schemas - this will also save us from having to add it to content_schemas/allowed_document_types.yml and content_schemas/formats/specialist_document.jsonnet . The question will then be whether or not that swings too far the other way. --- .../specialist_document/frontend/schema.json | 54 ++----------------- .../notification/schema.json | 54 ++----------------- .../publisher_v2/schema.json | 54 ++----------------- .../definitions/_specialist_document.jsonnet | 11 ---- 4 files changed, 9 insertions(+), 164 deletions(-) diff --git a/content_schemas/dist/formats/specialist_document/frontend/schema.json b/content_schemas/dist/formats/specialist_document/frontend/schema.json index 6474c713d2..796084bc79 100644 --- a/content_schemas/dist/formats/specialist_document/frontend/schema.json +++ b/content_schemas/dist/formats/specialist_document/frontend/schema.json @@ -32,44 +32,7 @@ "$ref": "#/definitions/details" }, "document_type": { - "type": "string", - "enum": [ - "aaib_report", - "ai_assurance_portfolio_technique", - "algorithmic_transparency_record", - "animal_disease_case", - "asylum_support_decision", - "business_finance_support_scheme", - "cma_case", - "countryside_stewardship_grant", - "drcf_digital_markets_research", - "drug_safety_update", - "employment_appeal_tribunal_decision", - "employment_tribunal_decision", - "esi_fund", - "export_health_certificate", - "farming_grant", - "flood_and_coastal_erosion_risk_management_research_report", - "international_development_fund", - "licence_transaction", - "life_saving_maritime_appliance_service_station", - "maib_report", - "marine_equipment_approved_recommendation", - "marine_notice", - "medical_safety_alert", - "mock_spike_finder_document", - "product_safety_alert_report_recall", - "protected_food_drink_name", - "raib_report", - "research_for_development_output", - "residential_property_tribunal_decision", - "service_standard_report", - "statutory_instrument", - "tax_tribunal_decision", - "traffic_commissioner_regulatory_decision", - "utaac_decision", - "veterans_support_organisation" - ] + "type": "string" }, "first_published_at": { "anyOf": [ @@ -2721,25 +2684,14 @@ "type": "object", "additionalProperties": false, "properties": { - "bulk_published": { - "type": "boolean" - }, "mock_spike_finder_document_facet_one": { "type": "array", "items": { - "type": "string", - "enum": [ - "facet_one_value_one", - "facet_one_value_two" - ] + "type": "string" } }, "mock_spike_finder_document_facet_two": { - "type": "string", - "enum": [ - "facet_two_value_one", - "facet_two_value_two" - ] + "type": "string" } } }, diff --git a/content_schemas/dist/formats/specialist_document/notification/schema.json b/content_schemas/dist/formats/specialist_document/notification/schema.json index 8f1ad6328c..21c02efa46 100644 --- a/content_schemas/dist/formats/specialist_document/notification/schema.json +++ b/content_schemas/dist/formats/specialist_document/notification/schema.json @@ -56,44 +56,7 @@ "$ref": "#/definitions/details" }, "document_type": { - "type": "string", - "enum": [ - "aaib_report", - "ai_assurance_portfolio_technique", - "algorithmic_transparency_record", - "animal_disease_case", - "asylum_support_decision", - "business_finance_support_scheme", - "cma_case", - "countryside_stewardship_grant", - "drcf_digital_markets_research", - "drug_safety_update", - "employment_appeal_tribunal_decision", - "employment_tribunal_decision", - "esi_fund", - "export_health_certificate", - "farming_grant", - "flood_and_coastal_erosion_risk_management_research_report", - "international_development_fund", - "licence_transaction", - "life_saving_maritime_appliance_service_station", - "maib_report", - "marine_equipment_approved_recommendation", - "marine_notice", - "medical_safety_alert", - "mock_spike_finder_document", - "product_safety_alert_report_recall", - "protected_food_drink_name", - "raib_report", - "research_for_development_output", - "residential_property_tribunal_decision", - "service_standard_report", - "statutory_instrument", - "tax_tribunal_decision", - "traffic_commissioner_regulatory_decision", - "utaac_decision", - "veterans_support_organisation" - ] + "type": "string" }, "email_document_supertype": { "description": "Document supertype grouping intended to power the Whitehall finders and email subscriptions", @@ -2822,25 +2785,14 @@ "type": "object", "additionalProperties": false, "properties": { - "bulk_published": { - "type": "boolean" - }, "mock_spike_finder_document_facet_one": { "type": "array", "items": { - "type": "string", - "enum": [ - "facet_one_value_one", - "facet_one_value_two" - ] + "type": "string" } }, "mock_spike_finder_document_facet_two": { - "type": "string", - "enum": [ - "facet_two_value_one", - "facet_two_value_two" - ] + "type": "string" } } }, diff --git a/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json b/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json index 60a2801a4a..f258039922 100644 --- a/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json +++ b/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json @@ -42,44 +42,7 @@ "$ref": "#/definitions/details" }, "document_type": { - "type": "string", - "enum": [ - "aaib_report", - "ai_assurance_portfolio_technique", - "algorithmic_transparency_record", - "animal_disease_case", - "asylum_support_decision", - "business_finance_support_scheme", - "cma_case", - "countryside_stewardship_grant", - "drcf_digital_markets_research", - "drug_safety_update", - "employment_appeal_tribunal_decision", - "employment_tribunal_decision", - "esi_fund", - "export_health_certificate", - "farming_grant", - "flood_and_coastal_erosion_risk_management_research_report", - "international_development_fund", - "licence_transaction", - "life_saving_maritime_appliance_service_station", - "maib_report", - "marine_equipment_approved_recommendation", - "marine_notice", - "medical_safety_alert", - "mock_spike_finder_document", - "product_safety_alert_report_recall", - "protected_food_drink_name", - "raib_report", - "research_for_development_output", - "residential_property_tribunal_decision", - "service_standard_report", - "statutory_instrument", - "tax_tribunal_decision", - "traffic_commissioner_regulatory_decision", - "utaac_decision", - "veterans_support_organisation" - ] + "type": "string" }, "first_published_at": { "$ref": "#/definitions/first_published_at" @@ -2519,25 +2482,14 @@ "type": "object", "additionalProperties": false, "properties": { - "bulk_published": { - "type": "boolean" - }, "mock_spike_finder_document_facet_one": { "type": "array", "items": { - "type": "string", - "enum": [ - "facet_one_value_one", - "facet_one_value_two" - ] + "type": "string" } }, "mock_spike_finder_document_facet_two": { - "type": "string", - "enum": [ - "facet_two_value_one", - "facet_two_value_two" - ] + "type": "string" } } }, diff --git a/content_schemas/formats/shared/definitions/_specialist_document.jsonnet b/content_schemas/formats/shared/definitions/_specialist_document.jsonnet index 9e1b3476bc..096f51482f 100644 --- a/content_schemas/formats/shared/definitions/_specialist_document.jsonnet +++ b/content_schemas/formats/shared/definitions/_specialist_document.jsonnet @@ -2176,25 +2176,14 @@ type: "object", additionalProperties: false, properties: { - bulk_published: { - type: "boolean", - }, mock_spike_finder_document_facet_one: { type: "array", items: { type: "string", - enum: [ - "facet_one_value_one", - "facet_one_value_two" - ], }, }, mock_spike_finder_document_facet_two: { type: "string", - enum: [ - "facet_two_value_one", - "facet_two_value_two" - ] }, }, },