UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

202 lines (201 loc) 9.13 kB
import { defineComponent as R, computed as n, createElementBlock as w, openBlock as i, Fragment as V, createVNode as r, createElementVNode as $, unref as o, renderSlot as p, createCommentVNode as l, createBlock as c, withCtx as s } from "vue"; import { useWorkspace as M, useActiveEntities as q } from "@scalar/api-client/store"; import { generateClientOptions as U } from "@scalar/api-client/v2/blocks/operation-code-sample"; import { ScalarErrorBoundary as v } from "@scalar/components"; import { getSlugUid as L } from "@scalar/oas-utils/transforms"; import N from "./IntroductionSection.vue.js"; import { getCurrentIndex as T } from "./Operations/get-current-index.js"; import j from "./Operations/TraversedEntry.vue.js"; import { useFreezing as W } from "../../hooks/useFreezing.js"; import { useNavState as z } from "../../hooks/useNavState.js"; import { getXKeysFromObject as D } from "../../features/specification-extension/helpers.js"; import { useSidebar as K } from "../../v2/blocks/scalar-sidebar-block/hooks/useSidebar.js"; import X from "../SectionFlare/SectionFlare.vue.js"; import G from "../../v2/blocks/scalar-info-block/components/InfoBlock.vue.js"; import f from "../../v2/blocks/scalar-info-block/components/IntroductionCardItem.vue.js"; import H from "../../v2/blocks/scalar-server-selector-block/components/ServerSelector.vue.js"; import J from "../../v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.js"; import Q from "../../v2/blocks/scalar-client-selector-block/components/ClientSelector.vue.js"; import Y from "./Models/Models.vue.js"; const Z = { class: "narrow-references-container" }, x = { key: 0 }, ke = /* @__PURE__ */ R({ __name: "Content", props: { contentId: {}, store: {}, options: {} }, setup(a) { W(); const d = n( () => U(a.options.hiddenClients) ), g = n( () => D(a.store.workspace.activeDocument) ), C = n( () => D(a.store.workspace.activeDocument?.info) ), { collections: E, securitySchemes: I, servers: h } = M(), { activeCollection: b, activeEnvVariables: A, activeEnvironment: B, activeWorkspace: S } = q(), t = n(() => { if (a.options.slug) { const e = E[L(a.options.slug)]; if (e) return e; } return b.value; }), k = n(() => { if (t.value) { if (t.value.selectedServerUid) { const e = h[t.value.selectedServerUid]; if (e) return e; } return h[t.value.servers[0]]; } }), O = () => a.store.exportActiveDocument("json") ?? "{}", { items: u } = K(), { hash: m } = z(), F = n( () => T(m.value, u.value.entries) ), P = n(() => { const e = u.value.entries.find((y) => y.id === "models"); return e && e.type === "text" ? e : void 0; }); return (e, y) => (i(), w(V, null, [ r(o(X)), $("div", Z, [ p(e.$slots, "start"), r(N, { showEmptyState: !e.store.workspace.activeDocument }, { "empty-state": s(() => [ p(e.$slots, "empty-state") ]), default: s(() => [ e.store.workspace.activeDocument ? (i(), c(o(G), { key: 0, id: e.contentId, documentExtensions: g.value, externalDocs: e.store.workspace.activeDocument.externalDocs, info: e.store.workspace.activeDocument.info, infoExtensions: C.value, layout: e.options.layout, oasVersion: e.store.workspace.activeDocument?.["x-original-oas-version"], options: { documentDownloadType: e.options.documentDownloadType, url: e.options.url, getOriginalDocument: O, isLoading: e.options.isLoading, layout: e.options.layout, onLoaded: e.options.onLoaded } }, { selectors: s(() => [ r(o(v), null, { default: s(() => [ e.store.workspace.activeDocument?.servers?.length ? (i(), c(o(f), { key: 0, class: "scalar-reference-intro-server scalar-client introduction-card-item text-base leading-normal [--scalar-address-bar-height:0px]" }, { default: s(() => [ r(o(H), { servers: e.store.workspace.activeDocument?.servers ?? [], xSelectedServer: e.store.workspace.activeDocument?.["x-scalar-active-server"] }, null, 8, ["servers", "xSelectedServer"]) ]), _: 1 })) : l("", !0) ]), _: 1 }), r(o(v), null, { default: s(() => [ t.value && o(S) && Object.keys(o(I) ?? {}).length ? (i(), c(o(f), { key: 0, class: "scalar-reference-intro-auth scalar-client introduction-card-item leading-normal" }, { default: s(() => [ r(o(J), { collection: t.value, envVariables: o(A), environment: o(B), layout: "reference", persistAuth: e.options.persistAuth, selectedSecuritySchemeUids: t.value?.selectedSecuritySchemeUids ?? [], server: k.value, title: "Authentication", workspace: o(S) }, null, 8, ["collection", "envVariables", "environment", "persistAuth", "selectedSecuritySchemeUids", "server", "workspace"]) ]), _: 1 })) : l("", !0) ]), _: 1 }), r(o(v), null, { default: s(() => [ e.options.hiddenClients !== !0 && d.value.length ? (i(), c(o(f), { key: 0, class: "introduction-card-item scalar-reference-intro-clients" }, { default: s(() => [ r(o(Q), { class: "introduction-card-item scalar-reference-intro-clients", clientOptions: d.value, xScalarSdkInstallation: e.store.workspace.activeDocument?.info?.["x-scalar-sdk-installation"], xSelectedClient: e.store.workspace["x-scalar-default-client"] }, null, 8, ["clientOptions", "xScalarSdkInstallation", "xSelectedClient"]) ]), _: 1 })) : l("", !0) ]), _: 1 }) ]), _: 1 }, 8, ["id", "documentExtensions", "externalDocs", "info", "infoExtensions", "layout", "oasVersion", "options"])) : l("", !0) ]), _: 3 }, 8, ["showEmptyState"]), o(u).entries.length && t.value ? (i(), w("div", x, [ r(j, { activeCollection: t.value, activeServer: k.value, entries: o(u).entries, hash: o(m), options: { layout: e.options.layout ?? "modern", showOperationId: e.options.showOperationId, hideTestRequestButton: e.options.hideTestRequestButton, expandAllResponses: e.options.expandAllResponses, clientOptions: d.value, orderRequiredPropertiesFirst: e.options.orderRequiredPropertiesFirst, orderSchemaPropertiesBy: e.options.orderSchemaPropertiesBy, onShowMore: e.options.onShowMore }, paths: e.store.workspace.activeDocument?.paths ?? {}, rootIndex: F.value, security: e.store.workspace.activeDocument?.security, store: e.store, webhooks: e.store.workspace.activeDocument?.webhooks ?? {} }, null, 8, ["activeCollection", "activeServer", "entries", "hash", "options", "paths", "rootIndex", "security", "store", "webhooks"]) ])) : l("", !0), !e.options.hideModels && e.store.workspace.activeDocument ? (i(), c(o(Y), { key: 1, hash: o(m), models: P.value, options: { layout: e.options.layout ?? "modern", expandAllModelSections: e.options.expandAllModelSections, orderRequiredPropertiesFirst: e.options.orderRequiredPropertiesFirst, orderSchemaPropertiesBy: e.options.orderSchemaPropertiesBy, onShowMore: e.options.onShowMore }, schemas: e.store.workspace.activeDocument.components?.schemas }, null, 8, ["hash", "models", "options", "schemas"])) : l("", !0), p(e.$slots, "end") ]) ], 64)); } }); export { ke as default };