@scalar/api-reference 1.59.2 → 1.60.0
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 +28 -0
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.d.ts.map +1 -1
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.js.map +1 -1
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.script.js +12 -7
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.script.js.map +1 -1
- package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.d.ts +4 -4
- package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.d.ts.map +1 -1
- package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.js +1 -1
- package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.js.map +1 -1
- package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.script.js +14 -17
- package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.script.js.map +1 -1
- package/dist/blocks/scalar-info-block/components/IntroductionLoading.vue.d.ts +12 -0
- package/dist/blocks/scalar-info-block/components/IntroductionLoading.vue.d.ts.map +1 -0
- package/dist/blocks/scalar-info-block/components/IntroductionLoading.vue.js +9 -0
- package/dist/blocks/scalar-info-block/components/IntroductionLoading.vue.js.map +1 -0
- package/dist/blocks/scalar-info-block/components/IntroductionLoading.vue.script.js +63 -0
- package/dist/blocks/scalar-info-block/components/IntroductionLoading.vue.script.js.map +1 -0
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.d.ts +13 -0
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.d.ts.map +1 -1
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.js +1 -1
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.js.map +1 -1
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.script.js +32 -8
- package/dist/blocks/scalar-sdk-installation-instructions/components/SdkInstallationInstructions.vue.script.js.map +1 -1
- package/dist/browser/chunks/AgentScalarChatInterface-CesFQ_Ax.js +27 -0
- package/dist/browser/chunks/ScalarTextInput.vue-C14zmVNI.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-BZzcBkVp.js +99 -0
- package/dist/browser/chunks/{modal-CgDbMGa1.js → modal-LBDjZSmM.js} +2 -2
- 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-wW8jg8wN.js +306 -0
- package/dist/browser/standalone.esm.js +20 -20
- package/dist/browser/standalone.js +249 -248
- 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 +39 -11
- package/dist/components/ApiReference.vue.script.js.map +1 -1
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.d.ts.map +1 -1
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.js.map +1 -1
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.script.js +0 -1
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.script.js.map +1 -1
- package/dist/components/Content/Content.vue.d.ts +4 -2
- 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 +25 -2
- package/dist/components/Content/Content.vue.script.js.map +1 -1
- package/dist/components/Content/Operations/TraversedEntry.vue.d.ts.map +1 -1
- package/dist/components/Content/Operations/TraversedEntry.vue.js.map +1 -1
- package/dist/components/Content/Operations/TraversedEntry.vue.script.js +2 -2
- package/dist/components/Content/Operations/TraversedEntry.vue.script.js.map +1 -1
- package/dist/components/Content/Schema/Schema.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/Schema.vue.js +1 -1
- package/dist/components/Content/Schema/Schema.vue.js.map +1 -1
- package/dist/components/Content/Schema/Schema.vue.script.js +22 -2
- package/dist/components/Content/Schema/Schema.vue.script.js.map +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.d.ts +0 -6
- 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 +16 -2
- package/dist/components/Content/Schema/SchemaProperty.vue.script.js.map +1 -1
- package/dist/components/Content/Schema/helpers/should-display-description.d.ts.map +1 -1
- package/dist/components/Content/Schema/helpers/should-display-description.js +1 -1
- package/dist/components/Content/Schema/helpers/should-display-description.js.map +1 -1
- package/dist/components/Content/Tags/Tag.vue.d.ts +0 -1
- package/dist/components/Content/Tags/Tag.vue.d.ts.map +1 -1
- package/dist/components/Content/Tags/Tag.vue.js.map +1 -1
- package/dist/components/Content/Tags/Tag.vue.script.js +0 -3
- package/dist/components/Content/Tags/Tag.vue.script.js.map +1 -1
- package/dist/components/Content/Tags/components/ModernLayout.vue.d.ts +0 -1
- package/dist/components/Content/Tags/components/ModernLayout.vue.d.ts.map +1 -1
- package/dist/components/Content/Tags/components/ModernLayout.vue.js +1 -1
- package/dist/components/Content/Tags/components/ModernLayout.vue.js.map +1 -1
- package/dist/components/Content/Tags/components/ModernLayout.vue.script.js +0 -3
- package/dist/components/Content/Tags/components/ModernLayout.vue.script.js.map +1 -1
- package/dist/components/Content/Tags/components/TagSection.vue.d.ts +0 -1
- package/dist/components/Content/Tags/components/TagSection.vue.d.ts.map +1 -1
- package/dist/components/Content/Tags/components/TagSection.vue.js.map +1 -1
- package/dist/components/Content/Tags/components/TagSection.vue.script.js +5 -6
- package/dist/components/Content/Tags/components/TagSection.vue.script.js.map +1 -1
- package/dist/components/RenderPlugins/RenderPluginView.vue.d.ts +11 -0
- package/dist/components/RenderPlugins/RenderPluginView.vue.d.ts.map +1 -0
- package/dist/components/RenderPlugins/RenderPluginView.vue.js +7 -0
- package/dist/components/RenderPlugins/RenderPluginView.vue.js.map +1 -0
- package/dist/components/RenderPlugins/RenderPluginView.vue.script.js +45 -0
- package/dist/components/RenderPlugins/RenderPluginView.vue.script.js.map +1 -0
- package/dist/components/RenderPlugins/RenderPlugins.vue.d.ts +5 -1
- package/dist/components/RenderPlugins/RenderPlugins.vue.d.ts.map +1 -1
- package/dist/components/RenderPlugins/RenderPlugins.vue.js.map +1 -1
- package/dist/components/RenderPlugins/RenderPlugins.vue.script.js +17 -22
- package/dist/components/RenderPlugins/RenderPlugins.vue.script.js.map +1 -1
- package/dist/components/Section/SectionContent.vue.d.ts +1 -6
- package/dist/components/Section/SectionContent.vue.d.ts.map +1 -1
- package/dist/components/Section/SectionContent.vue.js +7 -2
- package/dist/components/Section/SectionContent.vue.js.map +1 -1
- package/dist/components/Section/SectionHeader.vue.d.ts +3 -4
- package/dist/components/Section/SectionHeader.vue.d.ts.map +1 -1
- package/dist/components/Section/SectionHeader.vue.js +1 -1
- package/dist/components/Section/SectionHeader.vue.js.map +1 -1
- package/dist/components/Section/SectionHeader.vue.script.js +5 -10
- package/dist/components/Section/SectionHeader.vue.script.js.map +1 -1
- package/dist/features/Search/helpers/create-search-index.d.ts.map +1 -1
- package/dist/features/Search/helpers/create-search-index.js +4 -3
- package/dist/features/Search/helpers/create-search-index.js.map +1 -1
- package/dist/helpers/id-routing.d.ts +6 -13
- package/dist/helpers/id-routing.d.ts.map +1 -1
- package/dist/helpers/id-routing.js +104 -34
- package/dist/helpers/id-routing.js.map +1 -1
- package/dist/helpers/lazy-bus.d.ts +10 -0
- package/dist/helpers/lazy-bus.d.ts.map +1 -1
- package/dist/helpers/lazy-bus.js +22 -1
- package/dist/helpers/lazy-bus.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 +27 -2
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +32 -2
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/style.css +440 -265
- package/dist/vue-styles.css +157 -159
- package/package.json +15 -13
- package/dist/browser/chunks/AgentScalarChatInterface-D4DCmV5y.js +0 -27
- package/dist/browser/chunks/ScalarTextInput.vue-C5aaO8tA.js +0 -27
- package/dist/browser/chunks/modal-B4LeCbAi.js +0 -66
- package/dist/browser/chunks/vendor-BNhbieDE.js +0 -338
- package/dist/components/LoadingSkeleton.vue.d.ts +0 -9
- package/dist/components/LoadingSkeleton.vue.d.ts.map +0 -1
- package/dist/components/LoadingSkeleton.vue.js +0 -9
- package/dist/components/LoadingSkeleton.vue.js.map +0 -1
- package/dist/components/LoadingSkeleton.vue.script.js +0 -20
- package/dist/components/LoadingSkeleton.vue.script.js.map +0 -1
- package/dist/components/Section/SectionContent.vue.script.js +0 -23
- package/dist/components/Section/SectionContent.vue.script.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.vue.script.js","names":[],"sources":["../../../src/components/Content/Content.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { generateClientOptions } from '@scalar/api-client/blocks/operation-code-sample'\nimport { mapHiddenClientsConfig } from '@scalar/api-client/modal/map-hidden-clients-config'\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} = defineProps<{\n infoSectionId: 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 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 <!-- 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 :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 :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 :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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8FA,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,QAA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ACL,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,YAYiB,wBAAA;;KAVd,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,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,YAE2B,MAAA,sBAAA,EAAA;KADxB,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 { generateClientOptions } from '@scalar/api-client/blocks/operation-code-sample'\nimport { mapHiddenClientsConfig } from '@scalar/api-client/modal/map-hidden-clients-config'\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 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 :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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiGA,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,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tC,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,YAYiB,wBAAA;;KAVd,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,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":"TraversedEntry.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Content/Operations/TraversedEntry.vue"],"names":[],"mappings":"AA+NA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAA;AACxF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"TraversedEntry.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Content/Operations/TraversedEntry.vue"],"names":[],"mappings":"AA+NA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAA;AACxF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAGvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAA;AACpF,OAAO,KAAK,EACV,cAAc,EAMf,MAAM,4CAA4C,CAAA;AACnD,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AASrE,KAAK,WAAW,GAAG;IACjB,qBAAqB;IACrB,SAAS,EAAE,SAAS,CAAA;IACpB,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kCAAkC;IAClC,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,0BAA0B;IAC1B,QAAQ,EAAE,eAAe,CAAA;IACzB,+CAA+C;IAC/C,aAAa,EAAE,iBAAiB,EAAE,CAAA;IAClC,kFAAkF;IAClF,OAAO,EAAE,IAAI,CACX,4BAA4B,EAC1B,oBAAoB,GACpB,uBAAuB,GACvB,QAAQ,GACR,8BAA8B,GAC9B,yBAAyB,GACzB,2BAA2B,GAC3B,iBAAiB,GACjB,YAAY,GACZ,oBAAoB,CACvB,CAAA;IACD,iDAAiD;IACjD,cAAc,EAAE,YAAY,GAAG,IAAI,CAAA;IACnC,wFAAwF;IACxF,eAAe,EAAE,qBAAqB,CAAA;IACtC,sDAAsD;IACtD,cAAc,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC,yBAAyB,CAAC,CAAA;IACtE,iDAAiD;IACjD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC,iDAAiD;IACjD,QAAQ,EAAE,iBAAiB,CAAA;CAC5B,CAAC;AAsTF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TraversedEntry.vue.js","names":[],"sources":["../../../../src/components/Content/Operations/TraversedEntry.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ClientOptionGroup } from '@scalar/api-client/blocks/operation-code-sample'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\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 type { MergedSecuritySchemes } from '@scalar/workspace-store/request-example'\nimport type {\n TraversedEntry,\n TraversedModels,\n TraversedOperation,\n TraversedSchema,\n TraversedTag,\n TraversedWebhook,\n} from '@scalar/workspace-store/schemas/navigation'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport Model from '@/components/Content/Models/Model.vue'\nimport ModelTag from '@/components/Content/Models/ModelTag.vue'\nimport { Tag } from '@/components/Content/Tags'\nimport Lazy from '@/components/Lazy/Lazy.vue'\nimport { SectionContainer } from '@/components/Section'\nimport { Operation } from '@/features/Operation'\n\nconst {\n level = 0,\n clientOptions,\n document,\n authStore,\n entries,\n} = defineProps<{\n /** The auth store */\n authStore: AuthStore\n /** The level of depth */\n level?: number\n /** Traversed entries to render */\n entries: TraversedEntry[]\n /** The document object */\n document: OpenApiDocument\n /** The http client options for the dropdown */\n clientOptions: ClientOptionGroup[]\n /** The subset of the configuration object required for the operation component */\n options: Pick<\n ApiReferenceConfigurationRaw,\n | 'expandAllResponses'\n | 'hideTestRequestButton'\n | 'layout'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n | 'showOperationId'\n | 'hideModels'\n | 'modelsSectionLabel'\n >\n /** Currently selected server for the document */\n selectedServer: ServerObject | null\n /** The merged security schemes for the document and the authentication configuration */\n securitySchemes: MergedSecuritySchemes\n /** Currently selected http client for the document */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Used to determine if an entry is collapsed */\n expandedItems: Record<string, boolean>\n /** The event bus for the handling all events. */\n eventBus: WorkspaceEventBus\n}>()\n\n/**\n * Type guards for different entry types\n */\nconst isTagGroup = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: true } =>\n entry['type'] === 'tag' && entry.isGroup === true\n\nconst isTag = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: false } =>\n entry['type'] === 'tag' && !isTagGroup(entry) && entry.id !== 'models'\n\nconst isOperation = (entry: TraversedEntry): entry is TraversedOperation =>\n entry['type'] === 'operation'\n\nconst isWebhook = (entry: TraversedEntry): entry is TraversedWebhook =>\n entry['type'] === 'webhook'\n\n/** Models are special form of tag entry */\nconst isModelsTag = (entry: TraversedEntry): entry is TraversedModels =>\n entry['type'] === 'models'\n\nconst isModel = (entry: TraversedEntry): entry is TraversedSchema =>\n entry['type'] === 'model'\n\nfunction getPathValue(entry: TraversedOperation | TraversedWebhook) {\n return isWebhook(entry)\n ? document.webhooks?.[entry.name]\n : document.paths?.[entry.path]\n}\n</script>\n\n<template>\n <!-- The key must be joined with the layout to force a re-render when the layout changes -->\n <!-- Without this we get a timing issue where the lazy bus is reset and the element is not rendered -->\n <Lazy\n v-for=\"entry in entries\"\n :id=\"entry.id\"\n :key=\"`${entry.id}-${options.layout}`\"\n :expanded=\"!!expandedItems[entry.id]\">\n <!-- Operation or Webhook -->\n <SectionContainer\n v-if=\"isOperation(entry) || isWebhook(entry)\"\n :omit=\"level !== 0\">\n <Operation\n :id=\"entry.id\"\n :authStore\n :clientOptions\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :isWebhook=\"isWebhook(entry)\"\n :method=\"entry.method\"\n :options=\"options\"\n :path=\"isWebhook(entry) ? entry.name : entry.path\"\n :pathValue=\"getPathValue(entry)\"\n :securitySchemes=\"securitySchemes\"\n :selectedClient=\"selectedClient\"\n :server=\"selectedServer\" />\n </SectionContainer>\n\n <!-- Webhook Group, Tag or Tag Group (only in classic layout) -->\n <Tag\n v-else-if=\"\n isTag(entry) || (isTagGroup(entry) && options.layout === 'classic')\n \"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :
|
|
1
|
+
{"version":3,"file":"TraversedEntry.vue.js","names":[],"sources":["../../../../src/components/Content/Operations/TraversedEntry.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ClientOptionGroup } from '@scalar/api-client/blocks/operation-code-sample'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedPathItem } from '@scalar/workspace-store/helpers/for-each-path-item-operation'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { MergedSecuritySchemes } from '@scalar/workspace-store/request-example'\nimport type {\n TraversedEntry,\n TraversedModels,\n TraversedOperation,\n TraversedSchema,\n TraversedTag,\n TraversedWebhook,\n} from '@scalar/workspace-store/schemas/navigation'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport Model from '@/components/Content/Models/Model.vue'\nimport ModelTag from '@/components/Content/Models/ModelTag.vue'\nimport { Tag } from '@/components/Content/Tags'\nimport Lazy from '@/components/Lazy/Lazy.vue'\nimport { SectionContainer } from '@/components/Section'\nimport { Operation } from '@/features/Operation'\n\nconst {\n level = 0,\n clientOptions,\n document,\n authStore,\n entries,\n} = defineProps<{\n /** The auth store */\n authStore: AuthStore\n /** The level of depth */\n level?: number\n /** Traversed entries to render */\n entries: TraversedEntry[]\n /** The document object */\n document: OpenApiDocument\n /** The http client options for the dropdown */\n clientOptions: ClientOptionGroup[]\n /** The subset of the configuration object required for the operation component */\n options: Pick<\n ApiReferenceConfigurationRaw,\n | 'expandAllResponses'\n | 'hideTestRequestButton'\n | 'layout'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n | 'showOperationId'\n | 'hideModels'\n | 'modelsSectionLabel'\n >\n /** Currently selected server for the document */\n selectedServer: ServerObject | null\n /** The merged security schemes for the document and the authentication configuration */\n securitySchemes: MergedSecuritySchemes\n /** Currently selected http client for the document */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Used to determine if an entry is collapsed */\n expandedItems: Record<string, boolean>\n /** The event bus for the handling all events. */\n eventBus: WorkspaceEventBus\n}>()\n\n/**\n * Type guards for different entry types\n */\nconst isTagGroup = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: true } =>\n entry['type'] === 'tag' && entry.isGroup === true\n\nconst isTag = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: false } =>\n entry['type'] === 'tag' && !isTagGroup(entry) && entry.id !== 'models'\n\nconst isOperation = (entry: TraversedEntry): entry is TraversedOperation =>\n entry['type'] === 'operation'\n\nconst isWebhook = (entry: TraversedEntry): entry is TraversedWebhook =>\n entry['type'] === 'webhook'\n\n/** Models are special form of tag entry */\nconst isModelsTag = (entry: TraversedEntry): entry is TraversedModels =>\n entry['type'] === 'models'\n\nconst isModel = (entry: TraversedEntry): entry is TraversedSchema =>\n entry['type'] === 'model'\n\nfunction getPathValue(entry: TraversedOperation | TraversedWebhook) {\n return isWebhook(entry)\n ? getResolvedPathItem(document.webhooks?.[entry.name])\n : getResolvedPathItem(document.paths?.[entry.path])\n}\n</script>\n\n<template>\n <!-- The key must be joined with the layout to force a re-render when the layout changes -->\n <!-- Without this we get a timing issue where the lazy bus is reset and the element is not rendered -->\n <Lazy\n v-for=\"entry in entries\"\n :id=\"entry.id\"\n :key=\"`${entry.id}-${options.layout}`\"\n :expanded=\"!!expandedItems[entry.id]\">\n <!-- Operation or Webhook -->\n <SectionContainer\n v-if=\"isOperation(entry) || isWebhook(entry)\"\n :omit=\"level !== 0\">\n <Operation\n :id=\"entry.id\"\n :authStore\n :clientOptions\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :isWebhook=\"isWebhook(entry)\"\n :method=\"entry.method\"\n :options=\"options\"\n :path=\"isWebhook(entry) ? entry.name : entry.path\"\n :pathValue=\"getPathValue(entry)\"\n :securitySchemes=\"securitySchemes\"\n :selectedClient=\"selectedClient\"\n :server=\"selectedServer\" />\n </SectionContainer>\n\n <!-- Webhook Group, Tag or Tag Group (only in classic layout) -->\n <Tag\n v-else-if=\"\n isTag(entry) || (isTagGroup(entry) && options.layout === 'classic')\n \"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :layout=\"options.layout\"\n :moreThanOneTag=\"entries.filter(isTag).length > 1\"\n :tag=\"entry\">\n <template v-if=\"'children' in entry && entry.children?.length\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children\"\n :eventBus\n :expandedItems\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </template>\n </Tag>\n\n <!-- Display tag group entries for modern layout (flattened) -->\n <!--\n The wrapping element carries the tag group id so it remains a scroll\n target. Modern layout flattens groups and renders no header of their own,\n so without this anchor, selecting a tag group (from search or the sidebar)\n would have nothing to scroll to.\n -->\n <div\n v-else-if=\"isTagGroup(entry)\"\n :id=\"entry.id\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children || []\"\n :eventBus\n :expandedItems\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </div>\n\n <!-- Models -->\n <ModelTag\n v-else-if=\"isModelsTag(entry) && document.components?.schemas\"\n :id=\"entry.id\"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :layout=\"options.layout\"\n :modelsSectionLabel=\"options.modelsSectionLabel\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children || []\"\n :eventBus\n :expandedItems=\"expandedItems\"\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </ModelTag>\n\n <Model\n v-else-if=\"isModel(entry) && document.components?.schemas?.[entry.name]\"\n :id=\"entry.id\"\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :name=\"entry.name\"\n :options\n :schema=\"getResolvedRef(document.components.schemas[entry.name])\">\n </Model>\n </Lazy>\n</template>\n"],"mappings":""}
|
|
@@ -6,6 +6,7 @@ import Lazy_default from "../../Lazy/Lazy.vue.js";
|
|
|
6
6
|
import Operation_default from "../../../features/Operation/Operation.vue.js";
|
|
7
7
|
import { Fragment, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, openBlock, renderList, resolveComponent, unref, withCtx } from "vue";
|
|
8
8
|
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
9
|
+
import { getResolvedPathItem } from "@scalar/workspace-store/helpers/for-each-path-item-operation";
|
|
9
10
|
//#region src/components/Content/Operations/TraversedEntry.vue?vue&type=script&setup=true&lang.ts
|
|
10
11
|
var _hoisted_1 = ["id"];
|
|
11
12
|
var TraversedEntry_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
@@ -35,7 +36,7 @@ var TraversedEntry_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
35
36
|
const isModelsTag = (entry) => entry["type"] === "models";
|
|
36
37
|
const isModel = (entry) => entry["type"] === "model";
|
|
37
38
|
function getPathValue(entry) {
|
|
38
|
-
return isWebhook(entry) ? __props.document.webhooks?.[entry.name] : __props.document.paths?.[entry.path];
|
|
39
|
+
return isWebhook(entry) ? getResolvedPathItem(__props.document.webhooks?.[entry.name]) : getResolvedPathItem(__props.document.paths?.[entry.path]);
|
|
39
40
|
}
|
|
40
41
|
return (_ctx, _cache) => {
|
|
41
42
|
const _component_TraversedEntry = resolveComponent("TraversedEntry", true);
|
|
@@ -85,7 +86,6 @@ var TraversedEntry_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
85
86
|
key: 1,
|
|
86
87
|
eventBus: __props.eventBus,
|
|
87
88
|
isCollapsed: !__props.expandedItems[entry.id],
|
|
88
|
-
isLoading: false,
|
|
89
89
|
layout: __props.options.layout,
|
|
90
90
|
moreThanOneTag: __props.entries.filter(isTag).length > 1,
|
|
91
91
|
tag: entry
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TraversedEntry.vue.script.js","names":[],"sources":["../../../../src/components/Content/Operations/TraversedEntry.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ClientOptionGroup } from '@scalar/api-client/blocks/operation-code-sample'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\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 type { MergedSecuritySchemes } from '@scalar/workspace-store/request-example'\nimport type {\n TraversedEntry,\n TraversedModels,\n TraversedOperation,\n TraversedSchema,\n TraversedTag,\n TraversedWebhook,\n} from '@scalar/workspace-store/schemas/navigation'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport Model from '@/components/Content/Models/Model.vue'\nimport ModelTag from '@/components/Content/Models/ModelTag.vue'\nimport { Tag } from '@/components/Content/Tags'\nimport Lazy from '@/components/Lazy/Lazy.vue'\nimport { SectionContainer } from '@/components/Section'\nimport { Operation } from '@/features/Operation'\n\nconst {\n level = 0,\n clientOptions,\n document,\n authStore,\n entries,\n} = defineProps<{\n /** The auth store */\n authStore: AuthStore\n /** The level of depth */\n level?: number\n /** Traversed entries to render */\n entries: TraversedEntry[]\n /** The document object */\n document: OpenApiDocument\n /** The http client options for the dropdown */\n clientOptions: ClientOptionGroup[]\n /** The subset of the configuration object required for the operation component */\n options: Pick<\n ApiReferenceConfigurationRaw,\n | 'expandAllResponses'\n | 'hideTestRequestButton'\n | 'layout'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n | 'showOperationId'\n | 'hideModels'\n | 'modelsSectionLabel'\n >\n /** Currently selected server for the document */\n selectedServer: ServerObject | null\n /** The merged security schemes for the document and the authentication configuration */\n securitySchemes: MergedSecuritySchemes\n /** Currently selected http client for the document */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Used to determine if an entry is collapsed */\n expandedItems: Record<string, boolean>\n /** The event bus for the handling all events. */\n eventBus: WorkspaceEventBus\n}>()\n\n/**\n * Type guards for different entry types\n */\nconst isTagGroup = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: true } =>\n entry['type'] === 'tag' && entry.isGroup === true\n\nconst isTag = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: false } =>\n entry['type'] === 'tag' && !isTagGroup(entry) && entry.id !== 'models'\n\nconst isOperation = (entry: TraversedEntry): entry is TraversedOperation =>\n entry['type'] === 'operation'\n\nconst isWebhook = (entry: TraversedEntry): entry is TraversedWebhook =>\n entry['type'] === 'webhook'\n\n/** Models are special form of tag entry */\nconst isModelsTag = (entry: TraversedEntry): entry is TraversedModels =>\n entry['type'] === 'models'\n\nconst isModel = (entry: TraversedEntry): entry is TraversedSchema =>\n entry['type'] === 'model'\n\nfunction getPathValue(entry: TraversedOperation | TraversedWebhook) {\n return isWebhook(entry)\n ? document.webhooks?.[entry.name]\n : document.paths?.[entry.path]\n}\n</script>\n\n<template>\n <!-- The key must be joined with the layout to force a re-render when the layout changes -->\n <!-- Without this we get a timing issue where the lazy bus is reset and the element is not rendered -->\n <Lazy\n v-for=\"entry in entries\"\n :id=\"entry.id\"\n :key=\"`${entry.id}-${options.layout}`\"\n :expanded=\"!!expandedItems[entry.id]\">\n <!-- Operation or Webhook -->\n <SectionContainer\n v-if=\"isOperation(entry) || isWebhook(entry)\"\n :omit=\"level !== 0\">\n <Operation\n :id=\"entry.id\"\n :authStore\n :clientOptions\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :isWebhook=\"isWebhook(entry)\"\n :method=\"entry.method\"\n :options=\"options\"\n :path=\"isWebhook(entry) ? entry.name : entry.path\"\n :pathValue=\"getPathValue(entry)\"\n :securitySchemes=\"securitySchemes\"\n :selectedClient=\"selectedClient\"\n :server=\"selectedServer\" />\n </SectionContainer>\n\n <!-- Webhook Group, Tag or Tag Group (only in classic layout) -->\n <Tag\n v-else-if=\"\n isTag(entry) || (isTagGroup(entry) && options.layout === 'classic')\n \"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :
|
|
1
|
+
{"version":3,"file":"TraversedEntry.vue.script.js","names":[],"sources":["../../../../src/components/Content/Operations/TraversedEntry.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ClientOptionGroup } from '@scalar/api-client/blocks/operation-code-sample'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedPathItem } from '@scalar/workspace-store/helpers/for-each-path-item-operation'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { MergedSecuritySchemes } from '@scalar/workspace-store/request-example'\nimport type {\n TraversedEntry,\n TraversedModels,\n TraversedOperation,\n TraversedSchema,\n TraversedTag,\n TraversedWebhook,\n} from '@scalar/workspace-store/schemas/navigation'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport Model from '@/components/Content/Models/Model.vue'\nimport ModelTag from '@/components/Content/Models/ModelTag.vue'\nimport { Tag } from '@/components/Content/Tags'\nimport Lazy from '@/components/Lazy/Lazy.vue'\nimport { SectionContainer } from '@/components/Section'\nimport { Operation } from '@/features/Operation'\n\nconst {\n level = 0,\n clientOptions,\n document,\n authStore,\n entries,\n} = defineProps<{\n /** The auth store */\n authStore: AuthStore\n /** The level of depth */\n level?: number\n /** Traversed entries to render */\n entries: TraversedEntry[]\n /** The document object */\n document: OpenApiDocument\n /** The http client options for the dropdown */\n clientOptions: ClientOptionGroup[]\n /** The subset of the configuration object required for the operation component */\n options: Pick<\n ApiReferenceConfigurationRaw,\n | 'expandAllResponses'\n | 'hideTestRequestButton'\n | 'layout'\n | 'orderRequiredPropertiesFirst'\n | 'orderSchemaPropertiesBy'\n | 'expandAllSchemaProperties'\n | 'showOperationId'\n | 'hideModels'\n | 'modelsSectionLabel'\n >\n /** Currently selected server for the document */\n selectedServer: ServerObject | null\n /** The merged security schemes for the document and the authentication configuration */\n securitySchemes: MergedSecuritySchemes\n /** Currently selected http client for the document */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Used to determine if an entry is collapsed */\n expandedItems: Record<string, boolean>\n /** The event bus for the handling all events. */\n eventBus: WorkspaceEventBus\n}>()\n\n/**\n * Type guards for different entry types\n */\nconst isTagGroup = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: true } =>\n entry['type'] === 'tag' && entry.isGroup === true\n\nconst isTag = (\n entry: TraversedEntry,\n): entry is TraversedTag & { isGroup: false } =>\n entry['type'] === 'tag' && !isTagGroup(entry) && entry.id !== 'models'\n\nconst isOperation = (entry: TraversedEntry): entry is TraversedOperation =>\n entry['type'] === 'operation'\n\nconst isWebhook = (entry: TraversedEntry): entry is TraversedWebhook =>\n entry['type'] === 'webhook'\n\n/** Models are special form of tag entry */\nconst isModelsTag = (entry: TraversedEntry): entry is TraversedModels =>\n entry['type'] === 'models'\n\nconst isModel = (entry: TraversedEntry): entry is TraversedSchema =>\n entry['type'] === 'model'\n\nfunction getPathValue(entry: TraversedOperation | TraversedWebhook) {\n return isWebhook(entry)\n ? getResolvedPathItem(document.webhooks?.[entry.name])\n : getResolvedPathItem(document.paths?.[entry.path])\n}\n</script>\n\n<template>\n <!-- The key must be joined with the layout to force a re-render when the layout changes -->\n <!-- Without this we get a timing issue where the lazy bus is reset and the element is not rendered -->\n <Lazy\n v-for=\"entry in entries\"\n :id=\"entry.id\"\n :key=\"`${entry.id}-${options.layout}`\"\n :expanded=\"!!expandedItems[entry.id]\">\n <!-- Operation or Webhook -->\n <SectionContainer\n v-if=\"isOperation(entry) || isWebhook(entry)\"\n :omit=\"level !== 0\">\n <Operation\n :id=\"entry.id\"\n :authStore\n :clientOptions\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :isWebhook=\"isWebhook(entry)\"\n :method=\"entry.method\"\n :options=\"options\"\n :path=\"isWebhook(entry) ? entry.name : entry.path\"\n :pathValue=\"getPathValue(entry)\"\n :securitySchemes=\"securitySchemes\"\n :selectedClient=\"selectedClient\"\n :server=\"selectedServer\" />\n </SectionContainer>\n\n <!-- Webhook Group, Tag or Tag Group (only in classic layout) -->\n <Tag\n v-else-if=\"\n isTag(entry) || (isTagGroup(entry) && options.layout === 'classic')\n \"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :layout=\"options.layout\"\n :moreThanOneTag=\"entries.filter(isTag).length > 1\"\n :tag=\"entry\">\n <template v-if=\"'children' in entry && entry.children?.length\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children\"\n :eventBus\n :expandedItems\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </template>\n </Tag>\n\n <!-- Display tag group entries for modern layout (flattened) -->\n <!--\n The wrapping element carries the tag group id so it remains a scroll\n target. Modern layout flattens groups and renders no header of their own,\n so without this anchor, selecting a tag group (from search or the sidebar)\n would have nothing to scroll to.\n -->\n <div\n v-else-if=\"isTagGroup(entry)\"\n :id=\"entry.id\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children || []\"\n :eventBus\n :expandedItems\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </div>\n\n <!-- Models -->\n <ModelTag\n v-else-if=\"isModelsTag(entry) && document.components?.schemas\"\n :id=\"entry.id\"\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :layout=\"options.layout\"\n :modelsSectionLabel=\"options.modelsSectionLabel\">\n <TraversedEntry\n :authStore\n :clientOptions\n :document\n :entries=\"entry.children || []\"\n :eventBus\n :expandedItems=\"expandedItems\"\n :level=\"level + 1\"\n :options\n :securitySchemes\n :selectedClient\n :selectedServer>\n </TraversedEntry>\n </ModelTag>\n\n <Model\n v-else-if=\"isModel(entry) && document.components?.schemas?.[entry.name]\"\n :id=\"entry.id\"\n :document\n :eventBus\n :isCollapsed=\"!expandedItems[entry.id]\"\n :name=\"entry.name\"\n :options\n :schema=\"getResolvedRef(document.components.schemas[entry.name])\">\n </Model>\n </Lazy>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0EA,MAAM,cACJ,UAEA,MAAM,YAAY,SAAS,MAAM,YAAY;EAE/C,MAAM,SACJ,UAEA,MAAM,YAAY,SAAS,CAAC,WAAW,MAAM,IAAI,MAAM,OAAO;EAEhE,MAAM,eAAe,UACnB,MAAM,YAAY;EAEpB,MAAM,aAAa,UACjB,MAAM,YAAY;;EAGpB,MAAM,eAAe,UACnB,MAAM,YAAY;EAEpB,MAAM,WAAW,UACf,MAAM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1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Content/Schema/Schema.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Schema.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Content/Schema/Schema.vue"],"names":[],"mappings":"AAybA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACb,MAAM,8DAA8D,CAAA;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAWtE,KAAK,WAAW,GAAG;IACjB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,uBAAuB;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,kCAAkC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,+FAA+F;IAC/F,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,uCAAuC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,2BAA2B;IAC3B,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,iCAAiC;IACjC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,0EAA0E;IAC1E,OAAO,EAAE,aAAa,CAAA;IACtB,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AA6gBF,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 Schema_vue_vue_type_script_setup_true_lang_default from "./Schema.vue.script.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region src/components/Content/Schema/Schema.vue
|
|
5
|
-
var Schema_default = /* @__PURE__ */ _plugin_vue_export_helper_default(Schema_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var Schema_default = /* @__PURE__ */ _plugin_vue_export_helper_default(Schema_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-4d9df79c"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Schema_default as default };
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.vue.js","names":[],"sources":["../../../../src/components/Content/Schema/Schema.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarMarkdown } from '@scalar/components/markdown'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, inject, provide } from 'vue'\n\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\nimport ScreenReader from '@/components/ScreenReader.vue'\n\nimport { isEmptySchemaObject } from './helpers/is-empty-schema-object'\nimport { isTypeObject } from './helpers/is-type-object'\nimport { SCHEMA_ANCESTORS_SYMBOL } from './helpers/schema-cycle'\nimport SchemaHeading from './SchemaHeading.vue'\nimport SchemaObjectProperties from './SchemaObjectProperties.vue'\nimport SchemaProperty from './SchemaProperty.vue'\n\nconst {\n schema,\n level = 0,\n name,\n compact,\n noncollapsible = false,\n hideHeading,\n hideDescription = false,\n additionalProperties,\n discriminator,\n breadcrumb,\n hideModelNames = false,\n options,\n schemaContext,\n compositionPath,\n cycleKey,\n} = defineProps<{\n schema?: SchemaObject\n /** Track how deep we've gone */\n level?: number\n /* Show as a heading */\n name?: string\n /** A tighter layout with less borders and without a heading */\n compact?: boolean\n /** Shows a toggle to hide/show children */\n noncollapsible?: boolean\n /** Hide the heading */\n hideHeading?: boolean\n /** Hide the schema description */\n hideDescription?: boolean\n /** Show a special one way toggle for additional properties, also has a top border when open */\n additionalProperties?: boolean\n /** Hide model names in type display */\n hideModelNames?: boolean\n /** Discriminator object */\n discriminator?: DiscriminatorObject\n /** Breadcrumb for the schema */\n breadcrumb?: string[]\n /** Event bus emitting actions */\n eventBus: WorkspaceEventBus | null\n /** Move the options into a single prop so they are easy to pass around */\n options: SchemaOptions\n /** When \"requestBody\", composition dropdown 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 /**\n * Stable identity of this schema node, derived from its raw (unresolved)\n * value by the parent. Used to detect self-referential cycles. See\n * {@link getCycleKey}.\n */\n cycleKey?: unknown\n}>()\n\n/**\n * Cycle-safe `expandAllSchemaProperties`.\n *\n * We track ancestor schema keys along the current render path. A node is\n * treated as cyclic when its key is already present in the ancestor set, which\n * indicates that rendering has looped back onto a self-referential schema.\n *\n * This lets us default-expand finite branches while stopping automatic\n * expansion only at cycle boundaries, preventing infinite recursion.\n */\nconst ancestors = inject(SCHEMA_ANCESTORS_SYMBOL, undefined)\n\nconst isCyclic = computed(\n (): boolean => cycleKey != null && !!ancestors?.has(cycleKey),\n)\n\n// Re-provide the ancestor set augmented with this node so descendants can\n// detect cycles back to it. Built once at setup; a node's key is stable.\nconst childAncestors = new Set<unknown>(ancestors ?? [])\nif (cycleKey != null) {\n childAncestors.add(cycleKey)\n}\nprovide(SCHEMA_ANCESTORS_SYMBOL, childAncestors)\n\nconst shouldForceExpand = computed(\n (): boolean => !!options.expandAllSchemaProperties && !isCyclic.value,\n)\n\n/**\n * Determines whether to show the collapse/expand toggle button.\n * We hide the toggle for non-collapsible schemas and root-level schemas.\n */\nconst shouldShowToggle = computed((): boolean => !noncollapsible && level > 0)\n\n/**\n * Whether the disclosure starts expanded. Non-collapsible schemas are always\n * open. When `expandAllSchemaProperties` is enabled, finite branches start\n * expanded by default while cyclic branches remain collapsed to avoid recursion\n * loops.\n */\nconst defaultOpen = computed(\n (): boolean => noncollapsible || shouldForceExpand.value,\n)\n\n/** Gets the description to show for the schema */\nconst schemaDescription = computed(() => {\n if (hideDescription) {\n return null\n }\n\n // For the request body we want to show the base description or the first allOf schema description\n if (schema?.allOf && schema.allOf.length > 0 && name === 'Request Body') {\n return schema.description || schema.allOf[0]?.description || null\n }\n\n // Don't show description if there's no description or it's not a string\n if (!schema?.description || typeof schema.description !== 'string') {\n return null\n }\n\n // Don't show description for enum schemas (they have special handling)\n if (schema.enum) {\n return null\n }\n\n // Will be shown in the properties anyway\n if (\n !('properties' in schema) &&\n !('patternProperties' in schema) &&\n !('additionalProperties' in schema)\n ) {\n return null\n }\n\n // Return the schema's own description\n return schema.description\n})\n\n// Prevent click action if noncollapsible\nconst handleClick = (e: MouseEvent) => {\n if (noncollapsible) {\n e.stopPropagation()\n }\n}\n</script>\n<template>\n <Disclosure\n v-if=\"typeof schema === 'object' && Object.keys(schema).length\"\n v-slot=\"{ open }\"\n :defaultOpen=\"defaultOpen\">\n <div\n class=\"schema-card\"\n :class=\"[\n `schema-card--level-${level}`,\n { 'schema-card--compact': compact, 'schema-card--open': open },\n { 'border-t': additionalProperties && open },\n ]\">\n <!-- Schema description -->\n <div\n v-if=\"schemaDescription\"\n class=\"schema-card-description\">\n <ScalarMarkdown :value=\"schemaDescription\" />\n </div>\n <div\n v-if=\"isEmptySchemaObject(schema)\"\n class=\"pt-2\">\n Empty object\n </div>\n <div\n class=\"schema-properties\"\n :class=\"{\n 'schema-properties-open': open,\n }\">\n <!-- Toggle to collapse/expand long lists of properties -->\n <div\n v-if=\"additionalProperties\"\n v-show=\"!open\"\n class=\"schema-properties\">\n <DisclosureButton\n as=\"button\"\n class=\"schema-card-title schema-card-title--compact\"\n @click.capture=\"handleClick\">\n <ScalarIcon\n class=\"schema-card-title-icon\"\n icon=\"Add\"\n size=\"sm\" />\n Show additional properties\n <ScreenReader v-if=\"name\">for {{ name }}</ScreenReader>\n </DisclosureButton>\n </div>\n\n <DisclosureButton\n v-else-if=\"shouldShowToggle\"\n v-show=\"!hideHeading && !(noncollapsible && compact)\"\n :as=\"noncollapsible ? 'div' : 'button'\"\n class=\"schema-card-title\"\n :class=\"{ 'schema-card-title--compact': compact }\"\n :style=\"{\n top: `calc(var(--refs-viewport-offset) + calc(var(--schema-title-height) * ${level}))`,\n }\"\n @click.capture=\"handleClick\">\n <template v-if=\"compact\">\n <ScalarIcon\n class=\"schema-card-title-icon\"\n :class=\"{ 'schema-card-title-icon--open': open }\"\n icon=\"Add\"\n size=\"sm\" />\n <template v-if=\"open\">\n Hide {{ schema?.title ?? 'Child Attributes' }}\n </template>\n <template v-else>\n Show {{ schema?.title ?? 'Child Attributes' }}\n </template>\n <ScreenReader v-if=\"name\">for {{ name }}</ScreenReader>\n </template>\n <template v-else>\n <ScalarIcon\n class=\"schema-card-title-icon\"\n :class=\"{ 'schema-card-title-icon--open': open }\"\n icon=\"Add\"\n size=\"sm\" />\n <SchemaHeading\n :name=\"schema?.title ?? name\"\n :value=\"schema\" />\n </template>\n </DisclosureButton>\n <DisclosurePanel\n v-if=\"!additionalProperties || open\"\n as=\"ul\"\n :static=\"!shouldShowToggle\">\n <!-- Object properties -->\n <SchemaObjectProperties\n v-if=\"isTypeObject(schema)\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level=\"level + 1\"\n :options\n :schema\n :schemaContext=\"schemaContext\" />\n <!-- Not an object -->\n <template v-else>\n <SchemaProperty\n v-if=\"schema\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :options\n :schema\n :schemaContext=\"schemaContext\" />\n </template>\n </DisclosurePanel>\n </div>\n </div>\n </Disclosure>\n</template>\n<style scoped>\n.error {\n background-color: var(--scalar-color-red);\n}\n.schema-card {\n font-size: var(--scalar-font-size-4);\n color: var(--scalar-color-1);\n}\n.schema-card-title {\n height: var(--schema-title-height);\n\n padding: 6px 8px;\n\n display: flex;\n align-items: center;\n gap: 4px;\n\n color: var(--scalar-color-2);\n font-weight: var(--scalar-semibold);\n font-size: var(--scalar-mini);\n border-bottom: var(--scalar-border-width) solid transparent;\n}\nbutton.schema-card-title {\n cursor: pointer;\n}\nbutton.schema-card-title:hover {\n color: var(--scalar-color-1);\n}\n.schema-card-title-icon--open {\n transform: rotate(45deg);\n}\n.schema-properties-open > .schema-card-title {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n.schema-properties-open > .schema-properties {\n width: fit-content;\n}\n.schema-card-description {\n color: var(--scalar-color-2);\n}\n.schema-card-description + .schema-properties {\n width: fit-content;\n}\n.schema-card-description + .schema-properties {\n margin-top: 8px;\n}\n.schema-card--level-0:nth-of-type(1)\n > .schema-card-description:has(+ .schema-properties) {\n margin-bottom: -8px;\n padding-bottom: 8px;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n.schema-card--level-0\n ~ .schema-card--level-0\n > .schema-card-description:has(+ .schema-properties) {\n padding-top: 8px;\n}\n\n.schema-properties-open.schema-properties,\n.schema-properties-open > .schema-card--open {\n width: 100%;\n}\n.schema-properties {\n display: flex;\n flex-direction: column;\n\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius-lg);\n width: fit-content;\n}\n.schema-properties-name {\n width: 100%;\n}\n.schema-properties .schema-properties {\n border-radius: 13.5px;\n}\n.schema-properties .schema-properties.schema-properties-open {\n border-radius: var(--scalar-radius-lg);\n}\n.schema-properties-open {\n width: 100%;\n}\n.schema-card--compact {\n align-self: flex-start;\n}\n.schema-card--compact.schema-card--open {\n align-self: initial;\n}\n.schema-card-title--compact {\n color: var(--scalar-color-2);\n padding: 6px 10px 6px 8px;\n height: auto;\n border-bottom: none;\n}\n.schema-card-title--compact > .schema-card-title-icon {\n margin: 0;\n}\n.schema-card-title--compact > .schema-card-title-icon--open {\n transform: rotate(45deg);\n}\n.schema-properties-open > .schema-card-title--compact {\n position: static;\n}\n.property--level-0\n > .schema-properties\n > .schema-card--level-0\n > .schema-properties {\n border: none;\n}\n.property--level-0\n .schema-card--level-0:not(.schema-card--compact)\n .property--level-1 {\n padding: 0 0 8px;\n}\n:not(.composition-panel)\n > .schema-card--compact.schema-card--level-0\n > .schema-properties {\n border: none;\n}\n:deep(.schema-card-description) p {\n font-size: var(--scalar-small, var(--scalar-paragraph));\n color: var(--scalar-color-2);\n margin-bottom: 0;\n display: block;\n margin-bottom: 6px;\n}\n.children .schema-card-description:first-of-type {\n padding-top: 0;\n}\n</style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Schema.vue.js","names":[],"sources":["../../../../src/components/Content/Schema/Schema.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarMarkdown } from '@scalar/components/markdown'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, inject, provide } from 'vue'\n\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\nimport ScreenReader from '@/components/ScreenReader.vue'\nimport { scrollTargetId } from '@/helpers/lazy-bus'\n\nimport { isEmptySchemaObject } from './helpers/is-empty-schema-object'\nimport { isTypeObject } from './helpers/is-type-object'\nimport { SCHEMA_ANCESTORS_SYMBOL } from './helpers/schema-cycle'\nimport SchemaHeading from './SchemaHeading.vue'\nimport SchemaObjectProperties from './SchemaObjectProperties.vue'\nimport SchemaProperty from './SchemaProperty.vue'\n\nconst {\n schema,\n level = 0,\n name,\n compact,\n noncollapsible = false,\n hideHeading,\n hideDescription = false,\n additionalProperties,\n discriminator,\n breadcrumb,\n hideModelNames = false,\n options,\n schemaContext,\n compositionPath,\n cycleKey,\n} = defineProps<{\n schema?: SchemaObject\n /** Track how deep we've gone */\n level?: number\n /* Show as a heading */\n name?: string\n /** A tighter layout with less borders and without a heading */\n compact?: boolean\n /** Shows a toggle to hide/show children */\n noncollapsible?: boolean\n /** Hide the heading */\n hideHeading?: boolean\n /** Hide the schema description */\n hideDescription?: boolean\n /** Show a special one way toggle for additional properties, also has a top border when open */\n additionalProperties?: boolean\n /** Hide model names in type display */\n hideModelNames?: boolean\n /** Discriminator object */\n discriminator?: DiscriminatorObject\n /** Breadcrumb for the schema */\n breadcrumb?: string[]\n /** Event bus emitting actions */\n eventBus: WorkspaceEventBus | null\n /** Move the options into a single prop so they are easy to pass around */\n options: SchemaOptions\n /** When \"requestBody\", composition dropdown 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 /**\n * Stable identity of this schema node, derived from its raw (unresolved)\n * value by the parent. Used to detect self-referential cycles. See\n * {@link getCycleKey}.\n */\n cycleKey?: unknown\n}>()\n\n/**\n * Cycle-safe `expandAllSchemaProperties`.\n *\n * We track ancestor schema keys along the current render path. A node is\n * treated as cyclic when its key is already present in the ancestor set, which\n * indicates that rendering has looped back onto a self-referential schema.\n *\n * This lets us default-expand finite branches while stopping automatic\n * expansion only at cycle boundaries, preventing infinite recursion.\n */\nconst ancestors = inject(SCHEMA_ANCESTORS_SYMBOL, undefined)\n\nconst isCyclic = computed(\n (): boolean => cycleKey != null && !!ancestors?.has(cycleKey),\n)\n\n// Re-provide the ancestor set augmented with this node so descendants can\n// detect cycles back to it. Built once at setup; a node's key is stable.\nconst childAncestors = new Set<unknown>(ancestors ?? [])\nif (cycleKey != null) {\n childAncestors.add(cycleKey)\n}\nprovide(SCHEMA_ANCESTORS_SYMBOL, childAncestors)\n\nconst shouldForceExpand = computed(\n (): boolean => !!options.expandAllSchemaProperties && !isCyclic.value,\n)\n\n/**\n * Determines whether to show the collapse/expand toggle button.\n * We hide the toggle for non-collapsible schemas and root-level schemas.\n */\nconst shouldShowToggle = computed((): boolean => !noncollapsible && level > 0)\n\n/**\n * Whether this schema sits on the path to the current anchor/scroll target.\n *\n * Property anchors are dot-joined breadcrumbs, so every disclosure that wraps\n * the target has a breadcrumb that is a prefix of the target id. Opening those\n * disclosures is what makes deep links to collapsed (hidden) properties work\n * without forcing every schema open via `expandAllSchemaProperties`.\n */\nconst isOnScrollTargetPath = computed((): boolean => {\n if (!breadcrumb?.length) {\n return false\n }\n const path = breadcrumb.join('.')\n const target = scrollTargetId.value\n return target === path || target.startsWith(`${path}.`)\n})\n\n/**\n * Whether the disclosure starts expanded. Non-collapsible schemas are always\n * open. When `expandAllSchemaProperties` is enabled, finite branches start\n * expanded by default while cyclic branches remain collapsed to avoid recursion\n * loops. We also open any disclosure on the path to the current scroll target so\n * deep links resolve even when the property is collapsed.\n *\n * Note: the Disclosure only reads this at mount, so it expands collapsed\n * properties on a fresh navigation (the schema mounts after the target is set),\n * not when the target changes for an already-mounted disclosure.\n */\nconst defaultOpen = computed(\n (): boolean =>\n noncollapsible || shouldForceExpand.value || isOnScrollTargetPath.value,\n)\n\n/** Gets the description to show for the schema */\nconst schemaDescription = computed(() => {\n if (hideDescription) {\n return null\n }\n\n // For the request body we want to show the base description or the first allOf schema description\n if (schema?.allOf && schema.allOf.length > 0 && name === 'Request Body') {\n return schema.description || schema.allOf[0]?.description || null\n }\n\n // Don't show description if there's no description or it's not a string\n if (!schema?.description || typeof schema.description !== 'string') {\n return null\n }\n\n // Don't show description for enum schemas (they have special handling)\n if (schema.enum) {\n return null\n }\n\n // Will be shown in the properties anyway\n if (\n !('properties' in schema) &&\n !('patternProperties' in schema) &&\n !('additionalProperties' in schema)\n ) {\n return null\n }\n\n // Return the schema's own description\n return schema.description\n})\n\n// Prevent click action if noncollapsible\nconst handleClick = (e: MouseEvent) => {\n if (noncollapsible) {\n e.stopPropagation()\n }\n}\n</script>\n<template>\n <Disclosure\n v-if=\"typeof schema === 'object' && Object.keys(schema).length\"\n v-slot=\"{ open }\"\n :defaultOpen=\"defaultOpen\">\n <div\n class=\"schema-card\"\n :class=\"[\n `schema-card--level-${level}`,\n { 'schema-card--compact': compact, 'schema-card--open': open },\n { 'border-t': additionalProperties && open },\n ]\">\n <!-- Schema description -->\n <div\n v-if=\"schemaDescription\"\n class=\"schema-card-description\">\n <ScalarMarkdown :value=\"schemaDescription\" />\n </div>\n <div\n v-if=\"isEmptySchemaObject(schema)\"\n class=\"pt-2\">\n Empty object\n </div>\n <div\n class=\"schema-properties\"\n :class=\"{\n 'schema-properties-open': open,\n }\">\n <!-- Toggle to collapse/expand long lists of properties -->\n <div\n v-if=\"additionalProperties\"\n v-show=\"!open\"\n class=\"schema-properties\">\n <DisclosureButton\n as=\"button\"\n class=\"schema-card-title schema-card-title--compact\"\n @click.capture=\"handleClick\">\n <ScalarIcon\n class=\"schema-card-title-icon\"\n icon=\"Add\"\n size=\"sm\" />\n Show additional properties\n <ScreenReader v-if=\"name\">for {{ name }}</ScreenReader>\n </DisclosureButton>\n </div>\n\n <DisclosureButton\n v-else-if=\"shouldShowToggle\"\n v-show=\"!hideHeading && !(noncollapsible && compact)\"\n :as=\"noncollapsible ? 'div' : 'button'\"\n class=\"schema-card-title\"\n :class=\"{ 'schema-card-title--compact': compact }\"\n :style=\"{\n top: `calc(var(--refs-viewport-offset) + calc(var(--schema-title-height) * ${level}))`,\n }\"\n @click.capture=\"handleClick\">\n <template v-if=\"compact\">\n <ScalarIcon\n class=\"schema-card-title-icon\"\n :class=\"{ 'schema-card-title-icon--open': open }\"\n icon=\"Add\"\n size=\"sm\" />\n <template v-if=\"open\">\n Hide {{ schema?.title ?? 'Child Attributes' }}\n </template>\n <template v-else>\n Show {{ schema?.title ?? 'Child Attributes' }}\n </template>\n <ScreenReader v-if=\"name\">for {{ name }}</ScreenReader>\n </template>\n <template v-else>\n <ScalarIcon\n class=\"schema-card-title-icon\"\n :class=\"{ 'schema-card-title-icon--open': open }\"\n icon=\"Add\"\n size=\"sm\" />\n <SchemaHeading\n :name=\"schema?.title ?? name\"\n :value=\"schema\" />\n </template>\n </DisclosureButton>\n <DisclosurePanel\n v-if=\"!additionalProperties || open\"\n as=\"ul\"\n :static=\"!shouldShowToggle\">\n <!-- Object properties -->\n <SchemaObjectProperties\n v-if=\"isTypeObject(schema)\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level=\"level + 1\"\n :options\n :schema\n :schemaContext=\"schemaContext\" />\n <!-- Not an object -->\n <template v-else>\n <SchemaProperty\n v-if=\"schema\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :options\n :schema\n :schemaContext=\"schemaContext\" />\n </template>\n </DisclosurePanel>\n </div>\n </div>\n </Disclosure>\n</template>\n<style scoped>\n.error {\n background-color: var(--scalar-color-red);\n}\n.schema-card {\n font-size: var(--scalar-font-size-4);\n color: var(--scalar-color-1);\n}\n.schema-card-title {\n height: var(--schema-title-height);\n\n padding: 6px 8px;\n\n display: flex;\n align-items: center;\n gap: 4px;\n\n color: var(--scalar-color-2);\n font-weight: var(--scalar-semibold);\n font-size: var(--scalar-mini);\n border-bottom: var(--scalar-border-width) solid transparent;\n}\nbutton.schema-card-title {\n cursor: pointer;\n}\nbutton.schema-card-title:hover {\n color: var(--scalar-color-1);\n}\n.schema-card-title-icon--open {\n transform: rotate(45deg);\n}\n.schema-properties-open > .schema-card-title {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n.schema-properties-open > .schema-properties {\n width: fit-content;\n}\n.schema-card-description {\n color: var(--scalar-color-2);\n}\n.schema-card-description + .schema-properties {\n width: fit-content;\n}\n.schema-card-description + .schema-properties {\n margin-top: 8px;\n}\n.schema-card--level-0:nth-of-type(1)\n > .schema-card-description:has(+ .schema-properties) {\n margin-bottom: -8px;\n padding-bottom: 8px;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n.schema-card--level-0\n ~ .schema-card--level-0\n > .schema-card-description:has(+ .schema-properties) {\n padding-top: 8px;\n}\n\n.schema-properties-open.schema-properties,\n.schema-properties-open > .schema-card--open {\n width: 100%;\n}\n.schema-properties {\n display: flex;\n flex-direction: column;\n\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius-lg);\n width: fit-content;\n}\n.schema-properties-name {\n width: 100%;\n}\n.schema-properties .schema-properties {\n border-radius: 13.5px;\n}\n.schema-properties .schema-properties.schema-properties-open {\n border-radius: var(--scalar-radius-lg);\n}\n.schema-properties-open {\n width: 100%;\n}\n.schema-card--compact {\n align-self: flex-start;\n}\n.schema-card--compact.schema-card--open {\n align-self: initial;\n}\n.schema-card-title--compact {\n color: var(--scalar-color-2);\n padding: 6px 10px 6px 8px;\n height: auto;\n border-bottom: none;\n}\n.schema-card-title--compact > .schema-card-title-icon {\n margin: 0;\n}\n.schema-card-title--compact > .schema-card-title-icon--open {\n transform: rotate(45deg);\n}\n.schema-properties-open > .schema-card-title--compact {\n position: static;\n}\n.property--level-0\n > .schema-properties\n > .schema-card--level-0\n > .schema-properties {\n border: none;\n}\n.property--level-0\n .schema-card--level-0:not(.schema-card--compact)\n .property--level-1 {\n padding: 0 0 8px;\n}\n:not(.composition-panel)\n > .schema-card--compact.schema-card--level-0\n > .schema-properties {\n border: none;\n}\n:deep(.schema-card-description) p {\n font-size: var(--scalar-small, var(--scalar-paragraph));\n color: var(--scalar-color-2);\n margin-bottom: 0;\n display: block;\n margin-bottom: 6px;\n}\n.children .schema-card-description:first-of-type {\n padding-top: 0;\n}\n</style>\n"],"mappings":""}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ScreenReader_default from "../../ScreenReader.vue.js";
|
|
2
|
+
import { scrollTargetId } from "../../../helpers/lazy-bus.js";
|
|
2
3
|
import { isTypeObject } from "./helpers/is-type-object.js";
|
|
3
4
|
import { isEmptySchemaObject } from "./helpers/is-empty-schema-object.js";
|
|
4
5
|
import { SCHEMA_ANCESTORS_SYMBOL } from "./helpers/schema-cycle.js";
|
|
@@ -74,12 +75,31 @@ var Schema_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
74
75
|
*/
|
|
75
76
|
const shouldShowToggle = computed(() => !__props.noncollapsible && __props.level > 0);
|
|
76
77
|
/**
|
|
78
|
+
* Whether this schema sits on the path to the current anchor/scroll target.
|
|
79
|
+
*
|
|
80
|
+
* Property anchors are dot-joined breadcrumbs, so every disclosure that wraps
|
|
81
|
+
* the target has a breadcrumb that is a prefix of the target id. Opening those
|
|
82
|
+
* disclosures is what makes deep links to collapsed (hidden) properties work
|
|
83
|
+
* without forcing every schema open via `expandAllSchemaProperties`.
|
|
84
|
+
*/
|
|
85
|
+
const isOnScrollTargetPath = computed(() => {
|
|
86
|
+
if (!__props.breadcrumb?.length) return false;
|
|
87
|
+
const path = __props.breadcrumb.join(".");
|
|
88
|
+
const target = scrollTargetId.value;
|
|
89
|
+
return target === path || target.startsWith(`${path}.`);
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
77
92
|
* Whether the disclosure starts expanded. Non-collapsible schemas are always
|
|
78
93
|
* open. When `expandAllSchemaProperties` is enabled, finite branches start
|
|
79
94
|
* expanded by default while cyclic branches remain collapsed to avoid recursion
|
|
80
|
-
* loops.
|
|
95
|
+
* loops. We also open any disclosure on the path to the current scroll target so
|
|
96
|
+
* deep links resolve even when the property is collapsed.
|
|
97
|
+
*
|
|
98
|
+
* Note: the Disclosure only reads this at mount, so it expands collapsed
|
|
99
|
+
* properties on a fresh navigation (the schema mounts after the target is set),
|
|
100
|
+
* not when the target changes for an already-mounted disclosure.
|
|
81
101
|
*/
|
|
82
|
-
const defaultOpen = computed(() => __props.noncollapsible || shouldForceExpand.value);
|
|
102
|
+
const defaultOpen = computed(() => __props.noncollapsible || shouldForceExpand.value || isOnScrollTargetPath.value);
|
|
83
103
|
/** Gets the description to show for the schema */
|
|
84
104
|
const schemaDescription = computed(() => {
|
|
85
105
|
if (__props.hideDescription) return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.vue.script.js","names":[],"sources":["../../../../src/components/Content/Schema/Schema.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarMarkdown } from '@scalar/components/markdown'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, inject, provide } from 'vue'\n\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\nimport ScreenReader from '@/components/ScreenReader.vue'\n\nimport { isEmptySchemaObject } from './helpers/is-empty-schema-object'\nimport { isTypeObject } from './helpers/is-type-object'\nimport { SCHEMA_ANCESTORS_SYMBOL } from './helpers/schema-cycle'\nimport SchemaHeading from './SchemaHeading.vue'\nimport SchemaObjectProperties from './SchemaObjectProperties.vue'\nimport SchemaProperty from './SchemaProperty.vue'\n\nconst {\n schema,\n level = 0,\n name,\n compact,\n noncollapsible = false,\n hideHeading,\n hideDescription = false,\n additionalProperties,\n discriminator,\n breadcrumb,\n hideModelNames = false,\n options,\n schemaContext,\n compositionPath,\n cycleKey,\n} = defineProps<{\n schema?: SchemaObject\n /** Track how deep we've gone */\n level?: number\n /* Show as a heading */\n name?: string\n /** A tighter layout with less borders and without a heading */\n compact?: boolean\n /** Shows a toggle to hide/show children */\n noncollapsible?: boolean\n /** Hide the heading */\n hideHeading?: boolean\n /** Hide the schema description */\n hideDescription?: boolean\n /** Show a special one way toggle for additional properties, also has a top border when open */\n additionalProperties?: boolean\n /** Hide model names in type display */\n hideModelNames?: boolean\n /** Discriminator object */\n discriminator?: DiscriminatorObject\n /** Breadcrumb for the schema */\n breadcrumb?: string[]\n /** Event bus emitting actions */\n eventBus: WorkspaceEventBus | null\n /** Move the options into a single prop so they are easy to pass around */\n options: SchemaOptions\n /** When \"requestBody\", composition dropdown 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 /**\n * Stable identity of this schema node, derived from its raw (unresolved)\n * value by the parent. Used to detect self-referential cycles. See\n * {@link getCycleKey}.\n */\n cycleKey?: unknown\n}>()\n\n/**\n * Cycle-safe `expandAllSchemaProperties`.\n *\n * We track ancestor schema keys along the current render path. A node is\n * treated as cyclic when its key is already present in the ancestor set, which\n * indicates that rendering has looped back onto a self-referential schema.\n *\n * This lets us default-expand finite branches while stopping automatic\n * expansion only at cycle boundaries, preventing infinite recursion.\n */\nconst ancestors = inject(SCHEMA_ANCESTORS_SYMBOL, undefined)\n\nconst isCyclic = computed(\n (): boolean => cycleKey != null && !!ancestors?.has(cycleKey),\n)\n\n// Re-provide the ancestor set augmented with this node so descendants can\n// detect cycles back to it. Built once at setup; a node's key is stable.\nconst childAncestors = new Set<unknown>(ancestors ?? [])\nif (cycleKey != null) {\n childAncestors.add(cycleKey)\n}\nprovide(SCHEMA_ANCESTORS_SYMBOL, childAncestors)\n\nconst shouldForceExpand = computed(\n (): boolean => !!options.expandAllSchemaProperties && !isCyclic.value,\n)\n\n/**\n * Determines whether to show the collapse/expand toggle button.\n * We hide the toggle for non-collapsible schemas and root-level schemas.\n */\nconst shouldShowToggle = computed((): boolean => !noncollapsible && level > 0)\n\n/**\n * Whether the disclosure starts expanded. Non-collapsible schemas are always\n * open. When `expandAllSchemaProperties` is enabled, finite branches start\n * expanded by default while cyclic branches remain collapsed to avoid recursion\n * loops.\n */\nconst defaultOpen = computed(\n (): boolean => noncollapsible || shouldForceExpand.value,\n)\n\n/** Gets the description to show for the schema */\nconst schemaDescription = computed(() => {\n if (hideDescription) {\n return null\n }\n\n // For the request body we want to show the base description or the first allOf schema description\n if (schema?.allOf && schema.allOf.length > 0 && name === 'Request Body') {\n return schema.description || schema.allOf[0]?.description || null\n }\n\n // Don't show description if there's no description or it's not a string\n if (!schema?.description || typeof schema.description !== 'string') {\n return null\n }\n\n // Don't show description for enum schemas (they have special handling)\n if (schema.enum) {\n return null\n }\n\n // Will be shown in the properties anyway\n if (\n !('properties' in schema) &&\n !('patternProperties' in schema) &&\n !('additionalProperties' in schema)\n ) {\n return null\n }\n\n // Return the schema's own description\n return schema.description\n})\n\n// Prevent click action if noncollapsible\nconst handleClick = (e: MouseEvent) => {\n if (noncollapsible) {\n e.stopPropagation()\n }\n}\n</script>\n<template>\n <Disclosure\n v-if=\"typeof schema === 'object' && Object.keys(schema).length\"\n v-slot=\"{ open }\"\n :defaultOpen=\"defaultOpen\">\n <div\n class=\"schema-card\"\n :class=\"[\n `schema-card--level-${level}`,\n { 'schema-card--compact': compact, 'schema-card--open': open },\n { 'border-t': additionalProperties && open },\n ]\">\n <!-- Schema description -->\n <div\n v-if=\"schemaDescription\"\n class=\"schema-card-description\">\n <ScalarMarkdown :value=\"schemaDescription\" />\n </div>\n <div\n v-if=\"isEmptySchemaObject(schema)\"\n class=\"pt-2\">\n Empty object\n </div>\n <div\n class=\"schema-properties\"\n :class=\"{\n 'schema-properties-open': open,\n }\">\n <!-- Toggle to collapse/expand long lists of properties -->\n <div\n v-if=\"additionalProperties\"\n v-show=\"!open\"\n class=\"schema-properties\">\n <DisclosureButton\n as=\"button\"\n class=\"schema-card-title schema-card-title--compact\"\n @click.capture=\"handleClick\">\n <ScalarIcon\n class=\"schema-card-title-icon\"\n icon=\"Add\"\n size=\"sm\" />\n Show additional properties\n <ScreenReader v-if=\"name\">for {{ name }}</ScreenReader>\n </DisclosureButton>\n </div>\n\n <DisclosureButton\n v-else-if=\"shouldShowToggle\"\n v-show=\"!hideHeading && !(noncollapsible && compact)\"\n :as=\"noncollapsible ? 'div' : 'button'\"\n class=\"schema-card-title\"\n :class=\"{ 'schema-card-title--compact': compact }\"\n :style=\"{\n top: `calc(var(--refs-viewport-offset) + calc(var(--schema-title-height) * ${level}))`,\n }\"\n @click.capture=\"handleClick\">\n <template v-if=\"compact\">\n <ScalarIcon\n class=\"schema-card-title-icon\"\n :class=\"{ 'schema-card-title-icon--open': open }\"\n icon=\"Add\"\n size=\"sm\" />\n <template v-if=\"open\">\n Hide {{ schema?.title ?? 'Child Attributes' }}\n </template>\n <template v-else>\n Show {{ schema?.title ?? 'Child Attributes' }}\n </template>\n <ScreenReader v-if=\"name\">for {{ name }}</ScreenReader>\n </template>\n <template v-else>\n <ScalarIcon\n class=\"schema-card-title-icon\"\n :class=\"{ 'schema-card-title-icon--open': open }\"\n icon=\"Add\"\n size=\"sm\" />\n <SchemaHeading\n :name=\"schema?.title ?? name\"\n :value=\"schema\" />\n </template>\n </DisclosureButton>\n <DisclosurePanel\n v-if=\"!additionalProperties || open\"\n as=\"ul\"\n :static=\"!shouldShowToggle\">\n <!-- Object properties -->\n <SchemaObjectProperties\n v-if=\"isTypeObject(schema)\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level=\"level + 1\"\n :options\n :schema\n :schemaContext=\"schemaContext\" />\n <!-- Not an object -->\n <template v-else>\n <SchemaProperty\n v-if=\"schema\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :options\n :schema\n :schemaContext=\"schemaContext\" />\n </template>\n </DisclosurePanel>\n </div>\n </div>\n </Disclosure>\n</template>\n<style scoped>\n.error {\n background-color: var(--scalar-color-red);\n}\n.schema-card {\n font-size: var(--scalar-font-size-4);\n color: var(--scalar-color-1);\n}\n.schema-card-title {\n height: var(--schema-title-height);\n\n padding: 6px 8px;\n\n display: flex;\n align-items: center;\n gap: 4px;\n\n color: var(--scalar-color-2);\n font-weight: var(--scalar-semibold);\n font-size: var(--scalar-mini);\n border-bottom: var(--scalar-border-width) solid transparent;\n}\nbutton.schema-card-title {\n cursor: pointer;\n}\nbutton.schema-card-title:hover {\n color: var(--scalar-color-1);\n}\n.schema-card-title-icon--open {\n transform: rotate(45deg);\n}\n.schema-properties-open > .schema-card-title {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n.schema-properties-open > .schema-properties {\n width: fit-content;\n}\n.schema-card-description {\n color: var(--scalar-color-2);\n}\n.schema-card-description + .schema-properties {\n width: fit-content;\n}\n.schema-card-description + .schema-properties {\n margin-top: 8px;\n}\n.schema-card--level-0:nth-of-type(1)\n > .schema-card-description:has(+ .schema-properties) {\n margin-bottom: -8px;\n padding-bottom: 8px;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n.schema-card--level-0\n ~ .schema-card--level-0\n > .schema-card-description:has(+ .schema-properties) {\n padding-top: 8px;\n}\n\n.schema-properties-open.schema-properties,\n.schema-properties-open > .schema-card--open {\n width: 100%;\n}\n.schema-properties {\n display: flex;\n flex-direction: column;\n\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius-lg);\n width: fit-content;\n}\n.schema-properties-name {\n width: 100%;\n}\n.schema-properties .schema-properties {\n border-radius: 13.5px;\n}\n.schema-properties .schema-properties.schema-properties-open {\n border-radius: var(--scalar-radius-lg);\n}\n.schema-properties-open {\n width: 100%;\n}\n.schema-card--compact {\n align-self: flex-start;\n}\n.schema-card--compact.schema-card--open {\n align-self: initial;\n}\n.schema-card-title--compact {\n color: var(--scalar-color-2);\n padding: 6px 10px 6px 8px;\n height: auto;\n border-bottom: none;\n}\n.schema-card-title--compact > .schema-card-title-icon {\n margin: 0;\n}\n.schema-card-title--compact > .schema-card-title-icon--open {\n transform: rotate(45deg);\n}\n.schema-properties-open > .schema-card-title--compact {\n position: static;\n}\n.property--level-0\n > .schema-properties\n > .schema-card--level-0\n > .schema-properties {\n border: none;\n}\n.property--level-0\n .schema-card--level-0:not(.schema-card--compact)\n .property--level-1 {\n padding: 0 0 8px;\n}\n:not(.composition-panel)\n > .schema-card--compact.schema-card--level-0\n > .schema-properties {\n border: none;\n}\n:deep(.schema-card-description) p {\n font-size: var(--scalar-small, var(--scalar-paragraph));\n color: var(--scalar-color-2);\n margin-bottom: 0;\n display: block;\n margin-bottom: 6px;\n}\n.children .schema-card-description:first-of-type {\n padding-top: 0;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqFA,MAAM,YAAY,OAAO,yBAAyB,KAAA,EAAS;EAE3D,MAAM,WAAW,eACA,QAAA,YAAY,QAAQ,CAAC,CAAC,WAAW,IAAI,QAAA,SAAS,CAC/D;EAIA,MAAM,iBAAiB,IAAI,IAAa,aAAa,EAAE,CAAA;AACvD,MAAI,QAAA,YAAY,KACd,gBAAe,IAAI,QAAA,SAAQ;AAE7B,UAAQ,yBAAyB,eAAc;EAE/C,MAAM,oBAAoB,eACT,CAAC,CAAC,QAAA,QAAQ,6BAA6B,CAAC,SAAS,MAClE;;;;;EAMA,MAAM,mBAAmB,eAAwB,CAAC,QAAA,kBAAkB,QAAA,QAAQ,EAAC;;;;;;;EAQ7E,MAAM,cAAc,eACH,QAAA,kBAAkB,kBAAkB,MACrD;;EAGA,MAAM,oBAAoB,eAAe;AACvC,OAAI,QAAA,gBACF,QAAO;AAIT,OAAI,QAAA,QAAQ,SAAS,QAAA,OAAO,MAAM,SAAS,KAAK,QAAA,SAAS,eACvD,QAAO,QAA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AAQ,SAAS,QAAA;OACvB,OAAO,QAAA;;;;;;;oBA9BH,QAAA,eAAW,EAAM,QAAA,kBAAkB,QAAA,SAAO,CAAA,CAAA,GAAA,mBAAA,IAAA,KAAA,EAAA,CAkC5C,QAAA,wBAAwB,QAAA,WAAA,EADjC,YAiCkB,MAAA,gBAAA,EAAA;;MA/BhB,IAAG;MACF,QAAM,CAAG,iBAAA;;6BAcyB,CAX3B,MAAA,aAAY,CAAC,QAAA,OAAM,IAAA,WAAA,EAD3B,YAYmC,gCAAA;;OAVhC,YAAA,QAAA;OACA,SAAA,QAAA;OACA,iBAAiB,QAAA;OACjB,eAAA,QAAA;OACA,UAAU,QAAA;OACV,aAAA,QAAA;OACA,gBAAA,QAAA;OACA,OAAO,QAAA,QAAK;OACZ,SAAA,QAAA;OACA,QAAA,QAAA;OACA,eAAe,QAAA;;;;;;;;;;;;;0BAElB,mBAaW,UAAA,EAAA,KAAA,GAAA,EAAA,CAXD,QAAA,UAAA,WAAA,EADR,YAWmC,wBAAA;;OAThC,YAAA,QAAA;OACA,SAAA,QAAA;OACA,iBAAiB,QAAA;OACjB,UAAU,QAAA;OACV,aAAA,QAAA;OACA,gBAAA,QAAA;OACA,OAAA,QAAA;OACA,SAAA,QAAA;OACA,QAAA,QAAA;OACA,eAAe,QAAA"}
|
|
1
|
+
{"version":3,"file":"Schema.vue.script.js","names":[],"sources":["../../../../src/components/Content/Schema/Schema.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarMarkdown } from '@scalar/components/markdown'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, inject, provide } from 'vue'\n\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\nimport ScreenReader from '@/components/ScreenReader.vue'\nimport { scrollTargetId } from '@/helpers/lazy-bus'\n\nimport { isEmptySchemaObject } from './helpers/is-empty-schema-object'\nimport { isTypeObject } from './helpers/is-type-object'\nimport { SCHEMA_ANCESTORS_SYMBOL } from './helpers/schema-cycle'\nimport SchemaHeading from './SchemaHeading.vue'\nimport SchemaObjectProperties from './SchemaObjectProperties.vue'\nimport SchemaProperty from './SchemaProperty.vue'\n\nconst {\n schema,\n level = 0,\n name,\n compact,\n noncollapsible = false,\n hideHeading,\n hideDescription = false,\n additionalProperties,\n discriminator,\n breadcrumb,\n hideModelNames = false,\n options,\n schemaContext,\n compositionPath,\n cycleKey,\n} = defineProps<{\n schema?: SchemaObject\n /** Track how deep we've gone */\n level?: number\n /* Show as a heading */\n name?: string\n /** A tighter layout with less borders and without a heading */\n compact?: boolean\n /** Shows a toggle to hide/show children */\n noncollapsible?: boolean\n /** Hide the heading */\n hideHeading?: boolean\n /** Hide the schema description */\n hideDescription?: boolean\n /** Show a special one way toggle for additional properties, also has a top border when open */\n additionalProperties?: boolean\n /** Hide model names in type display */\n hideModelNames?: boolean\n /** Discriminator object */\n discriminator?: DiscriminatorObject\n /** Breadcrumb for the schema */\n breadcrumb?: string[]\n /** Event bus emitting actions */\n eventBus: WorkspaceEventBus | null\n /** Move the options into a single prop so they are easy to pass around */\n options: SchemaOptions\n /** When \"requestBody\", composition dropdown 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 /**\n * Stable identity of this schema node, derived from its raw (unresolved)\n * value by the parent. Used to detect self-referential cycles. See\n * {@link getCycleKey}.\n */\n cycleKey?: unknown\n}>()\n\n/**\n * Cycle-safe `expandAllSchemaProperties`.\n *\n * We track ancestor schema keys along the current render path. A node is\n * treated as cyclic when its key is already present in the ancestor set, which\n * indicates that rendering has looped back onto a self-referential schema.\n *\n * This lets us default-expand finite branches while stopping automatic\n * expansion only at cycle boundaries, preventing infinite recursion.\n */\nconst ancestors = inject(SCHEMA_ANCESTORS_SYMBOL, undefined)\n\nconst isCyclic = computed(\n (): boolean => cycleKey != null && !!ancestors?.has(cycleKey),\n)\n\n// Re-provide the ancestor set augmented with this node so descendants can\n// detect cycles back to it. Built once at setup; a node's key is stable.\nconst childAncestors = new Set<unknown>(ancestors ?? [])\nif (cycleKey != null) {\n childAncestors.add(cycleKey)\n}\nprovide(SCHEMA_ANCESTORS_SYMBOL, childAncestors)\n\nconst shouldForceExpand = computed(\n (): boolean => !!options.expandAllSchemaProperties && !isCyclic.value,\n)\n\n/**\n * Determines whether to show the collapse/expand toggle button.\n * We hide the toggle for non-collapsible schemas and root-level schemas.\n */\nconst shouldShowToggle = computed((): boolean => !noncollapsible && level > 0)\n\n/**\n * Whether this schema sits on the path to the current anchor/scroll target.\n *\n * Property anchors are dot-joined breadcrumbs, so every disclosure that wraps\n * the target has a breadcrumb that is a prefix of the target id. Opening those\n * disclosures is what makes deep links to collapsed (hidden) properties work\n * without forcing every schema open via `expandAllSchemaProperties`.\n */\nconst isOnScrollTargetPath = computed((): boolean => {\n if (!breadcrumb?.length) {\n return false\n }\n const path = breadcrumb.join('.')\n const target = scrollTargetId.value\n return target === path || target.startsWith(`${path}.`)\n})\n\n/**\n * Whether the disclosure starts expanded. Non-collapsible schemas are always\n * open. When `expandAllSchemaProperties` is enabled, finite branches start\n * expanded by default while cyclic branches remain collapsed to avoid recursion\n * loops. We also open any disclosure on the path to the current scroll target so\n * deep links resolve even when the property is collapsed.\n *\n * Note: the Disclosure only reads this at mount, so it expands collapsed\n * properties on a fresh navigation (the schema mounts after the target is set),\n * not when the target changes for an already-mounted disclosure.\n */\nconst defaultOpen = computed(\n (): boolean =>\n noncollapsible || shouldForceExpand.value || isOnScrollTargetPath.value,\n)\n\n/** Gets the description to show for the schema */\nconst schemaDescription = computed(() => {\n if (hideDescription) {\n return null\n }\n\n // For the request body we want to show the base description or the first allOf schema description\n if (schema?.allOf && schema.allOf.length > 0 && name === 'Request Body') {\n return schema.description || schema.allOf[0]?.description || null\n }\n\n // Don't show description if there's no description or it's not a string\n if (!schema?.description || typeof schema.description !== 'string') {\n return null\n }\n\n // Don't show description for enum schemas (they have special handling)\n if (schema.enum) {\n return null\n }\n\n // Will be shown in the properties anyway\n if (\n !('properties' in schema) &&\n !('patternProperties' in schema) &&\n !('additionalProperties' in schema)\n ) {\n return null\n }\n\n // Return the schema's own description\n return schema.description\n})\n\n// Prevent click action if noncollapsible\nconst handleClick = (e: MouseEvent) => {\n if (noncollapsible) {\n e.stopPropagation()\n }\n}\n</script>\n<template>\n <Disclosure\n v-if=\"typeof schema === 'object' && Object.keys(schema).length\"\n v-slot=\"{ open }\"\n :defaultOpen=\"defaultOpen\">\n <div\n class=\"schema-card\"\n :class=\"[\n `schema-card--level-${level}`,\n { 'schema-card--compact': compact, 'schema-card--open': open },\n { 'border-t': additionalProperties && open },\n ]\">\n <!-- Schema description -->\n <div\n v-if=\"schemaDescription\"\n class=\"schema-card-description\">\n <ScalarMarkdown :value=\"schemaDescription\" />\n </div>\n <div\n v-if=\"isEmptySchemaObject(schema)\"\n class=\"pt-2\">\n Empty object\n </div>\n <div\n class=\"schema-properties\"\n :class=\"{\n 'schema-properties-open': open,\n }\">\n <!-- Toggle to collapse/expand long lists of properties -->\n <div\n v-if=\"additionalProperties\"\n v-show=\"!open\"\n class=\"schema-properties\">\n <DisclosureButton\n as=\"button\"\n class=\"schema-card-title schema-card-title--compact\"\n @click.capture=\"handleClick\">\n <ScalarIcon\n class=\"schema-card-title-icon\"\n icon=\"Add\"\n size=\"sm\" />\n Show additional properties\n <ScreenReader v-if=\"name\">for {{ name }}</ScreenReader>\n </DisclosureButton>\n </div>\n\n <DisclosureButton\n v-else-if=\"shouldShowToggle\"\n v-show=\"!hideHeading && !(noncollapsible && compact)\"\n :as=\"noncollapsible ? 'div' : 'button'\"\n class=\"schema-card-title\"\n :class=\"{ 'schema-card-title--compact': compact }\"\n :style=\"{\n top: `calc(var(--refs-viewport-offset) + calc(var(--schema-title-height) * ${level}))`,\n }\"\n @click.capture=\"handleClick\">\n <template v-if=\"compact\">\n <ScalarIcon\n class=\"schema-card-title-icon\"\n :class=\"{ 'schema-card-title-icon--open': open }\"\n icon=\"Add\"\n size=\"sm\" />\n <template v-if=\"open\">\n Hide {{ schema?.title ?? 'Child Attributes' }}\n </template>\n <template v-else>\n Show {{ schema?.title ?? 'Child Attributes' }}\n </template>\n <ScreenReader v-if=\"name\">for {{ name }}</ScreenReader>\n </template>\n <template v-else>\n <ScalarIcon\n class=\"schema-card-title-icon\"\n :class=\"{ 'schema-card-title-icon--open': open }\"\n icon=\"Add\"\n size=\"sm\" />\n <SchemaHeading\n :name=\"schema?.title ?? name\"\n :value=\"schema\" />\n </template>\n </DisclosureButton>\n <DisclosurePanel\n v-if=\"!additionalProperties || open\"\n as=\"ul\"\n :static=\"!shouldShowToggle\">\n <!-- Object properties -->\n <SchemaObjectProperties\n v-if=\"isTypeObject(schema)\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level=\"level + 1\"\n :options\n :schema\n :schemaContext=\"schemaContext\" />\n <!-- Not an object -->\n <template v-else>\n <SchemaProperty\n v-if=\"schema\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :options\n :schema\n :schemaContext=\"schemaContext\" />\n </template>\n </DisclosurePanel>\n </div>\n </div>\n </Disclosure>\n</template>\n<style scoped>\n.error {\n background-color: var(--scalar-color-red);\n}\n.schema-card {\n font-size: var(--scalar-font-size-4);\n color: var(--scalar-color-1);\n}\n.schema-card-title {\n height: var(--schema-title-height);\n\n padding: 6px 8px;\n\n display: flex;\n align-items: center;\n gap: 4px;\n\n color: var(--scalar-color-2);\n font-weight: var(--scalar-semibold);\n font-size: var(--scalar-mini);\n border-bottom: var(--scalar-border-width) solid transparent;\n}\nbutton.schema-card-title {\n cursor: pointer;\n}\nbutton.schema-card-title:hover {\n color: var(--scalar-color-1);\n}\n.schema-card-title-icon--open {\n transform: rotate(45deg);\n}\n.schema-properties-open > .schema-card-title {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n.schema-properties-open > .schema-properties {\n width: fit-content;\n}\n.schema-card-description {\n color: var(--scalar-color-2);\n}\n.schema-card-description + .schema-properties {\n width: fit-content;\n}\n.schema-card-description + .schema-properties {\n margin-top: 8px;\n}\n.schema-card--level-0:nth-of-type(1)\n > .schema-card-description:has(+ .schema-properties) {\n margin-bottom: -8px;\n padding-bottom: 8px;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n.schema-card--level-0\n ~ .schema-card--level-0\n > .schema-card-description:has(+ .schema-properties) {\n padding-top: 8px;\n}\n\n.schema-properties-open.schema-properties,\n.schema-properties-open > .schema-card--open {\n width: 100%;\n}\n.schema-properties {\n display: flex;\n flex-direction: column;\n\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius-lg);\n width: fit-content;\n}\n.schema-properties-name {\n width: 100%;\n}\n.schema-properties .schema-properties {\n border-radius: 13.5px;\n}\n.schema-properties .schema-properties.schema-properties-open {\n border-radius: var(--scalar-radius-lg);\n}\n.schema-properties-open {\n width: 100%;\n}\n.schema-card--compact {\n align-self: flex-start;\n}\n.schema-card--compact.schema-card--open {\n align-self: initial;\n}\n.schema-card-title--compact {\n color: var(--scalar-color-2);\n padding: 6px 10px 6px 8px;\n height: auto;\n border-bottom: none;\n}\n.schema-card-title--compact > .schema-card-title-icon {\n margin: 0;\n}\n.schema-card-title--compact > .schema-card-title-icon--open {\n transform: rotate(45deg);\n}\n.schema-properties-open > .schema-card-title--compact {\n position: static;\n}\n.property--level-0\n > .schema-properties\n > .schema-card--level-0\n > .schema-properties {\n border: none;\n}\n.property--level-0\n .schema-card--level-0:not(.schema-card--compact)\n .property--level-1 {\n padding: 0 0 8px;\n}\n:not(.composition-panel)\n > .schema-card--compact.schema-card--level-0\n > .schema-properties {\n border: none;\n}\n:deep(.schema-card-description) p {\n font-size: var(--scalar-small, var(--scalar-paragraph));\n color: var(--scalar-color-2);\n margin-bottom: 0;\n display: block;\n margin-bottom: 6px;\n}\n.children .schema-card-description:first-of-type {\n padding-top: 0;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsFA,MAAM,YAAY,OAAO,yBAAyB,KAAA,EAAS;EAE3D,MAAM,WAAW,eACA,QAAA,YAAY,QAAQ,CAAC,CAAC,WAAW,IAAI,QAAA,SAAS,CAC/D;EAIA,MAAM,iBAAiB,IAAI,IAAa,aAAa,EAAE,CAAA;AACvD,MAAI,QAAA,YAAY,KACd,gBAAe,IAAI,QAAA,SAAQ;AAE7B,UAAQ,yBAAyB,eAAc;EAE/C,MAAM,oBAAoB,eACT,CAAC,CAAC,QAAA,QAAQ,6BAA6B,CAAC,SAAS,MAClE;;;;;EAMA,MAAM,mBAAmB,eAAwB,CAAC,QAAA,kBAAkB,QAAA,QAAQ,EAAC;;;;;;;;;EAU7E,MAAM,uBAAuB,eAAwB;AACnD,OAAI,CAAC,QAAA,YAAY,OACf,QAAO;GAET,MAAM,OAAO,QAAA,WAAW,KAAK,IAAG;GAChC,MAAM,SAAS,eAAe;AAC9B,UAAO,WAAW,QAAQ,OAAO,WAAW,GAAG,KAAK,GAAE;IACvD;;;;;;;;;;;;EAaD,MAAM,cAAc,eAEhB,QAAA,kBAAkB,kBAAkB,SAAS,qBAAqB,MACtE;;EAGA,MAAM,oBAAoB,eAAe;AACvC,OAAI,QAAA,gBACF,QAAO;AAIT,OAAI,QAAA,QAAQ,SAAS,QAAA,OAAO,MAAM,SAAS,KAAK,QAAA,SAAS,eACvD,QAAO,QAAA,OAAO,eAAe,QAAA,OAAO,MAAM,IAAI,eAAe;AAI/D,OAAI,CAAC,QAAA,QAAQ,eA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AkB,QAAA,SAAO,CAAA,CAAA,GAAA,mBAAA,IAAA,KAAA,EAAA,CAkC5C,QAAA,wBAAwB,QAAA,WAAA,EADjC,YAiCkB,MAAA,gBAAA,EAAA;;MA/BhB,IAAG;MACF,QAAM,CAAG,iBAAA;;6BAcyB,CAX3B,MAAA,aAAY,CAAC,QAAA,OAAM,IAAA,WAAA,EAD3B,YAYmC,gCAAA;;OAVhC,YAAA,QAAA;OACA,SAAA,QAAA;OACA,iBAAiB,QAAA;OACjB,eAAA,QAAA;OACA,UAAU,QAAA;OACV,aAAA,QAAA;OACA,gBAAA,QAAA;OACA,OAAO,QAAA,QAAK;OACZ,SAAA,QAAA;OACA,QAAA,QAAA;OACA,eAAe,QAAA;;;;;;;;;;;;;0BAElB,mBAaW,UAAA,EAAA,KAAA,GAAA,EAAA,CAXD,QAAA,UAAA,WAAA,EADR,YAWmC,wBAAA;;OAThC,YAAA,QAAA;OACA,SAAA,QAAA;OACA,iBAAiB,QAAA;OACjB,UAAU,QAAA;OACV,aAAA,QAAA;OACA,gBAAA,QAAA;OACA,OAAA,QAAA;OACA,SAAA,QAAA;OACA,QAAA,QAAA;OACA,eAAe,QAAA"}
|
|
@@ -2,12 +2,6 @@ import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
|
2
2
|
import type { DiscriminatorObject, SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
3
3
|
import { type Component } from 'vue';
|
|
4
4
|
import type { SchemaOptions } from '../../../components/Content/Schema/types';
|
|
5
|
-
/**
|
|
6
|
-
* Note: We're taking in a prop called `value` which should be a JSON Schema.
|
|
7
|
-
*
|
|
8
|
-
* We're using `optimizeValueForDisplay` to merge null types in compositions (anyOf, allOf, oneOf, not).
|
|
9
|
-
* So you should basically use the optimizedValue everywhere in the component.
|
|
10
|
-
*/
|
|
11
5
|
type __VLS_Props = {
|
|
12
6
|
is?: string | Component;
|
|
13
7
|
schema: SchemaObject | undefined;
|
|
@@ -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":"AA0gBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACb,MAAM,8DAA8D,CAAA;AAErE,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,KAAK,CAAA;AAK9C,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,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;AAuiBJ,QAAA,MAAM,YAAY;WA/jBN,MAAM;cAEH,OAAO;aACR,OAAO;oBAGA,OAAO;6EA4jB1B,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-e16b102d"]]);
|
|
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 { 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 { 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\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 /** 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/** Simplified composition with `null` type. */\nconst optimizedValue = computed(() => optimizeValueForDisplay(props.schema))\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/** Checks if array items have complex structure */\nconst hasComplexArrayItemsComputed = computed(() =>\n hasComplexArrayItems(optimizedValue.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 return (\n isTypeObject(value) &&\n ('properties' in value || 'additionalProperties' in value)\n )\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 * When the property already renders the description, avoid repeating it in the nested object schema card.\n */\nconst objectSchemaForChildren = computed(() => {\n const value = optimizedValue.value\n if (!value || !displayDescription.value || !('description' in value)) {\n return value\n }\n\n const { description: _description, ...schemaWithoutDescription } = value\n return schemaWithoutDescription 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/** Get resolved array items for rendering */\nconst resolvedArrayItems = computed(() => {\n const value = optimizedValue.value\n if (!value || !isArraySchema(value) || typeof value.items !== 'object') {\n return undefined\n }\n return resolve.schema(value.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 :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 { 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 { 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 /** 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/** Simplified composition with `null` type. */\nconst optimizedValue = computed(() => optimizeValueForDisplay(props.schema))\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/** Checks if array items have complex structure */\nconst hasComplexArrayItemsComputed = computed(() =>\n hasComplexArrayItems(optimizedValue.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 return (\n isTypeObject(value) &&\n ('properties' in value || 'additionalProperties' in value)\n )\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 * When the property already renders the description, avoid repeating it in the nested object schema card.\n */\nconst objectSchemaForChildren = computed(() => {\n const value = optimizedValue.value\n if (!value || !displayDescription.value || !('description' in value)) {\n return value\n }\n\n const { description: _description, ...schemaWithoutDescription } = value\n return schemaWithoutDescription 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.\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 = optimizedValue.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 :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":""}
|