UNPKG

@mintlify/validation

Version:

Validates mint.json files

32 lines (31 loc) 1.03 kB
import { v4 as uuidv4 } from 'uuid'; import { getObjectById } from './getObjectById.js'; import { mapPath } from './mapPath.js'; export const mapWebhooks = ({ spec, refUuidMap, uuidObjectHashMap, hashedNodeMap, documentId, }) => { if (!('webhooks' in spec)) return; const webhooks = spec.webhooks; if (!webhooks) return; const document = getObjectById({ uuidObjectHashMap, hashedNodeMap, id: documentId }); if (!document) return; Object.entries(webhooks).forEach(([webhookPath, webhook]) => { if (!webhook) return; const uuid = uuidv4(); // map to uuidObjectHashMap, hashedNodeMap // map path + operation in refUuidMap in mapPath mapPath({ pathItem: webhook, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, path: webhookPath, isWebhook: true, }); // add webhook to document document.webhooks.push(uuid); }); };