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