@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
267 lines (266 loc) • 12.4 kB
JavaScript
import Badge_default from "../../../components/Badge/Badge.vue.js";
import SectionAccordion_default from "../../../components/Section/SectionAccordion.vue.js";
import Anchor_default from "../../../components/Anchor/Anchor.vue.js";
import { getXKeysFromObject } from "../../specification-extension/helpers.js";
import SpecificationExtension_default from "../../specification-extension/SpecificationExtension.vue.js";
import LinkList_default from "../../../components/LinkList/LinkList.vue.js";
import ExternalDocs_default from "../../external-docs/ExternalDocs.vue.js";
import { REQUEST_BODY_COMPOSITION_INDEX_SYMBOL } from "../request-body-composition-index.js";
import HttpMethod_default from "../../../components/HttpMethod/HttpMethod.vue.js";
import OperationPath_default from "../../../components/OperationPath.vue.js";
import ExampleResponses_default from "../../example-responses/ExampleResponses.vue.js";
import OperationParameters_default from "../components/OperationParameters.vue.js";
import OperationResponses_default from "../components/OperationResponses.vue.js";
import Callbacks_default from "../components/callbacks/Callbacks.vue.js";
import SecurityRequirementBadge_default from "../components/SecurityRequirementBadge.vue.js";
import { getOperationStability, getOperationStabilityColor, isOperationDeprecated } from "../helpers/operation-stability.js";
import TestRequestButton_default from "../../test-request-button/TestRequestButton.vue.js";
import XBadges_default from "../../x-badges/XBadges.vue.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, provide, ref, toDisplayString, unref, withCtx, withModifiers } from "vue";
import { ScalarErrorBoundary, ScalarIconButton, ScalarMarkdown } from "@scalar/components";
import { useClipboard } from "@scalar/use-hooks/useClipboard";
import { ScalarIconCopy, ScalarIconPlay, ScalarIconWebhooksLogo } from "@scalar/icons";
import { OperationCodeSample } from "@scalar/api-client/blocks/operation-code-sample";
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
//#region src/features/Operation/layouts/ClassicLayout.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "operation-title" };
var _hoisted_2 = { class: "operation-details" };
var _hoisted_3 = { class: "endpoint-label" };
var _hoisted_4 = { class: "endpoint-label-path" };
var _hoisted_5 = { class: "endpoint-label-name" };
var _hoisted_6 = {
key: 1,
class: "font-code text-sm"
};
var _hoisted_7 = { class: "endpoint-content" };
var _hoisted_8 = { class: "operation-details-card" };
var _hoisted_9 = {
key: 0,
class: "operation-details-card-item"
};
var _hoisted_10 = { class: "operation-details-card-item" };
var _hoisted_11 = { class: "operation-details-card-item" };
var _hoisted_12 = {
key: 1,
class: "operation-details-card-item"
};
var ClassicLayout_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
__name: "ClassicLayout",
props: {
id: {},
method: {},
options: {},
path: {},
clientOptions: {},
isCollapsed: { type: Boolean },
isWebhook: { type: Boolean },
selectedClient: {},
eventBus: {},
operation: {},
selectedServer: {},
selectedSecuritySchemes: {},
requiredSecurity: {}
},
setup(__props) {
const operationTitle = computed(() => __props.operation.summary || __props.path || "");
const operationExtensions = computed(() => getXKeysFromObject(__props.operation));
/** Track the currently selected example for passing to the modal */
const selectedExampleKey = ref("");
/** Track the selected request body content type so the code sample stays in sync */
const selectedRequestBodyContentType = ref();
/** Selected request body oneOf/anyOf variants; synced with schema dropdowns and code sample */
const requestBodyCompositionSelection = ref({});
const requestBodyCompositionSelectionForCodeSample = computed(() => ({ ...requestBodyCompositionSelection.value }));
const requestBodyCompositionSelectionKey = computed(() => JSON.stringify(requestBodyCompositionSelectionForCodeSample.value));
provide(REQUEST_BODY_COMPOSITION_INDEX_SYMBOL, requestBodyCompositionSelection);
const { copyToClipboard } = useClipboard();
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(SectionAccordion_default), {
id: __props.id,
"aria-label": operationTitle.value,
class: "reference-endpoint",
modelValue: !__props.isCollapsed,
transparent: "",
"onUpdate:modelValue": _cache[4] || (_cache[4] = (value) => __props.eventBus?.emit("toggle:nav-item", {
id: __props.id,
open: value
}))
}, createSlots({
title: withCtx(() => [createElementVNode("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createVNode(unref(HttpMethod_default), {
class: "endpoint-type",
method: __props.method,
short: ""
}, null, 8, ["method"]), createVNode(unref(Anchor_default), {
class: "endpoint-anchor",
onCopyAnchorUrl: _cache[0] || (_cache[0] = () => __props.eventBus?.emit("copy-url:nav-item", { id: __props.id }))
}, {
default: withCtx(() => [createElementVNode("h3", _hoisted_3, [
createElementVNode("div", _hoisted_4, [createVNode(OperationPath_default, {
deprecated: unref(isOperationDeprecated)(__props.operation),
path: __props.path
}, null, 8, ["deprecated", "path"])]),
createElementVNode("div", _hoisted_5, toDisplayString(operationTitle.value), 1),
unref(getOperationStability)(__props.operation) ? (openBlock(), createBlock(unref(Badge_default), {
key: 0,
class: normalizeClass(["capitalize", unref(getOperationStabilityColor)(__props.operation)])
}, {
default: withCtx(() => [createTextVNode(toDisplayString(unref(getOperationStability)(__props.operation)), 1)]),
_: 1
}, 8, ["class"])) : createCommentVNode("", true),
__props.isWebhook ? (openBlock(), createBlock(unref(Badge_default), {
key: 1,
class: "font-code text-green flex w-fit items-center justify-center gap-1"
}, {
default: withCtx(() => [createVNode(unref(ScalarIconWebhooksLogo), { weight: "bold" }), _cache[5] || (_cache[5] = createTextVNode("Webhook ", -1))]),
_: 1
})) : createCommentVNode("", true),
createVNode(unref(XBadges_default), {
badges: __props.operation["x-badges"],
position: "before"
}, null, 8, ["badges"])
])]),
_: 1
})])])]),
actions: withCtx(({ active }) => [
createVNode(SecurityRequirementBadge_default, {
hideLabel: "",
requiredSecurity: __props.requiredSecurity
}, null, 8, ["requiredSecurity"]),
createVNode(unref(XBadges_default), {
badges: __props.operation["x-badges"],
position: "after"
}, null, 8, ["badges"]),
!__props.options.hideTestRequestButton ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [active && !__props.isWebhook ? (openBlock(), createBlock(unref(TestRequestButton_default), {
key: 0,
id: __props.id,
eventBus: __props.eventBus,
exampleName: selectedExampleKey.value,
method: __props.method,
path: __props.path,
requestBodyCompositionSelection: requestBodyCompositionSelectionForCodeSample.value
}, null, 8, [
"id",
"eventBus",
"exampleName",
"method",
"path",
"requestBodyCompositionSelection"
])) : (openBlock(), createBlock(unref(ScalarIconPlay), {
key: 1,
class: "endpoint-try-hint size-4.5"
}))], 64)) : createCommentVNode("", true),
__props.options.showOperationId && __props.operation.operationId ? (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString(__props.operation.operationId), 1)) : createCommentVNode("", true),
createVNode(unref(ScalarIconButton), {
class: "endpoint-copy p-0.5",
icon: unref(ScalarIconCopy),
label: "Copy endpoint URL",
size: "xs",
variant: "ghost",
onClick: _cache[1] || (_cache[1] = withModifiers(($event) => unref(copyToClipboard)(__props.path), ["stop"]))
}, null, 8, ["icon"])
]),
default: withCtx(() => [createElementVNode("div", _hoisted_7, [
createElementVNode("div", _hoisted_8, [
Object.keys(operationExtensions.value).length > 0 ? (openBlock(), createElementBlock("div", _hoisted_9, [createVNode(SpecificationExtension_default, { value: operationExtensions.value }, null, 8, ["value"])])) : createCommentVNode("", true),
createElementVNode("div", _hoisted_10, [createVNode(OperationParameters_default, {
selectedContentType: selectedRequestBodyContentType.value,
"onUpdate:selectedContentType": _cache[2] || (_cache[2] = ($event) => selectedRequestBodyContentType.value = $event),
eventBus: __props.eventBus,
options: __props.options,
parameters: __props.operation.parameters,
requestBody: unref(getResolvedRef)(__props.operation.requestBody)
}, null, 8, [
"selectedContentType",
"eventBus",
"options",
"parameters",
"requestBody"
])]),
createElementVNode("div", _hoisted_11, [createVNode(OperationResponses_default, {
eventBus: __props.eventBus,
options: __props.options,
responses: __props.operation.responses
}, null, 8, [
"eventBus",
"options",
"responses"
])]),
__props.operation?.callbacks ? (openBlock(), createElementBlock("div", _hoisted_12, [createVNode(Callbacks_default, {
callbacks: __props.operation.callbacks,
eventBus: __props.eventBus,
options: __props.options,
path: __props.path
}, null, 8, [
"callbacks",
"eventBus",
"options",
"path"
])])) : createCommentVNode("", true)
]),
__props.operation.responses ? (openBlock(), createBlock(unref(ExampleResponses_default), {
key: 0,
class: "operation-example-card",
responses: __props.operation.responses
}, null, 8, ["responses"])) : createCommentVNode("", true),
createElementVNode("div", null, [__props.operation.externalDocs ? (openBlock(), createBlock(unref(LinkList_default), { key: 0 }, {
default: withCtx(() => [createVNode(unref(ExternalDocs_default), { value: __props.operation.externalDocs }, null, 8, ["value"])]),
_: 1
})) : createCommentVNode("", true), createVNode(unref(ScalarErrorBoundary), null, {
default: withCtx(() => [(openBlock(), createBlock(unref(OperationCodeSample), {
key: requestBodyCompositionSelectionKey.value,
selectedExample: selectedExampleKey.value,
"onUpdate:selectedExample": _cache[3] || (_cache[3] = ($event) => selectedExampleKey.value = $event),
class: "operation-example-card",
clientOptions: __props.clientOptions,
eventBus: __props.eventBus,
fallback: "",
isWebhook: __props.isWebhook,
method: __props.method,
operation: __props.operation,
path: __props.path,
requestBodyCompositionSelection: requestBodyCompositionSelectionForCodeSample.value,
securitySchemes: __props.selectedSecuritySchemes,
selectedClient: __props.selectedClient,
selectedContentType: selectedRequestBodyContentType.value,
selectedServer: __props.selectedServer
}, null, 8, [
"selectedExample",
"clientOptions",
"eventBus",
"isWebhook",
"method",
"operation",
"path",
"requestBodyCompositionSelection",
"securitySchemes",
"selectedClient",
"selectedContentType",
"selectedServer"
]))]),
_: 1
})])
])]),
_: 2
}, [__props.operation.description ? {
name: "description",
fn: withCtx(() => [createVNode(unref(ScalarMarkdown), {
anchorPrefix: __props.id,
"aria-label": "Operation Description",
role: "group",
transformType: "heading",
value: __props.operation.description,
withAnchors: "",
withImages: ""
}, null, 8, ["anchorPrefix", "value"])]),
key: "0"
} : void 0]), 1032, [
"id",
"aria-label",
"modelValue"
]);
};
}
});
//#endregion
export { ClassicLayout_vue_vue_type_script_setup_true_lang_default as default };
//# sourceMappingURL=ClassicLayout.vue.script.js.map