@scalar/api-client
Version:
the open source API testing client
126 lines (125 loc) • 4.84 kB
JavaScript
import { defineComponent as f, computed as n, toValue as o, createBlock as k, createElementBlock as g, openBlock as l, unref as u, createElementVNode as x } from "vue";
import { getResolvedRef as m } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { mapHiddenClientsConfig as w } from "../modal/helpers/map-hidden-clients-config.js";
import { combineParams as C } from "./helpers/combine-params.js";
import { getSelectedServer as B } from "./helpers/get-selected-server.js";
import { getActiveProxyUrl as U } from "../../helpers/get-active-proxy-url.js";
import { getServers as b } from "../../helpers/get-servers.js";
import N from "../../blocks/operation-block/OperationBlock.vue.js";
const A = {
key: 1,
class: "flex h-full w-full items-center justify-center"
}, E = {}, $ = /* @__PURE__ */ f({
...E,
__name: "Operation",
props: {
documentSlug: {},
document: {},
eventBus: {},
layout: {},
path: {},
method: {},
exampleName: {},
environment: {},
securitySchemes: {},
workspaceStore: {},
activeWorkspace: {},
plugins: {},
customThemes: {},
options: {}
},
setup(e) {
const r = n(() => e.path ? m(e.document?.paths?.[e.path]) : null), c = n(() => {
if (!e.path || !e.method)
return null;
const t = m(e.document?.paths?.[e.path]?.[e.method]);
if (!t)
return null;
if (!r.value)
return t;
const a = C(
r.value.parameters,
t.parameters
);
return { ...t, parameters: a };
}), s = n(() => [
...(e.workspaceStore.workspace?.["x-scalar-cookies"] ?? []).map((t) => ({
...t,
location: "workspace"
})),
...(e.document?.["x-scalar-cookies"] ?? []).map((t) => ({
...t,
location: "document"
}))
]), i = n(() => {
const t = o(e.options)?.servers ?? c.value?.servers ?? r.value?.servers ?? e.document?.servers;
return b(t, {
baseServerUrl: o(e.options)?.baseServerURL,
documentUrl: e.document?.["x-scalar-original-source-url"]
});
}), d = n(
() => B(e.document, i.value)
), v = n(() => e.document?.["x-scalar-set-operation-security"] ? {
type: "operation",
path: e.path ?? "",
method: e.method ?? "get"
} : {
type: "document"
}), h = n(() => Array.from(
new Set(
Object.keys({
...e.document?.["x-scalar-environments"],
...e.workspaceStore.workspace["x-scalar-environments"]
})
)
)), S = n(
() => w(o(e.options)?.hiddenClients)
), y = "2.29.3";
return (t, a) => e.path && e.method && e.exampleName && c.value ? (l(), k(u(N), {
key: 0,
activeEnvironment: e.workspaceStore.workspace["x-scalar-active-environment"],
appVersion: u(y),
authMeta: v.value,
documentSecurity: e.document?.security ?? [],
documentSelectedSecurity: e.workspaceStore.auth.getAuthSelectedSchemas({
type: "document",
documentName: e.documentSlug
}),
documentUrl: e.document?.["x-scalar-original-source-url"],
environment: e.environment,
environments: h.value,
eventBus: e.eventBus,
exampleKey: e.exampleName,
globalCookies: s.value,
hideClientButton: o(e.options)?.hideClientButton ?? !1,
history: e.workspaceStore.history.getHistory(e.documentSlug, e.path, e.method),
httpClients: S.value,
layout: e.layout,
method: e.method,
operation: c.value,
operationSelectedSecurity: e.workspaceStore.auth.getAuthSelectedSchemas({
type: "operation",
documentName: e.documentSlug,
path: e.path,
method: e.method
}),
path: e.path,
plugins: e.plugins,
proxyUrl: u(U)(
e.workspaceStore.workspace["x-scalar-active-proxy"],
e.layout
) ?? "",
securitySchemes: e.securitySchemes,
selectedClient: e.workspaceStore.workspace["x-scalar-default-client"],
server: d.value,
servers: i.value,
setOperationSecurity: e.document?.["x-scalar-set-operation-security"] ?? !1,
"onUpdate:servers": a[0] || (a[0] = (O) => e.eventBus.emit("ui:navigate", { page: "document", path: "servers" }))
}, null, 8, ["activeEnvironment", "appVersion", "authMeta", "documentSecurity", "documentSelectedSecurity", "documentUrl", "environment", "environments", "eventBus", "exampleKey", "globalCookies", "hideClientButton", "history", "httpClients", "layout", "method", "operation", "operationSelectedSecurity", "path", "plugins", "proxyUrl", "securitySchemes", "selectedClient", "server", "servers", "setOperationSecurity"])) : (l(), g("div", A, [...a[1] || (a[1] = [
x("span", { class: "text-c-3" }, "Select an operation to view details", -1)
])]));
}
});
export {
$ as default
};