UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

64 lines (63 loc) 2.2 kB
import { defineComponent, computed, createElementBlock, openBlock, createElementVNode, Fragment, renderList, createBlock } from "vue"; import { isHttpMethod } from "@scalar/helpers/http/is-http-method"; import { objectEntries } from "@scalar/helpers/object/object-entries"; import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref"; import Callback from "./Callback.vue.js"; const _hoisted_1 = { "aria-label": "Callbacks", class: "callbacks-list gap-3", role: "group" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "Callbacks", props: { path: {}, callbacks: {}, eventBus: {}, options: {} }, setup(__props) { const flattenedCallbacks = computed(() => { const _callbacks = []; objectEntries(__props.callbacks).forEach(([name, pathItem]) => { objectEntries(getResolvedRef(pathItem)).forEach(([url, methods]) => { if (typeof methods !== "object" || !methods) { return; } objectEntries(methods).forEach(([callbackMethod, callback]) => { if (!isHttpMethod(callbackMethod)) { return; } _callbacks.push({ name, url, method: callbackMethod, callback }); }); }); }); return _callbacks; }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ _cache[0] || (_cache[0] = createElementVNode("div", { class: "callbacks-title text-c-1 my-3 text-lg font-medium" }, " Callbacks ", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(flattenedCallbacks.value, ({ callback, method, name, url }) => { return openBlock(), createBlock(Callback, { key: `${name}-${url}-${method}`, callback, eventBus: __props.eventBus, method, name, options: __props.options, path: __props.path, url }, null, 8, ["callback", "eventBus", "method", "name", "options", "path", "url"]); }), 128)) ]); }; } }); export { _sfc_main as default };