feat: expose FSSP source APIs and exports
This commit is contained in:
@@ -6,7 +6,7 @@ import converter from 'swagger2openapi';
|
||||
import validator from 'oas-validator';
|
||||
|
||||
const base = fileURLToPath(new URL('../..', import.meta.url));
|
||||
const input = process.argv[2] || resolve(base, 'tools/openapi/swagger.json');
|
||||
const input = process.argv.slice(2).find(argument => !argument.startsWith('--')) || resolve(base, 'tools/openapi/swagger.json');
|
||||
const output = resolve(base, 'src/core/openapi.json');
|
||||
const check = process.argv.includes('--check');
|
||||
const swagger = JSON.parse(readFileSync(input, 'utf8'));
|
||||
@@ -26,6 +26,7 @@ const variants = [
|
||||
['SroMembership', 'sro_membership', 'sro_membership_check', 'sro_membership', 'SroMembership'],
|
||||
];
|
||||
const extendedVariants = [
|
||||
['FsspEnforcementProceeding', 'enforcement_proceedings', 'fssp_enforcement_proceedings', 'enforcement_proceeding', 'FsspEnforcementProceeding'],
|
||||
['IntegratedStructure', 'integrated_structure_documents', 'integrated_structures', 'integrated_structure', 'IntegratedStructure'],
|
||||
['FedresursCompanyProfile', 'fedresurs_company_profile', 'fedresurs_company_profile', 'company_profile', 'FedresursCompanyProfile'],
|
||||
];
|
||||
@@ -49,6 +50,15 @@ for (const field of schemas.SroSourceRecordOrganization.required) {
|
||||
delete schemas.SroSourceRecordOrganization.properties[field].nullable;
|
||||
}
|
||||
|
||||
schemas.FsspSourceRecordOrganization = clone(schemas.PublishedSourceRecordOrganization);
|
||||
for (const field of ['name', 'inn', 'ogrn', 'okpo']) {
|
||||
delete schemas.FsspSourceRecordOrganization.properties[field].nullable;
|
||||
schemas.FsspSourceRecordOrganization.properties[field].minLength = 1;
|
||||
}
|
||||
for (const [field, length] of [['inn', 10], ['ogrn', 13], ['okpo', 8]]) {
|
||||
schemas.FsspSourceRecordOrganization.properties[field].pattern = `^[0-9]{${length}}$`;
|
||||
}
|
||||
|
||||
for (const [schemaName, kind] of [
|
||||
['OrganizationSourceRecordList', 'List'],
|
||||
['OrganizationSourceRecord', 'Detail'],
|
||||
@@ -134,6 +144,15 @@ for (const [prefix, group, source, recordType, payloadPrefix] of extendedVariant
|
||||
schema.properties.status = { type: 'string' };
|
||||
schema.properties.payload = ref(payloadName);
|
||||
schema.properties.organization = ref('SroSourceRecordOrganization');
|
||||
if (group === 'enforcement_proceedings') {
|
||||
schema.required = [...new Set([...schema.required, 'extension_uid', 'record_date', 'amount', 'url', 'legacy_model', 'legacy_pk', 'load_batch', 'financial_lines'])];
|
||||
schema.properties.status = { type: 'string', enum: ['unknown', 'ended', 'terminated'] };
|
||||
schema.properties.amount = { type: 'string', pattern: '^-?[0-9]+\\.[0-9]{2}$', nullable: true };
|
||||
schema.properties.record_date = { type: 'string', format: 'date', nullable: true };
|
||||
for (const field of ['legacy_model', 'legacy_pk']) schema.properties[field] = { type: 'string', enum: [''] };
|
||||
schema.properties.financial_lines = { type: 'array', items: {}, maxItems: 0 };
|
||||
schema.properties.organization = ref('FsspSourceRecordOrganization');
|
||||
}
|
||||
schemas[variantName] = schema;
|
||||
schemas[schemaName].oneOf.push(ref(variantName));
|
||||
schemas[schemaName].discriminator.mapping[group] = ref(variantName).$ref;
|
||||
|
||||
Reference in New Issue
Block a user