From 663c5b3ac518d567e14efd06b9a076d3322af86c Mon Sep 17 00:00:00 2001 From: Laura Ghiorghisor Date: Wed, 16 Oct 2024 12:55:58 +0100 Subject: [PATCH] Remove custom logic for specialist document type Since we need to use the allowed list anyway, we can remove the if-else check and allow the generator to populate the doc type list with all the allowed types, which makes it a bit more restrictive than just "string". --- .../specialist_document/frontend/schema.json | 188 +++++++++++++++++- .../notification/schema.json | 188 +++++++++++++++++- .../publisher_v2/schema.json | 188 +++++++++++++++++- lib/schema_generator/format.rb | 4 - .../schema_generator/document_type_spec.rb | 11 - 5 files changed, 561 insertions(+), 18 deletions(-) delete mode 100644 spec/lib/schema_generator/document_type_spec.rb diff --git a/content_schemas/dist/formats/specialist_document/frontend/schema.json b/content_schemas/dist/formats/specialist_document/frontend/schema.json index 94dfdcfaa..801cfda6c 100644 --- a/content_schemas/dist/formats/specialist_document/frontend/schema.json +++ b/content_schemas/dist/formats/specialist_document/frontend/schema.json @@ -32,7 +32,193 @@ "$ref": "#/definitions/details" }, "document_type": { - "type": "string" + "type": "string", + "enum": [ + "aaib_report", + "about", + "about_our_services", + "accessible_documents_policy", + "access_and_opening", + "ai_assurance_portfolio_technique", + "algorithmic_transparency_record", + "ambassador_role", + "animal_disease_case", + "answer", + "asylum_support_decision", + "authored_article", + "board_member_role", + "business_finance_support_scheme", + "calendar", + "call_for_evidence", + "call_for_evidence_outcome", + "case_study", + "chief_professional_officer_role", + "chief_scientific_officer_role", + "chief_scientific_advisor_role", + "closed_call_for_evidence", + "closed_consultation", + "cma_case", + "content_block_email_address", + "content_block_postal_address", + "complaints_procedure", + "completed_transaction", + "consultation", + "consultation_outcome", + "contact", + "coronavirus_landing_page", + "corporate_report", + "correspondence", + "countryside_stewardship_grant", + "decision", + "deputy_head_of_mission_role", + "detailed_guide", + "document_collection", + "drcf_digital_markets_research", + "drug_safety_update", + "email_alert_signup", + "embassies_index", + "employment_appeal_tribunal_decision", + "employment_tribunal_decision", + "equality_and_diversity", + "esi_fund", + "export_health_certificate", + "external_content", + "facet", + "farming_grant", + "fatality_notice", + "field_of_operation", + "fields_of_operation", + "finder", + "finder_email_signup", + "flood_and_coastal_erosion_risk_management_research_report", + "foi_release", + "form", + "get_involved", + "gone", + "government", + "government_response", + "governor_role", + "guidance", + "guide", + "help_page", + "high_commissioner_role", + "historic_appointment", + "historic_appointments", + "history", + "hmrc_manual", + "hmrc_manual_section", + "homepage", + "how_government_works", + "html_publication", + "impact_assessment", + "independent_report", + "international_development_fund", + "international_treaty", + "landing_page", + "licence", + "license_finder", + "licence_transaction", + "life_saving_maritime_appliance_service_station", + "link_collection", + "local_transaction", + "maib_report", + "mainstream_browse_page", + "marine_equipment_approved_recommendation", + "manual", + "manual_section", + "map", + "marine_notice", + "media_enquiries", + "medical_safety_alert", + "membership", + "military_role", + "ministerial_role", + "ministers_index", + "modern_slavery_statement", + "national", + "national_statistics", + "national_statistics_announcement", + "need", + "news_story", + "notice", + "official", + "official_statistics", + "official_statistics_announcement", + "open_call_for_evidence", + "open_consultation", + "oral_statement", + "organisation", + "our_energy_use", + "our_governance", + "person", + "personal_information_charter", + "petitions_and_campaigns", + "place", + "policy_paper", + "press_release", + "procurement", + "product_safety_alert_report_recall", + "promotional", + "protected_food_drink_name", + "publication_scheme", + "raib_report", + "recruitment", + "redirect", + "regulation", + "research", + "research_for_development_output", + "residential_property_tribunal_decision", + "role_appointment", + "search", + "service_manual_guide", + "service_manual_homepage", + "service_manual_service_standard", + "service_manual_service_toolkit", + "service_manual_topic", + "service_sign_in", + "service_standard_report", + "services_and_information", + "simple_smart_answer", + "smart_answer", + "social_media_use", + "special_representative_role", + "special_route", + "speech", + "staff_update", + "standard", + "statistical_data_set", + "statistics", + "statistics_announcement", + "statutory_guidance", + "statutory_instrument", + "step_by_step_nav", + "substitute", + "take_part", + "tax_tribunal_decision", + "taxon", + "terms_of_reference", + "topical_event", + "topical_event_about_page", + "traffic_commissioner_regulatory_decision", + "traffic_commissioner_role", + "transaction", + "transparency", + "travel_advice", + "travel_advice_index", + "utaac_decision", + "vanish", + "veterans_support_organisation", + "welsh_language_scheme", + "working_group", + "world_index", + "world_location", + "world_location_news", + "world_news_story", + "worldwide_office_staff_role", + "worldwide_office", + "worldwide_organisation", + "written_statement" + ] }, "first_published_at": { "anyOf": [ diff --git a/content_schemas/dist/formats/specialist_document/notification/schema.json b/content_schemas/dist/formats/specialist_document/notification/schema.json index bbacccc23..34c529e66 100644 --- a/content_schemas/dist/formats/specialist_document/notification/schema.json +++ b/content_schemas/dist/formats/specialist_document/notification/schema.json @@ -56,7 +56,193 @@ "$ref": "#/definitions/details" }, "document_type": { - "type": "string" + "type": "string", + "enum": [ + "aaib_report", + "about", + "about_our_services", + "accessible_documents_policy", + "access_and_opening", + "ai_assurance_portfolio_technique", + "algorithmic_transparency_record", + "ambassador_role", + "animal_disease_case", + "answer", + "asylum_support_decision", + "authored_article", + "board_member_role", + "business_finance_support_scheme", + "calendar", + "call_for_evidence", + "call_for_evidence_outcome", + "case_study", + "chief_professional_officer_role", + "chief_scientific_officer_role", + "chief_scientific_advisor_role", + "closed_call_for_evidence", + "closed_consultation", + "cma_case", + "content_block_email_address", + "content_block_postal_address", + "complaints_procedure", + "completed_transaction", + "consultation", + "consultation_outcome", + "contact", + "coronavirus_landing_page", + "corporate_report", + "correspondence", + "countryside_stewardship_grant", + "decision", + "deputy_head_of_mission_role", + "detailed_guide", + "document_collection", + "drcf_digital_markets_research", + "drug_safety_update", + "email_alert_signup", + "embassies_index", + "employment_appeal_tribunal_decision", + "employment_tribunal_decision", + "equality_and_diversity", + "esi_fund", + "export_health_certificate", + "external_content", + "facet", + "farming_grant", + "fatality_notice", + "field_of_operation", + "fields_of_operation", + "finder", + "finder_email_signup", + "flood_and_coastal_erosion_risk_management_research_report", + "foi_release", + "form", + "get_involved", + "gone", + "government", + "government_response", + "governor_role", + "guidance", + "guide", + "help_page", + "high_commissioner_role", + "historic_appointment", + "historic_appointments", + "history", + "hmrc_manual", + "hmrc_manual_section", + "homepage", + "how_government_works", + "html_publication", + "impact_assessment", + "independent_report", + "international_development_fund", + "international_treaty", + "landing_page", + "licence", + "license_finder", + "licence_transaction", + "life_saving_maritime_appliance_service_station", + "link_collection", + "local_transaction", + "maib_report", + "mainstream_browse_page", + "marine_equipment_approved_recommendation", + "manual", + "manual_section", + "map", + "marine_notice", + "media_enquiries", + "medical_safety_alert", + "membership", + "military_role", + "ministerial_role", + "ministers_index", + "modern_slavery_statement", + "national", + "national_statistics", + "national_statistics_announcement", + "need", + "news_story", + "notice", + "official", + "official_statistics", + "official_statistics_announcement", + "open_call_for_evidence", + "open_consultation", + "oral_statement", + "organisation", + "our_energy_use", + "our_governance", + "person", + "personal_information_charter", + "petitions_and_campaigns", + "place", + "policy_paper", + "press_release", + "procurement", + "product_safety_alert_report_recall", + "promotional", + "protected_food_drink_name", + "publication_scheme", + "raib_report", + "recruitment", + "redirect", + "regulation", + "research", + "research_for_development_output", + "residential_property_tribunal_decision", + "role_appointment", + "search", + "service_manual_guide", + "service_manual_homepage", + "service_manual_service_standard", + "service_manual_service_toolkit", + "service_manual_topic", + "service_sign_in", + "service_standard_report", + "services_and_information", + "simple_smart_answer", + "smart_answer", + "social_media_use", + "special_representative_role", + "special_route", + "speech", + "staff_update", + "standard", + "statistical_data_set", + "statistics", + "statistics_announcement", + "statutory_guidance", + "statutory_instrument", + "step_by_step_nav", + "substitute", + "take_part", + "tax_tribunal_decision", + "taxon", + "terms_of_reference", + "topical_event", + "topical_event_about_page", + "traffic_commissioner_regulatory_decision", + "traffic_commissioner_role", + "transaction", + "transparency", + "travel_advice", + "travel_advice_index", + "utaac_decision", + "vanish", + "veterans_support_organisation", + "welsh_language_scheme", + "working_group", + "world_index", + "world_location", + "world_location_news", + "world_news_story", + "worldwide_office_staff_role", + "worldwide_office", + "worldwide_organisation", + "written_statement" + ] }, "email_document_supertype": { "description": "Document supertype grouping intended to power the Whitehall finders and email subscriptions", 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 ce96d5363..add22564d 100644 --- a/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json +++ b/content_schemas/dist/formats/specialist_document/publisher_v2/schema.json @@ -45,7 +45,193 @@ "$ref": "#/definitions/details" }, "document_type": { - "type": "string" + "type": "string", + "enum": [ + "aaib_report", + "about", + "about_our_services", + "accessible_documents_policy", + "access_and_opening", + "ai_assurance_portfolio_technique", + "algorithmic_transparency_record", + "ambassador_role", + "animal_disease_case", + "answer", + "asylum_support_decision", + "authored_article", + "board_member_role", + "business_finance_support_scheme", + "calendar", + "call_for_evidence", + "call_for_evidence_outcome", + "case_study", + "chief_professional_officer_role", + "chief_scientific_officer_role", + "chief_scientific_advisor_role", + "closed_call_for_evidence", + "closed_consultation", + "cma_case", + "content_block_email_address", + "content_block_postal_address", + "complaints_procedure", + "completed_transaction", + "consultation", + "consultation_outcome", + "contact", + "coronavirus_landing_page", + "corporate_report", + "correspondence", + "countryside_stewardship_grant", + "decision", + "deputy_head_of_mission_role", + "detailed_guide", + "document_collection", + "drcf_digital_markets_research", + "drug_safety_update", + "email_alert_signup", + "embassies_index", + "employment_appeal_tribunal_decision", + "employment_tribunal_decision", + "equality_and_diversity", + "esi_fund", + "export_health_certificate", + "external_content", + "facet", + "farming_grant", + "fatality_notice", + "field_of_operation", + "fields_of_operation", + "finder", + "finder_email_signup", + "flood_and_coastal_erosion_risk_management_research_report", + "foi_release", + "form", + "get_involved", + "gone", + "government", + "government_response", + "governor_role", + "guidance", + "guide", + "help_page", + "high_commissioner_role", + "historic_appointment", + "historic_appointments", + "history", + "hmrc_manual", + "hmrc_manual_section", + "homepage", + "how_government_works", + "html_publication", + "impact_assessment", + "independent_report", + "international_development_fund", + "international_treaty", + "landing_page", + "licence", + "license_finder", + "licence_transaction", + "life_saving_maritime_appliance_service_station", + "link_collection", + "local_transaction", + "maib_report", + "mainstream_browse_page", + "marine_equipment_approved_recommendation", + "manual", + "manual_section", + "map", + "marine_notice", + "media_enquiries", + "medical_safety_alert", + "membership", + "military_role", + "ministerial_role", + "ministers_index", + "modern_slavery_statement", + "national", + "national_statistics", + "national_statistics_announcement", + "need", + "news_story", + "notice", + "official", + "official_statistics", + "official_statistics_announcement", + "open_call_for_evidence", + "open_consultation", + "oral_statement", + "organisation", + "our_energy_use", + "our_governance", + "person", + "personal_information_charter", + "petitions_and_campaigns", + "place", + "policy_paper", + "press_release", + "procurement", + "product_safety_alert_report_recall", + "promotional", + "protected_food_drink_name", + "publication_scheme", + "raib_report", + "recruitment", + "redirect", + "regulation", + "research", + "research_for_development_output", + "residential_property_tribunal_decision", + "role_appointment", + "search", + "service_manual_guide", + "service_manual_homepage", + "service_manual_service_standard", + "service_manual_service_toolkit", + "service_manual_topic", + "service_sign_in", + "service_standard_report", + "services_and_information", + "simple_smart_answer", + "smart_answer", + "social_media_use", + "special_representative_role", + "special_route", + "speech", + "staff_update", + "standard", + "statistical_data_set", + "statistics", + "statistics_announcement", + "statutory_guidance", + "statutory_instrument", + "step_by_step_nav", + "substitute", + "take_part", + "tax_tribunal_decision", + "taxon", + "terms_of_reference", + "topical_event", + "topical_event_about_page", + "traffic_commissioner_regulatory_decision", + "traffic_commissioner_role", + "transaction", + "transparency", + "travel_advice", + "travel_advice_index", + "utaac_decision", + "vanish", + "veterans_support_organisation", + "welsh_language_scheme", + "working_group", + "world_index", + "world_location", + "world_location_news", + "world_news_story", + "worldwide_office_staff_role", + "worldwide_office", + "worldwide_organisation", + "written_statement" + ] }, "first_published_at": { "$ref": "#/definitions/first_published_at" diff --git a/lib/schema_generator/format.rb b/lib/schema_generator/format.rb index 1ba94605d..1ef0fd960 100644 --- a/lib/schema_generator/format.rb +++ b/lib/schema_generator/format.rb @@ -172,10 +172,6 @@ def initialize(schema_name, document_types) end def definition - if schema_name == "specialist_document" - return { "type" => "string" } - end - if document_types.blank? return build_definition(allowed_document_types) end diff --git a/spec/lib/schema_generator/document_type_spec.rb b/spec/lib/schema_generator/document_type_spec.rb deleted file mode 100644 index b34c23d32..000000000 --- a/spec/lib/schema_generator/document_type_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "spec_helper" - -RSpec.describe SchemaGenerator::Format::DocumentType do - let!(:schema_filename) { "specialist_document" } - let!(:data) { Jsonnet.load("content_schemas/formats/#{schema_filename}.jsonnet") } - let!(:format) { SchemaGenerator::Format.new("specialist_document", data) } - - it "returns custom definition for specialist documents" do - expect(format.document_type.definition).to eq({ "type" => "string" }) - end -end