From 553d787076e04bd07f744277dc028cf7064000dd Mon Sep 17 00:00:00 2001 From: Aleksandr Meshchryakov Date: Thu, 24 Sep 2026 14:46:08 +0200 Subject: [PATCH] feat: publish canonical source contracts --- src/core/openapi.json | 1391 ++++++++++++++++- .../organizations/test_canonical_openapi.py | 32 +- tools/openapi/README.md | 3 + tools/openapi/build.mjs | 80 +- tools/openapi/source-record-extensions.json | 465 ++++++ 5 files changed, 1956 insertions(+), 15 deletions(-) create mode 100644 tools/openapi/source-record-extensions.json diff --git a/src/core/openapi.json b/src/core/openapi.json index b8a78c7..ad0750f 100644 --- a/src/core/openapi.json +++ b/src/core/openapi.json @@ -2601,6 +2601,9 @@ }, "415": { "description": "Неподдерживаемый тип файла" + }, + "422": { + "description": "Неверные листы, идентификаторы или вложения" } }, "tags": [ @@ -5282,6 +5285,69 @@ }, "parameters": [] }, + "/api/v1/parsers/upload/integrated_structure_documents/": { + "post": { + "operationId": "api_v1_parsers_upload_integrated_structure_documents_create", + "summary": "Документы интегрированных структур: загрузить файл", + "description": "Ручная загрузка файла для источника: События и документы интегрированных структур. Файл обрабатывается через Celery.", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "workbook": { + "description": "Один XLSX с листами is_stages и is_stages_docs, до 20 МиБ", + "type": "string", + "format": "binary" + }, + "attachments": { + "description": "Повторяемые RTF-вложения; каждый файл проверяется по сигнатуре и SHA-256", + "type": "string", + "format": "binary" + } + }, + "required": [ + "workbook" + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IntegratedStructureUploadResponse" + } + } + } + }, + "400": { + "description": "Ошибка валидации" + }, + "409": { + "description": "Загрузка уже выполняется" + }, + "413": { + "description": "Файл превышает лимит" + }, + "415": { + "description": "Неподдерживаемый тип файла" + }, + "422": { + "description": "Неверные листы, идентификаторы или вложения" + } + }, + "tags": [ + "Parser Management" + ] + }, + "parameters": [] + }, "/api/v1/parsers/upload/media_news/": { "post": { "operationId": "api_v1_parsers_upload_media_news_create", @@ -5329,6 +5395,9 @@ }, "415": { "description": "Неподдерживаемый тип файла" + }, + "422": { + "description": "Неверные листы, идентификаторы или вложения" } }, "tags": [ @@ -5384,6 +5453,9 @@ }, "415": { "description": "Неподдерживаемый тип файла" + }, + "422": { + "description": "Неверные листы, идентификаторы или вложения" } }, "tags": [ @@ -9212,6 +9284,15 @@ "type": "string" } }, + { + "name": "company_status", + "in": "query", + "description": "Фильтр записей источника: company_status.", + "required": false, + "schema": { + "type": "string" + } + }, { "name": "establishment_kind", "in": "query", @@ -9221,6 +9302,15 @@ "type": "string" } }, + { + "name": "has_bankruptcy_information", + "in": "query", + "description": "Фильтр записей источника: has_bankruptcy_information.", + "required": false, + "schema": { + "type": "boolean" + } + }, { "name": "has_procurement_permission", "in": "query", @@ -9230,6 +9320,24 @@ "type": "boolean" } }, + { + "name": "has_publications", + "in": "query", + "description": "Фильтр записей источника: has_publications.", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "has_reorganizations", + "in": "query", + "description": "Фильтр записей источника: has_reorganizations.", + "required": false, + "schema": { + "type": "boolean" + } + }, { "name": "has_violation", "in": "query", @@ -9297,6 +9405,26 @@ "type": "string" } }, + { + "name": "registration_date_from", + "in": "query", + "description": "Фильтр записей источника: registration_date_from.", + "required": false, + "schema": { + "type": "string", + "format": "date" + } + }, + { + "name": "registration_date_to", + "in": "query", + "description": "Фильтр записей источника: registration_date_to.", + "required": false, + "schema": { + "type": "string", + "format": "date" + } + }, { "name": "registry_entry_from", "in": "query", @@ -9317,6 +9445,15 @@ "format": "date" } }, + { + "name": "section_state", + "in": "query", + "description": "Фильтр записей источника: section_state.", + "required": false, + "schema": { + "type": "string" + } + }, { "name": "sme_category", "in": "query", @@ -9458,7 +9595,9 @@ "sanctions", "government_support", "sro_membership", - "budget_process_registry" + "budget_process_registry", + "integrated_structure_documents", + "fedresurs_company_profile" ] } }, @@ -9531,7 +9670,7 @@ { "name": "ordering", "in": "query", - "description": "Сортировка по полям: record_date, record_type, external_id, organization__name, extension__organization__name, extension__organization__full_name, created_at, updated_at, title, uid, extension__organization__inn, extension__organization__ogrn, extension__organization__okpo, status, payload__attestation_status, payload__full_name, payload__medo_address, payload__registration_number, payload__uk_hm_treasury, payload__european_union, payload__united_states, payload__switzerland, payload__united_states_sectoral, payload__uk_uksl, payload__ukraine, payload__sentiment, payload__news_source, organization__full_name, organization__inn, organization__ogrn, organization__okpo, payload__classification__organization_type__name, payload__classification__establishment_kind__name, payload__budget__level__name, payload__address__region__name, payload__is_separate_division, payload__support_form__name, payload__support_kind__name, payload__support_until, payload__provider__name, payload__sme_category__name, payload__has_violation, amount, payload__membership_status, payload__region, payload__sro_name, payload__admission_date. Для обратной сортировки используйте префикс -. Несколько полей перечисляются через запятую без пробелов, например -record_date,-external_id. Значения record_date с null сортируются последними.", + "description": "Сортировка по полям: record_date, record_type, external_id, organization__name, extension__organization__name, extension__organization__full_name, created_at, updated_at, title, uid, extension__organization__inn, extension__organization__ogrn, extension__organization__okpo, status, payload__attestation_status, payload__full_name, payload__medo_address, payload__registration_number, payload__uk_hm_treasury, payload__european_union, payload__united_states, payload__switzerland, payload__united_states_sectoral, payload__uk_uksl, payload__ukraine, payload__sentiment, payload__news_source, events_count, documents_count, first_event_date, organization__full_name, organization__inn, organization__ogrn, organization__okpo, payload__classification__organization_type__name, payload__classification__establishment_kind__name, payload__budget__level__name, payload__address__region__name, payload__is_separate_division, payload__support_form__name, payload__support_kind__name, payload__support_until, payload__provider__name, payload__sme_category__name, payload__has_violation, amount, payload__membership_status, payload__region, payload__sro_name, payload__admission_date, payload__status__name, payload__executive_body_name, payload__registration_date, payload__publication_count, payload__reorganization_count, payload__captured_at. Для обратной сортировки используйте префикс -. Несколько полей перечисляются через запятую без пробелов, например -record_date,-external_id. Значения record_date с null сортируются последними.", "required": false, "schema": { "anyOf": [ @@ -9768,6 +9907,79 @@ } ] }, + "/api/v2/organization-source-records/{uid}/documents/{document_id}/attachment/": { + "get": { + "operationId": "api_v2_organization_source_records_documents_attachment_read", + "summary": "Скачать RTF интегрированной структуры", + "description": "Read-only flat API for source records across source extensions.", + "responses": { + "200": { + "description": "Immutable RTF attachment", + "content": { + "application/rtf": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + }, + "401": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SourceRecordErrorResponse" + } + } + } + }, + "404": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SourceRecordErrorResponse" + } + } + } + }, + "409": { + "description": "attachment_unavailable", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AttachmentUnavailableError" + } + } + } + } + }, + "tags": [ + "Организации" + ] + }, + "parameters": [ + { + "name": "uid", + "in": "path", + "description": "A UUID string identifying this запись источника организации.", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "document_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, "/api/v2/organization-sources/": { "get": { "operationId": "api_v2_organization-sources_list", @@ -10055,7 +10267,9 @@ "sanctions", "government_support", "sro_membership", - "budget_process_registry" + "budget_process_registry", + "integrated_structure_documents", + "fedresurs_company_profile" ] } }, @@ -10357,6 +10571,24 @@ "schema": { "type": "boolean" } + }, + { + "name": "has_integrated_structure_documents", + "in": "query", + "description": "Фильтр наличия группы источников integrated_structure_documents.", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "has_fedresurs_company_profile", + "in": "query", + "description": "Фильтр наличия группы источников fedresurs_company_profile.", + "required": false, + "schema": { + "type": "boolean" + } } ], "responses": { @@ -10936,6 +11168,28 @@ ] }, "parameters": [] + }, + "/api/v1/parsers/upload/fedresurs_company_profile/": { + "post": { + "operationId": "api_v1_parsers_upload_fedresurs_company_profile_create", + "summary": "Fedresurs public UI does not accept file uploads", + "description": "Use the Fedresurs refresh endpoint instead of multipart upload.", + "responses": { + "405": { + "description": "upload_not_supported", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FedresursUploadNotSupportedError" + } + } + } + } + }, + "tags": [ + "Parser Management" + ] + } } }, "components": { @@ -12402,7 +12656,9 @@ "ropk_sanctions", "fns_sme_support_recipients", "budget_ubpandnubp", - "sro_membership_check" + "sro_membership_check", + "integrated_structure_documents", + "fedresurs_company_profile" ] }, "title": { @@ -12681,7 +12937,9 @@ "ropk_sanctions", "fns_sme_support_recipients", "budget_ubpandnubp", - "sro_membership_check" + "sro_membership_check", + "integrated_structure_documents", + "fedresurs_company_profile" ], "readOnly": true }, @@ -13089,6 +13347,74 @@ } } }, + "IntegratedStructureUploadResponse": { + "required": [ + "status", + "artifact_id", + "task_id", + "batch_id", + "records_count", + "structures_count", + "event_rows_count", + "document_link_rows_count", + "unique_documents_count", + "events_without_documents_count" + ], + "type": "object", + "properties": { + "status": { + "title": "Status", + "type": "string", + "enum": [ + "published", + "skipped" + ] + }, + "artifact_id": { + "title": "Artifact id", + "type": "string", + "format": "uuid" + }, + "task_id": { + "title": "Task id", + "type": "string", + "minLength": 1 + }, + "batch_id": { + "title": "Batch id", + "type": "integer" + }, + "records_count": { + "title": "Records count", + "type": "integer" + }, + "structures_count": { + "title": "Structures count", + "type": "integer" + }, + "event_rows_count": { + "title": "Event rows count", + "type": "integer" + }, + "document_link_rows_count": { + "title": "Document link rows count", + "type": "integer" + }, + "unique_documents_count": { + "title": "Unique documents count", + "type": "integer" + }, + "events_without_documents_count": { + "title": "Events without documents count", + "type": "integer" + }, + "reason": { + "title": "Reason", + "type": "string", + "minLength": 1 + } + } + }, "ParsingSettings": { "type": "object", "properties": { @@ -13451,7 +13777,9 @@ "ropk_sanctions", "fns_sme_support_recipients", "budget_ubpandnubp", - "sro_membership_check" + "sro_membership_check", + "integrated_structure_documents", + "fedresurs_company_profile" ], "readOnly": true }, @@ -14080,6 +14408,8 @@ "fns_sme_support_recipients", "budget_ubpandnubp", "sro_membership_check", + "integrated_structure_documents", + "fedresurs_company_profile", "financial-indicators", "public-procurements", "manufacturers-and-products", @@ -14094,7 +14424,9 @@ "media-mentions", "sme-support-recipients-registry", "budget-process-registry", - "sro-membership-check" + "sro-membership-check", + "integrated-structure-documents", + "fedresurs-company-profile" ], "readOnly": true }, @@ -17803,6 +18135,12 @@ }, { "$ref": "#/components/schemas/SroMembershipRecordList" + }, + { + "$ref": "#/components/schemas/IntegratedStructureRecordList" + }, + { + "$ref": "#/components/schemas/FedresursCompanyProfileRecordList" } ], "discriminator": { @@ -17822,7 +18160,9 @@ "sanctions": "#/components/schemas/LegacyOrganizationSourceRecordList", "budget_process_registry": "#/components/schemas/BudgetRegistryRecordList", "government_support": "#/components/schemas/SmeSupportRecordList", - "sro_membership": "#/components/schemas/SroMembershipRecordList" + "sro_membership": "#/components/schemas/SroMembershipRecordList", + "integrated_structure_documents": "#/components/schemas/IntegratedStructureRecordList", + "fedresurs_company_profile": "#/components/schemas/FedresursCompanyProfileRecordList" } }, "description": "Published source record. source_group selects the variant; record_type and source are fixed within each registry variant." @@ -18052,7 +18392,9 @@ "sanctions", "government_support", "sro_membership", - "budget_process_registry" + "budget_process_registry", + "integrated_structure_documents", + "fedresurs_company_profile" ] } }, @@ -18531,6 +18873,12 @@ }, { "$ref": "#/components/schemas/SroMembershipRecordDetail" + }, + { + "$ref": "#/components/schemas/IntegratedStructureRecordDetail" + }, + { + "$ref": "#/components/schemas/FedresursCompanyProfileRecordDetail" } ], "discriminator": { @@ -18550,7 +18898,9 @@ "sanctions": "#/components/schemas/LegacyOrganizationSourceRecord", "budget_process_registry": "#/components/schemas/BudgetRegistryRecordDetail", "government_support": "#/components/schemas/SmeSupportRecordDetail", - "sro_membership": "#/components/schemas/SroMembershipRecordDetail" + "sro_membership": "#/components/schemas/SroMembershipRecordDetail", + "integrated_structure_documents": "#/components/schemas/IntegratedStructureRecordDetail", + "fedresurs_company_profile": "#/components/schemas/FedresursCompanyProfileRecordDetail" } }, "description": "Published source record. source_group selects the variant; record_type and source are fixed within each registry variant." @@ -18582,7 +18932,9 @@ "sanctions", "government_support", "sro_membership", - "budget_process_registry" + "budget_process_registry", + "integrated_structure_documents", + "fedresurs_company_profile" ], "readOnly": true }, @@ -20383,6 +20735,12 @@ "-payload__sentiment", "payload__news_source", "-payload__news_source", + "events_count", + "-events_count", + "documents_count", + "-documents_count", + "first_event_date", + "-first_event_date", "organization__full_name", "-organization__full_name", "organization__inn", @@ -20422,13 +20780,1020 @@ "payload__sro_name", "-payload__sro_name", "payload__admission_date", - "-payload__admission_date" + "-payload__admission_date", + "payload__status__name", + "-payload__status__name", + "payload__executive_body_name", + "-payload__executive_body_name", + "payload__registration_date", + "-payload__registration_date", + "payload__publication_count", + "-payload__publication_count", + "payload__reorganization_count", + "-payload__reorganization_count", + "payload__captured_at", + "-payload__captured_at" ] }, "SourceRecordOrderingSequence": { "type": "string", - "pattern": "^(?:record_date|-record_date|record_type|-record_type|external_id|-external_id|organization__name|-organization__name|extension__organization__name|-extension__organization__name|extension__organization__full_name|-extension__organization__full_name|created_at|-created_at|updated_at|-updated_at|title|-title|uid|-uid|extension__organization__inn|-extension__organization__inn|extension__organization__ogrn|-extension__organization__ogrn|extension__organization__okpo|-extension__organization__okpo|status|-status|payload__attestation_status|-payload__attestation_status|payload__full_name|-payload__full_name|payload__medo_address|-payload__medo_address|payload__registration_number|-payload__registration_number|payload__uk_hm_treasury|-payload__uk_hm_treasury|payload__european_union|-payload__european_union|payload__united_states|-payload__united_states|payload__switzerland|-payload__switzerland|payload__united_states_sectoral|-payload__united_states_sectoral|payload__uk_uksl|-payload__uk_uksl|payload__ukraine|-payload__ukraine|payload__sentiment|-payload__sentiment|payload__news_source|-payload__news_source|organization__full_name|-organization__full_name|organization__inn|-organization__inn|organization__ogrn|-organization__ogrn|organization__okpo|-organization__okpo|payload__classification__organization_type__name|-payload__classification__organization_type__name|payload__classification__establishment_kind__name|-payload__classification__establishment_kind__name|payload__budget__level__name|-payload__budget__level__name|payload__address__region__name|-payload__address__region__name|payload__is_separate_division|-payload__is_separate_division|payload__support_form__name|-payload__support_form__name|payload__support_kind__name|-payload__support_kind__name|payload__support_until|-payload__support_until|payload__provider__name|-payload__provider__name|payload__sme_category__name|-payload__sme_category__name|payload__has_violation|-payload__has_violation|amount|-amount|payload__membership_status|-payload__membership_status|payload__region|-payload__region|payload__sro_name|-payload__sro_name|payload__admission_date|-payload__admission_date)(?:,(?:record_date|-record_date|record_type|-record_type|external_id|-external_id|organization__name|-organization__name|extension__organization__name|-extension__organization__name|extension__organization__full_name|-extension__organization__full_name|created_at|-created_at|updated_at|-updated_at|title|-title|uid|-uid|extension__organization__inn|-extension__organization__inn|extension__organization__ogrn|-extension__organization__ogrn|extension__organization__okpo|-extension__organization__okpo|status|-status|payload__attestation_status|-payload__attestation_status|payload__full_name|-payload__full_name|payload__medo_address|-payload__medo_address|payload__registration_number|-payload__registration_number|payload__uk_hm_treasury|-payload__uk_hm_treasury|payload__european_union|-payload__european_union|payload__united_states|-payload__united_states|payload__switzerland|-payload__switzerland|payload__united_states_sectoral|-payload__united_states_sectoral|payload__uk_uksl|-payload__uk_uksl|payload__ukraine|-payload__ukraine|payload__sentiment|-payload__sentiment|payload__news_source|-payload__news_source|organization__full_name|-organization__full_name|organization__inn|-organization__inn|organization__ogrn|-organization__ogrn|organization__okpo|-organization__okpo|payload__classification__organization_type__name|-payload__classification__organization_type__name|payload__classification__establishment_kind__name|-payload__classification__establishment_kind__name|payload__budget__level__name|-payload__budget__level__name|payload__address__region__name|-payload__address__region__name|payload__is_separate_division|-payload__is_separate_division|payload__support_form__name|-payload__support_form__name|payload__support_kind__name|-payload__support_kind__name|payload__support_until|-payload__support_until|payload__provider__name|-payload__provider__name|payload__sme_category__name|-payload__sme_category__name|payload__has_violation|-payload__has_violation|amount|-amount|payload__membership_status|-payload__membership_status|payload__region|-payload__region|payload__sro_name|-payload__sro_name|payload__admission_date|-payload__admission_date))+$", + "pattern": "^(?:record_date|-record_date|record_type|-record_type|external_id|-external_id|organization__name|-organization__name|extension__organization__name|-extension__organization__name|extension__organization__full_name|-extension__organization__full_name|created_at|-created_at|updated_at|-updated_at|title|-title|uid|-uid|extension__organization__inn|-extension__organization__inn|extension__organization__ogrn|-extension__organization__ogrn|extension__organization__okpo|-extension__organization__okpo|status|-status|payload__attestation_status|-payload__attestation_status|payload__full_name|-payload__full_name|payload__medo_address|-payload__medo_address|payload__registration_number|-payload__registration_number|payload__uk_hm_treasury|-payload__uk_hm_treasury|payload__european_union|-payload__european_union|payload__united_states|-payload__united_states|payload__switzerland|-payload__switzerland|payload__united_states_sectoral|-payload__united_states_sectoral|payload__uk_uksl|-payload__uk_uksl|payload__ukraine|-payload__ukraine|payload__sentiment|-payload__sentiment|payload__news_source|-payload__news_source|events_count|-events_count|documents_count|-documents_count|first_event_date|-first_event_date|organization__full_name|-organization__full_name|organization__inn|-organization__inn|organization__ogrn|-organization__ogrn|organization__okpo|-organization__okpo|payload__classification__organization_type__name|-payload__classification__organization_type__name|payload__classification__establishment_kind__name|-payload__classification__establishment_kind__name|payload__budget__level__name|-payload__budget__level__name|payload__address__region__name|-payload__address__region__name|payload__is_separate_division|-payload__is_separate_division|payload__support_form__name|-payload__support_form__name|payload__support_kind__name|-payload__support_kind__name|payload__support_until|-payload__support_until|payload__provider__name|-payload__provider__name|payload__sme_category__name|-payload__sme_category__name|payload__has_violation|-payload__has_violation|amount|-amount|payload__membership_status|-payload__membership_status|payload__region|-payload__region|payload__sro_name|-payload__sro_name|payload__admission_date|-payload__admission_date|payload__status__name|-payload__status__name|payload__executive_body_name|-payload__executive_body_name|payload__registration_date|-payload__registration_date|payload__publication_count|-payload__publication_count|payload__reorganization_count|-payload__reorganization_count|payload__captured_at|-payload__captured_at)(?:,(?:record_date|-record_date|record_type|-record_type|external_id|-external_id|organization__name|-organization__name|extension__organization__name|-extension__organization__name|extension__organization__full_name|-extension__organization__full_name|created_at|-created_at|updated_at|-updated_at|title|-title|uid|-uid|extension__organization__inn|-extension__organization__inn|extension__organization__ogrn|-extension__organization__ogrn|extension__organization__okpo|-extension__organization__okpo|status|-status|payload__attestation_status|-payload__attestation_status|payload__full_name|-payload__full_name|payload__medo_address|-payload__medo_address|payload__registration_number|-payload__registration_number|payload__uk_hm_treasury|-payload__uk_hm_treasury|payload__european_union|-payload__european_union|payload__united_states|-payload__united_states|payload__switzerland|-payload__switzerland|payload__united_states_sectoral|-payload__united_states_sectoral|payload__uk_uksl|-payload__uk_uksl|payload__ukraine|-payload__ukraine|payload__sentiment|-payload__sentiment|payload__news_source|-payload__news_source|events_count|-events_count|documents_count|-documents_count|first_event_date|-first_event_date|organization__full_name|-organization__full_name|organization__inn|-organization__inn|organization__ogrn|-organization__ogrn|organization__okpo|-organization__okpo|payload__classification__organization_type__name|-payload__classification__organization_type__name|payload__classification__establishment_kind__name|-payload__classification__establishment_kind__name|payload__budget__level__name|-payload__budget__level__name|payload__address__region__name|-payload__address__region__name|payload__is_separate_division|-payload__is_separate_division|payload__support_form__name|-payload__support_form__name|payload__support_kind__name|-payload__support_kind__name|payload__support_until|-payload__support_until|payload__provider__name|-payload__provider__name|payload__sme_category__name|-payload__sme_category__name|payload__has_violation|-payload__has_violation|amount|-amount|payload__membership_status|-payload__membership_status|payload__region|-payload__region|payload__sro_name|-payload__sro_name|payload__admission_date|-payload__admission_date|payload__status__name|-payload__status__name|payload__executive_body_name|-payload__executive_body_name|payload__registration_date|-payload__registration_date|payload__publication_count|-payload__publication_count|payload__reorganization_count|-payload__reorganization_count|payload__captured_at|-payload__captured_at))+$", "description": "Two or more allowlisted ordering fields, separated by commas without spaces." + }, + "AttachmentUnavailableError": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "enum": [ + false + ] + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "code": { + "type": "string", + "enum": [ + "attachment_unavailable" + ] + }, + "message": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ] + } + } + }, + "required": [ + "success", + "errors" + ] + }, + "IntegratedStructureSummary": { + "type": "object", + "properties": { + "events_count": { + "type": "integer" + }, + "document_links_count": { + "type": "integer" + }, + "unique_documents_count": { + "type": "integer" + }, + "first_event_date": { + "type": "string" + }, + "latest_event_date": { + "type": "string" + } + }, + "required": [ + "events_count", + "document_links_count", + "unique_documents_count", + "first_event_date", + "latest_event_date" + ] + }, + "IntegratedStructureAttachment": { + "type": "object", + "properties": { + "available": { + "type": "boolean" + }, + "download_allowed": { + "type": "boolean" + }, + "filename": { + "type": "string", + "nullable": true + }, + "mime_type": { + "type": "string", + "nullable": true + }, + "sha256": { + "type": "string", + "nullable": true + }, + "size": { + "type": "integer", + "nullable": true + } + }, + "required": [ + "available", + "download_allowed", + "filename", + "mime_type", + "sha256", + "size" + ] + }, + "IntegratedStructureDocument": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "number": { + "type": "string" + }, + "date": { + "type": "string" + }, + "dsp": { + "type": "boolean" + }, + "have_text": { + "type": "boolean" + }, + "consultant_web_url": { + "type": "string", + "nullable": true + }, + "attachment": { + "$ref": "#/components/schemas/IntegratedStructureAttachment" + } + }, + "required": [ + "id", + "name", + "type", + "number", + "date", + "dsp", + "have_text", + "attachment" + ] + }, + "IntegratedStructureEvent": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "date": { + "type": "string" + }, + "note": { + "type": "string", + "nullable": true + }, + "documents_count": { + "type": "integer" + }, + "documents": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IntegratedStructureDocument" + } + } + }, + "required": [ + "id", + "date", + "note", + "documents_count", + "documents" + ] + }, + "IntegratedStructureListPayload": { + "type": "object", + "properties": { + "structure": { + "$ref": "#/components/schemas/IntegratedStructureSummary" + } + }, + "required": [ + "structure" + ] + }, + "IntegratedStructureDetailPayload": { + "type": "object", + "properties": { + "structure": { + "$ref": "#/components/schemas/IntegratedStructureSummary" + }, + "events": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IntegratedStructureEvent" + } + } + }, + "required": [ + "structure", + "events" + ] + }, + "FedresursRenderedNode": { + "type": "object", + "properties": { + "tag": { + "type": "string" + }, + "attributes": { + "type": "object", + "additionalProperties": true + }, + "children": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "string" + }, + { + "$ref": "#/components/schemas/FedresursRenderedNode" + } + ] + } + } + }, + "required": [ + "tag", + "attributes", + "children" + ] + }, + "FedresursRenderedPage": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "tree": { + "$ref": "#/components/schemas/FedresursRenderedNode" + }, + "attributes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "label": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "label", + "value" + ] + } + }, + "links": { + "type": "array", + "items": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "url": { + "type": "string", + "format": "uri" + } + }, + "required": [ + "text", + "url" + ] + } + }, + "url": { + "type": "string", + "format": "uri" + }, + "page_type": { + "type": "string" + }, + "reported_records_count": { + "type": "integer" + }, + "records": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FedresursRenderedPage" + } + } + }, + "required": [ + "text", + "tree", + "attributes", + "links" + ] + }, + "FedresursStatus": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "code": { + "type": "string", + "nullable": true + }, + "is_active": { + "type": "boolean" + } + }, + "required": [ + "name", + "code", + "is_active" + ] + }, + "FedresursCompanyProfileListPayload": { + "type": "object", + "properties": { + "fedresurs_guid": { + "type": "string", + "format": "uuid" + }, + "short_name": { + "type": "string" + }, + "kpp": { + "type": "string", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/FedresursStatus" + }, + "executive_body_name": { + "type": "string", + "nullable": true + }, + "registration_date": { + "type": "string", + "format": "date", + "nullable": true + }, + "publication_count": { + "type": "integer" + }, + "reorganization_count": { + "type": "integer" + }, + "has_bankruptcy_information": { + "type": "boolean" + }, + "captured_at": { + "type": "string", + "format": "date-time" + }, + "source_url": { + "type": "string", + "format": "uri" + }, + "sections": { + "type": "object", + "additionalProperties": { + "type": "string", + "enum": [ + "loaded", + "empty", + "not_available", + "blocked", + "schema_unverified" + ] + } + } + }, + "required": [ + "fedresurs_guid", + "short_name", + "kpp", + "status", + "registration_date", + "publication_count", + "reorganization_count", + "has_bankruptcy_information", + "captured_at", + "source_url", + "sections" + ] + }, + "FedresursCompanyProfileDetailPayload": { + "type": "object", + "properties": { + "profile": { + "type": "object", + "properties": { + "full_name": { + "type": "string" + }, + "inn": { + "type": "string" + }, + "ogrn": { + "type": "string" + }, + "kpp": { + "type": "string", + "nullable": true + }, + "registration_date": { + "type": "string", + "format": "date", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/FedresursStatus" + } + }, + "required": [ + "full_name", + "inn", + "ogrn", + "status" + ], + "additionalProperties": true + }, + "rendered_sections": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/FedresursRenderedPage" + } + }, + "rendered_page": { + "$ref": "#/components/schemas/FedresursRenderedPage" + }, + "related_pages": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/FedresursRenderedPage" + } + }, + "message_details": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FedresursRenderedPage" + } + }, + "lineage": { + "type": "object", + "additionalProperties": true + } + }, + "required": [ + "profile", + "rendered_page", + "rendered_sections", + "related_pages", + "message_details", + "lineage" + ] + }, + "IntegratedStructureRecordList": { + "type": "object", + "properties": { + "uid": { + "title": "UID", + "type": "string", + "format": "uuid", + "readOnly": true + }, + "extension_uid": { + "title": "Extension uid", + "type": "string", + "format": "uuid", + "readOnly": true + }, + "source_group": { + "type": "string", + "enum": [ + "integrated_structure_documents" + ] + }, + "record_type": { + "type": "string", + "enum": [ + "integrated_structure" + ] + }, + "source": { + "type": "string", + "enum": [ + "integrated_structures" + ] + }, + "external_id": { + "title": "Внешний ID", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "title": { + "title": "Заголовок", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "record_date": { + "title": "Record date", + "type": "string", + "format": "date", + "readOnly": true, + "nullable": true + }, + "amount": { + "title": "Сумма", + "type": "string", + "format": "decimal", + "readOnly": true, + "nullable": true + }, + "status": { + "type": "string" + }, + "url": { + "title": "URL", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "payload": { + "$ref": "#/components/schemas/IntegratedStructureListPayload" + }, + "legacy_model": { + "title": "Legacy model", + "type": "string", + "readOnly": true + }, + "legacy_pk": { + "title": "Legacy pk", + "type": "string", + "readOnly": true + }, + "load_batch": { + "title": "ID пакета загрузки", + "type": "integer", + "readOnly": true, + "nullable": true + }, + "created_at": { + "title": "Дата создания", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "updated_at": { + "title": "Дата обновления", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "financial_lines": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrganizationSourceFinancialLine" + }, + "readOnly": true + }, + "organization": { + "$ref": "#/components/schemas/SroSourceRecordOrganization" + } + }, + "required": [ + "source_group", + "uid", + "source", + "record_type", + "external_id", + "title", + "status", + "created_at", + "updated_at", + "organization", + "payload" + ] + }, + "IntegratedStructureRecordDetail": { + "type": "object", + "properties": { + "uid": { + "title": "UID", + "type": "string", + "format": "uuid", + "readOnly": true + }, + "extension_uid": { + "title": "Extension uid", + "type": "string", + "format": "uuid", + "readOnly": true + }, + "source_group": { + "type": "string", + "enum": [ + "integrated_structure_documents" + ] + }, + "record_type": { + "type": "string", + "enum": [ + "integrated_structure" + ] + }, + "source": { + "type": "string", + "enum": [ + "integrated_structures" + ] + }, + "external_id": { + "title": "Внешний ID", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "title": { + "title": "Заголовок", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "record_date": { + "title": "Record date", + "type": "string", + "format": "date", + "readOnly": true, + "nullable": true + }, + "amount": { + "title": "Сумма", + "type": "string", + "format": "decimal", + "readOnly": true, + "nullable": true + }, + "status": { + "type": "string" + }, + "url": { + "title": "URL", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "payload": { + "$ref": "#/components/schemas/IntegratedStructureDetailPayload" + }, + "legacy_model": { + "title": "Legacy model", + "type": "string", + "readOnly": true + }, + "legacy_pk": { + "title": "Legacy pk", + "type": "string", + "readOnly": true + }, + "load_batch": { + "title": "ID пакета загрузки", + "type": "integer", + "readOnly": true, + "nullable": true + }, + "created_at": { + "title": "Дата создания", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "updated_at": { + "title": "Дата обновления", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "financial_lines": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrganizationSourceFinancialLine" + }, + "readOnly": true + }, + "organization": { + "$ref": "#/components/schemas/SroSourceRecordOrganization" + } + }, + "required": [ + "source_group", + "uid", + "source", + "record_type", + "external_id", + "title", + "status", + "created_at", + "updated_at", + "organization", + "payload" + ] + }, + "FedresursCompanyProfileRecordList": { + "type": "object", + "properties": { + "uid": { + "title": "UID", + "type": "string", + "format": "uuid", + "readOnly": true + }, + "extension_uid": { + "title": "Extension uid", + "type": "string", + "format": "uuid", + "readOnly": true + }, + "source_group": { + "type": "string", + "enum": [ + "fedresurs_company_profile" + ] + }, + "record_type": { + "type": "string", + "enum": [ + "company_profile" + ] + }, + "source": { + "type": "string", + "enum": [ + "fedresurs_company_profile" + ] + }, + "external_id": { + "title": "Внешний ID", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "title": { + "title": "Заголовок", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "record_date": { + "title": "Record date", + "type": "string", + "format": "date", + "readOnly": true, + "nullable": true + }, + "amount": { + "title": "Сумма", + "type": "string", + "format": "decimal", + "readOnly": true, + "nullable": true + }, + "status": { + "type": "string" + }, + "url": { + "title": "URL", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "payload": { + "$ref": "#/components/schemas/FedresursCompanyProfileListPayload" + }, + "legacy_model": { + "title": "Legacy model", + "type": "string", + "readOnly": true + }, + "legacy_pk": { + "title": "Legacy pk", + "type": "string", + "readOnly": true + }, + "load_batch": { + "title": "ID пакета загрузки", + "type": "integer", + "readOnly": true, + "nullable": true + }, + "created_at": { + "title": "Дата создания", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "updated_at": { + "title": "Дата обновления", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "financial_lines": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrganizationSourceFinancialLine" + }, + "readOnly": true + }, + "organization": { + "$ref": "#/components/schemas/SroSourceRecordOrganization" + } + }, + "required": [ + "source_group", + "uid", + "source", + "record_type", + "external_id", + "title", + "status", + "created_at", + "updated_at", + "organization", + "payload" + ] + }, + "FedresursCompanyProfileRecordDetail": { + "type": "object", + "properties": { + "uid": { + "title": "UID", + "type": "string", + "format": "uuid", + "readOnly": true + }, + "extension_uid": { + "title": "Extension uid", + "type": "string", + "format": "uuid", + "readOnly": true + }, + "source_group": { + "type": "string", + "enum": [ + "fedresurs_company_profile" + ] + }, + "record_type": { + "type": "string", + "enum": [ + "company_profile" + ] + }, + "source": { + "type": "string", + "enum": [ + "fedresurs_company_profile" + ] + }, + "external_id": { + "title": "Внешний ID", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "title": { + "title": "Заголовок", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "record_date": { + "title": "Record date", + "type": "string", + "format": "date", + "readOnly": true, + "nullable": true + }, + "amount": { + "title": "Сумма", + "type": "string", + "format": "decimal", + "readOnly": true, + "nullable": true + }, + "status": { + "type": "string" + }, + "url": { + "title": "URL", + "type": "string", + "readOnly": true, + "minLength": 1 + }, + "payload": { + "$ref": "#/components/schemas/FedresursCompanyProfileDetailPayload" + }, + "legacy_model": { + "title": "Legacy model", + "type": "string", + "readOnly": true + }, + "legacy_pk": { + "title": "Legacy pk", + "type": "string", + "readOnly": true + }, + "load_batch": { + "title": "ID пакета загрузки", + "type": "integer", + "readOnly": true, + "nullable": true + }, + "created_at": { + "title": "Дата создания", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "updated_at": { + "title": "Дата обновления", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "financial_lines": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrganizationSourceFinancialLine" + }, + "readOnly": true + }, + "organization": { + "$ref": "#/components/schemas/SroSourceRecordOrganization" + } + }, + "required": [ + "source_group", + "uid", + "source", + "record_type", + "external_id", + "title", + "status", + "created_at", + "updated_at", + "organization", + "payload" + ] + }, + "FedresursUploadNotSupportedError": { + "type": "object", + "required": [ + "success", + "errors" + ], + "properties": { + "success": { + "type": "boolean", + "enum": [ + false + ] + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": [ + "upload_not_supported" + ] + }, + "message": { + "type": "string" + } + } + } + } + } } } } diff --git a/tests/apps/organizations/test_canonical_openapi.py b/tests/apps/organizations/test_canonical_openapi.py index 28ea6b9..4164b1e 100644 --- a/tests/apps/organizations/test_canonical_openapi.py +++ b/tests/apps/organizations/test_canonical_openapi.py @@ -36,7 +36,7 @@ def test_discriminated_records_keep_named_ordering_and_old_operations(contract): schemas = contract["components"]["schemas"] for name in ("OrganizationSourceRecord", "OrganizationSourceRecordList"): record = schemas[name] - assert len(record["oneOf"]) == 4 + assert len(record["oneOf"]) == 6 assert record["discriminator"]["propertyName"] == "source_group" for group, record_type in ( ("budget_process_registry", "budget_registry_organization"), @@ -75,6 +75,36 @@ def test_discriminated_records_keep_named_ordering_and_old_operations(contract): ) +def test_extended_source_contracts_document_full_page_and_typed_errors(contract): + schemas = contract["components"]["schemas"] + for kind, payload_name in ( + ("List", "IntegratedStructureListPayload"), + ("Detail", "IntegratedStructureDetailPayload"), + ): + variant = schemas[f"IntegratedStructureRecord{kind}"] + assert variant["properties"]["payload"]["$ref"].endswith(payload_name) + fed_detail = schemas["FedresursCompanyProfileRecordDetail"] + assert fed_detail["properties"]["payload"]["$ref"].endswith( + "FedresursCompanyProfileDetailPayload" + ) + assert ( + "rendered_page" in schemas["FedresursCompanyProfileDetailPayload"]["properties"] + ) + + paths = contract["paths"] + attachment = paths[ + "/api/v2/organization-source-records/{uid}/documents/{document_id}/attachment/" + ]["get"] + assert "application/rtf" in attachment["responses"]["200"]["content"] + assert attachment["responses"]["409"]["content"]["application/json"]["schema"][ + "$ref" + ].endswith("AttachmentUnavailableError") + upload = paths["/api/v1/parsers/upload/fedresurs_company_profile/"]["post"] + assert upload["responses"]["405"]["content"]["application/json"]["schema"][ + "$ref" + ].endswith("FedresursUploadNotSupportedError") + + @pytest.mark.parametrize( ("source", "list_serializer", "detail_serializer"), [ diff --git a/tools/openapi/README.md b/tools/openapi/README.md index 294ef78..55c011a 100644 --- a/tools/openapi/README.md +++ b/tools/openapi/README.md @@ -7,6 +7,9 @@ The source is the actual DRF serializers and view annotations. `build.mjs` conve Swagger 2 to OpenAPI 3, adds the source-record discriminated variants and the named ordering enum with comma-separated ordering, then validates the resulting document. Do not edit `src/core/openapi.json` or generated TypeScript by hand. +The public-UI Fedresurs and integrated-structure DTOs live in +`source-record-extensions.json`; `build.mjs` adds their discriminated list/detail +variants and typed upload/attachment errors to the generated contract. From the backend root (Python dependencies installed with uv): diff --git a/tools/openapi/build.mjs b/tools/openapi/build.mjs index 051b0f4..d409597 100644 --- a/tools/openapi/build.mjs +++ b/tools/openapi/build.mjs @@ -25,6 +25,10 @@ const variants = [ ['SmeSupport', 'government_support', 'fns_sme_support_recipients', 'sme_support_measure', 'SmeSupportRecord'], ['SroMembership', 'sro_membership', 'sro_membership_check', 'sro_membership', 'SroMembership'], ]; +const extendedVariants = [ + ['IntegratedStructure', 'integrated_structure_documents', 'integrated_structures', 'integrated_structure', 'IntegratedStructure'], + ['FedresursCompanyProfile', 'fedresurs_company_profile', 'fedresurs_company_profile', 'company_profile', 'FedresursCompanyProfile'], +]; const requiredRecordFields = [ 'uid', 'source_group', 'source', 'record_type', 'external_id', 'title', 'status', 'created_at', 'updated_at', 'organization', 'payload', @@ -32,7 +36,7 @@ const requiredRecordFields = [ const listOperation = document.paths['/api/v2/organization-source-records/']?.get; if (!listOperation) throw new Error('Source records list operation missing'); const groupParameter = listOperation.parameters.find((parameter) => parameter.name === 'source_group'); -const legacyGroups = groupParameter.schema.enum.filter((group) => !variants.some((variant) => variant[1] === group)); +const legacyGroups = groupParameter.schema.enum.filter((group) => ![...variants, ...extendedVariants].some((variant) => variant[1] === group)); schemas.PublishedSourceRecordOrganization = clone(schemas.OrganizationSourceRecordOrganization); schemas.PublishedSourceRecordOrganization.required = ['uid', 'name', 'inn', 'ogrn', 'okpo']; @@ -106,6 +110,80 @@ for (const name of ['OrganizationSourceRecordListResponse', 'SourceRecordMeta', } schemas.OrganizationSourceRecordListResponse.properties.errors = { type: 'object', nullable: true, enum: [null] }; +// The two richer source payloads have stable public DTOs in addition to the +// generic DRF JSONField. Keep these schemas beside the canonical converter so +// both backend /openapi.json and the frontend client come from one contract. +const extensions = JSON.parse(readFileSync(resolve(base, 'tools/openapi/source-record-extensions.json'), 'utf8')); +for (const [name, schema] of Object.entries(extensions)) { + if (schemas[name]) throw new Error(`Duplicate source schema: ${name}`); + schemas[name] = schema; +} +for (const [prefix, group, source, recordType, payloadPrefix] of extendedVariants) { + for (const [schemaName, kind] of [ + ['OrganizationSourceRecordList', 'List'], + ['OrganizationSourceRecord', 'Detail'], + ]) { + const variantName = `${prefix}Record${kind}`; + const payloadName = `${payloadPrefix}${kind}Payload`; + if (!schemas[payloadName]) throw new Error(`Named payload missing: ${payloadName}`); + const schema = clone(schemas[`Legacy${schemaName}`]); + schema.required = [...new Set([...(schema.required || []), ...requiredRecordFields])]; + schema.properties.source_group = { type: 'string', enum: [group] }; + schema.properties.source = { type: 'string', enum: [source] }; + schema.properties.record_type = { type: 'string', enum: [recordType] }; + schema.properties.status = { type: 'string' }; + schema.properties.payload = ref(payloadName); + schema.properties.organization = ref('SroSourceRecordOrganization'); + schemas[variantName] = schema; + schemas[schemaName].oneOf.push(ref(variantName)); + schemas[schemaName].discriminator.mapping[group] = ref(variantName).$ref; + } +} + +const attachmentPath = document.paths['/api/v2/organization-source-records/{uid}/documents/{document_id}/attachment/']; +if (!attachmentPath?.get) throw new Error('Integrated attachment endpoint missing'); +attachmentPath.get.responses['200'] = { + description: 'Immutable RTF attachment', + content: { 'application/rtf': { schema: { type: 'string', format: 'binary' } } }, +}; +attachmentPath.get.responses['409'] = { + description: 'attachment_unavailable', + content: { 'application/json': { schema: ref('AttachmentUnavailableError') } }, +}; + +document.paths['/api/v1/parsers/upload/fedresurs_company_profile/'] = { + post: { + operationId: 'api_v1_parsers_upload_fedresurs_company_profile_create', + summary: 'Fedresurs public UI does not accept file uploads', + description: 'Use the Fedresurs refresh endpoint instead of multipart upload.', + responses: { + '405': { + description: 'upload_not_supported', + content: { 'application/json': { schema: ref('FedresursUploadNotSupportedError') } }, + }, + }, + tags: ['Parser Management'], + }, +}; +schemas.FedresursUploadNotSupportedError = { + type: 'object', + required: ['success', 'errors'], + properties: { + success: { type: 'boolean', enum: [false] }, + errors: { + type: 'array', + items: { + type: 'object', + required: ['code', 'message'], + properties: { + code: { type: 'string', enum: ['upload_not_supported'] }, + message: { type: 'string' }, + }, + }, + }, + }, +}; + // Swagger's pagination inspector emits required:[] for legacy envelopes. Omitting // this empty constraint preserves its meaning and is valid in OpenAPI 3.0. function removeEmptyRequired(value) { diff --git a/tools/openapi/source-record-extensions.json b/tools/openapi/source-record-extensions.json new file mode 100644 index 0000000..ab843ba --- /dev/null +++ b/tools/openapi/source-record-extensions.json @@ -0,0 +1,465 @@ +{ + "AttachmentUnavailableError": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "enum": [ + false + ] + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "code": { + "type": "string", + "enum": [ + "attachment_unavailable" + ] + }, + "message": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ] + } + } + }, + "required": [ + "success", + "errors" + ] + }, + "IntegratedStructureSummary": { + "type": "object", + "properties": { + "events_count": { + "type": "integer" + }, + "document_links_count": { + "type": "integer" + }, + "unique_documents_count": { + "type": "integer" + }, + "first_event_date": { + "type": "string" + }, + "latest_event_date": { + "type": "string" + } + }, + "required": [ + "events_count", + "document_links_count", + "unique_documents_count", + "first_event_date", + "latest_event_date" + ] + }, + "IntegratedStructureAttachment": { + "type": "object", + "properties": { + "available": { + "type": "boolean" + }, + "download_allowed": { + "type": "boolean" + }, + "filename": { + "type": "string", + "nullable": true + }, + "mime_type": { + "type": "string", + "nullable": true + }, + "sha256": { + "type": "string", + "nullable": true + }, + "size": { + "type": "integer", + "nullable": true + } + }, + "required": [ + "available", + "download_allowed", + "filename", + "mime_type", + "sha256", + "size" + ] + }, + "IntegratedStructureDocument": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "number": { + "type": "string" + }, + "date": { + "type": "string" + }, + "dsp": { + "type": "boolean" + }, + "have_text": { + "type": "boolean" + }, + "consultant_web_url": { + "type": "string", + "nullable": true + }, + "attachment": { + "$ref": "#/components/schemas/IntegratedStructureAttachment" + } + }, + "required": [ + "id", + "name", + "type", + "number", + "date", + "dsp", + "have_text", + "attachment" + ] + }, + "IntegratedStructureEvent": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "date": { + "type": "string" + }, + "note": { + "type": "string", + "nullable": true + }, + "documents_count": { + "type": "integer" + }, + "documents": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IntegratedStructureDocument" + } + } + }, + "required": [ + "id", + "date", + "note", + "documents_count", + "documents" + ] + }, + "IntegratedStructureListPayload": { + "type": "object", + "properties": { + "structure": { + "$ref": "#/components/schemas/IntegratedStructureSummary" + } + }, + "required": [ + "structure" + ] + }, + "IntegratedStructureDetailPayload": { + "type": "object", + "properties": { + "structure": { + "$ref": "#/components/schemas/IntegratedStructureSummary" + }, + "events": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IntegratedStructureEvent" + } + } + }, + "required": [ + "structure", + "events" + ] + }, + "FedresursRenderedNode": { + "type": "object", + "properties": { + "tag": { + "type": "string" + }, + "attributes": { + "type": "object", + "additionalProperties": true + }, + "children": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "string" + }, + { + "$ref": "#/components/schemas/FedresursRenderedNode" + } + ] + } + } + }, + "required": [ + "tag", + "attributes", + "children" + ] + }, + "FedresursRenderedPage": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "tree": { + "$ref": "#/components/schemas/FedresursRenderedNode" + }, + "attributes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "label": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "label", + "value" + ] + } + }, + "links": { + "type": "array", + "items": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "url": { + "type": "string", + "format": "uri" + } + }, + "required": [ + "text", + "url" + ] + } + }, + "url": { + "type": "string", + "format": "uri" + }, + "page_type": { + "type": "string" + }, + "reported_records_count": { + "type": "integer" + }, + "records": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FedresursRenderedPage" + } + } + }, + "required": [ + "text", + "tree", + "attributes", + "links" + ] + }, + "FedresursStatus": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "code": { + "type": "string", + "nullable": true + }, + "is_active": { + "type": "boolean" + } + }, + "required": [ + "name", + "code", + "is_active" + ] + }, + "FedresursCompanyProfileListPayload": { + "type": "object", + "properties": { + "fedresurs_guid": { + "type": "string", + "format": "uuid" + }, + "short_name": { + "type": "string" + }, + "kpp": { + "type": "string", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/FedresursStatus" + }, + "executive_body_name": { + "type": "string", + "nullable": true + }, + "registration_date": { + "type": "string", + "format": "date", + "nullable": true + }, + "publication_count": { + "type": "integer" + }, + "reorganization_count": { + "type": "integer" + }, + "has_bankruptcy_information": { + "type": "boolean" + }, + "captured_at": { + "type": "string", + "format": "date-time" + }, + "source_url": { + "type": "string", + "format": "uri" + }, + "sections": { + "type": "object", + "additionalProperties": { + "type": "string", + "enum": [ + "loaded", + "empty", + "not_available", + "blocked", + "schema_unverified" + ] + } + } + }, + "required": [ + "fedresurs_guid", + "short_name", + "kpp", + "status", + "registration_date", + "publication_count", + "reorganization_count", + "has_bankruptcy_information", + "captured_at", + "source_url", + "sections" + ] + }, + "FedresursCompanyProfileDetailPayload": { + "type": "object", + "properties": { + "profile": { + "type": "object", + "properties": { + "full_name": { + "type": "string" + }, + "inn": { + "type": "string" + }, + "ogrn": { + "type": "string" + }, + "kpp": { + "type": "string", + "nullable": true + }, + "registration_date": { + "type": "string", + "format": "date", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/FedresursStatus" + } + }, + "required": [ + "full_name", + "inn", + "ogrn", + "status" + ], + "additionalProperties": true + }, + "rendered_sections": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/FedresursRenderedPage" + } + }, + "rendered_page": { + "$ref": "#/components/schemas/FedresursRenderedPage" + }, + "related_pages": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/FedresursRenderedPage" + } + }, + "message_details": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FedresursRenderedPage" + } + }, + "lineage": { + "type": "object", + "additionalProperties": true + } + }, + "required": [ + "profile", + "rendered_page", + "rendered_sections", + "related_pages", + "message_details", + "lineage" + ] + } +}