UNPKG

@mintlify/common

Version:

Commonly shared code within Mintlify

25 lines (24 loc) 1.13 kB
import { camelToSentenceCase } from '../../camelToSentenceCase.js'; import { getBindingsData } from './getBindingsData.js'; import { getMessagesData } from './getMessagesData.js'; export const getOperationsData = (operations, extensions) => { return operations.map((operation) => { var _a, _b, _c, _d; const id = (_a = operation.operationId()) !== null && _a !== void 0 ? _a : operation.id(); const title = (_c = (_b = operation['_json']) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : id; const type = operation.action(); const niceTitle = id && title === id ? camelToSentenceCase(id) : title; const description = (_d = operation.summary()) !== null && _d !== void 0 ? _d : operation.description(); const messages = getMessagesData(operation.messages().all(), extensions); const bindings = getBindingsData(operation.bindings().all()); return { id, title: niceTitle, description, type, messages, bindings, extensions, }; }); };