@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
74 lines (73 loc) • 2.36 kB
JavaScript
import { defineComponent as c, computed as o, createElementBlock as l, createCommentVNode as p, openBlock as s, Fragment as h, createBlock as n } from "vue";
import { useWorkspace as d } from "@scalar/api-client/store";
import { filterSecurityRequirements as v } from "@scalar/api-client/views/Request/RequestSection";
import { getResolvedRef as y } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { combineParams as f } from "./helpers/combine-params.js";
import { convertSecurityScheme as S } from "../../helpers/convert-security-scheme.js";
import { getFirstServer as k } from "./helpers/get-first-server.js";
import V from "./layouts/ClassicLayout.vue.js";
import g from "./layouts/ModernLayout.vue.js";
const N = /* @__PURE__ */ c({
__name: "Operation",
props: {
id: {},
method: {},
path: {},
pathValue: {},
server: {},
security: {},
store: {},
collection: {},
options: {}
},
setup(t) {
const r = o(() => {
const e = y(t.pathValue?.[t.method]);
if (!e)
return null;
const m = f(t.pathValue?.parameters, e.parameters);
return { ...e, parameters: m };
}), { securitySchemes: u } = d(), i = o(
() => v(
r.value?.security || t.security || [],
t.collection.selectedSecuritySchemeUids,
u
).map(S)
), a = o(
() => k(
// 1) Operation
r.value?.servers,
// 2) Path Item
t.pathValue?.servers,
// 3) Document
t.server
)
);
return (e, m) => r.value ? (s(), l(h, { key: 0 }, [
e.options?.layout === "classic" ? (s(), n(V, {
key: 0,
id: e.id,
method: e.method,
operation: r.value,
options: e.options,
path: e.path,
securitySchemes: i.value,
server: a.value,
store: e.store
}, null, 8, ["id", "method", "operation", "options", "path", "securitySchemes", "server", "store"])) : (s(), n(g, {
key: 1,
id: e.id,
method: e.method,
operation: r.value,
options: e.options,
path: e.path,
securitySchemes: i.value,
server: a.value,
store: e.store
}, null, 8, ["id", "method", "operation", "options", "path", "securitySchemes", "server", "store"]))
], 64)) : p("", !0);
}
});
export {
N as default
};