@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
209 lines (208 loc) • 8.22 kB
JavaScript
import { defineComponent as v, computed as S, createBlock as a, openBlock as i, unref as o, createSlots as g, withCtx as r, createElementVNode as s, createCommentVNode as n, createElementBlock as l, createVNode as t, Fragment as C, toDisplayString as d, withModifiers as B, normalizeClass as w, createTextVNode as c } from "vue";
import { OperationCodeSample as O } from "@scalar/api-client/v2/blocks/operation-code-sample";
import { ScalarErrorBoundary as I, ScalarIconButton as P, ScalarMarkdown as R } from "@scalar/components";
import { ScalarIconPlay as $, ScalarIconCopy as q, ScalarIconWebhooksLogo as W } from "@scalar/icons";
import { isOperationDeprecated as T, getOperationStability as h, getOperationStabilityColor as L } from "@scalar/oas-utils/helpers";
import { useClipboard as z } from "@scalar/use-hooks/useClipboard";
import { getResolvedRef as D } from "@scalar/workspace-store/helpers/get-resolved-ref";
import E from "../../../components/OperationPath.vue.js";
import N from "../components/callbacks/Callbacks.vue.js";
import V from "../components/OperationParameters.vue.js";
import F from "../components/OperationResponses.vue.js";
import A from "../../../components/Section/SectionAccordion.vue.js";
import M from "../../example-responses/ExampleResponses.vue.js";
import j from "../../../components/LinkList/LinkList.vue.js";
import U from "../../external-docs/ExternalDocs.vue.js";
import u from "../../x-badges/XBadges.vue.js";
import G from "../../test-request-button/TestRequestButton.vue.js";
import H from "../../../components/HttpMethod/HttpMethod.vue.js";
import J from "../../../components/Anchor/Anchor.vue.js";
import f from "../../../components/Badge/Badge.vue.js";
const K = { class: "operation-title" }, Q = { class: "operation-details" }, X = { class: "endpoint-label" }, Y = { class: "endpoint-label-path" }, Z = { class: "endpoint-label-name" }, _ = {
key: 1,
class: "font-code text-sm"
}, x = { class: "endpoint-content" }, ee = { class: "operation-details-card" }, oe = { class: "operation-details-card-item" }, te = { class: "operation-details-card-item" }, ie = {
key: 0,
class: "operation-details-card-item"
}, Oe = /* @__PURE__ */ v({
__name: "ClassicLayout",
props: {
id: {},
path: {},
method: {},
operation: {},
server: {},
securitySchemes: {},
store: {},
options: {}
},
setup(m) {
const y = S(() => m.operation.summary || m.path || ""), { copyToClipboard: k } = z();
return (e, p) => (i(), a(o(A), {
id: e.id,
class: "reference-endpoint",
transparent: ""
}, g({
title: r(() => [
s("div", K, [
s("div", Q, [
t(o(H), {
class: "endpoint-type",
method: e.method,
short: ""
}, null, 8, ["method"]),
t(o(J), {
id: e.id,
class: "endpoint-anchor"
}, {
default: r(() => [
s("h3", X, [
s("div", Y, [
t(E, {
deprecated: o(T)(e.operation),
path: e.path
}, null, 8, ["deprecated", "path"])
]),
s("div", Z, d(y.value), 1),
o(h)(e.operation) ? (i(), a(o(f), {
key: 0,
class: w(["capitalize", o(L)(e.operation)])
}, {
default: r(() => [
c(d(o(h)(e.operation)), 1)
]),
_: 1
}, 8, ["class"])) : n("", !0),
e.options.isWebhook ? (i(), a(o(f), {
key: 1,
class: "font-code text-green flex w-fit items-center justify-center gap-1"
}, {
default: r(() => [
t(o(W), { weight: "bold" }),
p[1] || (p[1] = c("Webhook "))
]),
_: 1,
__: [1]
})) : n("", !0),
t(o(u), {
badges: e.operation["x-badges"],
position: "before"
}, null, 8, ["badges"])
])
]),
_: 1
}, 8, ["id"])
])
])
]),
actions: r(({ active: b }) => [
t(o(u), {
badges: e.operation["x-badges"],
position: "after"
}, null, 8, ["badges"]),
e.options?.hideTestRequestButton ? n("", !0) : (i(), l(C, { key: 0 }, [
b && !e.options.isWebhook ? (i(), a(o(G), {
key: 0,
method: e.method,
path: e.path
}, null, 8, ["method", "path"])) : (i(), a(o($), {
key: 1,
class: "endpoint-try-hint size-4.5"
}))
], 64)),
e.options?.showOperationId && e.operation.operationId ? (i(), l("span", _, d(e.operation.operationId), 1)) : n("", !0),
t(o(P), {
class: "endpoint-copy p-0.5",
icon: o(q),
label: "Copy endpoint URL",
size: "xs",
variant: "ghost",
onClick: p[0] || (p[0] = B((se) => o(k)(e.path), ["stop"]))
}, null, 8, ["icon"])
]),
default: r(() => [
s("div", x, [
s("div", ee, [
s("div", oe, [
t(V, {
options: e.options,
parameters: (
// These have been resolved in the Operation.vue component
e.operation.parameters
),
requestBody: o(D)(e.operation.requestBody)
}, null, 8, ["options", "parameters", "requestBody"])
]),
s("div", te, [
t(F, {
options: {
orderRequiredPropertiesFirst: e.options.orderRequiredPropertiesFirst,
orderSchemaPropertiesBy: e.options.orderSchemaPropertiesBy
},
responses: e.operation.responses
}, null, 8, ["options", "responses"])
]),
e.operation?.callbacks ? (i(), l("div", ie, [
t(N, {
callbacks: e.operation.callbacks,
method: e.method,
options: e.options,
path: e.path
}, null, 8, ["callbacks", "method", "options", "path"])
])) : n("", !0)
]),
e.operation.responses ? (i(), a(o(M), {
key: 0,
class: "operation-example-card",
responses: e.operation.responses
}, null, 8, ["responses"])) : n("", !0),
s("div", null, [
e.operation.externalDocs ? (i(), a(o(j), { key: 0 }, {
default: r(() => [
t(o(U), {
value: e.operation.externalDocs
}, null, 8, ["value"])
]),
_: 1
})) : n("", !0),
t(o(I), null, {
default: r(() => [
t(o(O), {
class: "operation-example-card",
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
}, null, 8, ["clientOptions", "isWebhook", "method", "operation", "path", "securitySchemes", "selectedClient", "selectedServer"])
]),
_: 1
})
])
])
]),
_: 2
}, [
e.operation.description ? {
name: "description",
fn: r(() => [
t(o(R), {
anchorPrefix: e.id,
transformType: "heading",
value: e.operation.description,
withAnchors: "",
withImages: ""
}, null, 8, ["anchorPrefix", "value"])
]),
key: "0"
} : void 0
]), 1032, ["id"]));
}
});
export {
Oe as default
};