UNPKG

@scalar/api-client

Version:

the open source API testing client

103 lines (102 loc) 3.92 kB
import { defineComponent as h, computed as a, onMounted as p, watch as y, createBlock as f, createElementBlock as k, openBlock as s, unref as n, createElementVNode as S } from "vue"; import { getResolvedRef as g } from "@scalar/workspace-store/helpers/get-resolved-ref"; import { useRouter as w } from "vue-router"; import { getOperationHeader as B } from "./helpers/get-operation-header.js"; import { getSecurityRequirements as C } from "./helpers/get-security-requirements.js"; import { getSelectedSecurity as R } from "./helpers/get-selected-security.js"; import x from "../../blocks/operation-block/OperationBlock.vue.js"; const N = { key: 1, class: "flex h-full w-full items-center justify-center" }, q = {}, O = /* @__PURE__ */ h({ ...q, __name: "Operation", props: { documentSlug: {}, document: {}, eventBus: {}, layout: {}, path: {}, method: {}, exampleName: {}, environment: {}, workspaceStore: {}, activeWorkspace: {}, plugins: {} }, setup(e) { const o = a( () => e.path && e.method ? g(e.document?.paths?.[e.path]?.[e.method]) ?? null : null ), u = a(() => [ ...e.workspaceStore.workspace?.["x-scalar-cookies"] ?? [], ...e.document?.["x-scalar-cookies"] ?? [] ]), m = a( () => e.document?.servers?.find( ({ url: t }) => t === e.document?.["x-scalar-selected-server"] ) ?? null ); p(() => { typeof e.document?.["x-scalar-selected-server"] > "u" && e.document?.servers?.[0]?.url && e.eventBus.emit("server:update:selected", { url: e.document.servers[0].url }); }), y( o, (t) => { t && e.path && e.method && !B({ operation: t, name: "Accept", type: "header" }) && e.eventBus.emit("operation:add:parameter", { type: "header", meta: { method: e.method, path: e.path, exampleKey: e.exampleName ?? "default" }, payload: { key: "Accept", value: "*/*", isDisabled: !1 } }); }, { immediate: !0 } ); const l = a( () => C(e.document, o.value) ), c = a( () => R(e.document, o.value, l.value) ), i = a(() => e.document?.["x-scalar-set-operation-security"] ? { type: "operation", path: e.path ?? "", method: e.method ?? "get" } : { type: "document" }), d = "2.17.1", v = w(); return (t, r) => t.path && t.method && t.exampleName && o.value ? (s(), f(n(x), { key: 0, appVersion: n(d), authMeta: i.value, documentUrl: t.document?.["x-scalar-original-source-url"], environment: t.environment, eventBus: t.eventBus, exampleKey: t.exampleName, globalCookies: u.value, history: [], httpClients: t.workspaceStore.config["x-scalar-reference-config"]?.httpClients, layout: t.layout, method: t.method, operation: o.value, path: t.path, plugins: t.plugins, proxyUrl: t.workspaceStore.workspace["x-scalar-active-proxy"] ?? "", securityRequirements: l.value, securitySchemes: t.document?.components?.securitySchemes ?? {}, selectedClient: t.workspaceStore.workspace["x-scalar-default-client"], selectedSecurity: c.value, server: m.value, servers: t.document?.servers ?? [], totalPerformedRequests: 0, "onUpdate:servers": r[0] || (r[0] = (U) => n(v).push({ name: "document.servers" })) }, null, 8, ["appVersion", "authMeta", "documentUrl", "environment", "eventBus", "exampleKey", "globalCookies", "httpClients", "layout", "method", "operation", "path", "plugins", "proxyUrl", "securityRequirements", "securitySchemes", "selectedClient", "selectedSecurity", "server", "servers"])) : (s(), k("div", N, [...r[1] || (r[1] = [ S("span", { class: "text-c-3" }, "Select an operation to view details", -1) ])])); } }); export { O as default };