UNPKG

@scalar/api-client

Version:

the open source API testing client

64 lines (63 loc) 1.43 kB
import { getResolvedRef as d } from "@scalar/workspace-store/helpers/get-resolved-ref"; function h(i) { const o = []; function t(e, a) { e.forEach((p) => { s(p, o, a), "children" in p && p.children && t(p.children, a); }); } return i?.forEach((e) => t(e["x-scalar-navigation"]?.children ?? [], e)), o; } function s(i, o, t) { if (i.type === "operation") { const e = d(t?.paths?.[i.path]?.[i.method]) ?? {}; o.push({ type: "operation", title: i.title, id: i.id, description: e.description || "", method: i.method, path: i.path, operationId: e.operationId, entry: i, documentName: t?.info.title ?? "" }); return; } if (i.type === "tag" && i.isGroup === !1) { o.push({ id: i.id, title: i.title, description: i.description || "", type: "tag", entry: i, documentName: t?.info.title ?? "" }); return; } if (i.type === "tag" && i.isGroup === !0) { o.push({ id: i.id, title: i.title, description: "Tag Group", type: "tag", entry: i, documentName: t?.info.title ?? "" }); return; } if (i.type === "text") { o.push({ id: i.id, type: "heading", title: i.title ?? "", description: "Heading", entry: i, documentName: t?.info.title ?? "" }); return; } } export { h as createSearchIndex };