UNPKG

@mintlify/validation

Version:

Validates mint.json files

21 lines (20 loc) 927 B
import hash from 'object-hash'; import { v4 as uuidv4 } from 'uuid'; import { mapParameter } from './mapParameter.js'; export const mapParameterComponents = ({ spec, refUuidMap, uuidObjectHashMap, hashedNodeMap, }) => { var _a; const parameterComponents = (_a = spec.components) === null || _a === void 0 ? void 0 : _a.parameters; if (!parameterComponents) return; // for each parameter component Object.entries(parameterComponents).forEach(([parameterName, parameter]) => { // match the refId to uuid const refId = `#/components/parameters/${parameterName}`; const uuid = refUuidMap[refId] || uuidv4(); // hash the raw object const objectHash = hash(parameter); // map uuid and hash to uuidObjectHashMap uuidObjectHashMap[uuid] = objectHash; mapParameter({ parameter, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid }); }); };