UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

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