UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

172 lines (171 loc) 8.6 kB
import { defineComponent, computed, createElementBlock, openBlock, Fragment, createVNode, createElementVNode, unref, renderSlot, createBlock, createCommentVNode, withCtx } from "vue"; import { generateClientOptions } from "@scalar/api-client/v2/blocks/operation-code-sample"; import { mergeAuthConfig } from "@scalar/api-client/v2/blocks/scalar-auth-selector-block"; import { mapHiddenClientsConfig } from "@scalar/api-client/v2/features/modal"; import { getSelectedServer } from "@scalar/api-client/v2/features/operation"; import { getServers } from "@scalar/api-client/v2/helpers"; import { ScalarErrorBoundary } from "@scalar/components"; import _sfc_main$5 from "./Operations/TraversedEntry.vue.js"; import _sfc_main$1 from "../Lazy/Lazy.vue.js"; import { firstLazyLoadComplete } from "../../helpers/lazy-bus.js"; import { getXKeysFromObject } from "../../features/specification-extension/helpers.js"; import SectionFlare from "../SectionFlare/SectionFlare.vue.js"; import _sfc_main$2 from "../../blocks/scalar-info-block/components/InfoBlock.vue.js"; import IntroductionCardItem from "../../blocks/scalar-info-block/components/IntroductionCardItem.vue.js"; import _sfc_main$3 from "../../blocks/scalar-server-selector-block/components/ServerSelector.vue.js"; import _sfc_main$4 from "./Auth/Auth.vue.js"; import ClientSelector from "../../blocks/scalar-client-selector-block/components/ClientSelector.vue.js"; import _sfc_main$6 from "../RenderPlugins/RenderPlugins.vue.js"; const _hoisted_1 = { class: "narrow-references-container" }; const _hoisted_2 = { key: 1, class: "h-dvh" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "Content", props: { infoSectionId: {}, options: {}, document: {}, xScalarDefaultClient: {}, items: {}, expandedItems: {}, eventBus: {}, environment: {}, headingSlugGenerator: { type: Function } }, setup(__props) { const clientOptions = computed( () => generateClientOptions(mapHiddenClientsConfig(__props.options.hiddenClients)) ); const documentExtensions = computed(() => getXKeysFromObject(__props.document)); const infoExtensions = computed(() => getXKeysFromObject(__props.document?.info)); const servers = computed( () => getServers(__props.options?.servers ?? __props.document?.servers, { baseServerUrl: __props.options?.baseServerURL, documentUrl: __props.document?.["x-scalar-original-source-url"] }) ); const selectedServer = computed( () => getSelectedServer(__props.document ?? null, servers.value) ); const securitySchemes = computed( () => mergeAuthConfig( __props.document?.components?.securitySchemes, __props.options.authentication?.securitySchemes ) ); return (_ctx, _cache) => { return openBlock(), createElementBlock(Fragment, null, [ createVNode(unref(SectionFlare)), createElementVNode("div", _hoisted_1, [ renderSlot(_ctx.$slots, "start"), createVNode(_sfc_main$1, { id: __props.infoSectionId }, { "empty-state": withCtx(() => [ renderSlot(_ctx.$slots, "empty-state") ]), default: withCtx(() => [ createVNode(unref(_sfc_main$2), { id: __props.infoSectionId, documentDownloadType: __props.options.documentDownloadType, documentExtensions: documentExtensions.value, eventBus: __props.eventBus, externalDocs: __props.document?.externalDocs, headingSlugGenerator: __props.headingSlugGenerator, info: __props.document?.info, infoExtensions: infoExtensions.value, layout: __props.options.layout, oasVersion: __props.document?.["x-original-oas-version"] }, { selectors: withCtx(() => [ createVNode(unref(ScalarErrorBoundary), null, { default: withCtx(() => [ servers.value?.length ? (openBlock(), createBlock(unref(IntroductionCardItem), { key: 0, class: "scalar-reference-intro-server scalar-client introduction-card-item text-base leading-normal [--scalar-address-bar-height:0px]" }, { default: withCtx(() => [ createVNode(unref(_sfc_main$3), { eventBus: __props.eventBus, selectedServer: selectedServer.value, servers: servers.value }, null, 8, ["eventBus", "selectedServer", "servers"]) ]), _: 1 })) : createCommentVNode("", true) ]), _: 1 }), createVNode(unref(ScalarErrorBoundary), null, { default: withCtx(() => [ __props.document ? (openBlock(), createBlock(unref(IntroductionCardItem), { key: 0, class: "scalar-reference-intro-auth scalar-client introduction-card-item leading-normal" }, { default: withCtx(() => [ createVNode(unref(_sfc_main$4), { document: __props.document, environment: __props.environment, eventBus: __props.eventBus, options: __props.options, securitySchemes: securitySchemes.value, selectedServer: selectedServer.value }, null, 8, ["document", "environment", "eventBus", "options", "securitySchemes", "selectedServer"]) ]), _: 1 })) : createCommentVNode("", true) ]), _: 1 }), createVNode(unref(ScalarErrorBoundary), null, { default: withCtx(() => [ clientOptions.value.length ? (openBlock(), createBlock(unref(IntroductionCardItem), { key: 0, class: "introduction-card-item scalar-reference-intro-clients" }, { default: withCtx(() => [ createVNode(unref(ClientSelector), { class: "introduction-card-item scalar-reference-intro-clients", clientOptions: clientOptions.value, eventBus: __props.eventBus, selectedClient: __props.xScalarDefaultClient, xScalarSdkInstallation: __props.document?.info?.["x-scalar-sdk-installation"] }, null, 8, ["clientOptions", "eventBus", "selectedClient", "xScalarSdkInstallation"]) ]), _: 1 })) : createCommentVNode("", true) ]), _: 1 }) ]), _: 1 }, 8, ["id", "documentDownloadType", "documentExtensions", "eventBus", "externalDocs", "headingSlugGenerator", "info", "infoExtensions", "layout", "oasVersion"]) ]), _: 3 }, 8, ["id"]), __props.items.length && __props.document ? (openBlock(), createBlock(_sfc_main$5, { key: 0, clientOptions: clientOptions.value, document: __props.document, entries: __props.items, eventBus: __props.eventBus, expandedItems: __props.expandedItems, options: __props.options, securitySchemes: securitySchemes.value, selectedClient: __props.xScalarDefaultClient, selectedServer: selectedServer.value }, null, 8, ["clientOptions", "document", "entries", "eventBus", "expandedItems", "options", "securitySchemes", "selectedClient", "selectedServer"])) : createCommentVNode("", true), createVNode(unref(_sfc_main$6), { options: __props.options, viewName: "content.end" }, null, 8, ["options"]), renderSlot(_ctx.$slots, "end"), !unref(firstLazyLoadComplete) ? (openBlock(), createElementBlock("div", _hoisted_2)) : createCommentVNode("", true) ]) ], 64); }; } }); export { _sfc_main as default };