@scalar/api-reference 1.62.4 → 1.62.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +14 -0
- package/dist/blocks/scalar-info-block/components/SpecificationVersion.vue.d.ts.map +1 -1
- package/dist/blocks/scalar-info-block/components/SpecificationVersion.vue.js.map +1 -1
- package/dist/blocks/scalar-info-block/components/SpecificationVersion.vue.script.js +2 -1
- package/dist/blocks/scalar-info-block/components/SpecificationVersion.vue.script.js.map +1 -1
- package/dist/browser/chunks/{AgentScalarChatInterface-uEJhFXkB.js → AgentScalarChatInterface-Bd03__M5.js} +4 -4
- package/dist/browser/chunks/ScalarTextInput.vue-Cg0WEkPQ.js +27 -0
- package/dist/browser/chunks/basic-shape-diamond.svg-BTEOT1FL.js +1 -1
- package/dist/browser/chunks/basic-shape-hexagon.svg-BSPzaCgF.js +1 -1
- package/dist/browser/chunks/basic-shape-primary-circle-ellipse-round.svg-DKmZ8UUU.js +1 -1
- package/dist/browser/chunks/basic-shape-primary-square-rectangle.svg-n2YRykHD.js +1 -1
- package/dist/browser/chunks/basic-shape-shield.svg-Bec9cJDA.js +1 -1
- package/dist/browser/chunks/browser-67K6wmG9.js +1 -1
- package/dist/browser/chunks/computer-device-desktop-monitor.svg-m6j893Hb.js +1 -1
- package/dist/browser/chunks/computer-device-desktop.svg-Dk1VVO7k.js +1 -1
- package/dist/browser/chunks/computer-device-laptop.svg-BNGVUCYS.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-phone-android-samsung-back.svg-CC4UUTFw.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-phone-android-samsung.svg-D8ExpMpL.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-phone-iphone-x-back.svg-CLm7sgMM.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-phone-iphone-x.svg-Xrttg6_7.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-tablet-touch.svg-DQ2oTvOG.js +1 -1
- package/dist/browser/chunks/computer-device-mobile-tablet.svg-DCr0XlRc.js +1 -1
- package/dist/browser/chunks/computer-device-network-ethernet-cat6.svg-AK9l0iOl.js +1 -1
- package/dist/browser/chunks/computer-device-network-lan-www.svg-gUIdFBlE.js +1 -1
- package/dist/browser/chunks/computer-device-network-wifi-connection.svg-Be-EMm4e.js +1 -1
- package/dist/browser/chunks/computer-device-network-wifi-router.svg-Dc2VzyqK.js +1 -1
- package/dist/browser/chunks/ecology-science-erlenmeyer-flask.svg-DHgy7Jfd.js +1 -1
- package/dist/browser/chunks/image-flash-lightning.svg-EETR_y1q.js +1 -1
- package/dist/browser/chunks/image-picture-flower.svg-DN1AYzJU.js +1 -1
- package/dist/browser/chunks/interface-alert-exclamation-diamond.svg-C5NozMV_.js +1 -1
- package/dist/browser/chunks/interface-alert-exclamation-triangle-warning.svg-DaAg2fF5.js +1 -1
- package/dist/browser/chunks/interface-alert-information-circle.svg-ckkkt9Mv.js +1 -1
- package/dist/browser/chunks/interface-award-crown.svg-pjvn9hY-.js +1 -1
- package/dist/browser/chunks/interface-bookmark-tag.svg-r2r-lQq4.js +1 -1
- package/dist/browser/chunks/interface-bookmark.svg-BK9HKQBT.js +1 -1
- package/dist/browser/chunks/interface-calendar-date-one.svg-DNnF0M1I.js +1 -1
- package/dist/browser/chunks/interface-content-book-open-pages.svg-CQj_w9Vp.js +1 -1
- package/dist/browser/chunks/interface-content-book-page.svg-DppoeJRe.js +1 -1
- package/dist/browser/chunks/interface-content-file.svg-CvcD7OiY.js +1 -1
- package/dist/browser/chunks/interface-content-folder.svg-BmtS5I9A.js +1 -1
- package/dist/browser/chunks/interface-copy-clipboard.svg-Be6EI50X.js +1 -1
- package/dist/browser/chunks/interface-edit-attachment.svg-G5TKzpWX.js +1 -1
- package/dist/browser/chunks/interface-edit-binocular.svg-jzL-DvGB.js +1 -1
- package/dist/browser/chunks/interface-edit-magic-wand.svg-BOTlymvp.js +1 -1
- package/dist/browser/chunks/interface-edit-tool-paint-roller.svg-s9dwryx7.js +1 -1
- package/dist/browser/chunks/interface-edit-tool-pencil.svg-C7v0dbB3.js +1 -1
- package/dist/browser/chunks/interface-favorite-award.svg-CYHUgUG0.js +1 -1
- package/dist/browser/chunks/interface-favorite-flag.svg-C10zlKOb.js +1 -1
- package/dist/browser/chunks/interface-favorite-heart.svg-eoduXxlz.js +1 -1
- package/dist/browser/chunks/interface-favorite-star.svg-BSmxJetr.js +1 -1
- package/dist/browser/chunks/interface-favorite-stars-sparkles.svg-JTFLj3Ls.js +1 -1
- package/dist/browser/chunks/interface-hierarchy-flowchart.svg-Cg_Wy0kN.js +1 -1
- package/dist/browser/chunks/interface-home-house.svg-DytoGRnv.js +1 -1
- package/dist/browser/chunks/interface-hyperlink.svg-CuEfmmQI.js +1 -1
- package/dist/browser/chunks/interface-lighting-brightness.svg-DSK0h_Pa.js +1 -1
- package/dist/browser/chunks/interface-lock-closed.svg-Cn6TaLYv.js +1 -1
- package/dist/browser/chunks/interface-lock-open-unlock.svg-CVkG5-9W.js +1 -1
- package/dist/browser/chunks/interface-login-key.svg-y-cwwXjN.js +1 -1
- package/dist/browser/chunks/interface-search.svg-S-puVFJB.js +1 -1
- package/dist/browser/chunks/interface-setting-cog.svg-CTH4_lLg.js +1 -1
- package/dist/browser/chunks/interface-share-megaphone-bullhorn.svg-Pbp39MyC.js +1 -1
- package/dist/browser/chunks/interface-share-rocket.svg-BgCsIRZO.js +1 -1
- package/dist/browser/chunks/interface-share-satellite.svg-DAMN9d5G.js +1 -1
- package/dist/browser/chunks/interface-share-space-ship.svg-Dt-Mejxk.js +1 -1
- package/dist/browser/chunks/interface-share.svg-vFYTXSti.js +1 -1
- package/dist/browser/chunks/interface-signal-square.svg-DNG4LpAe.js +1 -1
- package/dist/browser/chunks/interface-time-clock-circle.svg-Bpz-nLxo.js +1 -1
- package/dist/browser/chunks/interface-time-hour-glass.svg-D7agfKsH.js +1 -1
- package/dist/browser/chunks/interface-users-multiple.svg-CkPJBBnG.js +1 -1
- package/dist/browser/chunks/interface-weather-moon.svg-CaTZFMPO.js +1 -1
- package/dist/browser/chunks/mail-chat-bubble-square.svg-DC8RIihp.js +1 -1
- package/dist/browser/chunks/mail-send-email-paper-airplane.svg-D8OLs9jz.js +1 -1
- package/dist/browser/chunks/mail-send-envelope.svg-CV33h5Sx.js +1 -1
- package/dist/browser/chunks/{modal-D09WtmIH.js → modal-CssEjGY3.js} +2 -2
- package/dist/browser/chunks/modal-DXAlZ4Y8.js +99 -0
- package/dist/browser/chunks/money-cashier-receipt.svg-CJL8C2gs.js +1 -1
- package/dist/browser/chunks/money-currency-dollar-pay.svg-VdBplCTx.js +1 -1
- package/dist/browser/chunks/money-graph-arrow-increase.svg-DcRov3zk.js +1 -1
- package/dist/browser/chunks/money-graph-bar-chart-increase.svg-Cc7KxjX-.js +1 -1
- package/dist/browser/chunks/nature-ecology-leaf.svg-DR3cTZxt.js +1 -1
- package/dist/browser/chunks/phone-telephone.svg-DyY0gUlk.js +1 -1
- package/dist/browser/chunks/programming-bug.svg-BHLT-Qhp.js +1 -1
- package/dist/browser/chunks/programming-cloud.svg-B6YW33ba.js +1 -1
- package/dist/browser/chunks/programming-computer-database-server.svg-B6o5Sdn-.js +1 -1
- package/dist/browser/chunks/programming-computer-database.svg-Cl7OVtpJ.js +1 -1
- package/dist/browser/chunks/programming-module-four-layout.svg-BQrerL1x.js +1 -1
- package/dist/browser/chunks/programming-module-three.svg-B2KTQzBM.js +1 -1
- package/dist/browser/chunks/programming-module.svg-CiID7kPm.js +1 -1
- package/dist/browser/chunks/programming-script-code.svg-D1M5rtkN.js +1 -1
- package/dist/browser/chunks/runtime-core.esm-bundler-Byrbbu5Q.js +1 -1
- package/dist/browser/chunks/shopping-cart.svg-BEegiIR9.js +1 -1
- package/dist/browser/chunks/shopping-gift-present.svg-BUHwuLix.js +1 -1
- package/dist/browser/chunks/shopping-shipping-box-parcel-package.svg-D6fxWdYx.js +1 -1
- package/dist/browser/chunks/tag-new-circle.svg-jsg1bGs0.js +1 -1
- package/dist/browser/chunks/travel-map-earth-globe.svg-ClbMiU-f.js +1 -1
- package/dist/browser/chunks/vendor-DfF1NNVy.js +306 -0
- package/dist/browser/standalone.esm.js +20 -20
- package/dist/browser/standalone.js +246 -246
- package/dist/components/ApiReference.vue.d.ts.map +1 -1
- package/dist/components/ApiReference.vue.js +1 -1
- package/dist/components/ApiReference.vue.js.map +1 -1
- package/dist/components/ApiReference.vue.script.js +24 -20
- package/dist/components/ApiReference.vue.script.js.map +1 -1
- package/dist/components/Content/Auth/Auth.vue.d.ts.map +1 -1
- package/dist/components/Content/Auth/Auth.vue.js.map +1 -1
- package/dist/components/Content/Auth/Auth.vue.script.js +26 -4
- package/dist/components/Content/Auth/Auth.vue.script.js.map +1 -1
- package/dist/components/Content/Content.vue.d.ts.map +1 -1
- package/dist/components/Content/Content.vue.js.map +1 -1
- package/dist/components/Content/Content.vue.script.js +14 -2
- package/dist/components/Content/Content.vue.script.js.map +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.js +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.js.map +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.script.js +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.script.js.map +1 -1
- package/dist/components/Content/Schema/helpers/optimize-value-for-display.d.ts.map +1 -1
- package/dist/components/Content/Schema/helpers/optimize-value-for-display.js +36 -9
- package/dist/components/Content/Schema/helpers/optimize-value-for-display.js.map +1 -1
- package/dist/features/Operation/components/OperationResponses.vue.js.map +1 -1
- package/dist/features/Operation/components/OperationResponses.vue.script.js +1 -1
- package/dist/features/Operation/components/OperationResponses.vue.script.js.map +1 -1
- package/dist/features/Operation/components/ParameterListItem.vue.d.ts.map +1 -1
- package/dist/features/Operation/components/ParameterListItem.vue.js +1 -1
- package/dist/features/Operation/components/ParameterListItem.vue.js.map +1 -1
- package/dist/features/Operation/components/ParameterListItem.vue.script.js +21 -3
- package/dist/features/Operation/components/ParameterListItem.vue.script.js.map +1 -1
- package/dist/helpers/id-routing.d.ts.map +1 -1
- package/dist/helpers/id-routing.js +23 -6
- package/dist/helpers/id-routing.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +17 -3
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +20 -3
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/style.css +77 -68
- package/dist/vue-styles.css +68 -68
- package/package.json +13 -13
- package/dist/browser/chunks/ScalarTextInput.vue-DfHAfVG5.js +0 -27
- package/dist/browser/chunks/modal-VSnkfbyL.js +0 -99
- package/dist/browser/chunks/vendor-C5HmjoOQ.js +0 -306
|
@@ -16,6 +16,7 @@ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock
|
|
|
16
16
|
import { getAsyncApiServers, getSelectedAsyncApiServer } from "@scalar/workspace-store/channel-example";
|
|
17
17
|
import { getSelectedServer, getServers, mergeSecurity } from "@scalar/workspace-store/request-example";
|
|
18
18
|
import { getDocumentType, isAsyncApiDocument, isOpenApiDocument } from "@scalar/workspace-store/schemas/type-guards";
|
|
19
|
+
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
19
20
|
import { mapHiddenClientsConfig } from "@scalar/api-client/modal/map-hidden-clients-config";
|
|
20
21
|
import { generateClientOptions } from "@scalar/blocks/code-example";
|
|
21
22
|
import { ScalarErrorBoundary } from "@scalar/components/error-boundary";
|
|
@@ -85,7 +86,18 @@ var Content_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
85
86
|
/** Compute the selected AsyncAPI server for the document */
|
|
86
87
|
const asyncApiSelectedServer = computed(() => getSelectedAsyncApiServer(asyncApiClientDocument.value ?? null, asyncApiServers.value));
|
|
87
88
|
/** Merge authentication config with the document security schemes */
|
|
88
|
-
const securitySchemes = computed(() =>
|
|
89
|
+
const securitySchemes = computed(() => {
|
|
90
|
+
const sourceDocument = asyncApiClientDocument.value ?? openApiClientDocument.value;
|
|
91
|
+
return mergeSecurity((sourceDocument?.components ? getResolvedRef(sourceDocument.components) : void 0)?.securitySchemes, __props.options.authentication?.securitySchemes, __props.authStore, sourceDocument?.["x-scalar-navigation"]?.name ?? "", __props.options.oauth2RedirectUri);
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* Whether to show the document-level auth selector.
|
|
95
|
+
*
|
|
96
|
+
* For OpenAPI it stays tied to `hideTestRequestButton`, since the auth feeds the interactive
|
|
97
|
+
* test client. AsyncAPI has no document-level test request, so its auth display is decoupled
|
|
98
|
+
* from that flag and shown whenever a document is present.
|
|
99
|
+
*/
|
|
100
|
+
const showAuthSelector = computed(() => Boolean(__props.document) && (Boolean(asyncApiDocument.value) || !__props.options.hideTestRequestButton));
|
|
89
101
|
/** Ensures firstLazyLoadComplete is set for documents with no Lazy sections (e.g. no operations/tags/models). */
|
|
90
102
|
onMounted(() => {
|
|
91
103
|
scheduleInitialLoadComplete();
|
|
@@ -155,7 +167,7 @@ var Content_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
155
167
|
_: 1
|
|
156
168
|
}),
|
|
157
169
|
createVNode(unref(ScalarErrorBoundary), null, {
|
|
158
|
-
default: withCtx(() => [
|
|
170
|
+
default: withCtx(() => [showAuthSelector.value ? (openBlock(), createBlock(unref(IntroductionCardItem_default), {
|
|
159
171
|
key: 0,
|
|
160
172
|
class: "scalar-reference-intro-auth scalar-client introduction-card-item leading-normal"
|
|
161
173
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.vue.script.js","names":[],"sources":["../../../src/components/Content/Content.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { mapHiddenClientsConfig } from '@scalar/api-client/modal/map-hidden-clients-config'\nimport { generateClientOptions } from '@scalar/blocks/code-example'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { Heading } from '@scalar/types/legacy'\nimport {\n getAsyncApiServers,\n getSelectedAsyncApiServer,\n} from '@scalar/workspace-store/channel-example'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport {\n getSelectedServer,\n getServers,\n mergeSecurity,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { TraversedEntry as TraversedEntryType } from '@scalar/workspace-store/schemas/navigation'\nimport {\n getDocumentType,\n isAsyncApiDocument,\n isOpenApiDocument,\n} from '@scalar/workspace-store/schemas/type-guards'\nimport type {\n Workspace,\n WorkspaceDocument,\n} from '@scalar/workspace-store/schemas/workspace'\nimport { computed, onMounted } from 'vue'\n\nimport { AsyncApiServerSelector } from '@/blocks/scalar-asyncapi-server-selector-block'\nimport { ClientSelector } from '@/blocks/scalar-client-selector-block'\nimport { InfoBlock } from '@/blocks/scalar-info-block'\nimport { IntroductionCardItem } from '@/blocks/scalar-info-block/'\nimport {\n getRenderableSdks,\n SdkInstallationInstructions,\n} from '@/blocks/scalar-sdk-installation-instructions'\nimport { ServerSelector } from '@/blocks/scalar-server-selector-block'\nimport { AsyncApiTraversedEntry } from '@/components/Content/AsyncApi'\nimport { Auth } from '@/components/Content/Auth'\nimport TraversedEntry from '@/components/Content/Operations/TraversedEntry.vue'\nimport { RenderPlugins } from '@/components/RenderPlugins'\nimport { SectionFlare } from '@/components/SectionFlare'\nimport { getXKeysFromObject } from '@/features/specification-extension'\nimport {\n firstLazyLoadComplete,\n scheduleInitialLoadComplete,\n} from '@/helpers/lazy-bus'\n\nconst {\n document,\n clientDocument,\n items,\n environment,\n eventBus,\n options,\n authStore,\n documentSlug,\n} = defineProps<{\n infoSectionId: string\n /** Slug of the active document, used to scope plugin view ids for navigation and deep-linking */\n documentSlug: string\n /** The subset of the configuration object required for the content component */\n options: Pick<\n ApiReferenceConfigurationRaw,\n | 'authentication'\n | 'baseServerURL'\n | 'documentDownloadType'\n | 'expandAllResponses'\n | 'hiddenClients'\n | 'hideTestRequestButton'\n | 'layout'\n | 'oauth2RedirectUri'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n | 'persistAuth'\n | 'proxyUrl'\n | 'servers'\n | 'showOperationId'\n | 'hideModels'\n | 'modelsSectionLabel'\n >\n document: WorkspaceDocument | undefined\n clientDocument: WorkspaceDocument | undefined\n authStore: AuthStore\n xScalarDefaultClient: Workspace['x-scalar-default-client']\n xScalarDefaultExample: Workspace['x-scalar-default-example']\n items: TraversedEntryType[]\n expandedItems: Record<string, boolean>\n eventBus: WorkspaceEventBus\n environment: XScalarEnvironment\n /** Heading id generator for Markdown headings */\n headingSlugGenerator: (heading: Heading) => string\n}>()\n\n/** Generate all client options so that it can be shared between the top client picker and the operations */\nconst clientOptions = computed(() =>\n generateClientOptions(mapHiddenClientsConfig(options.hiddenClients)),\n)\n\n/**\n * Custom SDK installation instructions that actually have something to render.\n * Entries with only a `lang` are ignored so we can fall back to the client\n * selector instead of showing an empty card.\n */\nconst sdkInstallation = computed(() =>\n getRenderableSdks(openApiDocument.value?.info?.['x-scalar-sdk-installation']),\n)\n\n/**\n * Narrow the (possibly AsyncAPI) documents to OpenAPI documents. api-reference\n * is OpenAPI-native, so AsyncAPI fields surface as undefined/empty.\n */\nconst openApiDocument = computed(() =>\n isOpenApiDocument(document) ? document : undefined,\n)\nconst openApiClientDocument = computed(() =>\n isOpenApiDocument(clientDocument) ? clientDocument : undefined,\n)\n\n/** AsyncAPI narrow, used to render the (currently channel-only) AsyncAPI content tree. */\nconst asyncApiDocument = computed(() =>\n isAsyncApiDocument(document) ? document : undefined,\n)\n\n/** AsyncAPI narrow of the client document, where server selection/variables are persisted. */\nconst asyncApiClientDocument = computed(() =>\n isAsyncApiDocument(clientDocument) ? clientDocument : undefined,\n)\n\nconst documentType = computed(() => getDocumentType(document))\n\nconst specificationVersion = computed(() => {\n if (isAsyncApiDocument(document)) {\n return document['x-original-aas-version'] ?? document.asyncapi\n }\n return openApiDocument.value?.['x-original-oas-version']\n})\n\n/** Computed property to get all OpenAPI extension fields from the root document object */\nconst documentExtensions = computed(() => getXKeysFromObject(document))\n\n/** Computed property to get all OpenAPI extension fields from the document's info object */\nconst infoExtensions = computed(() => getXKeysFromObject(document?.info))\n\n/** Compute the servers for the document */\nconst servers = computed(() =>\n getServers(options?.servers ?? openApiClientDocument.value?.servers, {\n baseServerUrl: options?.baseServerURL,\n documentUrl: clientDocument?.['x-scalar-original-source-url'],\n }),\n)\n\n/** Compute the selected server for the document only (for now) */\nconst selectedServer = computed(() =>\n getSelectedServer(\n openApiClientDocument.value ?? null,\n null,\n null,\n servers.value,\n ),\n)\n\n/**\n * Compute the AsyncAPI servers (all protocols, not just WebSocket) for the\n * document-level server selector.\n */\nconst asyncApiServers = computed(() =>\n asyncApiClientDocument.value\n ? getAsyncApiServers(asyncApiClientDocument.value, { webSocketOnly: false })\n : [],\n)\n\n/** Compute the selected AsyncAPI server for the document */\nconst asyncApiSelectedServer = computed(() =>\n getSelectedAsyncApiServer(\n asyncApiClientDocument.value ?? null,\n asyncApiServers.value,\n ),\n)\n\n/** Merge authentication config with the document security schemes */\nconst securitySchemes = computed(() =>\n mergeSecurity(\n openApiClientDocument.value?.components?.securitySchemes,\n options.authentication?.securitySchemes,\n authStore,\n openApiClientDocument.value?.['x-scalar-navigation']?.name ?? '',\n options.oauth2RedirectUri,\n ),\n)\n\n/** Ensures firstLazyLoadComplete is set for documents with no Lazy sections (e.g. no operations/tags/models). */\nonMounted(() => {\n scheduleInitialLoadComplete()\n})\n</script>\n<template>\n <SectionFlare />\n\n <div class=\"narrow-references-container\">\n <slot name=\"start\" />\n\n <!-- Render plugins at content.start view -->\n <RenderPlugins\n :documentSlug\n :eventBus\n :options\n viewName=\"content.start\" />\n\n <!-- Introduction -->\n\n <InfoBlock\n :id=\"infoSectionId\"\n :documentDownloadType=\"options.documentDownloadType\"\n :documentExtensions\n :documentType\n :documentUrl=\"document?.['x-scalar-original-source-url']\"\n :eventBus\n :externalDocs=\"openApiDocument?.externalDocs\"\n :headingSlugGenerator\n :info=\"document?.info\"\n :infoExtensions\n :layout=\"options.layout\"\n :specificationVersion>\n <template #selectors>\n <!-- Server Selector -->\n <ScalarErrorBoundary>\n <IntroductionCardItem\n v-if=\"servers?.length\"\n class=\"scalar-reference-intro-server scalar-client introduction-card-item text-base leading-normal [--scalar-address-bar-height:0px]\">\n <ServerSelector\n :eventBus\n :selectedServer\n :servers />\n </IntroductionCardItem>\n </ScalarErrorBoundary>\n\n <!-- AsyncAPI Server Selector -->\n <ScalarErrorBoundary>\n <IntroductionCardItem\n v-if=\"asyncApiServers.length\"\n class=\"scalar-reference-intro-server scalar-client introduction-card-item text-base leading-normal [--scalar-address-bar-height:0px]\">\n <AsyncApiServerSelector\n :eventBus\n :selectedServer=\"asyncApiSelectedServer\"\n :servers=\"asyncApiServers\" />\n </IntroductionCardItem>\n </ScalarErrorBoundary>\n\n <!-- Auth selector -->\n <ScalarErrorBoundary>\n <IntroductionCardItem\n v-if=\"document && !options.hideTestRequestButton\"\n class=\"scalar-reference-intro-auth scalar-client introduction-card-item leading-normal\">\n <Auth\n :authStore\n :document=\"clientDocument\"\n :environment\n :eventBus\n :options\n :securitySchemes\n :selectedServer />\n </IntroductionCardItem>\n </ScalarErrorBoundary>\n\n <!-- Custom SDK installation instructions, or the generic client selector -->\n <ScalarErrorBoundary>\n <IntroductionCardItem\n v-if=\"sdkInstallation.length\"\n class=\"introduction-card-item scalar-reference-intro-clients\">\n <SdkInstallationInstructions\n class=\"introduction-card-item scalar-reference-intro-clients\"\n :eventBus\n :selectedClient=\"xScalarDefaultClient\"\n :xScalarSdkInstallation=\"sdkInstallation\" />\n </IntroductionCardItem>\n <IntroductionCardItem\n v-else-if=\"clientOptions.length && !asyncApiDocument\"\n class=\"introduction-card-item scalar-reference-intro-clients\">\n <ClientSelector\n class=\"introduction-card-item scalar-reference-intro-clients\"\n :clientOptions\n :eventBus\n :selectedClient=\"xScalarDefaultClient\" />\n </IntroductionCardItem>\n </ScalarErrorBoundary>\n </template>\n </InfoBlock>\n\n <!-- Render traversed operations and webhooks -->\n <!-- Use recursive component for cleaner rendering -->\n <TraversedEntry\n v-if=\"items.length && openApiDocument\"\n :authStore\n :clientOptions\n :document=\"openApiDocument\"\n :entries=\"items\"\n :eventBus\n :expandedItems\n :options\n :securitySchemes\n :selectedClient=\"xScalarDefaultClient\"\n :selectedExample=\"xScalarDefaultExample\"\n :selectedServer>\n </TraversedEntry>\n\n <!-- AsyncAPI: render channels grouped by tag, mirroring the sidebar order. -->\n <AsyncApiTraversedEntry\n v-else-if=\"items.length && asyncApiDocument\"\n :document=\"asyncApiDocument\"\n :entries=\"items\"\n :eventBus\n :expandedItems\n :options />\n\n <!-- Render plugins at content.end view -->\n <RenderPlugins\n :documentSlug\n :eventBus\n :options\n viewName=\"content.end\" />\n\n <slot name=\"end\" />\n <!-- Placeholder content to allow the active item to be scrolled to the top while the rest of the content is lazy loaded -->\n <div\n v-if=\"!firstLazyLoadComplete\"\n class=\"h-dvh\"></div>\n </div>\n</template>\n\n<style>\n.narrow-references-container {\n container-name: narrow-references-container;\n container-type: inline-size;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkGA,MAAM,gBAAgB,eACpB,sBAAsB,uBAAuB,QAAA,QAAQ,cAAc,CAAC,CACtE;;;;;;EAOA,MAAM,kBAAkB,eACtB,kBAAkB,gBAAgB,OAAO,OAAO,6BAA6B,CAC/E;;;;;EAMA,MAAM,kBAAkB,eACtB,kBAAkB,QAAA,SAAS,GAAG,QAAA,WAAW,KAAA,EAC3C;EACA,MAAM,wBAAwB,eAC5B,kBAAkB,QAAA,eAAe,GAA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,WAAA,EADxB,YAQuB,MAAA,6BAAA,EAAA;;QANrB,OAAM;;+BAKwC,CAJ9C,YAI8C,MAAA,oCAAA,EAAA;SAH5C,OAAM;SACL,UAAA,QAAA;SACA,gBAAgB,QAAA;SAChB,wBAAwB,gBAAA;;;;;;;aAGhB,cAAA,MAAc,UAAM,CAAK,iBAAA,SAAA,WAAA,EADtC,YAQuB,MAAA,6BAAA,EAAA;;QANrB,OAAM;;+BAKqC,CAJ3C,YAI2C,MAAA,uBAAA,EAAA;SAHzC,OAAM;SACL,eAAA,cAAA;SACA,UAAA,QAAA;SACA,gBAAgB,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;IASnB,QAAA,MAAM,UAAU,gBAAA,SAAA,WAAA,EADxB,YAaiB,wBAAA;;KAXd,WAAA,QAAA;KACA,eAAA,cAAA;KACA,UAAU,gBAAA;KACV,SAAS,QAAA;KACT,UAAA,QAAA;KACA,eAAA,QAAA;KACA,SAAA,QAAA;KACA,iBAAA,gBAAA;KACA,gBAAgB,QAAA;KAChB,iBAAiB,QAAA;KACjB,gBAAA,eAAA;;;;;;;;;;;;;UAKU,QAAA,MAAM,UAAU,iBAAA,SAAA,WAAA,EAD7B,YAMa,MAAA,+BAAA,EAAA;;KAJV,UAAU,iBAAA;KACV,SAAS,QAAA;KACT,UAAA,QAAA;KACA,eAAA,QAAA;KACA,SAAA,QAAA;;;;;;;;IAGH,YAI2B,MAAA,sBAAA,EAAA;KAHxB,cAAA,QAAA;KACA,UAAA,QAAA;KACA,SAAA,QAAA;KACD,UAAS;;;;;;IAEX,WAAmB,KAAA,QAAA,MAAA;KAGV,MAAA,sBAAqB,IAAA,WAAA,EAD9B,mBAEsB,OAFtB,WAEsB,IAAA,mBAAA,IAAA,KAAA"}
|
|
1
|
+
{"version":3,"file":"Content.vue.script.js","names":[],"sources":["../../../src/components/Content/Content.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { mapHiddenClientsConfig } from '@scalar/api-client/modal/map-hidden-clients-config'\nimport { generateClientOptions } from '@scalar/blocks/code-example'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { Heading } from '@scalar/types/legacy'\nimport {\n getAsyncApiServers,\n getSelectedAsyncApiServer,\n} from '@scalar/workspace-store/channel-example'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getSelectedServer,\n getServers,\n mergeSecurity,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { TraversedEntry as TraversedEntryType } from '@scalar/workspace-store/schemas/navigation'\nimport {\n getDocumentType,\n isAsyncApiDocument,\n isOpenApiDocument,\n} from '@scalar/workspace-store/schemas/type-guards'\nimport type {\n Workspace,\n WorkspaceDocument,\n} from '@scalar/workspace-store/schemas/workspace'\nimport { computed, onMounted } from 'vue'\n\nimport { AsyncApiServerSelector } from '@/blocks/scalar-asyncapi-server-selector-block'\nimport { ClientSelector } from '@/blocks/scalar-client-selector-block'\nimport { InfoBlock } from '@/blocks/scalar-info-block'\nimport { IntroductionCardItem } from '@/blocks/scalar-info-block/'\nimport {\n getRenderableSdks,\n SdkInstallationInstructions,\n} from '@/blocks/scalar-sdk-installation-instructions'\nimport { ServerSelector } from '@/blocks/scalar-server-selector-block'\nimport { AsyncApiTraversedEntry } from '@/components/Content/AsyncApi'\nimport { Auth } from '@/components/Content/Auth'\nimport TraversedEntry from '@/components/Content/Operations/TraversedEntry.vue'\nimport { RenderPlugins } from '@/components/RenderPlugins'\nimport { SectionFlare } from '@/components/SectionFlare'\nimport { getXKeysFromObject } from '@/features/specification-extension'\nimport {\n firstLazyLoadComplete,\n scheduleInitialLoadComplete,\n} from '@/helpers/lazy-bus'\n\nconst {\n document,\n clientDocument,\n items,\n environment,\n eventBus,\n options,\n authStore,\n documentSlug,\n} = defineProps<{\n infoSectionId: string\n /** Slug of the active document, used to scope plugin view ids for navigation and deep-linking */\n documentSlug: string\n /** The subset of the configuration object required for the content component */\n options: Pick<\n ApiReferenceConfigurationRaw,\n | 'authentication'\n | 'baseServerURL'\n | 'documentDownloadType'\n | 'expandAllResponses'\n | 'hiddenClients'\n | 'hideTestRequestButton'\n | 'layout'\n | 'oauth2RedirectUri'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n | 'persistAuth'\n | 'proxyUrl'\n | 'servers'\n | 'showOperationId'\n | 'hideModels'\n | 'modelsSectionLabel'\n >\n document: WorkspaceDocument | undefined\n clientDocument: WorkspaceDocument | undefined\n authStore: AuthStore\n xScalarDefaultClient: Workspace['x-scalar-default-client']\n xScalarDefaultExample: Workspace['x-scalar-default-example']\n items: TraversedEntryType[]\n expandedItems: Record<string, boolean>\n eventBus: WorkspaceEventBus\n environment: XScalarEnvironment\n /** Heading id generator for Markdown headings */\n headingSlugGenerator: (heading: Heading) => string\n}>()\n\n/** Generate all client options so that it can be shared between the top client picker and the operations */\nconst clientOptions = computed(() =>\n generateClientOptions(mapHiddenClientsConfig(options.hiddenClients)),\n)\n\n/**\n * Custom SDK installation instructions that actually have something to render.\n * Entries with only a `lang` are ignored so we can fall back to the client\n * selector instead of showing an empty card.\n */\nconst sdkInstallation = computed(() =>\n getRenderableSdks(openApiDocument.value?.info?.['x-scalar-sdk-installation']),\n)\n\n/**\n * Narrow the (possibly AsyncAPI) documents to OpenAPI documents. api-reference\n * is OpenAPI-native, so AsyncAPI fields surface as undefined/empty.\n */\nconst openApiDocument = computed(() =>\n isOpenApiDocument(document) ? document : undefined,\n)\nconst openApiClientDocument = computed(() =>\n isOpenApiDocument(clientDocument) ? clientDocument : undefined,\n)\n\n/** AsyncAPI narrow, used to render the (currently channel-only) AsyncAPI content tree. */\nconst asyncApiDocument = computed(() =>\n isAsyncApiDocument(document) ? document : undefined,\n)\n\n/** AsyncAPI narrow of the client document, where server selection/variables are persisted. */\nconst asyncApiClientDocument = computed(() =>\n isAsyncApiDocument(clientDocument) ? clientDocument : undefined,\n)\n\nconst documentType = computed(() => getDocumentType(document))\n\nconst specificationVersion = computed(() => {\n if (isAsyncApiDocument(document)) {\n return document['x-original-aas-version'] ?? document.asyncapi\n }\n return openApiDocument.value?.['x-original-oas-version']\n})\n\n/** Computed property to get all OpenAPI extension fields from the root document object */\nconst documentExtensions = computed(() => getXKeysFromObject(document))\n\n/** Computed property to get all OpenAPI extension fields from the document's info object */\nconst infoExtensions = computed(() => getXKeysFromObject(document?.info))\n\n/** Compute the servers for the document */\nconst servers = computed(() =>\n getServers(options?.servers ?? openApiClientDocument.value?.servers, {\n baseServerUrl: options?.baseServerURL,\n documentUrl: clientDocument?.['x-scalar-original-source-url'],\n }),\n)\n\n/** Compute the selected server for the document only (for now) */\nconst selectedServer = computed(() =>\n getSelectedServer(\n openApiClientDocument.value ?? null,\n null,\n null,\n servers.value,\n ),\n)\n\n/**\n * Compute the AsyncAPI servers (all protocols, not just WebSocket) for the\n * document-level server selector.\n */\nconst asyncApiServers = computed(() =>\n asyncApiClientDocument.value\n ? getAsyncApiServers(asyncApiClientDocument.value, { webSocketOnly: false })\n : [],\n)\n\n/** Compute the selected AsyncAPI server for the document */\nconst asyncApiSelectedServer = computed(() =>\n getSelectedAsyncApiServer(\n asyncApiClientDocument.value ?? null,\n asyncApiServers.value,\n ),\n)\n\n/** Merge authentication config with the document security schemes */\nconst securitySchemes = computed(() => {\n // AsyncAPI stores its security schemes in the same `components.securitySchemes` slot and shares\n // the http/apiKey/oauth2/openIdConnect shapes with OpenAPI; broker-specific types (scramSha*,\n // plain, X509, …) flow through unchanged and degrade gracefully downstream. Both document types\n // persist the auth-store scope key on `x-scalar-navigation.name`, so a single call handles both.\n const sourceDocument =\n asyncApiClientDocument.value ?? openApiClientDocument.value\n const components = sourceDocument?.components\n ? getResolvedRef(sourceDocument.components)\n : undefined\n\n return mergeSecurity(\n components?.securitySchemes,\n options.authentication?.securitySchemes,\n authStore,\n sourceDocument?.['x-scalar-navigation']?.name ?? '',\n options.oauth2RedirectUri,\n )\n})\n\n/**\n * Whether to show the document-level auth selector.\n *\n * For OpenAPI it stays tied to `hideTestRequestButton`, since the auth feeds the interactive\n * test client. AsyncAPI has no document-level test request, so its auth display is decoupled\n * from that flag and shown whenever a document is present.\n */\nconst showAuthSelector = computed(\n () =>\n Boolean(document) &&\n (Boolean(asyncApiDocument.value) || !options.hideTestRequestButton),\n)\n\n/** Ensures firstLazyLoadComplete is set for documents with no Lazy sections (e.g. no operations/tags/models). */\nonMounted(() => {\n scheduleInitialLoadComplete()\n})\n</script>\n<template>\n <SectionFlare />\n\n <div class=\"narrow-references-container\">\n <slot name=\"start\" />\n\n <!-- Render plugins at content.start view -->\n <RenderPlugins\n :documentSlug\n :eventBus\n :options\n viewName=\"content.start\" />\n\n <!-- Introduction -->\n\n <InfoBlock\n :id=\"infoSectionId\"\n :documentDownloadType=\"options.documentDownloadType\"\n :documentExtensions\n :documentType\n :documentUrl=\"document?.['x-scalar-original-source-url']\"\n :eventBus\n :externalDocs=\"openApiDocument?.externalDocs\"\n :headingSlugGenerator\n :info=\"document?.info\"\n :infoExtensions\n :layout=\"options.layout\"\n :specificationVersion>\n <template #selectors>\n <!-- Server Selector -->\n <ScalarErrorBoundary>\n <IntroductionCardItem\n v-if=\"servers?.length\"\n class=\"scalar-reference-intro-server scalar-client introduction-card-item text-base leading-normal [--scalar-address-bar-height:0px]\">\n <ServerSelector\n :eventBus\n :selectedServer\n :servers />\n </IntroductionCardItem>\n </ScalarErrorBoundary>\n\n <!-- AsyncAPI Server Selector -->\n <ScalarErrorBoundary>\n <IntroductionCardItem\n v-if=\"asyncApiServers.length\"\n class=\"scalar-reference-intro-server scalar-client introduction-card-item text-base leading-normal [--scalar-address-bar-height:0px]\">\n <AsyncApiServerSelector\n :eventBus\n :selectedServer=\"asyncApiSelectedServer\"\n :servers=\"asyncApiServers\" />\n </IntroductionCardItem>\n </ScalarErrorBoundary>\n\n <!-- Auth selector -->\n <ScalarErrorBoundary>\n <IntroductionCardItem\n v-if=\"showAuthSelector\"\n class=\"scalar-reference-intro-auth scalar-client introduction-card-item leading-normal\">\n <Auth\n :authStore\n :document=\"clientDocument\"\n :environment\n :eventBus\n :options\n :securitySchemes\n :selectedServer />\n </IntroductionCardItem>\n </ScalarErrorBoundary>\n\n <!-- Custom SDK installation instructions, or the generic client selector -->\n <ScalarErrorBoundary>\n <IntroductionCardItem\n v-if=\"sdkInstallation.length\"\n class=\"introduction-card-item scalar-reference-intro-clients\">\n <SdkInstallationInstructions\n class=\"introduction-card-item scalar-reference-intro-clients\"\n :eventBus\n :selectedClient=\"xScalarDefaultClient\"\n :xScalarSdkInstallation=\"sdkInstallation\" />\n </IntroductionCardItem>\n <IntroductionCardItem\n v-else-if=\"clientOptions.length && !asyncApiDocument\"\n class=\"introduction-card-item scalar-reference-intro-clients\">\n <ClientSelector\n class=\"introduction-card-item scalar-reference-intro-clients\"\n :clientOptions\n :eventBus\n :selectedClient=\"xScalarDefaultClient\" />\n </IntroductionCardItem>\n </ScalarErrorBoundary>\n </template>\n </InfoBlock>\n\n <!-- Render traversed operations and webhooks -->\n <!-- Use recursive component for cleaner rendering -->\n <TraversedEntry\n v-if=\"items.length && openApiDocument\"\n :authStore\n :clientOptions\n :document=\"openApiDocument\"\n :entries=\"items\"\n :eventBus\n :expandedItems\n :options\n :securitySchemes\n :selectedClient=\"xScalarDefaultClient\"\n :selectedExample=\"xScalarDefaultExample\"\n :selectedServer>\n </TraversedEntry>\n\n <!-- AsyncAPI: render channels grouped by tag, mirroring the sidebar order. -->\n <AsyncApiTraversedEntry\n v-else-if=\"items.length && asyncApiDocument\"\n :document=\"asyncApiDocument\"\n :entries=\"items\"\n :eventBus\n :expandedItems\n :options />\n\n <!-- Render plugins at content.end view -->\n <RenderPlugins\n :documentSlug\n :eventBus\n :options\n viewName=\"content.end\" />\n\n <slot name=\"end\" />\n <!-- Placeholder content to allow the active item to be scrolled to the top while the rest of the content is lazy loaded -->\n <div\n v-if=\"!firstLazyLoadComplete\"\n class=\"h-dvh\"></div>\n </div>\n</template>\n\n<style>\n.narrow-references-container {\n container-name: narrow-references-container;\n container-type: inline-size;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmGA,MAAM,gBAAgB,eACpB,sBAAsB,uBAAuB,QAAA,QAAQ,cAAc,CAAC,CACtE;;;;;;EAOA,MAAM,kBAAkB,eACtB,kBAAkB,gBAAgB,OAAO,OAAO,6BAA6B,CAC/E;;;;;EAMA,MAAM,kBAAkB,eACtB,kBAAkB,QAAA,SAAS,GAAG,QAAA,WAAW,KAAA,EAC3C;EACA,MAAM,wBAAwB,eAC5B,kBAAkB,QAAA,eAAe,GAAG,QAAA,iBAAiB,KAAA,EACvD;;EAGA,MAAM,mBAAmB,eACvB,mBAAmB,QAAA,SAAS,GAAG,QAAA,WAAW,KAAA,EAC5C;;EAGA,MAAM,yBAAyB,eAC7B,mBAAmB,QAAA,eAAe,GAAG,QAAA,iBAAiB,KAAA,EACxD;EAEA,MAAM,eAAe,eAAe,gBAAgB,QAAA,SAAS,CAAA;EAE7D,MAAM,uBAAuB,eAAe;AAC1C,OAAI,mBAAmB,QAAA,SAAS,CAC9B,QAAO,QAAA,SAAS,6BAA6B,QAAA,SAAS;AAExD,UAAO,gBAAgB,QAAQ;IAChC;;EAGD,MAAM,qBAAqB,eAAe,mBAAmB,QAAA,SAAS,CAAA;;EAGtE,MAAM,iBAAiB,eAAe,mBAAmB,QAAA,UAAU,KAAK,CAAA;;EAGxE,MAAM,UAAU,eACd,WAAW,QAAA,SAAS,WAAW,sBAAsB,OAAO,SAAS;GACnE,eAAe,QAAA,SAAS;GACxB,aAAa,QAAA,iBAAiB;GAC/B,CAAC,CACJ;;EAGA,MAAM,iBAAiB,eACrB,kBACE,sB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AAA;KACA,UAAU,gBAAA;KACV,SAAS,QAAA;KACT,UAAA,QAAA;KACA,eAAA,QAAA;KACA,SAAA,QAAA;KACA,iBAAA,gBAAA;KACA,gBAAgB,QAAA;KAChB,iBAAiB,QAAA;KACjB,gBAAA,eAAA;;;;;;;;;;;;;UAKU,QAAA,MAAM,UAAU,iBAAA,SAAA,WAAA,EAD7B,YAMa,MAAA,+BAAA,EAAA;;KAJV,UAAU,iBAAA;KACV,SAAS,QAAA;KACT,UAAA,QAAA;KACA,eAAA,QAAA;KACA,SAAA,QAAA;;;;;;;;IAGH,YAI2B,MAAA,sBAAA,EAAA;KAHxB,cAAA,QAAA;KACA,UAAA,QAAA;KACA,SAAA,QAAA;KACD,UAAS;;;;;;IAEX,WAAmB,KAAA,QAAA,MAAA;KAGV,MAAA,sBAAqB,IAAA,WAAA,EAD9B,mBAEsB,OAFtB,WAEsB,IAAA,mBAAA,IAAA,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaProperty.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Content/Schema/SchemaProperty.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SchemaProperty.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Content/Schema/SchemaProperty.vue"],"names":[],"mappings":"AAimBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAMvE,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACb,MAAM,8DAA8D,CAAA;AAErE,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,KAAK,CAAA;AAS9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAyBtE,KAAK,WAAW,GAAG;IACf,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACvB,MAAM,EAAE,YAAY,GAAG,SAAS,CAAA;IAChC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,kGAAkG;IAClG,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,OAAO,CAAC,EAAE,sBAAsB,GAAG,mBAAmB,CAAA;IACtD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,OAAO,EAAE,aAAa,CAAA;IACtB,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,YAAY,CAAA;IAClC,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1B,oFAAoF;IACpF,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AAqnBJ,QAAA,MAAM,YAAY;cA7oBH,OAAO;WAFV,MAAM;aAGJ,OAAO;oBAGA,OAAO;6EA4oB1B,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -2,7 +2,7 @@ import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_exp
|
|
|
2
2
|
import SchemaProperty_vue_vue_type_script_setup_true_lang_default from "./SchemaProperty.vue.script.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region src/components/Content/Schema/SchemaProperty.vue
|
|
5
|
-
var SchemaProperty_default = /* @__PURE__ */ _plugin_vue_export_helper_default(SchemaProperty_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var SchemaProperty_default = /* @__PURE__ */ _plugin_vue_export_helper_default(SchemaProperty_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-df25c065"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { SchemaProperty_default as default };
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaProperty.vue.js","names":[],"sources":["../../../../src/components/Content/Schema/SchemaProperty.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { ScalarMarkdown } from '@scalar/components/markdown'\nimport { ScalarWrappingText } from '@scalar/components/wrapping-text'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport {\n isDynamicRef,\n resolveDynamicRef,\n} from '@scalar/workspace-store/helpers/dynamic-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards'\nimport { computed, type Component } from 'vue'\n\nimport { WithBreadcrumb } from '@/components/Anchor'\nimport {\n resolveDynamicSchema,\n useDynamicScope,\n} from '@/components/Content/Schema/helpers/dynamic-scope'\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { getCycleKey } from '@/components/Content/Schema/helpers/schema-cycle'\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\nimport { SpecificationExtension } from '@/features/specification-extension'\n\nimport { getCompositionsToRender } from './helpers/get-compositions-to-render'\nimport { getEnumValues } from './helpers/get-enum-values'\nimport { getPropertyDescription } from './helpers/get-property-description'\nimport { hasComplexArrayItems } from './helpers/has-complex-array-items'\nimport { optimizeValueForDisplay } from './helpers/optimize-value-for-display'\nimport { shouldDisplayDescription } from './helpers/should-display-description'\nimport { shouldDisplayHeading } from './helpers/should-display-heading'\nimport Schema from './Schema.vue'\nimport SchemaComposition from './SchemaComposition.vue'\nimport SchemaEnums from './SchemaEnums.vue'\nimport SchemaPropertyHeading from './SchemaPropertyHeading.vue'\n\n/**\n * Note: We're taking in a prop called `value` which should be a JSON Schema.\n *\n * We're using `optimizeValueForDisplay` to merge null types in compositions (anyOf, allOf, oneOf, not).\n * So you should basically use the optimizedValue everywhere in the component.\n */\n\n/** Composition keywords that hold a list of schemas and can be flattened when they contain a single member. */\nconst SINGLE_ITEM_COMPOSITIONS = ['oneOf', 'anyOf', 'allOf'] as const\n\nconst props = withDefaults(\n defineProps<{\n is?: string | Component\n schema: SchemaObject | undefined\n noncollapsible?: boolean\n level?: number\n name?: string\n required?: boolean\n compact?: boolean\n discriminator?: DiscriminatorObject\n description?: string\n hideModelNames?: boolean\n hideHeading?: boolean\n /** When the root schema was resolved from a $ref, pass the ref name for display (e.g. \"Data\"). */\n modelName?: string | null\n variant?: 'additionalProperties' | 'patternProperties'\n breadcrumb?: string[]\n eventBus: WorkspaceEventBus | null\n options: SchemaOptions\n /** Enum values for property names (from JSON Schema propertyNames keyword). */\n propertyNamesEnum?: string[]\n /** Resolved propertyNames schema, used to show key constraints like `format`. */\n propertyNamesSchema?: SchemaObject\n /** When \"requestBody\", composition selection is synced with the example snippet */\n schemaContext?: string\n /** Internal path used to sync nested request body compositions with the code sample */\n compositionPath?: string[]\n /** Internal path segment for this property when building nested composition keys */\n compositionPathSegment?: string\n /** Stable identity of this property's schema, used for cycle detection. */\n cycleKey?: unknown\n }>(),\n {\n level: 0,\n required: false,\n compact: false,\n hideModelNames: false,\n },\n)\n\n/** The dynamic scope inherited from the enclosing schema resources, used to bind `$dynamicRef`s. */\nconst dynamicScope = useDynamicScope()\n\n/**\n * Simplified composition with `null` type.\n *\n * A top-level `$dynamicRef` (e.g. a linked-list `next` node) is bound to its concrete type via the\n * dynamic scope first; for ordinary schemas this is a no-op.\n */\nconst optimizedValue = computed(() =>\n optimizeValueForDisplay(resolveDynamicSchema(props.schema, dynamicScope)),\n)\n\nconst childBreadcrumb = computed<string[] | undefined>(() =>\n props.breadcrumb && props.name\n ? [...props.breadcrumb, props.name]\n : undefined,\n)\n\nconst currentCompositionPath = computed<string[]>(() =>\n props.compositionPathSegment\n ? [...(props.compositionPath ?? []), props.compositionPathSegment]\n : (props.compositionPath ?? []),\n)\n\nconst arrayItemsCompositionPath = computed<string[]>(() => [\n ...currentCompositionPath.value,\n 'items',\n])\n\nconst shouldHaveLink = computed(() => props.level <= 2)\n\n/**\n * The array schema used for item inspection, with a `$dynamicRef` item bound to its concrete type.\n *\n * Returns the schema unchanged unless `items` is a `$dynamicRef` that resolves against the dynamic\n * scope, so ordinary arrays (including `$ref` items) keep their existing behavior exactly.\n */\nconst arrayValueWithBoundItems = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value) || !isDynamicRef(value.items)) {\n return value\n }\n\n const bound = resolveDynamicRef(value.items.$dynamicRef, dynamicScope)\n return bound ? ({ ...value, items: bound } as SchemaObject) : value\n})\n\n/** Checks if array items have complex structure */\nconst hasComplexArrayItemsComputed = computed(() =>\n hasComplexArrayItems(arrayValueWithBoundItems.value),\n)\n\n/** Check if enum should be displayed (from value schema or from propertyNames) */\nconst hasEnum = computed(() => enumValues.value.length > 0)\n\n/** Determine if object properties should be displayed */\nconst shouldRenderObjectProperties = computed(() => {\n const value = optimizedValue.value\n if (!value) {\n return false\n }\n\n if (!('properties' in value || 'additionalProperties' in value)) {\n return false\n }\n\n // `allOf` already merges the factored-out sibling `properties` into its\n // rendered result (see `mergeAllOfSchemas`), so rendering a separate object\n // block here would show those properties twice. Let the composition handle it.\n if ('allOf' in value) {\n return false\n }\n\n // A schema may factor its common `properties` out to the top level alongside\n // a composition keyword (anyOf/oneOf/not), as described in the JSON Schema\n // \"factoring schemas\" guide. `isTypeObject` deliberately rejects such schemas\n // so the composition is rendered, but the factored-out properties must still\n // show. Unlike `allOf`, these compositions do not merge sibling properties.\n // Render them unless the schema is an explicit non-object (scalar or array)\n // type. See https://github.com/scalar/scalar/issues/8593\n const type = (value as { type?: unknown }).type\n const isExplicitNonObject = typeof type === 'string' && type !== 'object'\n\n return isTypeObject(value) || !isExplicitNonObject\n})\n\n/** Determine if array of objects should be rendered */\nconst shouldRenderArrayOfObjects = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value) || typeof value.items !== 'object') {\n return false\n }\n\n return hasComplexArrayItemsComputed.value\n})\n\n/** Extract enum values from schema or array items */\nconst enumValues = computed(() => getEnumValues(optimizedValue.value))\n\n/** Generate property description from type/format */\nconst propertyDescription = computed(() =>\n getPropertyDescription(optimizedValue.value),\n)\n\n/** Determine if description should be displayed */\nconst displayDescription = computed(() =>\n shouldDisplayDescription(optimizedValue.value, props.description),\n)\n\n/**\n * The schema used to render the object's own properties.\n *\n * Composition keywords are stripped so the nested object renders only its\n * properties. The compositions are rendered separately below; leaving them here\n * would route the nested `Schema` back through `SchemaProperty` and recurse.\n *\n * The `discriminator` is stripped too: its variant selector is part of the\n * composition rendered below (including the one inferred from a bare\n * `discriminator.mapping`), so keeping it here would make the nested `Schema`\n * infer and render a second, identical selector.\n *\n * When the property already renders the description, we also drop it to avoid\n * repeating it in the nested object schema card.\n */\nconst objectSchemaForChildren = computed(() => {\n const value = optimizedValue.value\n if (!value) {\n return value\n }\n\n const {\n oneOf: _oneOf,\n anyOf: _anyOf,\n allOf: _allOf,\n not: _not,\n discriminator: _discriminator,\n ...objectSchema\n } = value as Record<string, unknown>\n\n if (displayDescription.value && 'description' in objectSchema) {\n const { description: _description, ...schemaWithoutDescription } =\n objectSchema\n return schemaWithoutDescription as SchemaObject\n }\n\n return objectSchema as SchemaObject\n})\n\n/** Determine if property heading should be displayed */\nconst shouldDisplayHeadingComputed = computed(() =>\n shouldDisplayHeading(optimizedValue.value, props.name, props.required),\n)\n\n/** Computes which compositions should be rendered and with which values */\nconst compositionsToRender = computed(() =>\n getCompositionsToRender(optimizedValue.value, props.options.document),\n)\n\n/**\n * Get resolved array items for rendering (with any `$dynamicRef` bound to the concrete type).\n *\n * When the items are wrapped in a single-item composition (e.g. `items: { allOf: [{ type: 'object', ... }] }`), we\n * flatten that wrapper into its plain form. A composition with a single member is equivalent to that member, so\n * keeping the composition keyword only makes the items render through an extra schema layer, which adds an\n * unnecessary level of nesting and duplicates the item description. See https://github.com/scalar/scalar/issues/5900\n */\nconst resolvedArrayItems = computed(() => {\n const value = arrayValueWithBoundItems.value\n if (!value || !isArraySchema(value) || typeof value.items !== 'object') {\n return undefined\n }\n\n const items = resolve.schema(value.items)\n const hasSingleItemComposition = SINGLE_ITEM_COMPOSITIONS.some(\n (keyword) =>\n Array.isArray(items?.[keyword]) && items[keyword]?.length === 1,\n )\n\n return hasSingleItemComposition ? optimizeValueForDisplay(items) : items\n})\n\n/**\n * Cycle key for the array items schema, derived from the raw (unresolved) items\n * so a self-referential array element is detected as a cycle.\n */\nconst arrayItemsCycleKey = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value)) {\n return undefined\n }\n return getCycleKey(value.items)\n})\n\n/** Check if discriminator matches current property */\nconst isDiscriminatorProperty = computed(() =>\n Boolean(props.name && props.discriminator?.propertyName === props.name),\n)\n</script>\n<template>\n <component\n :is=\"is ?? 'li'\"\n class=\"property\"\n :class=\"[\n `property--level-${level}`,\n {\n 'property--compact': compact,\n 'property--deprecated': optimizedValue?.deprecated,\n },\n ]\">\n <SchemaPropertyHeading\n v-if=\"shouldDisplayHeadingComputed\"\n class=\"group\"\n :enum=\"hasEnum\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :isDiscriminator=\"isDiscriminatorProperty\"\n :modelName=\"modelName\"\n :propertyNames=\"propertyNamesSchema\"\n :required\n :value=\"optimizedValue\">\n <template\n v-if=\"name\"\n #name>\n <WithBreadcrumb\n :breadcrumb=\"shouldHaveLink ? childBreadcrumb : undefined\"\n :eventBus=\"eventBus\">\n <span\n v-if=\"variant === 'patternProperties'\"\n class=\"property-name-pattern-properties\">\n <ScalarWrappingText\n preset=\"property\"\n :text=\"name\" />\n </span>\n <span\n v-else-if=\"variant === 'additionalProperties'\"\n class=\"property-name-additional-properties\">\n <ScalarWrappingText\n preset=\"property\"\n :text=\"name\" />\n </span>\n <ScalarWrappingText\n v-else\n preset=\"property\"\n :text=\"name\" />\n </WithBreadcrumb>\n </template>\n <template\n v-if=\"optimizedValue?.example !== undefined\"\n #example>\n Example:\n {{ optimizedValue.example }}\n </template>\n </SchemaPropertyHeading>\n\n <!-- Description -->\n <div\n v-if=\"displayDescription || propertyDescription\"\n class=\"property-description\">\n <ScalarMarkdown\n :value=\"displayDescription || propertyDescription || ''\" />\n </div>\n\n <!-- Enum for property names -->\n <SchemaEnums\n v-if=\"propertyNamesEnum && propertyNamesEnum.length > 0\"\n propertyNames\n :value=\"{ enum: propertyNamesEnum } as SchemaObject\" />\n\n <!-- Enum values -->\n <SchemaEnums\n v-if=\"enumValues.length > 0\"\n :value=\"optimizedValue\" />\n\n <!-- Object -->\n <div\n v-if=\"shouldRenderObjectProperties\"\n class=\"children\">\n <Schema\n :breadcrumb=\"childBreadcrumb\"\n :compact=\"compact\"\n :compositionPath=\"currentCompositionPath\"\n :cycleKey=\"cycleKey\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :level=\"level + 1\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"objectSchemaForChildren\"\n :schemaContext=\"schemaContext\" />\n </div>\n\n <!-- Array of objects or nested arrays -->\n <div\n v-if=\"shouldRenderArrayOfObjects && resolvedArrayItems\"\n class=\"children\">\n <Schema\n :compact=\"compact\"\n :compositionPath=\"arrayItemsCompositionPath\"\n :cycleKey=\"arrayItemsCycleKey\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :level=\"level + 1\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"resolve.schema(resolvedArrayItems)\"\n :schemaContext=\"schemaContext\" />\n </div>\n\n <!-- Compositions -->\n <SchemaComposition\n v-for=\"compositionData in compositionsToRender\"\n :key=\"compositionData.composition\"\n :breadcrumb=\"breadcrumb\"\n :compact=\"compact\"\n :composition=\"compositionData.composition\"\n :compositionPath=\"currentCompositionPath\"\n :discriminator=\"schema?.discriminator\"\n :eventBus=\"eventBus\"\n :hideHeading=\"hideHeading\"\n :hideModelNames\n :level=\"level\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"compositionData.value\"\n :schemaContext=\"schemaContext\" />\n <SpecificationExtension :value=\"optimizedValue\" />\n </component>\n</template>\n\n<style scoped>\n.property {\n color: var(--scalar-color-1);\n display: flex;\n flex-direction: column;\n padding: 10px;\n font-size: var(--scalar-small);\n position: relative;\n}\n\n/** Remove top padding for top level schema card */\n.property.property--level-0:has(\n > .property-rule\n > .schema-card\n > .schema-properties.schema-properties-open\n > ul\n > li.property\n ) {\n padding-top: 0;\n}\n\n.property--compact.property--level-0,\n.property--compact.property--level-1 {\n padding: 10px 0;\n}\n\n.composition-panel .property.property.property.property--level-0 {\n padding: 0px;\n}\n\n.property--compact.property--level-0\n .composition-panel\n .property--compact.property--level-1 {\n padding: 8px;\n}\n\n/* if a property doesn't have a heading, remove the top padding */\n.property:has(> .property-rule:nth-of-type(1)):not(.property--compact) {\n padding-top: 8px;\n padding-bottom: 8px;\n}\n\n.property--deprecated {\n background: repeating-linear-gradient(\n -45deg,\n var(--scalar-background-2) 0,\n var(--scalar-background-2) 2px,\n transparent 2px,\n transparent 5px\n );\n background-size: 100%;\n}\n\n.property--deprecated > * {\n opacity: 0.75;\n}\n\n.property-description {\n margin-top: 6px;\n line-height: 1.4;\n font-size: var(--scalar-small);\n}\n\n.property-description:has(+ .property-rule) {\n margin-bottom: 9px;\n}\n\n:deep(.property-description) * {\n color: var(--scalar-color-2) !important;\n}\n\n.property:not(:last-of-type) {\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n\n.property-description + .children,\n.children + .property-rule {\n margin-top: 9px;\n}\n\n.children {\n display: flex;\n flex-direction: column;\n}\n\n.children .property--compact.property--level-1 {\n padding: 12px;\n}\n\n.property-example-value {\n all: unset;\n font-family: var(--scalar-font-code);\n padding: 6px;\n border-top: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n\n.property-rule {\n border-radius: var(--scalar-radius-lg);\n display: flex;\n flex-direction: column;\n}\n\n.property--level-2 :deep(.relative > button) {\n left: -2rem;\n}\n\n.property-rule\n :deep(\n .composition-panel\n .schema-card--level-1\n > .schema-properties.schema-properties-open\n ) {\n border-radius: 0 0 var(--scalar-radius-lg) var(--scalar-radius-lg);\n}\n\n.property-rule\n :deep(.composition-panel > .schema-card > .schema-card-description) {\n padding: 10px;\n border-left: var(--scalar-border-width) solid var(--scalar-border-color);\n border-right: var(--scalar-border-width) solid var(--scalar-border-color);\n\n & + .schema-properties {\n margin-top: 0;\n }\n}\n\n.property-example {\n background: transparent;\n border: none;\n display: flex;\n flex-direction: row;\n gap: 8px;\n}\n\n.property-example-label,\n.property-example-value {\n padding: 3px 0 0 0;\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border-top: 0;\n border-radius: var(--scalar-radius);\n padding: 3px 4px;\n}\n\n.property-name {\n font-family: var(--scalar-font-code);\n font-weight: var(--scalar-semibold);\n}\n\n.property-name-additional-properties::before,\n.property-name-pattern-properties::before {\n text-transform: uppercase;\n font-size: var(--scalar-micro);\n display: inline-block;\n padding: 2px 4px;\n border-radius: var(--scalar-radius);\n color: var(--scalar-color-1);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n background-color: var(--scalar-background-2);\n margin-right: 4px;\n}\n\n.property-name-pattern-properties::before {\n content: 'regex';\n}\n\n.property-name-additional-properties,\n.property-name-pattern-properties {\n border: 1px dashed var(--scalar-border-color);\n color: var(--scalar-color-accent);\n display: inline-block;\n padding: 2px;\n border-radius: var(--scalar-radius);\n}\n</style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"SchemaProperty.vue.js","names":[],"sources":["../../../../src/components/Content/Schema/SchemaProperty.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { ScalarMarkdown } from '@scalar/components/markdown'\nimport { ScalarWrappingText } from '@scalar/components/wrapping-text'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport {\n isDynamicRef,\n resolveDynamicRef,\n} from '@scalar/workspace-store/helpers/dynamic-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards'\nimport { computed, type Component } from 'vue'\n\nimport { WithBreadcrumb } from '@/components/Anchor'\nimport {\n resolveDynamicSchema,\n useDynamicScope,\n} from '@/components/Content/Schema/helpers/dynamic-scope'\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { getCycleKey } from '@/components/Content/Schema/helpers/schema-cycle'\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\nimport { SpecificationExtension } from '@/features/specification-extension'\n\nimport { getCompositionsToRender } from './helpers/get-compositions-to-render'\nimport { getEnumValues } from './helpers/get-enum-values'\nimport { getPropertyDescription } from './helpers/get-property-description'\nimport { hasComplexArrayItems } from './helpers/has-complex-array-items'\nimport { optimizeValueForDisplay } from './helpers/optimize-value-for-display'\nimport { shouldDisplayDescription } from './helpers/should-display-description'\nimport { shouldDisplayHeading } from './helpers/should-display-heading'\nimport Schema from './Schema.vue'\nimport SchemaComposition from './SchemaComposition.vue'\nimport SchemaEnums from './SchemaEnums.vue'\nimport SchemaPropertyHeading from './SchemaPropertyHeading.vue'\n\n/**\n * Note: We're taking in a prop called `value` which should be a JSON Schema.\n *\n * We're using `optimizeValueForDisplay` to merge null types in compositions (anyOf, allOf, oneOf, not).\n * So you should basically use the optimizedValue everywhere in the component.\n */\n\n/** Composition keywords that hold a list of schemas and can be flattened when they contain a single member. */\nconst SINGLE_ITEM_COMPOSITIONS = ['oneOf', 'anyOf', 'allOf'] as const\n\nconst props = withDefaults(\n defineProps<{\n is?: string | Component\n schema: SchemaObject | undefined\n noncollapsible?: boolean\n level?: number\n name?: string\n required?: boolean\n compact?: boolean\n discriminator?: DiscriminatorObject\n description?: string\n hideModelNames?: boolean\n hideHeading?: boolean\n /** When the root schema was resolved from a $ref, pass the ref name for display (e.g. \"Data\"). */\n modelName?: string | null\n variant?: 'additionalProperties' | 'patternProperties'\n breadcrumb?: string[]\n eventBus: WorkspaceEventBus | null\n options: SchemaOptions\n /** Enum values for property names (from JSON Schema propertyNames keyword). */\n propertyNamesEnum?: string[]\n /** Resolved propertyNames schema, used to show key constraints like `format`. */\n propertyNamesSchema?: SchemaObject\n /** When \"requestBody\", composition selection is synced with the example snippet */\n schemaContext?: string\n /** Internal path used to sync nested request body compositions with the code sample */\n compositionPath?: string[]\n /** Internal path segment for this property when building nested composition keys */\n compositionPathSegment?: string\n /** Stable identity of this property's schema, used for cycle detection. */\n cycleKey?: unknown\n }>(),\n {\n level: 0,\n required: false,\n compact: false,\n hideModelNames: false,\n },\n)\n\n/** The dynamic scope inherited from the enclosing schema resources, used to bind `$dynamicRef`s. */\nconst dynamicScope = useDynamicScope()\n\n/**\n * Simplified composition with `null` type.\n *\n * A top-level `$dynamicRef` (e.g. a linked-list `next` node) is bound to its concrete type via the\n * dynamic scope first; for ordinary schemas this is a no-op.\n */\nconst optimizedValue = computed(() =>\n optimizeValueForDisplay(resolveDynamicSchema(props.schema, dynamicScope)),\n)\n\nconst childBreadcrumb = computed<string[] | undefined>(() =>\n props.breadcrumb\n ? // A named property extends the breadcrumb with its own name. A nameless\n // container (e.g. a response object, rendered without a name to avoid a\n // duplicate heading) passes its breadcrumb straight through so its\n // properties stay linkable.\n props.name\n ? [...props.breadcrumb, props.name]\n : props.breadcrumb\n : undefined,\n)\n\nconst currentCompositionPath = computed<string[]>(() =>\n props.compositionPathSegment\n ? [...(props.compositionPath ?? []), props.compositionPathSegment]\n : (props.compositionPath ?? []),\n)\n\nconst arrayItemsCompositionPath = computed<string[]>(() => [\n ...currentCompositionPath.value,\n 'items',\n])\n\nconst shouldHaveLink = computed(() => props.level <= 2)\n\n/**\n * The array schema used for item inspection, with a `$dynamicRef` item bound to its concrete type.\n *\n * Returns the schema unchanged unless `items` is a `$dynamicRef` that resolves against the dynamic\n * scope, so ordinary arrays (including `$ref` items) keep their existing behavior exactly.\n */\nconst arrayValueWithBoundItems = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value) || !isDynamicRef(value.items)) {\n return value\n }\n\n const bound = resolveDynamicRef(value.items.$dynamicRef, dynamicScope)\n return bound ? ({ ...value, items: bound } as SchemaObject) : value\n})\n\n/** Checks if array items have complex structure */\nconst hasComplexArrayItemsComputed = computed(() =>\n hasComplexArrayItems(arrayValueWithBoundItems.value),\n)\n\n/** Check if enum should be displayed (from value schema or from propertyNames) */\nconst hasEnum = computed(() => enumValues.value.length > 0)\n\n/** Determine if object properties should be displayed */\nconst shouldRenderObjectProperties = computed(() => {\n const value = optimizedValue.value\n if (!value) {\n return false\n }\n\n if (!('properties' in value || 'additionalProperties' in value)) {\n return false\n }\n\n // `allOf` already merges the factored-out sibling `properties` into its\n // rendered result (see `mergeAllOfSchemas`), so rendering a separate object\n // block here would show those properties twice. Let the composition handle it.\n if ('allOf' in value) {\n return false\n }\n\n // A schema may factor its common `properties` out to the top level alongside\n // a composition keyword (anyOf/oneOf/not), as described in the JSON Schema\n // \"factoring schemas\" guide. `isTypeObject` deliberately rejects such schemas\n // so the composition is rendered, but the factored-out properties must still\n // show. Unlike `allOf`, these compositions do not merge sibling properties.\n // Render them unless the schema is an explicit non-object (scalar or array)\n // type. See https://github.com/scalar/scalar/issues/8593\n const type = (value as { type?: unknown }).type\n const isExplicitNonObject = typeof type === 'string' && type !== 'object'\n\n return isTypeObject(value) || !isExplicitNonObject\n})\n\n/** Determine if array of objects should be rendered */\nconst shouldRenderArrayOfObjects = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value) || typeof value.items !== 'object') {\n return false\n }\n\n return hasComplexArrayItemsComputed.value\n})\n\n/** Extract enum values from schema or array items */\nconst enumValues = computed(() => getEnumValues(optimizedValue.value))\n\n/** Generate property description from type/format */\nconst propertyDescription = computed(() =>\n getPropertyDescription(optimizedValue.value),\n)\n\n/** Determine if description should be displayed */\nconst displayDescription = computed(() =>\n shouldDisplayDescription(optimizedValue.value, props.description),\n)\n\n/**\n * The schema used to render the object's own properties.\n *\n * Composition keywords are stripped so the nested object renders only its\n * properties. The compositions are rendered separately below; leaving them here\n * would route the nested `Schema` back through `SchemaProperty` and recurse.\n *\n * The `discriminator` is stripped too: its variant selector is part of the\n * composition rendered below (including the one inferred from a bare\n * `discriminator.mapping`), so keeping it here would make the nested `Schema`\n * infer and render a second, identical selector.\n *\n * When the property already renders the description, we also drop it to avoid\n * repeating it in the nested object schema card.\n */\nconst objectSchemaForChildren = computed(() => {\n const value = optimizedValue.value\n if (!value) {\n return value\n }\n\n const {\n oneOf: _oneOf,\n anyOf: _anyOf,\n allOf: _allOf,\n not: _not,\n discriminator: _discriminator,\n ...objectSchema\n } = value as Record<string, unknown>\n\n if (displayDescription.value && 'description' in objectSchema) {\n const { description: _description, ...schemaWithoutDescription } =\n objectSchema\n return schemaWithoutDescription as SchemaObject\n }\n\n return objectSchema as SchemaObject\n})\n\n/** Determine if property heading should be displayed */\nconst shouldDisplayHeadingComputed = computed(() =>\n shouldDisplayHeading(optimizedValue.value, props.name, props.required),\n)\n\n/** Computes which compositions should be rendered and with which values */\nconst compositionsToRender = computed(() =>\n getCompositionsToRender(optimizedValue.value, props.options.document),\n)\n\n/**\n * Get resolved array items for rendering (with any `$dynamicRef` bound to the concrete type).\n *\n * When the items are wrapped in a single-item composition (e.g. `items: { allOf: [{ type: 'object', ... }] }`), we\n * flatten that wrapper into its plain form. A composition with a single member is equivalent to that member, so\n * keeping the composition keyword only makes the items render through an extra schema layer, which adds an\n * unnecessary level of nesting and duplicates the item description. See https://github.com/scalar/scalar/issues/5900\n */\nconst resolvedArrayItems = computed(() => {\n const value = arrayValueWithBoundItems.value\n if (!value || !isArraySchema(value) || typeof value.items !== 'object') {\n return undefined\n }\n\n const items = resolve.schema(value.items)\n const hasSingleItemComposition = SINGLE_ITEM_COMPOSITIONS.some(\n (keyword) =>\n Array.isArray(items?.[keyword]) && items[keyword]?.length === 1,\n )\n\n return hasSingleItemComposition ? optimizeValueForDisplay(items) : items\n})\n\n/**\n * Cycle key for the array items schema, derived from the raw (unresolved) items\n * so a self-referential array element is detected as a cycle.\n */\nconst arrayItemsCycleKey = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value)) {\n return undefined\n }\n return getCycleKey(value.items)\n})\n\n/** Check if discriminator matches current property */\nconst isDiscriminatorProperty = computed(() =>\n Boolean(props.name && props.discriminator?.propertyName === props.name),\n)\n</script>\n<template>\n <component\n :is=\"is ?? 'li'\"\n class=\"property\"\n :class=\"[\n `property--level-${level}`,\n {\n 'property--compact': compact,\n 'property--deprecated': optimizedValue?.deprecated,\n },\n ]\">\n <SchemaPropertyHeading\n v-if=\"shouldDisplayHeadingComputed\"\n class=\"group\"\n :enum=\"hasEnum\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :isDiscriminator=\"isDiscriminatorProperty\"\n :modelName=\"modelName\"\n :propertyNames=\"propertyNamesSchema\"\n :required\n :value=\"optimizedValue\">\n <template\n v-if=\"name\"\n #name>\n <WithBreadcrumb\n :breadcrumb=\"shouldHaveLink ? childBreadcrumb : undefined\"\n :eventBus=\"eventBus\">\n <span\n v-if=\"variant === 'patternProperties'\"\n class=\"property-name-pattern-properties\">\n <ScalarWrappingText\n preset=\"property\"\n :text=\"name\" />\n </span>\n <span\n v-else-if=\"variant === 'additionalProperties'\"\n class=\"property-name-additional-properties\">\n <ScalarWrappingText\n preset=\"property\"\n :text=\"name\" />\n </span>\n <ScalarWrappingText\n v-else\n preset=\"property\"\n :text=\"name\" />\n </WithBreadcrumb>\n </template>\n <template\n v-if=\"optimizedValue?.example !== undefined\"\n #example>\n Example:\n {{ optimizedValue.example }}\n </template>\n </SchemaPropertyHeading>\n\n <!-- Description -->\n <div\n v-if=\"displayDescription || propertyDescription\"\n class=\"property-description\">\n <ScalarMarkdown\n :value=\"displayDescription || propertyDescription || ''\" />\n </div>\n\n <!-- Enum for property names -->\n <SchemaEnums\n v-if=\"propertyNamesEnum && propertyNamesEnum.length > 0\"\n propertyNames\n :value=\"{ enum: propertyNamesEnum } as SchemaObject\" />\n\n <!-- Enum values -->\n <SchemaEnums\n v-if=\"enumValues.length > 0\"\n :value=\"optimizedValue\" />\n\n <!-- Object -->\n <div\n v-if=\"shouldRenderObjectProperties\"\n class=\"children\">\n <Schema\n :breadcrumb=\"childBreadcrumb\"\n :compact=\"compact\"\n :compositionPath=\"currentCompositionPath\"\n :cycleKey=\"cycleKey\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :level=\"level + 1\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"objectSchemaForChildren\"\n :schemaContext=\"schemaContext\" />\n </div>\n\n <!-- Array of objects or nested arrays -->\n <div\n v-if=\"shouldRenderArrayOfObjects && resolvedArrayItems\"\n class=\"children\">\n <Schema\n :compact=\"compact\"\n :compositionPath=\"arrayItemsCompositionPath\"\n :cycleKey=\"arrayItemsCycleKey\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :level=\"level + 1\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"resolve.schema(resolvedArrayItems)\"\n :schemaContext=\"schemaContext\" />\n </div>\n\n <!-- Compositions -->\n <SchemaComposition\n v-for=\"compositionData in compositionsToRender\"\n :key=\"compositionData.composition\"\n :breadcrumb=\"breadcrumb\"\n :compact=\"compact\"\n :composition=\"compositionData.composition\"\n :compositionPath=\"currentCompositionPath\"\n :discriminator=\"schema?.discriminator\"\n :eventBus=\"eventBus\"\n :hideHeading=\"hideHeading\"\n :hideModelNames\n :level=\"level\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"compositionData.value\"\n :schemaContext=\"schemaContext\" />\n <SpecificationExtension :value=\"optimizedValue\" />\n </component>\n</template>\n\n<style scoped>\n.property {\n color: var(--scalar-color-1);\n display: flex;\n flex-direction: column;\n padding: 10px;\n font-size: var(--scalar-small);\n position: relative;\n}\n\n/** Remove top padding for top level schema card */\n.property.property--level-0:has(\n > .property-rule\n > .schema-card\n > .schema-properties.schema-properties-open\n > ul\n > li.property\n ) {\n padding-top: 0;\n}\n\n.property--compact.property--level-0,\n.property--compact.property--level-1 {\n padding: 10px 0;\n}\n\n.composition-panel .property.property.property.property--level-0 {\n padding: 0px;\n}\n\n.property--compact.property--level-0\n .composition-panel\n .property--compact.property--level-1 {\n padding: 8px;\n}\n\n/* if a property doesn't have a heading, remove the top padding */\n.property:has(> .property-rule:nth-of-type(1)):not(.property--compact) {\n padding-top: 8px;\n padding-bottom: 8px;\n}\n\n.property--deprecated {\n background: repeating-linear-gradient(\n -45deg,\n var(--scalar-background-2) 0,\n var(--scalar-background-2) 2px,\n transparent 2px,\n transparent 5px\n );\n background-size: 100%;\n}\n\n.property--deprecated > * {\n opacity: 0.75;\n}\n\n.property-description {\n margin-top: 6px;\n line-height: 1.4;\n font-size: var(--scalar-small);\n}\n\n.property-description:has(+ .property-rule) {\n margin-bottom: 9px;\n}\n\n:deep(.property-description) * {\n color: var(--scalar-color-2) !important;\n}\n\n.property:not(:last-of-type) {\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n\n.property-description + .children,\n.children + .property-rule {\n margin-top: 9px;\n}\n\n.children {\n display: flex;\n flex-direction: column;\n}\n\n.children .property--compact.property--level-1 {\n padding: 12px;\n}\n\n.property-example-value {\n all: unset;\n font-family: var(--scalar-font-code);\n padding: 6px;\n border-top: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n\n.property-rule {\n border-radius: var(--scalar-radius-lg);\n display: flex;\n flex-direction: column;\n}\n\n.property--level-2 :deep(.relative > button) {\n left: -2rem;\n}\n\n.property-rule\n :deep(\n .composition-panel\n .schema-card--level-1\n > .schema-properties.schema-properties-open\n ) {\n border-radius: 0 0 var(--scalar-radius-lg) var(--scalar-radius-lg);\n}\n\n.property-rule\n :deep(.composition-panel > .schema-card > .schema-card-description) {\n padding: 10px;\n border-left: var(--scalar-border-width) solid var(--scalar-border-color);\n border-right: var(--scalar-border-width) solid var(--scalar-border-color);\n\n & + .schema-properties {\n margin-top: 0;\n }\n}\n\n.property-example {\n background: transparent;\n border: none;\n display: flex;\n flex-direction: row;\n gap: 8px;\n}\n\n.property-example-label,\n.property-example-value {\n padding: 3px 0 0 0;\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border-top: 0;\n border-radius: var(--scalar-radius);\n padding: 3px 4px;\n}\n\n.property-name {\n font-family: var(--scalar-font-code);\n font-weight: var(--scalar-semibold);\n}\n\n.property-name-additional-properties::before,\n.property-name-pattern-properties::before {\n text-transform: uppercase;\n font-size: var(--scalar-micro);\n display: inline-block;\n padding: 2px 4px;\n border-radius: var(--scalar-radius);\n color: var(--scalar-color-1);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n background-color: var(--scalar-background-2);\n margin-right: 4px;\n}\n\n.property-name-pattern-properties::before {\n content: 'regex';\n}\n\n.property-name-additional-properties,\n.property-name-pattern-properties {\n border: 1px dashed var(--scalar-border-color);\n color: var(--scalar-color-accent);\n display: inline-block;\n padding: 2px;\n border-radius: var(--scalar-radius);\n}\n</style>\n"],"mappings":""}
|
|
@@ -99,7 +99,7 @@ var SchemaProperty_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
99
99
|
* dynamic scope first; for ordinary schemas this is a no-op.
|
|
100
100
|
*/
|
|
101
101
|
const optimizedValue = computed(() => optimizeValueForDisplay(resolveDynamicSchema(props.schema, dynamicScope)));
|
|
102
|
-
const childBreadcrumb = computed(() => props.breadcrumb
|
|
102
|
+
const childBreadcrumb = computed(() => props.breadcrumb ? props.name ? [...props.breadcrumb, props.name] : props.breadcrumb : void 0);
|
|
103
103
|
const currentCompositionPath = computed(() => props.compositionPathSegment ? [...props.compositionPath ?? [], props.compositionPathSegment] : props.compositionPath ?? []);
|
|
104
104
|
const arrayItemsCompositionPath = computed(() => [...currentCompositionPath.value, "items"]);
|
|
105
105
|
const shouldHaveLink = computed(() => props.level <= 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaProperty.vue.script.js","names":[],"sources":["../../../../src/components/Content/Schema/SchemaProperty.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { ScalarMarkdown } from '@scalar/components/markdown'\nimport { ScalarWrappingText } from '@scalar/components/wrapping-text'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport {\n isDynamicRef,\n resolveDynamicRef,\n} from '@scalar/workspace-store/helpers/dynamic-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards'\nimport { computed, type Component } from 'vue'\n\nimport { WithBreadcrumb } from '@/components/Anchor'\nimport {\n resolveDynamicSchema,\n useDynamicScope,\n} from '@/components/Content/Schema/helpers/dynamic-scope'\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { getCycleKey } from '@/components/Content/Schema/helpers/schema-cycle'\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\nimport { SpecificationExtension } from '@/features/specification-extension'\n\nimport { getCompositionsToRender } from './helpers/get-compositions-to-render'\nimport { getEnumValues } from './helpers/get-enum-values'\nimport { getPropertyDescription } from './helpers/get-property-description'\nimport { hasComplexArrayItems } from './helpers/has-complex-array-items'\nimport { optimizeValueForDisplay } from './helpers/optimize-value-for-display'\nimport { shouldDisplayDescription } from './helpers/should-display-description'\nimport { shouldDisplayHeading } from './helpers/should-display-heading'\nimport Schema from './Schema.vue'\nimport SchemaComposition from './SchemaComposition.vue'\nimport SchemaEnums from './SchemaEnums.vue'\nimport SchemaPropertyHeading from './SchemaPropertyHeading.vue'\n\n/**\n * Note: We're taking in a prop called `value` which should be a JSON Schema.\n *\n * We're using `optimizeValueForDisplay` to merge null types in compositions (anyOf, allOf, oneOf, not).\n * So you should basically use the optimizedValue everywhere in the component.\n */\n\n/** Composition keywords that hold a list of schemas and can be flattened when they contain a single member. */\nconst SINGLE_ITEM_COMPOSITIONS = ['oneOf', 'anyOf', 'allOf'] as const\n\nconst props = withDefaults(\n defineProps<{\n is?: string | Component\n schema: SchemaObject | undefined\n noncollapsible?: boolean\n level?: number\n name?: string\n required?: boolean\n compact?: boolean\n discriminator?: DiscriminatorObject\n description?: string\n hideModelNames?: boolean\n hideHeading?: boolean\n /** When the root schema was resolved from a $ref, pass the ref name for display (e.g. \"Data\"). */\n modelName?: string | null\n variant?: 'additionalProperties' | 'patternProperties'\n breadcrumb?: string[]\n eventBus: WorkspaceEventBus | null\n options: SchemaOptions\n /** Enum values for property names (from JSON Schema propertyNames keyword). */\n propertyNamesEnum?: string[]\n /** Resolved propertyNames schema, used to show key constraints like `format`. */\n propertyNamesSchema?: SchemaObject\n /** When \"requestBody\", composition selection is synced with the example snippet */\n schemaContext?: string\n /** Internal path used to sync nested request body compositions with the code sample */\n compositionPath?: string[]\n /** Internal path segment for this property when building nested composition keys */\n compositionPathSegment?: string\n /** Stable identity of this property's schema, used for cycle detection. */\n cycleKey?: unknown\n }>(),\n {\n level: 0,\n required: false,\n compact: false,\n hideModelNames: false,\n },\n)\n\n/** The dynamic scope inherited from the enclosing schema resources, used to bind `$dynamicRef`s. */\nconst dynamicScope = useDynamicScope()\n\n/**\n * Simplified composition with `null` type.\n *\n * A top-level `$dynamicRef` (e.g. a linked-list `next` node) is bound to its concrete type via the\n * dynamic scope first; for ordinary schemas this is a no-op.\n */\nconst optimizedValue = computed(() =>\n optimizeValueForDisplay(resolveDynamicSchema(props.schema, dynamicScope)),\n)\n\nconst childBreadcrumb = computed<string[] | undefined>(() =>\n props.breadcrumb && props.name\n ? [...props.breadcrumb, props.name]\n : undefined,\n)\n\nconst currentCompositionPath = computed<string[]>(() =>\n props.compositionPathSegment\n ? [...(props.compositionPath ?? []), props.compositionPathSegment]\n : (props.compositionPath ?? []),\n)\n\nconst arrayItemsCompositionPath = computed<string[]>(() => [\n ...currentCompositionPath.value,\n 'items',\n])\n\nconst shouldHaveLink = computed(() => props.level <= 2)\n\n/**\n * The array schema used for item inspection, with a `$dynamicRef` item bound to its concrete type.\n *\n * Returns the schema unchanged unless `items` is a `$dynamicRef` that resolves against the dynamic\n * scope, so ordinary arrays (including `$ref` items) keep their existing behavior exactly.\n */\nconst arrayValueWithBoundItems = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value) || !isDynamicRef(value.items)) {\n return value\n }\n\n const bound = resolveDynamicRef(value.items.$dynamicRef, dynamicScope)\n return bound ? ({ ...value, items: bound } as SchemaObject) : value\n})\n\n/** Checks if array items have complex structure */\nconst hasComplexArrayItemsComputed = computed(() =>\n hasComplexArrayItems(arrayValueWithBoundItems.value),\n)\n\n/** Check if enum should be displayed (from value schema or from propertyNames) */\nconst hasEnum = computed(() => enumValues.value.length > 0)\n\n/** Determine if object properties should be displayed */\nconst shouldRenderObjectProperties = computed(() => {\n const value = optimizedValue.value\n if (!value) {\n return false\n }\n\n if (!('properties' in value || 'additionalProperties' in value)) {\n return false\n }\n\n // `allOf` already merges the factored-out sibling `properties` into its\n // rendered result (see `mergeAllOfSchemas`), so rendering a separate object\n // block here would show those properties twice. Let the composition handle it.\n if ('allOf' in value) {\n return false\n }\n\n // A schema may factor its common `properties` out to the top level alongside\n // a composition keyword (anyOf/oneOf/not), as described in the JSON Schema\n // \"factoring schemas\" guide. `isTypeObject` deliberately rejects such schemas\n // so the composition is rendered, but the factored-out properties must still\n // show. Unlike `allOf`, these compositions do not merge sibling properties.\n // Render them unless the schema is an explicit non-object (scalar or array)\n // type. See https://github.com/scalar/scalar/issues/8593\n const type = (value as { type?: unknown }).type\n const isExplicitNonObject = typeof type === 'string' && type !== 'object'\n\n return isTypeObject(value) || !isExplicitNonObject\n})\n\n/** Determine if array of objects should be rendered */\nconst shouldRenderArrayOfObjects = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value) || typeof value.items !== 'object') {\n return false\n }\n\n return hasComplexArrayItemsComputed.value\n})\n\n/** Extract enum values from schema or array items */\nconst enumValues = computed(() => getEnumValues(optimizedValue.value))\n\n/** Generate property description from type/format */\nconst propertyDescription = computed(() =>\n getPropertyDescription(optimizedValue.value),\n)\n\n/** Determine if description should be displayed */\nconst displayDescription = computed(() =>\n shouldDisplayDescription(optimizedValue.value, props.description),\n)\n\n/**\n * The schema used to render the object's own properties.\n *\n * Composition keywords are stripped so the nested object renders only its\n * properties. The compositions are rendered separately below; leaving them here\n * would route the nested `Schema` back through `SchemaProperty` and recurse.\n *\n * The `discriminator` is stripped too: its variant selector is part of the\n * composition rendered below (including the one inferred from a bare\n * `discriminator.mapping`), so keeping it here would make the nested `Schema`\n * infer and render a second, identical selector.\n *\n * When the property already renders the description, we also drop it to avoid\n * repeating it in the nested object schema card.\n */\nconst objectSchemaForChildren = computed(() => {\n const value = optimizedValue.value\n if (!value) {\n return value\n }\n\n const {\n oneOf: _oneOf,\n anyOf: _anyOf,\n allOf: _allOf,\n not: _not,\n discriminator: _discriminator,\n ...objectSchema\n } = value as Record<string, unknown>\n\n if (displayDescription.value && 'description' in objectSchema) {\n const { description: _description, ...schemaWithoutDescription } =\n objectSchema\n return schemaWithoutDescription as SchemaObject\n }\n\n return objectSchema as SchemaObject\n})\n\n/** Determine if property heading should be displayed */\nconst shouldDisplayHeadingComputed = computed(() =>\n shouldDisplayHeading(optimizedValue.value, props.name, props.required),\n)\n\n/** Computes which compositions should be rendered and with which values */\nconst compositionsToRender = computed(() =>\n getCompositionsToRender(optimizedValue.value, props.options.document),\n)\n\n/**\n * Get resolved array items for rendering (with any `$dynamicRef` bound to the concrete type).\n *\n * When the items are wrapped in a single-item composition (e.g. `items: { allOf: [{ type: 'object', ... }] }`), we\n * flatten that wrapper into its plain form. A composition with a single member is equivalent to that member, so\n * keeping the composition keyword only makes the items render through an extra schema layer, which adds an\n * unnecessary level of nesting and duplicates the item description. See https://github.com/scalar/scalar/issues/5900\n */\nconst resolvedArrayItems = computed(() => {\n const value = arrayValueWithBoundItems.value\n if (!value || !isArraySchema(value) || typeof value.items !== 'object') {\n return undefined\n }\n\n const items = resolve.schema(value.items)\n const hasSingleItemComposition = SINGLE_ITEM_COMPOSITIONS.some(\n (keyword) =>\n Array.isArray(items?.[keyword]) && items[keyword]?.length === 1,\n )\n\n return hasSingleItemComposition ? optimizeValueForDisplay(items) : items\n})\n\n/**\n * Cycle key for the array items schema, derived from the raw (unresolved) items\n * so a self-referential array element is detected as a cycle.\n */\nconst arrayItemsCycleKey = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value)) {\n return undefined\n }\n return getCycleKey(value.items)\n})\n\n/** Check if discriminator matches current property */\nconst isDiscriminatorProperty = computed(() =>\n Boolean(props.name && props.discriminator?.propertyName === props.name),\n)\n</script>\n<template>\n <component\n :is=\"is ?? 'li'\"\n class=\"property\"\n :class=\"[\n `property--level-${level}`,\n {\n 'property--compact': compact,\n 'property--deprecated': optimizedValue?.deprecated,\n },\n ]\">\n <SchemaPropertyHeading\n v-if=\"shouldDisplayHeadingComputed\"\n class=\"group\"\n :enum=\"hasEnum\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :isDiscriminator=\"isDiscriminatorProperty\"\n :modelName=\"modelName\"\n :propertyNames=\"propertyNamesSchema\"\n :required\n :value=\"optimizedValue\">\n <template\n v-if=\"name\"\n #name>\n <WithBreadcrumb\n :breadcrumb=\"shouldHaveLink ? childBreadcrumb : undefined\"\n :eventBus=\"eventBus\">\n <span\n v-if=\"variant === 'patternProperties'\"\n class=\"property-name-pattern-properties\">\n <ScalarWrappingText\n preset=\"property\"\n :text=\"name\" />\n </span>\n <span\n v-else-if=\"variant === 'additionalProperties'\"\n class=\"property-name-additional-properties\">\n <ScalarWrappingText\n preset=\"property\"\n :text=\"name\" />\n </span>\n <ScalarWrappingText\n v-else\n preset=\"property\"\n :text=\"name\" />\n </WithBreadcrumb>\n </template>\n <template\n v-if=\"optimizedValue?.example !== undefined\"\n #example>\n Example:\n {{ optimizedValue.example }}\n </template>\n </SchemaPropertyHeading>\n\n <!-- Description -->\n <div\n v-if=\"displayDescription || propertyDescription\"\n class=\"property-description\">\n <ScalarMarkdown\n :value=\"displayDescription || propertyDescription || ''\" />\n </div>\n\n <!-- Enum for property names -->\n <SchemaEnums\n v-if=\"propertyNamesEnum && propertyNamesEnum.length > 0\"\n propertyNames\n :value=\"{ enum: propertyNamesEnum } as SchemaObject\" />\n\n <!-- Enum values -->\n <SchemaEnums\n v-if=\"enumValues.length > 0\"\n :value=\"optimizedValue\" />\n\n <!-- Object -->\n <div\n v-if=\"shouldRenderObjectProperties\"\n class=\"children\">\n <Schema\n :breadcrumb=\"childBreadcrumb\"\n :compact=\"compact\"\n :compositionPath=\"currentCompositionPath\"\n :cycleKey=\"cycleKey\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :level=\"level + 1\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"objectSchemaForChildren\"\n :schemaContext=\"schemaContext\" />\n </div>\n\n <!-- Array of objects or nested arrays -->\n <div\n v-if=\"shouldRenderArrayOfObjects && resolvedArrayItems\"\n class=\"children\">\n <Schema\n :compact=\"compact\"\n :compositionPath=\"arrayItemsCompositionPath\"\n :cycleKey=\"arrayItemsCycleKey\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :level=\"level + 1\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"resolve.schema(resolvedArrayItems)\"\n :schemaContext=\"schemaContext\" />\n </div>\n\n <!-- Compositions -->\n <SchemaComposition\n v-for=\"compositionData in compositionsToRender\"\n :key=\"compositionData.composition\"\n :breadcrumb=\"breadcrumb\"\n :compact=\"compact\"\n :composition=\"compositionData.composition\"\n :compositionPath=\"currentCompositionPath\"\n :discriminator=\"schema?.discriminator\"\n :eventBus=\"eventBus\"\n :hideHeading=\"hideHeading\"\n :hideModelNames\n :level=\"level\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"compositionData.value\"\n :schemaContext=\"schemaContext\" />\n <SpecificationExtension :value=\"optimizedValue\" />\n </component>\n</template>\n\n<style scoped>\n.property {\n color: var(--scalar-color-1);\n display: flex;\n flex-direction: column;\n padding: 10px;\n font-size: var(--scalar-small);\n position: relative;\n}\n\n/** Remove top padding for top level schema card */\n.property.property--level-0:has(\n > .property-rule\n > .schema-card\n > .schema-properties.schema-properties-open\n > ul\n > li.property\n ) {\n padding-top: 0;\n}\n\n.property--compact.property--level-0,\n.property--compact.property--level-1 {\n padding: 10px 0;\n}\n\n.composition-panel .property.property.property.property--level-0 {\n padding: 0px;\n}\n\n.property--compact.property--level-0\n .composition-panel\n .property--compact.property--level-1 {\n padding: 8px;\n}\n\n/* if a property doesn't have a heading, remove the top padding */\n.property:has(> .property-rule:nth-of-type(1)):not(.property--compact) {\n padding-top: 8px;\n padding-bottom: 8px;\n}\n\n.property--deprecated {\n background: repeating-linear-gradient(\n -45deg,\n var(--scalar-background-2) 0,\n var(--scalar-background-2) 2px,\n transparent 2px,\n transparent 5px\n );\n background-size: 100%;\n}\n\n.property--deprecated > * {\n opacity: 0.75;\n}\n\n.property-description {\n margin-top: 6px;\n line-height: 1.4;\n font-size: var(--scalar-small);\n}\n\n.property-description:has(+ .property-rule) {\n margin-bottom: 9px;\n}\n\n:deep(.property-description) * {\n color: var(--scalar-color-2) !important;\n}\n\n.property:not(:last-of-type) {\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n\n.property-description + .children,\n.children + .property-rule {\n margin-top: 9px;\n}\n\n.children {\n display: flex;\n flex-direction: column;\n}\n\n.children .property--compact.property--level-1 {\n padding: 12px;\n}\n\n.property-example-value {\n all: unset;\n font-family: var(--scalar-font-code);\n padding: 6px;\n border-top: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n\n.property-rule {\n border-radius: var(--scalar-radius-lg);\n display: flex;\n flex-direction: column;\n}\n\n.property--level-2 :deep(.relative > button) {\n left: -2rem;\n}\n\n.property-rule\n :deep(\n .composition-panel\n .schema-card--level-1\n > .schema-properties.schema-properties-open\n ) {\n border-radius: 0 0 var(--scalar-radius-lg) var(--scalar-radius-lg);\n}\n\n.property-rule\n :deep(.composition-panel > .schema-card > .schema-card-description) {\n padding: 10px;\n border-left: var(--scalar-border-width) solid var(--scalar-border-color);\n border-right: var(--scalar-border-width) solid var(--scalar-border-color);\n\n & + .schema-properties {\n margin-top: 0;\n }\n}\n\n.property-example {\n background: transparent;\n border: none;\n display: flex;\n flex-direction: row;\n gap: 8px;\n}\n\n.property-example-label,\n.property-example-value {\n padding: 3px 0 0 0;\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border-top: 0;\n border-radius: var(--scalar-radius);\n padding: 3px 4px;\n}\n\n.property-name {\n font-family: var(--scalar-font-code);\n font-weight: var(--scalar-semibold);\n}\n\n.property-name-additional-properties::before,\n.property-name-pattern-properties::before {\n text-transform: uppercase;\n font-size: var(--scalar-micro);\n display: inline-block;\n padding: 2px 4px;\n border-radius: var(--scalar-radius);\n color: var(--scalar-color-1);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n background-color: var(--scalar-background-2);\n margin-right: 4px;\n}\n\n.property-name-pattern-properties::before {\n content: 'regex';\n}\n\n.property-name-additional-properties,\n.property-name-pattern-properties {\n border: 1px dashed var(--scalar-border-color);\n color: var(--scalar-color-accent);\n display: inline-block;\n padding: 2px;\n border-radius: var(--scalar-radius);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;KAClB,YAAkD,MAAA,+BAAA,EAAA,EAAzB,OAAO,eAAA,OAAc,EAAA,MAAA,GAAA,CAAA,QAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"SchemaProperty.vue.script.js","names":[],"sources":["../../../../src/components/Content/Schema/SchemaProperty.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { ScalarMarkdown } from '@scalar/components/markdown'\nimport { ScalarWrappingText } from '@scalar/components/wrapping-text'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport {\n isDynamicRef,\n resolveDynamicRef,\n} from '@scalar/workspace-store/helpers/dynamic-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards'\nimport { computed, type Component } from 'vue'\n\nimport { WithBreadcrumb } from '@/components/Anchor'\nimport {\n resolveDynamicSchema,\n useDynamicScope,\n} from '@/components/Content/Schema/helpers/dynamic-scope'\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { getCycleKey } from '@/components/Content/Schema/helpers/schema-cycle'\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\nimport { SpecificationExtension } from '@/features/specification-extension'\n\nimport { getCompositionsToRender } from './helpers/get-compositions-to-render'\nimport { getEnumValues } from './helpers/get-enum-values'\nimport { getPropertyDescription } from './helpers/get-property-description'\nimport { hasComplexArrayItems } from './helpers/has-complex-array-items'\nimport { optimizeValueForDisplay } from './helpers/optimize-value-for-display'\nimport { shouldDisplayDescription } from './helpers/should-display-description'\nimport { shouldDisplayHeading } from './helpers/should-display-heading'\nimport Schema from './Schema.vue'\nimport SchemaComposition from './SchemaComposition.vue'\nimport SchemaEnums from './SchemaEnums.vue'\nimport SchemaPropertyHeading from './SchemaPropertyHeading.vue'\n\n/**\n * Note: We're taking in a prop called `value` which should be a JSON Schema.\n *\n * We're using `optimizeValueForDisplay` to merge null types in compositions (anyOf, allOf, oneOf, not).\n * So you should basically use the optimizedValue everywhere in the component.\n */\n\n/** Composition keywords that hold a list of schemas and can be flattened when they contain a single member. */\nconst SINGLE_ITEM_COMPOSITIONS = ['oneOf', 'anyOf', 'allOf'] as const\n\nconst props = withDefaults(\n defineProps<{\n is?: string | Component\n schema: SchemaObject | undefined\n noncollapsible?: boolean\n level?: number\n name?: string\n required?: boolean\n compact?: boolean\n discriminator?: DiscriminatorObject\n description?: string\n hideModelNames?: boolean\n hideHeading?: boolean\n /** When the root schema was resolved from a $ref, pass the ref name for display (e.g. \"Data\"). */\n modelName?: string | null\n variant?: 'additionalProperties' | 'patternProperties'\n breadcrumb?: string[]\n eventBus: WorkspaceEventBus | null\n options: SchemaOptions\n /** Enum values for property names (from JSON Schema propertyNames keyword). */\n propertyNamesEnum?: string[]\n /** Resolved propertyNames schema, used to show key constraints like `format`. */\n propertyNamesSchema?: SchemaObject\n /** When \"requestBody\", composition selection is synced with the example snippet */\n schemaContext?: string\n /** Internal path used to sync nested request body compositions with the code sample */\n compositionPath?: string[]\n /** Internal path segment for this property when building nested composition keys */\n compositionPathSegment?: string\n /** Stable identity of this property's schema, used for cycle detection. */\n cycleKey?: unknown\n }>(),\n {\n level: 0,\n required: false,\n compact: false,\n hideModelNames: false,\n },\n)\n\n/** The dynamic scope inherited from the enclosing schema resources, used to bind `$dynamicRef`s. */\nconst dynamicScope = useDynamicScope()\n\n/**\n * Simplified composition with `null` type.\n *\n * A top-level `$dynamicRef` (e.g. a linked-list `next` node) is bound to its concrete type via the\n * dynamic scope first; for ordinary schemas this is a no-op.\n */\nconst optimizedValue = computed(() =>\n optimizeValueForDisplay(resolveDynamicSchema(props.schema, dynamicScope)),\n)\n\nconst childBreadcrumb = computed<string[] | undefined>(() =>\n props.breadcrumb\n ? // A named property extends the breadcrumb with its own name. A nameless\n // container (e.g. a response object, rendered without a name to avoid a\n // duplicate heading) passes its breadcrumb straight through so its\n // properties stay linkable.\n props.name\n ? [...props.breadcrumb, props.name]\n : props.breadcrumb\n : undefined,\n)\n\nconst currentCompositionPath = computed<string[]>(() =>\n props.compositionPathSegment\n ? [...(props.compositionPath ?? []), props.compositionPathSegment]\n : (props.compositionPath ?? []),\n)\n\nconst arrayItemsCompositionPath = computed<string[]>(() => [\n ...currentCompositionPath.value,\n 'items',\n])\n\nconst shouldHaveLink = computed(() => props.level <= 2)\n\n/**\n * The array schema used for item inspection, with a `$dynamicRef` item bound to its concrete type.\n *\n * Returns the schema unchanged unless `items` is a `$dynamicRef` that resolves against the dynamic\n * scope, so ordinary arrays (including `$ref` items) keep their existing behavior exactly.\n */\nconst arrayValueWithBoundItems = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value) || !isDynamicRef(value.items)) {\n return value\n }\n\n const bound = resolveDynamicRef(value.items.$dynamicRef, dynamicScope)\n return bound ? ({ ...value, items: bound } as SchemaObject) : value\n})\n\n/** Checks if array items have complex structure */\nconst hasComplexArrayItemsComputed = computed(() =>\n hasComplexArrayItems(arrayValueWithBoundItems.value),\n)\n\n/** Check if enum should be displayed (from value schema or from propertyNames) */\nconst hasEnum = computed(() => enumValues.value.length > 0)\n\n/** Determine if object properties should be displayed */\nconst shouldRenderObjectProperties = computed(() => {\n const value = optimizedValue.value\n if (!value) {\n return false\n }\n\n if (!('properties' in value || 'additionalProperties' in value)) {\n return false\n }\n\n // `allOf` already merges the factored-out sibling `properties` into its\n // rendered result (see `mergeAllOfSchemas`), so rendering a separate object\n // block here would show those properties twice. Let the composition handle it.\n if ('allOf' in value) {\n return false\n }\n\n // A schema may factor its common `properties` out to the top level alongside\n // a composition keyword (anyOf/oneOf/not), as described in the JSON Schema\n // \"factoring schemas\" guide. `isTypeObject` deliberately rejects such schemas\n // so the composition is rendered, but the factored-out properties must still\n // show. Unlike `allOf`, these compositions do not merge sibling properties.\n // Render them unless the schema is an explicit non-object (scalar or array)\n // type. See https://github.com/scalar/scalar/issues/8593\n const type = (value as { type?: unknown }).type\n const isExplicitNonObject = typeof type === 'string' && type !== 'object'\n\n return isTypeObject(value) || !isExplicitNonObject\n})\n\n/** Determine if array of objects should be rendered */\nconst shouldRenderArrayOfObjects = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value) || typeof value.items !== 'object') {\n return false\n }\n\n return hasComplexArrayItemsComputed.value\n})\n\n/** Extract enum values from schema or array items */\nconst enumValues = computed(() => getEnumValues(optimizedValue.value))\n\n/** Generate property description from type/format */\nconst propertyDescription = computed(() =>\n getPropertyDescription(optimizedValue.value),\n)\n\n/** Determine if description should be displayed */\nconst displayDescription = computed(() =>\n shouldDisplayDescription(optimizedValue.value, props.description),\n)\n\n/**\n * The schema used to render the object's own properties.\n *\n * Composition keywords are stripped so the nested object renders only its\n * properties. The compositions are rendered separately below; leaving them here\n * would route the nested `Schema` back through `SchemaProperty` and recurse.\n *\n * The `discriminator` is stripped too: its variant selector is part of the\n * composition rendered below (including the one inferred from a bare\n * `discriminator.mapping`), so keeping it here would make the nested `Schema`\n * infer and render a second, identical selector.\n *\n * When the property already renders the description, we also drop it to avoid\n * repeating it in the nested object schema card.\n */\nconst objectSchemaForChildren = computed(() => {\n const value = optimizedValue.value\n if (!value) {\n return value\n }\n\n const {\n oneOf: _oneOf,\n anyOf: _anyOf,\n allOf: _allOf,\n not: _not,\n discriminator: _discriminator,\n ...objectSchema\n } = value as Record<string, unknown>\n\n if (displayDescription.value && 'description' in objectSchema) {\n const { description: _description, ...schemaWithoutDescription } =\n objectSchema\n return schemaWithoutDescription as SchemaObject\n }\n\n return objectSchema as SchemaObject\n})\n\n/** Determine if property heading should be displayed */\nconst shouldDisplayHeadingComputed = computed(() =>\n shouldDisplayHeading(optimizedValue.value, props.name, props.required),\n)\n\n/** Computes which compositions should be rendered and with which values */\nconst compositionsToRender = computed(() =>\n getCompositionsToRender(optimizedValue.value, props.options.document),\n)\n\n/**\n * Get resolved array items for rendering (with any `$dynamicRef` bound to the concrete type).\n *\n * When the items are wrapped in a single-item composition (e.g. `items: { allOf: [{ type: 'object', ... }] }`), we\n * flatten that wrapper into its plain form. A composition with a single member is equivalent to that member, so\n * keeping the composition keyword only makes the items render through an extra schema layer, which adds an\n * unnecessary level of nesting and duplicates the item description. See https://github.com/scalar/scalar/issues/5900\n */\nconst resolvedArrayItems = computed(() => {\n const value = arrayValueWithBoundItems.value\n if (!value || !isArraySchema(value) || typeof value.items !== 'object') {\n return undefined\n }\n\n const items = resolve.schema(value.items)\n const hasSingleItemComposition = SINGLE_ITEM_COMPOSITIONS.some(\n (keyword) =>\n Array.isArray(items?.[keyword]) && items[keyword]?.length === 1,\n )\n\n return hasSingleItemComposition ? optimizeValueForDisplay(items) : items\n})\n\n/**\n * Cycle key for the array items schema, derived from the raw (unresolved) items\n * so a self-referential array element is detected as a cycle.\n */\nconst arrayItemsCycleKey = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value)) {\n return undefined\n }\n return getCycleKey(value.items)\n})\n\n/** Check if discriminator matches current property */\nconst isDiscriminatorProperty = computed(() =>\n Boolean(props.name && props.discriminator?.propertyName === props.name),\n)\n</script>\n<template>\n <component\n :is=\"is ?? 'li'\"\n class=\"property\"\n :class=\"[\n `property--level-${level}`,\n {\n 'property--compact': compact,\n 'property--deprecated': optimizedValue?.deprecated,\n },\n ]\">\n <SchemaPropertyHeading\n v-if=\"shouldDisplayHeadingComputed\"\n class=\"group\"\n :enum=\"hasEnum\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :isDiscriminator=\"isDiscriminatorProperty\"\n :modelName=\"modelName\"\n :propertyNames=\"propertyNamesSchema\"\n :required\n :value=\"optimizedValue\">\n <template\n v-if=\"name\"\n #name>\n <WithBreadcrumb\n :breadcrumb=\"shouldHaveLink ? childBreadcrumb : undefined\"\n :eventBus=\"eventBus\">\n <span\n v-if=\"variant === 'patternProperties'\"\n class=\"property-name-pattern-properties\">\n <ScalarWrappingText\n preset=\"property\"\n :text=\"name\" />\n </span>\n <span\n v-else-if=\"variant === 'additionalProperties'\"\n class=\"property-name-additional-properties\">\n <ScalarWrappingText\n preset=\"property\"\n :text=\"name\" />\n </span>\n <ScalarWrappingText\n v-else\n preset=\"property\"\n :text=\"name\" />\n </WithBreadcrumb>\n </template>\n <template\n v-if=\"optimizedValue?.example !== undefined\"\n #example>\n Example:\n {{ optimizedValue.example }}\n </template>\n </SchemaPropertyHeading>\n\n <!-- Description -->\n <div\n v-if=\"displayDescription || propertyDescription\"\n class=\"property-description\">\n <ScalarMarkdown\n :value=\"displayDescription || propertyDescription || ''\" />\n </div>\n\n <!-- Enum for property names -->\n <SchemaEnums\n v-if=\"propertyNamesEnum && propertyNamesEnum.length > 0\"\n propertyNames\n :value=\"{ enum: propertyNamesEnum } as SchemaObject\" />\n\n <!-- Enum values -->\n <SchemaEnums\n v-if=\"enumValues.length > 0\"\n :value=\"optimizedValue\" />\n\n <!-- Object -->\n <div\n v-if=\"shouldRenderObjectProperties\"\n class=\"children\">\n <Schema\n :breadcrumb=\"childBreadcrumb\"\n :compact=\"compact\"\n :compositionPath=\"currentCompositionPath\"\n :cycleKey=\"cycleKey\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :level=\"level + 1\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"objectSchemaForChildren\"\n :schemaContext=\"schemaContext\" />\n </div>\n\n <!-- Array of objects or nested arrays -->\n <div\n v-if=\"shouldRenderArrayOfObjects && resolvedArrayItems\"\n class=\"children\">\n <Schema\n :compact=\"compact\"\n :compositionPath=\"arrayItemsCompositionPath\"\n :cycleKey=\"arrayItemsCycleKey\"\n :eventBus=\"eventBus\"\n :hideModelNames\n :level=\"level + 1\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"resolve.schema(resolvedArrayItems)\"\n :schemaContext=\"schemaContext\" />\n </div>\n\n <!-- Compositions -->\n <SchemaComposition\n v-for=\"compositionData in compositionsToRender\"\n :key=\"compositionData.composition\"\n :breadcrumb=\"breadcrumb\"\n :compact=\"compact\"\n :composition=\"compositionData.composition\"\n :compositionPath=\"currentCompositionPath\"\n :discriminator=\"schema?.discriminator\"\n :eventBus=\"eventBus\"\n :hideHeading=\"hideHeading\"\n :hideModelNames\n :level=\"level\"\n :name=\"name\"\n :noncollapsible=\"noncollapsible\"\n :options=\"options\"\n :schema=\"compositionData.value\"\n :schemaContext=\"schemaContext\" />\n <SpecificationExtension :value=\"optimizedValue\" />\n </component>\n</template>\n\n<style scoped>\n.property {\n color: var(--scalar-color-1);\n display: flex;\n flex-direction: column;\n padding: 10px;\n font-size: var(--scalar-small);\n position: relative;\n}\n\n/** Remove top padding for top level schema card */\n.property.property--level-0:has(\n > .property-rule\n > .schema-card\n > .schema-properties.schema-properties-open\n > ul\n > li.property\n ) {\n padding-top: 0;\n}\n\n.property--compact.property--level-0,\n.property--compact.property--level-1 {\n padding: 10px 0;\n}\n\n.composition-panel .property.property.property.property--level-0 {\n padding: 0px;\n}\n\n.property--compact.property--level-0\n .composition-panel\n .property--compact.property--level-1 {\n padding: 8px;\n}\n\n/* if a property doesn't have a heading, remove the top padding */\n.property:has(> .property-rule:nth-of-type(1)):not(.property--compact) {\n padding-top: 8px;\n padding-bottom: 8px;\n}\n\n.property--deprecated {\n background: repeating-linear-gradient(\n -45deg,\n var(--scalar-background-2) 0,\n var(--scalar-background-2) 2px,\n transparent 2px,\n transparent 5px\n );\n background-size: 100%;\n}\n\n.property--deprecated > * {\n opacity: 0.75;\n}\n\n.property-description {\n margin-top: 6px;\n line-height: 1.4;\n font-size: var(--scalar-small);\n}\n\n.property-description:has(+ .property-rule) {\n margin-bottom: 9px;\n}\n\n:deep(.property-description) * {\n color: var(--scalar-color-2) !important;\n}\n\n.property:not(:last-of-type) {\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n\n.property-description + .children,\n.children + .property-rule {\n margin-top: 9px;\n}\n\n.children {\n display: flex;\n flex-direction: column;\n}\n\n.children .property--compact.property--level-1 {\n padding: 12px;\n}\n\n.property-example-value {\n all: unset;\n font-family: var(--scalar-font-code);\n padding: 6px;\n border-top: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n\n.property-rule {\n border-radius: var(--scalar-radius-lg);\n display: flex;\n flex-direction: column;\n}\n\n.property--level-2 :deep(.relative > button) {\n left: -2rem;\n}\n\n.property-rule\n :deep(\n .composition-panel\n .schema-card--level-1\n > .schema-properties.schema-properties-open\n ) {\n border-radius: 0 0 var(--scalar-radius-lg) var(--scalar-radius-lg);\n}\n\n.property-rule\n :deep(.composition-panel > .schema-card > .schema-card-description) {\n padding: 10px;\n border-left: var(--scalar-border-width) solid var(--scalar-border-color);\n border-right: var(--scalar-border-width) solid var(--scalar-border-color);\n\n & + .schema-properties {\n margin-top: 0;\n }\n}\n\n.property-example {\n background: transparent;\n border: none;\n display: flex;\n flex-direction: row;\n gap: 8px;\n}\n\n.property-example-label,\n.property-example-value {\n padding: 3px 0 0 0;\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border-top: 0;\n border-radius: var(--scalar-radius);\n padding: 3px 4px;\n}\n\n.property-name {\n font-family: var(--scalar-font-code);\n font-weight: var(--scalar-semibold);\n}\n\n.property-name-additional-properties::before,\n.property-name-pattern-properties::before {\n text-transform: uppercase;\n font-size: var(--scalar-micro);\n display: inline-block;\n padding: 2px 4px;\n border-radius: var(--scalar-radius);\n color: var(--scalar-color-1);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n background-color: var(--scalar-background-2);\n margin-right: 4px;\n}\n\n.property-name-pattern-properties::before {\n content: 'regex';\n}\n\n.property-name-additional-properties,\n.property-name-pattern-properties {\n border: 1px dashed var(--scalar-border-color);\n color: var(--scalar-color-accent);\n display: inline-block;\n padding: 2px;\n border-radius: var(--scalar-radius);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8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,EAAA,EAAzB,OAAO,eAAA,OAAc,EAAA,MAAA,GAAA,CAAA,QAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimize-value-for-display.d.ts","sourceRoot":"","sources":["../../../../../src/components/Content/Schema/helpers/optimize-value-for-display.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;
|
|
1
|
+
{"version":3,"file":"optimize-value-for-display.d.ts","sourceRoot":"","sources":["../../../../../src/components/Content/Schema/helpers/optimize-value-for-display.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAqDhG;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAyFjG"}
|
|
@@ -2,6 +2,40 @@ import { compositions } from "./schema-composition.js";
|
|
|
2
2
|
import { resolve } from "@scalar/workspace-store/resolve";
|
|
3
3
|
//#region src/components/Content/Schema/helpers/optimize-value-for-display.ts
|
|
4
4
|
/**
|
|
5
|
+
* Shallow-merges schema-like objects, but unions `properties` and `required`
|
|
6
|
+
* instead of letting a later object's `properties`/`required` completely
|
|
7
|
+
* overwrite an earlier one's. Without this, a variant schema (e.g. a `oneOf`
|
|
8
|
+
* branch) that declares its own `properties`/`required` would wipe out the
|
|
9
|
+
* shared base fields factored out at the root (or via a sibling `allOf`)
|
|
10
|
+
* instead of being combined with them (#9657).
|
|
11
|
+
*/
|
|
12
|
+
function mergeSchemaProperties(...objects) {
|
|
13
|
+
const merged = {};
|
|
14
|
+
const properties = {};
|
|
15
|
+
const required = /* @__PURE__ */ new Set();
|
|
16
|
+
let hasProperties = false;
|
|
17
|
+
let hasRequired = false;
|
|
18
|
+
for (const object of objects) {
|
|
19
|
+
if (!object) continue;
|
|
20
|
+
for (const [key, val] of Object.entries(object)) {
|
|
21
|
+
if (key === "properties" && val && typeof val === "object") {
|
|
22
|
+
Object.assign(properties, val);
|
|
23
|
+
hasProperties = true;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (key === "required" && Array.isArray(val)) {
|
|
27
|
+
for (const name of val) required.add(name);
|
|
28
|
+
hasRequired = true;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
merged[key] = val;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (hasProperties) merged.properties = properties;
|
|
35
|
+
if (hasRequired) merged.required = [...required];
|
|
36
|
+
return merged;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
5
39
|
* Optimize the value by removing nulls from compositions and merging root properties.
|
|
6
40
|
*
|
|
7
41
|
* TODO: figure out what this does
|
|
@@ -37,16 +71,9 @@ function optimizeValueForDisplay(value) {
|
|
|
37
71
|
const schema = resolve.schema(_schema);
|
|
38
72
|
if (schema.allOf?.length === 1) {
|
|
39
73
|
const { allOf, ...otherProps } = schema;
|
|
40
|
-
return
|
|
41
|
-
...rootProperties,
|
|
42
|
-
...otherProps,
|
|
43
|
-
...resolve.schema(allOf[0])
|
|
44
|
-
};
|
|
74
|
+
return mergeSchemaProperties(rootProperties, otherProps, resolve.schema(allOf[0]));
|
|
45
75
|
}
|
|
46
|
-
return
|
|
47
|
-
...rootProperties,
|
|
48
|
-
...schema
|
|
49
|
-
};
|
|
76
|
+
return mergeSchemaProperties(rootProperties, schema);
|
|
50
77
|
});
|
|
51
78
|
const result = { [composition]: mergedSchemas };
|
|
52
79
|
if (typeof value.description === "string") result.description = value.description;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimize-value-for-display.js","names":[],"sources":["../../../../../src/components/Content/Schema/helpers/optimize-value-for-display.ts"],"sourcesContent":["import { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { compositions } from './schema-composition'\n\n/**\n * Optimize the value by removing nulls from compositions and merging root properties.\n *\n * TODO: figure out what this does\n */\nexport function optimizeValueForDisplay(value: SchemaObject | undefined): SchemaObject | undefined {\n if (!value || typeof value !== 'object') {\n return value\n }\n\n // Find the composition keyword early to avoid unnecessary work\n const composition = compositions.find((keyword) => keyword in value && keyword !== 'not')\n\n // If there's no relevant composition keyword, return a shallow copy\n if (!composition) {\n return { ...value }\n }\n\n const schemas = value[composition]\n if (!Array.isArray(schemas)) {\n return { ...value }\n }\n\n // Extract root properties efficiently (excluding composition and nullable)\n const { [composition]: _, nullable: originalNullable, ...rootProperties } = value as any\n const hasRootProperties = Object.keys(rootProperties).length > 0\n\n // Check for null schemas and filter them out in one pass\n const { filteredSchemas, hasNullSchema } = schemas.reduce(\n (acc, _schema) => {\n const schema = resolve.schema(_schema)\n\n if ('type' in schema && schema.type === 'null') {\n acc.hasNullSchema = true\n } else {\n acc.filteredSchemas.push(schema)\n }\n return acc\n },\n { filteredSchemas: [] as SchemaObject[], hasNullSchema: false },\n )\n\n // Determine if nullable should be set\n const shouldBeNullable = hasNullSchema || originalNullable === true\n\n // If only one schema remains after filtering, merge with root properties\n if (filteredSchemas.length === 1) {\n const mergedSchema = { ...rootProperties, ...filteredSchemas[0] }\n if (shouldBeNullable) {\n mergedSchema.nullable = true\n }\n return mergedSchema\n }\n\n // Check if root properties should be merged into schemas\n const shouldMergeRootProperties =\n (composition === 'oneOf' || composition === 'anyOf') &&\n (hasRootProperties || filteredSchemas.some((schema) => schema.allOf))\n\n if (shouldMergeRootProperties) {\n const mergedSchemas = filteredSchemas.map((_schema) => {\n const schema = resolve.schema(_schema)\n\n // Flatten single-item allOf and merge with root properties\n if (schema.allOf?.length === 1) {\n const { allOf, ...otherProps } = schema\n return
|
|
1
|
+
{"version":3,"file":"optimize-value-for-display.js","names":[],"sources":["../../../../../src/components/Content/Schema/helpers/optimize-value-for-display.ts"],"sourcesContent":["import { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { compositions } from './schema-composition'\n\n/**\n * Shallow-merges schema-like objects, but unions `properties` and `required`\n * instead of letting a later object's `properties`/`required` completely\n * overwrite an earlier one's. Without this, a variant schema (e.g. a `oneOf`\n * branch) that declares its own `properties`/`required` would wipe out the\n * shared base fields factored out at the root (or via a sibling `allOf`)\n * instead of being combined with them (#9657).\n */\nfunction mergeSchemaProperties(...objects: (Record<string, unknown> | undefined)[]): Record<string, unknown> {\n const merged: Record<string, unknown> = {}\n const properties: Record<string, unknown> = {}\n const required = new Set<string>()\n let hasProperties = false\n let hasRequired = false\n\n for (const object of objects) {\n if (!object) {\n continue\n }\n\n for (const [key, val] of Object.entries(object)) {\n if (key === 'properties' && val && typeof val === 'object') {\n Object.assign(properties, val)\n hasProperties = true\n continue\n }\n\n if (key === 'required' && Array.isArray(val)) {\n for (const name of val) {\n required.add(name)\n }\n hasRequired = true\n continue\n }\n\n merged[key] = val\n }\n }\n\n if (hasProperties) {\n merged.properties = properties\n }\n if (hasRequired) {\n merged.required = [...required]\n }\n\n return merged\n}\n\n/**\n * Optimize the value by removing nulls from compositions and merging root properties.\n *\n * TODO: figure out what this does\n */\nexport function optimizeValueForDisplay(value: SchemaObject | undefined): SchemaObject | undefined {\n if (!value || typeof value !== 'object') {\n return value\n }\n\n // Find the composition keyword early to avoid unnecessary work\n const composition = compositions.find((keyword) => keyword in value && keyword !== 'not')\n\n // If there's no relevant composition keyword, return a shallow copy\n if (!composition) {\n return { ...value }\n }\n\n const schemas = value[composition]\n if (!Array.isArray(schemas)) {\n return { ...value }\n }\n\n // Extract root properties efficiently (excluding composition and nullable)\n const { [composition]: _, nullable: originalNullable, ...rootProperties } = value as any\n const hasRootProperties = Object.keys(rootProperties).length > 0\n\n // Check for null schemas and filter them out in one pass\n const { filteredSchemas, hasNullSchema } = schemas.reduce(\n (acc, _schema) => {\n const schema = resolve.schema(_schema)\n\n if ('type' in schema && schema.type === 'null') {\n acc.hasNullSchema = true\n } else {\n acc.filteredSchemas.push(schema)\n }\n return acc\n },\n { filteredSchemas: [] as SchemaObject[], hasNullSchema: false },\n )\n\n // Determine if nullable should be set\n const shouldBeNullable = hasNullSchema || originalNullable === true\n\n // If only one schema remains after filtering, merge with root properties\n if (filteredSchemas.length === 1) {\n const mergedSchema = { ...rootProperties, ...filteredSchemas[0] }\n if (shouldBeNullable) {\n mergedSchema.nullable = true\n }\n return mergedSchema\n }\n\n // Check if root properties should be merged into schemas\n const shouldMergeRootProperties =\n (composition === 'oneOf' || composition === 'anyOf') &&\n (hasRootProperties || filteredSchemas.some((schema) => schema.allOf))\n\n if (shouldMergeRootProperties) {\n const mergedSchemas = filteredSchemas.map((_schema) => {\n const schema = resolve.schema(_schema)\n\n // Flatten single-item allOf and merge with root properties\n if (schema.allOf?.length === 1) {\n const { allOf, ...otherProps } = schema\n return mergeSchemaProperties(rootProperties, otherProps, resolve.schema(allOf[0]))\n }\n return mergeSchemaProperties(rootProperties, schema)\n })\n\n // @ts-expect-error - We avoid using coerceValue here as it may be dangerous, so we type cast\n const result = { [composition]: mergedSchemas } as SchemaObject\n if (typeof value.description === 'string') {\n result.description = value.description\n }\n if (shouldBeNullable) {\n // @ts-expect-error We use nullable\n result.nullable = true\n }\n return result\n }\n\n // Return with filtered schemas if any nulls were removed\n if (filteredSchemas.length !== schemas.length) {\n const result: SchemaObject = { ...value, [composition]: filteredSchemas }\n if (shouldBeNullable) {\n // @ts-expect-error We use nullable\n result.nullable = true\n }\n return result\n }\n\n return { ...value }\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAS,sBAAsB,GAAG,SAA2E;CAC3G,MAAM,SAAkC,EAAE;CAC1C,MAAM,aAAsC,EAAE;CAC9C,MAAM,2BAAW,IAAI,KAAa;CAClC,IAAI,gBAAgB;CACpB,IAAI,cAAc;AAElB,MAAK,MAAM,UAAU,SAAS;AAC5B,MAAI,CAAC,OACH;AAGF,OAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,OAAO,EAAE;AAC/C,OAAI,QA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AM,GAEvC;EAC7B,MAAM,gBAAgB,gBAAgB,KAAK,YAAY;GACrD,MAAM,SAAS,QAAQ,OAAO,QAAQ;AAGtC,OAAI,OAAO,OAAO,WAAW,GAAG;IAC9B,MAAM,EAAE,OAAO,GAAG,eAAe;AACjC,WAAO,sBAAsB,gBAAgB,YAAY,QAAQ,OAAO,MAAM,GAAG,CAAC;;AAEpF,UAAO,sBAAsB,gBAAgB,OAAO;IACpD;EAGF,MAAM,SAAS,GAAG,cAAc,eAAe;AAC/C,MAAI,OAAO,MAAM,gBAAgB,SAC/B,QAAO,cAAc,MAAM;AAE7B,MAAI,iBAEF,QAAO,WAAW;AAEpB,SAAO;;AAIT,KAAI,gBAAgB,WAAW,QAAQ,QAAQ;EAC7C,MAAM,SAAuB;GAAE,GAAG;IAAQ,cAAc;GAAiB;AACzE,MAAI,iBAEF,QAAO,WAAW;AAEpB,SAAO;;AAGT,QAAO,EAAE,GAAG,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationResponses.vue.js","names":[],"sources":["../../../../src/features/Operation/components/OperationResponses.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type {\n OpenApiDocument,\n OperationObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { useLocalization } from '@/features/localization'\nimport type { OperationProps } from '@/features/Operation/Operation.vue'\n\nimport ParameterListItem from './ParameterListItem.vue'\n\nconst { responses } = defineProps<{\n responses: OperationObject['responses']\n breadcrumb?: string[]\n collapsableItems?: boolean\n eventBus: WorkspaceEventBus | null\n /** The document the operation belongs to, used to resolve schema references for display */\n document?: OpenApiDocument\n options: Pick<\n OperationProps['options'],\n | 'hideModels'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n >\n}>()\nconst { translate } = useLocalization()\n</script>\n<template>\n <div\n v-if=\"Object.keys(responses ?? {}).length\"\n class=\"mt-6\">\n <div class=\"text-c-1 mt-3 mb-3 leading-[1.45] font-medium\">\n {{ translate('operation.responses') }}\n </div>\n <ul\n :aria-label=\"translate('operation.responses')\"\n class=\"mb-3 list-none p-0 text-sm\">\n <ParameterListItem\n v-for=\"(response, status) in responses\"\n :key=\"status\"\n :breadcrumb\n :collapsableItems\n :document\n :eventBus\n :name=\"status\"\n :options\n :parameter=\"getResolvedRef(response)\" />\n </ul>\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"OperationResponses.vue.js","names":[],"sources":["../../../../src/features/Operation/components/OperationResponses.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type {\n OpenApiDocument,\n OperationObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { useLocalization } from '@/features/localization'\nimport type { OperationProps } from '@/features/Operation/Operation.vue'\n\nimport ParameterListItem from './ParameterListItem.vue'\n\nconst { responses } = defineProps<{\n responses: OperationObject['responses']\n breadcrumb?: string[]\n collapsableItems?: boolean\n eventBus: WorkspaceEventBus | null\n /** The document the operation belongs to, used to resolve schema references for display */\n document?: OpenApiDocument\n options: Pick<\n OperationProps['options'],\n | 'hideModels'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n >\n}>()\nconst { translate } = useLocalization()\n</script>\n<template>\n <div\n v-if=\"Object.keys(responses ?? {}).length\"\n class=\"mt-6\">\n <div class=\"text-c-1 mt-3 mb-3 leading-[1.45] font-medium\">\n {{ translate('operation.responses') }}\n </div>\n <ul\n :aria-label=\"translate('operation.responses')\"\n class=\"mb-3 list-none p-0 text-sm\">\n <ParameterListItem\n v-for=\"(response, status) in responses\"\n :key=\"status\"\n :breadcrumb=\"breadcrumb ? [...breadcrumb, 'responses'] : undefined\"\n :collapsableItems\n :document\n :eventBus\n :name=\"status\"\n :options\n :parameter=\"getResolvedRef(response)\" />\n </ul>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -28,7 +28,7 @@ var OperationResponses_vue_vue_type_script_setup_true_lang_default = /* @__PURE_
|
|
|
28
28
|
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.responses, (response, status) => {
|
|
29
29
|
return openBlock(), createBlock(ParameterListItem_default, {
|
|
30
30
|
key: status,
|
|
31
|
-
breadcrumb: __props.breadcrumb,
|
|
31
|
+
breadcrumb: __props.breadcrumb ? [...__props.breadcrumb, "responses"] : void 0,
|
|
32
32
|
collapsableItems: __props.collapsableItems,
|
|
33
33
|
document: __props.document,
|
|
34
34
|
eventBus: __props.eventBus,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationResponses.vue.script.js","names":[],"sources":["../../../../src/features/Operation/components/OperationResponses.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type {\n OpenApiDocument,\n OperationObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { useLocalization } from '@/features/localization'\nimport type { OperationProps } from '@/features/Operation/Operation.vue'\n\nimport ParameterListItem from './ParameterListItem.vue'\n\nconst { responses } = defineProps<{\n responses: OperationObject['responses']\n breadcrumb?: string[]\n collapsableItems?: boolean\n eventBus: WorkspaceEventBus | null\n /** The document the operation belongs to, used to resolve schema references for display */\n document?: OpenApiDocument\n options: Pick<\n OperationProps['options'],\n | 'hideModels'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n >\n}>()\nconst { translate } = useLocalization()\n</script>\n<template>\n <div\n v-if=\"Object.keys(responses ?? {}).length\"\n class=\"mt-6\">\n <div class=\"text-c-1 mt-3 mb-3 leading-[1.45] font-medium\">\n {{ translate('operation.responses') }}\n </div>\n <ul\n :aria-label=\"translate('operation.responses')\"\n class=\"mb-3 list-none p-0 text-sm\">\n <ParameterListItem\n v-for=\"(response, status) in responses\"\n :key=\"status\"\n :breadcrumb\n :collapsableItems\n :document\n :eventBus\n :name=\"status\"\n :options\n :parameter=\"getResolvedRef(response)\" />\n </ul>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EA4BA,MAAM,EAAE,cAAc,iBAAgB;;UAI5B,OAAO,KAAK,QAAA,aAAS,EAAA,CAAA,CAAQ,UAAA,WAAA,EADrC,mBAoBM,OApBN,YAoBM,CAjBJ,mBAEM,OAFN,YAEM,gBADD,MAAA,UAAS,CAAA,sBAAA,CAAA,EAAA,EAAA,EAEd,mBAaK,MAAA;IAZF,cAAY,MAAA,UAAS,CAAA,sBAAA;IACtB,OAAM;yBACN,mBAS0C,UAAA,MAAA,WARX,QAAA,YAArB,UAAU,WAAM;wBAD1B,YAS0C,2BAAA;KAPvC,KAAK;KACL,YAAA,
|
|
1
|
+
{"version":3,"file":"OperationResponses.vue.script.js","names":[],"sources":["../../../../src/features/Operation/components/OperationResponses.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type {\n OpenApiDocument,\n OperationObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { useLocalization } from '@/features/localization'\nimport type { OperationProps } from '@/features/Operation/Operation.vue'\n\nimport ParameterListItem from './ParameterListItem.vue'\n\nconst { responses } = defineProps<{\n responses: OperationObject['responses']\n breadcrumb?: string[]\n collapsableItems?: boolean\n eventBus: WorkspaceEventBus | null\n /** The document the operation belongs to, used to resolve schema references for display */\n document?: OpenApiDocument\n options: Pick<\n OperationProps['options'],\n | 'hideModels'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n >\n}>()\nconst { translate } = useLocalization()\n</script>\n<template>\n <div\n v-if=\"Object.keys(responses ?? {}).length\"\n class=\"mt-6\">\n <div class=\"text-c-1 mt-3 mb-3 leading-[1.45] font-medium\">\n {{ translate('operation.responses') }}\n </div>\n <ul\n :aria-label=\"translate('operation.responses')\"\n class=\"mb-3 list-none p-0 text-sm\">\n <ParameterListItem\n v-for=\"(response, status) in responses\"\n :key=\"status\"\n :breadcrumb=\"breadcrumb ? [...breadcrumb, 'responses'] : undefined\"\n :collapsableItems\n :document\n :eventBus\n :name=\"status\"\n :options\n :parameter=\"getResolvedRef(response)\" />\n </ul>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EA4BA,MAAM,EAAE,cAAc,iBAAgB;;UAI5B,OAAO,KAAK,QAAA,aAAS,EAAA,CAAA,CAAQ,UAAA,WAAA,EADrC,mBAoBM,OApBN,YAoBM,CAjBJ,mBAEM,OAFN,YAEM,gBADD,MAAA,UAAS,CAAA,sBAAA,CAAA,EAAA,EAAA,EAEd,mBAaK,MAAA;IAZF,cAAY,MAAA,UAAS,CAAA,sBAAA;IACtB,OAAM;yBACN,mBAS0C,UAAA,MAAA,WARX,QAAA,YAArB,UAAU,WAAM;wBAD1B,YAS0C,2BAAA;KAPvC,KAAK;KACL,YAAY,QAAA,aAAU,CAAA,GAAO,QAAA,YAAU,YAAA,GAAiB,KAAA;KACxD,kBAAA,QAAA;KACA,UAAA,QAAA;KACA,UAAA,QAAA;KACA,MAAM;KACN,SAAA,QAAA;KACA,WAAW,MAAA,eAAc,CAAC,SAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParameterListItem.vue.d.ts","sourceRoot":"","sources":["../../../../src/features/Operation/components/ParameterListItem.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ParameterListItem.vue.d.ts","sourceRoot":"","sources":["../../../../src/features/Operation/components/ParameterListItem.vue"],"names":[],"mappings":"AA0WA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,cAAc,EAEf,MAAM,8DAA8D,CAAA;AAKrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AAOxE,KAAK,WAAW,GAAG;IACf,SAAS,EAAE,eAAe,GAAG,cAAc,CAAA;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,OAAO,EAAE,IAAI,CACX,cAAc,CAAC,SAAS,CAAC,EACvB,YAAY,GACZ,8BAA8B,GAC9B,yBAAyB,GACzB,2BAA2B,CAC9B,CAAA;CACF,CAAC;AA0aJ,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -2,7 +2,7 @@ import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_exp
|
|
|
2
2
|
import ParameterListItem_vue_vue_type_script_setup_true_lang_default from "./ParameterListItem.vue.script.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region src/features/Operation/components/ParameterListItem.vue
|
|
5
|
-
var ParameterListItem_default = /* @__PURE__ */ _plugin_vue_export_helper_default(ParameterListItem_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var ParameterListItem_default = /* @__PURE__ */ _plugin_vue_export_helper_default(ParameterListItem_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-830e91ce"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ParameterListItem_default as default };
|
|
8
8
|
|