@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
191 lines (190 loc) • 8.36 kB
JavaScript
import ClientSelector_default from "../../blocks/scalar-client-selector-block/components/ClientSelector.vue.js";
import { getXKeysFromObject } from "../../features/specification-extension/helpers.js";
import InfoBlock_default from "../../blocks/scalar-info-block/components/InfoBlock.vue.js";
import IntroductionCardItem_default from "../../blocks/scalar-info-block/components/IntroductionCardItem.vue.js";
import ServerSelector_default from "../../blocks/scalar-server-selector-block/components/ServerSelector.vue.js";
import Auth_default from "./Auth/Auth.vue.js";
import { firstLazyLoadComplete, scheduleInitialLoadComplete } from "../../helpers/lazy-bus.js";
import TraversedEntry_default from "./Operations/TraversedEntry.vue.js";
import RenderPlugins_default from "../RenderPlugins/RenderPlugins.vue.js";
import SectionFlare_default from "../SectionFlare/SectionFlare.vue.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, onMounted, openBlock, renderSlot, unref, withCtx } from "vue";
import { mapHiddenClientsConfig } from "@scalar/api-client/modal";
import { ScalarErrorBoundary } from "@scalar/components";
import { getSelectedServer, getServers, mergeSecurity } from "@scalar/workspace-store/request-example";
import { generateClientOptions } from "@scalar/api-client/blocks/operation-code-sample";
//#region src/components/Content/Content.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "narrow-references-container" };
var _hoisted_2 = {
key: 1,
class: "h-dvh"
};
var Content_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
__name: "Content",
props: {
infoSectionId: {},
options: {},
document: {},
clientDocument: {},
authStore: {},
xScalarDefaultClient: {},
items: {},
expandedItems: {},
eventBus: {},
environment: {},
headingSlugGenerator: { type: Function }
},
setup(__props) {
/** Generate all client options so that it can be shared between the top client picker and the operations */
const clientOptions = computed(() => generateClientOptions(mapHiddenClientsConfig(__props.options.hiddenClients)));
/** Computed property to get all OpenAPI extension fields from the root document object */
const documentExtensions = computed(() => getXKeysFromObject(__props.document));
/** Computed property to get all OpenAPI extension fields from the document's info object */
const infoExtensions = computed(() => getXKeysFromObject(__props.document?.info));
/** Compute the servers for the document */
const servers = computed(() => getServers(__props.options?.servers ?? __props.clientDocument?.servers, {
baseServerUrl: __props.options?.baseServerURL,
documentUrl: __props.clientDocument?.["x-scalar-original-source-url"]
}));
/** Compute the selected server for the document only (for now) */
const selectedServer = computed(() => getSelectedServer(__props.clientDocument ?? null, null, null, servers.value));
/** Merge authentication config with the document security schemes */
const securitySchemes = computed(() => mergeSecurity(__props.clientDocument?.components?.securitySchemes, __props.options.authentication?.securitySchemes, __props.authStore, __props.clientDocument?.["x-scalar-navigation"]?.name ?? ""));
/** Ensures firstLazyLoadComplete is set for documents with no Lazy sections (e.g. no operations/tags/models). */
onMounted(() => {
scheduleInitialLoadComplete();
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock(Fragment, null, [createVNode(unref(SectionFlare_default)), createElementVNode("div", _hoisted_1, [
renderSlot(_ctx.$slots, "start"),
createVNode(unref(InfoBlock_default), {
id: __props.infoSectionId,
documentDownloadType: __props.options.documentDownloadType,
documentExtensions: documentExtensions.value,
documentUrl: __props.document?.["x-scalar-original-source-url"],
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_default), {
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(ServerSelector_default), {
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 && !__props.options.hideTestRequestButton ? (openBlock(), createBlock(unref(IntroductionCardItem_default), {
key: 0,
class: "scalar-reference-intro-auth scalar-client introduction-card-item leading-normal"
}, {
default: withCtx(() => [createVNode(unref(Auth_default), {
authStore: __props.authStore,
document: __props.clientDocument,
environment: __props.environment,
eventBus: __props.eventBus,
options: __props.options,
securitySchemes: securitySchemes.value,
selectedServer: selectedServer.value
}, null, 8, [
"authStore",
"document",
"environment",
"eventBus",
"options",
"securitySchemes",
"selectedServer"
])]),
_: 1
})) : createCommentVNode("", true)]),
_: 1
}),
createVNode(unref(ScalarErrorBoundary), null, {
default: withCtx(() => [clientOptions.value.length ? (openBlock(), createBlock(unref(IntroductionCardItem_default), {
key: 0,
class: "introduction-card-item scalar-reference-intro-clients"
}, {
default: withCtx(() => [createVNode(unref(ClientSelector_default), {
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",
"documentUrl",
"eventBus",
"externalDocs",
"headingSlugGenerator",
"info",
"infoExtensions",
"layout",
"oasVersion"
]),
__props.items.length && __props.document ? (openBlock(), createBlock(TraversedEntry_default, {
key: 0,
authStore: __props.authStore,
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, [
"authStore",
"clientOptions",
"document",
"entries",
"eventBus",
"expandedItems",
"options",
"securitySchemes",
"selectedClient",
"selectedServer"
])) : createCommentVNode("", true),
createVNode(unref(RenderPlugins_default), {
options: __props.options,
viewName: "content.end"
}, null, 8, ["options"]),
renderSlot(_ctx.$slots, "end"),
!unref(firstLazyLoadComplete) ? (openBlock(), createElementBlock("div", _hoisted_2)) : createCommentVNode("", true)
])], 64);
};
}
});
//#endregion
export { Content_vue_vue_type_script_setup_true_lang_default as default };
//# sourceMappingURL=Content.vue.script.js.map