@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
236 lines (235 loc) • 10.1 kB
JavaScript
import { defineComponent as g, computed as v, useId as B, createBlock as a, openBlock as i, unref as o, withCtx as t, createVNode as r, createElementVNode as n, createCommentVNode as s, createTextVNode as l, toDisplayString as p, normalizeClass as b, createSlots as C } from "vue";
import { OperationCodeSample as P } from "@scalar/api-client/v2/blocks/operation-code-sample";
import { ScalarMarkdown as w, ScalarErrorBoundary as d } from "@scalar/components";
import { ScalarIconWebhooksLogo as R } from "@scalar/icons";
import { getOperationStability as y, getOperationStabilityColor as q, isOperationDeprecated as O } from "@scalar/oas-utils/helpers";
import { getResolvedRef as I } from "@scalar/workspace-store/helpers/get-resolved-ref";
import W from "../../../components/OperationPath.vue.js";
import T from "../components/callbacks/Callbacks.vue.js";
import $ from "../components/OperationParameters.vue.js";
import D from "../components/OperationResponses.vue.js";
import F from "../../../components/Section/Section.vue.js";
import L from "../../../components/Section/SectionContent.vue.js";
import m from "../../../components/Badge/Badge.vue.js";
import k from "../../x-badges/XBadges.vue.js";
import N from "../../../components/Section/SectionHeader.vue.js";
import V from "../../../components/Anchor/Anchor.vue.js";
import E from "../../../components/Section/SectionHeaderTag.vue.js";
import j from "../../../components/Section/SectionColumns.vue.js";
import S from "../../../components/Section/SectionColumn.vue.js";
import z from "../../../components/LinkList/LinkList.vue.js";
import A from "../../external-docs/ExternalDocs.vue.js";
import H from "../../test-request-button/TestRequestButton.vue.js";
import M from "../../example-responses/ExampleResponses.vue.js";
const G = { class: "flex flex-row justify-between gap-1" }, J = { class: "flex gap-1" }, K = { class: "flex gap-1" }, Q = { class: "operation-details" }, U = { class: "examples" }, ke = /* @__PURE__ */ g({
__name: "ModernLayout",
props: {
id: {},
path: {},
method: {},
operation: {},
securitySchemes: {},
server: {},
store: {},
options: {}
},
setup(u) {
const f = v(() => u.operation.summary || u.path || ""), h = B();
return (e, c) => (i(), a(o(F), {
id: e.id,
"aria-labelledby": o(h),
label: f.value,
tabindex: "-1"
}, {
default: t(() => [
r(o(L), null, {
default: t(() => [
n("div", G, [
n("div", J, [
e.options?.showOperationId && e.operation.operationId ? (i(), a(o(m), { key: 0 }, {
default: t(() => [
l(p(e.operation.operationId), 1)
]),
_: 1
})) : s("", !0),
o(y)(e.operation) ? (i(), a(o(m), {
key: 1,
class: b(["capitalize", o(q)(e.operation)])
}, {
default: t(() => [
l(p(o(y)(e.operation)), 1)
]),
_: 1
}, 8, ["class"])) : s("", !0),
e.options.isWebhook ? (i(), a(o(m), {
key: 2,
class: "font-code text-green flex w-fit items-center justify-center gap-1"
}, {
default: t(() => [
r(o(R), { weight: "bold" }),
c[0] || (c[0] = l("Webhook "))
]),
_: 1,
__: [0]
})) : s("", !0),
r(o(k), {
badges: e.operation["x-badges"],
position: "before"
}, null, 8, ["badges"])
]),
n("div", K, [
r(o(k), {
badges: e.operation["x-badges"],
position: "after"
}, null, 8, ["badges"])
])
]),
n("div", {
class: b(o(O)(e.operation) ? "deprecated" : "")
}, [
r(o(N), null, {
default: t(() => [
r(o(V), { id: e.id }, {
default: t(() => [
r(o(E), {
id: o(h),
level: 3
}, {
default: t(() => [
l(p(f.value), 1)
]),
_: 1
}, 8, ["id"])
]),
_: 1
}, 8, ["id"])
]),
_: 1
})
], 2),
r(o(j), null, {
default: t(() => [
r(o(S), null, {
default: t(() => [
n("div", Q, [
r(o(w), {
anchorPrefix: e.id,
transformType: "heading",
value: e.operation.description,
withAnchors: "",
withImages: ""
}, null, 8, ["anchorPrefix", "value"]),
r($, {
breadcrumb: [e.id],
options: {
orderRequiredPropertiesFirst: e.options.orderRequiredPropertiesFirst,
orderSchemaPropertiesBy: e.options.orderSchemaPropertiesBy
},
parameters: (
// These have been resolved in the Operation.vue component
e.operation.parameters
),
requestBody: o(I)(e.operation.requestBody)
}, null, 8, ["breadcrumb", "options", "parameters", "requestBody"]),
r(D, {
breadcrumb: [e.id],
options: {
collapsableItems: !e.options.expandAllResponses,
orderRequiredPropertiesFirst: e.options.orderRequiredPropertiesFirst,
orderSchemaPropertiesBy: e.options.orderSchemaPropertiesBy
},
responses: e.operation.responses
}, null, 8, ["breadcrumb", "options", "responses"]),
r(o(d), null, {
default: t(() => [
e.operation.callbacks ? (i(), a(T, {
key: 0,
callbacks: e.operation.callbacks,
class: "mt-6",
method: e.method,
options: e.options,
path: e.path
}, null, 8, ["callbacks", "method", "options", "path"])) : s("", !0)
]),
_: 1
})
])
]),
_: 1
}),
r(o(S), null, {
default: t(() => [
n("div", U, [
e.operation.externalDocs ? (i(), a(o(z), { key: 0 }, {
default: t(() => [
r(o(A), {
value: e.operation.externalDocs
}, null, 8, ["value"])
]),
_: 1
})) : s("", !0),
r(o(d), null, {
default: t(() => [
r(o(P), {
clientOptions: e.options.clientOptions,
fallback: "",
isWebhook: e.options.isWebhook,
method: e.method,
operation: e.operation,
path: e.path,
securitySchemes: e.securitySchemes,
selectedClient: e.store.workspace["x-scalar-default-client"],
selectedServer: e.server
}, C({
header: t(() => [
r(W, {
class: "font-code text-c-2 [&_em]:text-c-1 [&_em]:not-italic",
deprecated: e.operation?.deprecated,
path: e.path
}, null, 8, ["deprecated", "path"])
]),
_: 2
}, [
e.options.isWebhook ? void 0 : {
name: "footer",
fn: t(() => [
e.options.hideTestRequestButton ? s("", !0) : (i(), a(o(H), {
key: 0,
method: e.method,
path: e.path
}, null, 8, ["method", "path"]))
]),
key: "0"
}
]), 1032, ["clientOptions", "isWebhook", "method", "operation", "path", "securitySchemes", "selectedClient", "selectedServer"])
]),
_: 1
}),
r(o(d), null, {
default: t(() => [
e.operation.responses ? (i(), a(o(M), {
key: 0,
responses: e.operation.responses,
style: { "margin-top": "12px" }
}, null, 8, ["responses"])) : s("", !0)
]),
_: 1
})
])
]),
_: 1
})
]),
_: 1
})
]),
_: 1
})
]),
_: 1
}, 8, ["id", "aria-labelledby", "label"]));
}
});
export {
ke as default
};