@scalar/api-reference 1.57.5 → 1.58.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 +37 -0
- package/dist/browser/chunks/AgentScalarChatInterface-DIIVMX31.js +27 -0
- package/dist/browser/chunks/ScalarTextInput.vue-DDsQgpOo.js +27 -0
- package/dist/browser/chunks/basic-shape-diamond.svg-BTEOT1FL.js +15 -0
- package/dist/browser/chunks/basic-shape-hexagon.svg-BSPzaCgF.js +15 -0
- package/dist/browser/chunks/basic-shape-primary-circle-ellipse-round.svg-DKmZ8UUU.js +15 -0
- package/dist/browser/chunks/basic-shape-primary-square-rectangle.svg-n2YRykHD.js +15 -0
- package/dist/browser/chunks/basic-shape-shield.svg-Bec9cJDA.js +15 -0
- package/dist/browser/chunks/browser-67K6wmG9.js +129 -0
- package/dist/browser/chunks/computer-device-desktop-monitor.svg-m6j893Hb.js +15 -0
- package/dist/browser/chunks/computer-device-desktop.svg-Dk1VVO7k.js +15 -0
- package/dist/browser/chunks/computer-device-laptop.svg-BNGVUCYS.js +15 -0
- package/dist/browser/chunks/computer-device-mobile-phone-android-samsung-back.svg-CC4UUTFw.js +15 -0
- package/dist/browser/chunks/computer-device-mobile-phone-android-samsung.svg-D8ExpMpL.js +15 -0
- package/dist/browser/chunks/computer-device-mobile-phone-iphone-x-back.svg-CLm7sgMM.js +15 -0
- package/dist/browser/chunks/computer-device-mobile-phone-iphone-x.svg-Xrttg6_7.js +15 -0
- package/dist/browser/chunks/computer-device-mobile-tablet-touch.svg-DQ2oTvOG.js +15 -0
- package/dist/browser/chunks/computer-device-mobile-tablet.svg-DCr0XlRc.js +15 -0
- package/dist/browser/chunks/computer-device-network-ethernet-cat6.svg-AK9l0iOl.js +15 -0
- package/dist/browser/chunks/computer-device-network-lan-www.svg-gUIdFBlE.js +15 -0
- package/dist/browser/chunks/computer-device-network-wifi-connection.svg-Be-EMm4e.js +15 -0
- package/dist/browser/chunks/computer-device-network-wifi-router.svg-Dc2VzyqK.js +15 -0
- package/dist/browser/chunks/ecology-science-erlenmeyer-flask.svg-DHgy7Jfd.js +15 -0
- package/dist/browser/chunks/image-flash-lightning.svg-EETR_y1q.js +15 -0
- package/dist/browser/chunks/image-picture-flower.svg-DN1AYzJU.js +15 -0
- package/dist/browser/chunks/interface-alert-exclamation-diamond.svg-C5NozMV_.js +15 -0
- package/dist/browser/chunks/interface-alert-exclamation-triangle-warning.svg-DaAg2fF5.js +15 -0
- package/dist/browser/chunks/interface-alert-information-circle.svg-ckkkt9Mv.js +15 -0
- package/dist/browser/chunks/interface-award-crown.svg-pjvn9hY-.js +15 -0
- package/dist/browser/chunks/interface-bookmark-tag.svg-r2r-lQq4.js +15 -0
- package/dist/browser/chunks/interface-bookmark.svg-BK9HKQBT.js +15 -0
- package/dist/browser/chunks/interface-calendar-date-one.svg-DNnF0M1I.js +15 -0
- package/dist/browser/chunks/interface-content-book-open-pages.svg-CQj_w9Vp.js +15 -0
- package/dist/browser/chunks/interface-content-book-page.svg-DppoeJRe.js +15 -0
- package/dist/browser/chunks/interface-content-file.svg-CvcD7OiY.js +15 -0
- package/dist/browser/chunks/interface-content-folder.svg-BmtS5I9A.js +15 -0
- package/dist/browser/chunks/interface-copy-clipboard.svg-Be6EI50X.js +15 -0
- package/dist/browser/chunks/interface-edit-attachment.svg-G5TKzpWX.js +15 -0
- package/dist/browser/chunks/interface-edit-binocular.svg-jzL-DvGB.js +15 -0
- package/dist/browser/chunks/interface-edit-magic-wand.svg-BOTlymvp.js +15 -0
- package/dist/browser/chunks/interface-edit-tool-paint-roller.svg-s9dwryx7.js +15 -0
- package/dist/browser/chunks/interface-edit-tool-pencil.svg-C7v0dbB3.js +15 -0
- package/dist/browser/chunks/interface-favorite-award.svg-CYHUgUG0.js +15 -0
- package/dist/browser/chunks/interface-favorite-flag.svg-C10zlKOb.js +15 -0
- package/dist/browser/chunks/interface-favorite-heart.svg-eoduXxlz.js +15 -0
- package/dist/browser/chunks/interface-favorite-star.svg-BSmxJetr.js +15 -0
- package/dist/browser/chunks/interface-favorite-stars-sparkles.svg-JTFLj3Ls.js +15 -0
- package/dist/browser/chunks/interface-hierarchy-flowchart.svg-Cg_Wy0kN.js +15 -0
- package/dist/browser/chunks/interface-home-house.svg-DytoGRnv.js +15 -0
- package/dist/browser/chunks/interface-hyperlink.svg-CuEfmmQI.js +15 -0
- package/dist/browser/chunks/interface-lighting-brightness.svg-DSK0h_Pa.js +15 -0
- package/dist/browser/chunks/interface-lock-closed.svg-Cn6TaLYv.js +15 -0
- package/dist/browser/chunks/interface-lock-open-unlock.svg-CVkG5-9W.js +15 -0
- package/dist/browser/chunks/interface-login-key.svg-y-cwwXjN.js +15 -0
- package/dist/browser/chunks/interface-search.svg-S-puVFJB.js +15 -0
- package/dist/browser/chunks/interface-setting-cog.svg-CTH4_lLg.js +15 -0
- package/dist/browser/chunks/interface-share-megaphone-bullhorn.svg-Pbp39MyC.js +15 -0
- package/dist/browser/chunks/interface-share-rocket.svg-BgCsIRZO.js +15 -0
- package/dist/browser/chunks/interface-share-satellite.svg-DAMN9d5G.js +15 -0
- package/dist/browser/chunks/interface-share-space-ship.svg-Dt-Mejxk.js +15 -0
- package/dist/browser/chunks/interface-share.svg-vFYTXSti.js +15 -0
- package/dist/browser/chunks/interface-signal-square.svg-DNG4LpAe.js +15 -0
- package/dist/browser/chunks/interface-time-clock-circle.svg-Bpz-nLxo.js +15 -0
- package/dist/browser/chunks/interface-time-hour-glass.svg-D7agfKsH.js +15 -0
- package/dist/browser/chunks/interface-users-multiple.svg-CkPJBBnG.js +15 -0
- package/dist/browser/chunks/interface-weather-moon.svg-CaTZFMPO.js +15 -0
- package/dist/browser/chunks/mail-chat-bubble-square.svg-DC8RIihp.js +15 -0
- package/dist/browser/chunks/mail-send-email-paper-airplane.svg-D8OLs9jz.js +15 -0
- package/dist/browser/chunks/mail-send-envelope.svg-CV33h5Sx.js +15 -0
- package/dist/browser/chunks/modal-BA6EnLMO.js +15 -0
- package/dist/browser/chunks/modal-DW-P3H1k.js +66 -0
- package/dist/browser/chunks/money-cashier-receipt.svg-CJL8C2gs.js +15 -0
- package/dist/browser/chunks/money-currency-dollar-pay.svg-VdBplCTx.js +15 -0
- package/dist/browser/chunks/money-graph-arrow-increase.svg-DcRov3zk.js +15 -0
- package/dist/browser/chunks/money-graph-bar-chart-increase.svg-Cc7KxjX-.js +15 -0
- package/dist/browser/chunks/nature-ecology-leaf.svg-DR3cTZxt.js +15 -0
- package/dist/browser/chunks/phone-telephone.svg-DyY0gUlk.js +15 -0
- package/dist/browser/chunks/programming-bug.svg-BHLT-Qhp.js +15 -0
- package/dist/browser/chunks/programming-cloud.svg-B6YW33ba.js +15 -0
- package/dist/browser/chunks/programming-computer-database-server.svg-B6o5Sdn-.js +15 -0
- package/dist/browser/chunks/programming-computer-database.svg-Cl7OVtpJ.js +15 -0
- package/dist/browser/chunks/programming-module-four-layout.svg-BQrerL1x.js +15 -0
- package/dist/browser/chunks/programming-module-three.svg-B2KTQzBM.js +15 -0
- package/dist/browser/chunks/programming-module.svg-CiID7kPm.js +15 -0
- package/dist/browser/chunks/programming-script-code.svg-D1M5rtkN.js +15 -0
- package/dist/browser/chunks/runtime-core.esm-bundler-Byrbbu5Q.js +17 -0
- package/dist/browser/chunks/shopping-cart.svg-BEegiIR9.js +15 -0
- package/dist/browser/chunks/shopping-gift-present.svg-BUHwuLix.js +15 -0
- package/dist/browser/chunks/shopping-shipping-box-parcel-package.svg-D6fxWdYx.js +15 -0
- package/dist/browser/chunks/tag-new-circle.svg-jsg1bGs0.js +15 -0
- package/dist/browser/chunks/travel-map-earth-globe.svg-ClbMiU-f.js +15 -0
- package/dist/browser/chunks/vendor-Ad2vN5Ro.js +333 -0
- package/dist/browser/standalone.esm.js +1852 -0
- package/dist/browser/standalone.js +253 -255
- 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 +61 -26
- package/dist/components/ApiReference.vue.script.js.map +1 -1
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.d.ts +16 -0
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.d.ts.map +1 -0
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.js +7 -0
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.js.map +1 -0
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.script.js +164 -0
- package/dist/components/Content/AsyncApi/AsyncApiTraversedEntry.vue.script.js.map +1 -0
- package/dist/components/Content/AsyncApi/Channel.vue.d.ts +14 -0
- package/dist/components/Content/AsyncApi/Channel.vue.d.ts.map +1 -0
- package/dist/components/Content/AsyncApi/Channel.vue.js +9 -0
- package/dist/components/Content/AsyncApi/Channel.vue.js.map +1 -0
- package/dist/components/Content/AsyncApi/Channel.vue.script.js +108 -0
- package/dist/components/Content/AsyncApi/Channel.vue.script.js.map +1 -0
- package/dist/components/Content/AsyncApi/index.d.ts +2 -0
- package/dist/components/Content/AsyncApi/index.d.ts.map +1 -0
- package/dist/components/Content/Content.vue.d.ts +3 -3
- 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 +19 -3
- package/dist/components/Content/Content.vue.script.js.map +1 -1
- package/dist/components/Content/Models/ModelTag.vue.d.ts +2 -0
- package/dist/components/Content/Models/ModelTag.vue.d.ts.map +1 -1
- package/dist/components/Content/Models/ModelTag.vue.js.map +1 -1
- package/dist/components/Content/Models/ModelTag.vue.script.js +11 -12
- package/dist/components/Content/Models/ModelTag.vue.script.js.map +1 -1
- package/dist/components/Content/Operations/TraversedEntry.vue.d.ts +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 +4 -2
- package/dist/components/Content/Operations/TraversedEntry.vue.script.js.map +1 -1
- package/dist/components/Content/Schema/SchemaObjectProperties.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/SchemaObjectProperties.vue.js.map +1 -1
- package/dist/components/Content/Schema/SchemaObjectProperties.vue.script.js +4 -6
- package/dist/components/Content/Schema/SchemaObjectProperties.vue.script.js.map +1 -1
- package/dist/components/Content/Schema/helpers/merge-all-of-schemas.d.ts +2 -1
- package/dist/components/Content/Schema/helpers/merge-all-of-schemas.d.ts.map +1 -1
- package/dist/components/Content/Schema/helpers/merge-all-of-schemas.js +40 -25
- package/dist/components/Content/Schema/helpers/merge-all-of-schemas.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/features/Search/components/SearchButton.vue.d.ts +4 -1
- package/dist/features/Search/components/SearchButton.vue.d.ts.map +1 -1
- package/dist/features/Search/components/SearchButton.vue.js.map +1 -1
- package/dist/features/Search/components/SearchButton.vue.script.js +7 -8
- package/dist/features/Search/components/SearchButton.vue.script.js.map +1 -1
- package/dist/features/Search/components/SearchModal.vue.d.ts +4 -1
- package/dist/features/Search/components/SearchModal.vue.d.ts.map +1 -1
- package/dist/features/Search/components/SearchModal.vue.js +1 -1
- package/dist/features/Search/components/SearchModal.vue.js.map +1 -1
- package/dist/features/Search/components/SearchModal.vue.script.js +5 -2
- package/dist/features/Search/components/SearchModal.vue.script.js.map +1 -1
- package/dist/features/Search/components/SearchResult.vue.d.ts +2 -0
- package/dist/features/Search/components/SearchResult.vue.d.ts.map +1 -1
- package/dist/features/Search/components/SearchResult.vue.js.map +1 -1
- package/dist/features/Search/components/SearchResult.vue.script.js +8 -6
- package/dist/features/Search/components/SearchResult.vue.script.js.map +1 -1
- package/dist/features/Search/helpers/create-search-index.d.ts +9 -1
- package/dist/features/Search/helpers/create-search-index.d.ts.map +1 -1
- package/dist/features/Search/helpers/create-search-index.js +27 -8
- package/dist/features/Search/helpers/create-search-index.js.map +1 -1
- package/dist/features/Search/hooks/useSearchIndex.d.ts +4 -2
- package/dist/features/Search/hooks/useSearchIndex.d.ts.map +1 -1
- package/dist/features/Search/hooks/useSearchIndex.js +4 -3
- package/dist/features/Search/hooks/useSearchIndex.js.map +1 -1
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigLayoutOptions.vue.d.ts +1 -1
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigLayoutOptions.vue.d.ts.map +1 -1
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigLayoutOptions.vue.js.map +1 -1
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigLayoutOptions.vue.script.js +11 -9
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigLayoutOptions.vue.script.js.map +1 -1
- package/dist/features/developer-tools/components/ApiReferenceToolbarShareRegister.vue.d.ts.map +1 -1
- package/dist/features/developer-tools/components/ApiReferenceToolbarShareRegister.vue.js.map +1 -1
- package/dist/features/developer-tools/components/ApiReferenceToolbarShareRegister.vue.script.js +9 -1
- package/dist/features/developer-tools/components/ApiReferenceToolbarShareRegister.vue.script.js.map +1 -1
- package/dist/helpers/get-async-api-model-schema.d.ts +15 -0
- package/dist/helpers/get-async-api-model-schema.d.ts.map +1 -0
- package/dist/helpers/get-async-api-model-schema.js +32 -0
- package/dist/helpers/get-async-api-model-schema.js.map +1 -0
- package/dist/helpers/id-routing.d.ts +18 -0
- package/dist/helpers/id-routing.d.ts.map +1 -1
- package/dist/helpers/id-routing.js +41 -1
- package/dist/helpers/id-routing.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/{persistance-plugin.d.ts → persistence-plugin.d.ts} +2 -8
- package/dist/plugins/persistence-plugin.d.ts.map +1 -0
- package/dist/plugins/{persistance-plugin.js → persistence-plugin.js} +4 -13
- package/dist/plugins/persistence-plugin.js.map +1 -0
- package/dist/standalone.esm.d.ts +4 -0
- package/dist/standalone.esm.d.ts.map +1 -0
- package/dist/style.css +90 -78
- package/dist/vue-styles.css +84 -76
- package/package.json +21 -19
- package/dist/browser/webpack-stats.json +0 -1
- package/dist/plugins/persistance-plugin.d.ts.map +0 -1
- package/dist/plugins/persistance-plugin.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaObjectProperties.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Content/Schema/SchemaObjectProperties.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SchemaObjectProperties.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Content/Schema/SchemaObjectProperties.vue"],"names":[],"mappings":"AA4PA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAEb,MAAM,8DAA8D,CAAA;AAKrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAItE,KAAK,WAAW,GAAG;IACf,MAAM,EAAE,YAAY,CAAA;IACpB,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,OAAO,EAAE,aAAa,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B,CAAC;AA8TJ,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaObjectProperties.vue.js","names":[],"sources":["../../../../src/components/Content/Schema/SchemaObjectProperties.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport {
|
|
1
|
+
{"version":3,"file":"SchemaObjectProperties.vue.js","names":[],"sources":["../../../../src/components/Content/Schema/SchemaObjectProperties.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n SchemaReferenceType,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { sortPropertyNames } from '@/components/Content/Schema/helpers/sort-property-names'\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\n\nimport SchemaProperty from './SchemaProperty.vue'\n\nconst { schema, discriminator, options, schemaContext, compositionPath } =\n defineProps<{\n schema: SchemaObject\n discriminator?: DiscriminatorObject\n compact?: boolean\n hideHeading?: boolean\n level?: number\n hideModelNames?: boolean\n breadcrumb?: string[]\n eventBus: WorkspaceEventBus | null\n options: SchemaOptions\n schemaContext?: string\n compositionPath?: string[]\n }>()\n\n/**\n * Sorts properties by required status first, then alphabetically.\n * Required properties appear first, followed by optional properties.\n */\nconst sortedProperties = computed(() =>\n sortPropertyNames(schema, discriminator, options),\n)\n\n/**\n * Get the display name for additional properties.\n *\n * Checks x-additionalPropertiesName extension first, then falls back to the\n * propertyNames schema title if available.\n */\nconst getAdditionalPropertiesName = (\n _additionalProperties: Extract<\n SchemaObject,\n { type: 'object' }\n >['additionalProperties'],\n _propertyNames?: Extract<SchemaObject, { type: 'object' }>['propertyNames'],\n) => {\n const additionalProperties =\n typeof _additionalProperties === 'boolean'\n ? _additionalProperties\n : resolve.schema(_additionalProperties)\n\n if (\n typeof additionalProperties === 'object' &&\n typeof additionalProperties['x-additionalPropertiesName'] === 'string' &&\n additionalProperties['x-additionalPropertiesName'].trim().length > 0\n ) {\n return `${additionalProperties['x-additionalPropertiesName'].trim()}`\n }\n\n // Fall back to the propertyNames title when available\n if (_propertyNames) {\n const resolved = resolve.schema(_propertyNames)\n if (resolved?.title) {\n return resolved.title\n }\n }\n\n return 'propertyName'\n}\n\n/**\n * Extract enum values from the propertyNames schema.\n *\n * JSON Schema's propertyNames keyword constrains which keys are valid\n * in an object with additionalProperties. When it contains an enum,\n * these are the allowed key names.\n */\nconst getPropertyNamesEnum = (\n _propertyNames?: Extract<SchemaObject, { type: 'object' }>['propertyNames'],\n): string[] | undefined => {\n if (!_propertyNames) {\n return undefined\n }\n\n const resolved = resolve.schema(_propertyNames)\n if (\n resolved &&\n 'enum' in resolved &&\n Array.isArray(resolved.enum) &&\n resolved.enum.length > 0\n ) {\n return resolved.enum as string[]\n }\n\n return undefined\n}\n\n/** Enum values for the property keys, derived from propertyNames if present. */\nconst additionalPropertiesEnum = computed(() => {\n if (!isTypeObject(schema) || !schema.additionalProperties) {\n return undefined\n }\n return getPropertyNamesEnum(schema.propertyNames)\n})\n\n/**\n * Keep sibling property descriptions separate from the referenced schema.\n *\n * This allows us to render both:\n * - the property-specific description written next to the $ref, and\n * - the referenced schema's own description (for example discriminator parent docs)\n */\nconst getPropertySchema = (\n property: SchemaReferenceType<SchemaObject> | undefined,\n): SchemaObject | undefined => {\n if (!property) {\n return undefined\n }\n return resolve.schema(property)\n}\n\nconst getPropertyDescription = (\n property: SchemaReferenceType<SchemaObject> | undefined,\n): string | undefined => {\n if (!property) {\n return undefined\n }\n\n return typeof property.description === 'string'\n ? property.description\n : undefined\n}\n\n/**\n * Get the value for additional properties.\n *\n * When additionalProperties is true or an empty object, it should render as { type: 'anything' }.\n * $ref values are resolved before the type check so the referenced schema is rendered correctly.\n */\nconst getAdditionalPropertiesValue = (\n additionalProperties: Extract<\n SchemaObject,\n { type: 'object' }\n >['additionalProperties'],\n): SchemaObject => {\n // Resolve $ref first so the type check below works on the actual schema\n const resolved =\n typeof additionalProperties === 'boolean'\n ? additionalProperties\n : resolve.schema(additionalProperties)\n\n if (\n resolved === true ||\n (typeof resolved === 'object' && Object.keys(resolved).length === 0) ||\n typeof resolved !== 'object' ||\n !('type' in resolved)\n ) {\n return {\n // @ts-expect-error - ask hans\n type: 'anything',\n ...(typeof resolved === 'object' ? resolved : {}),\n }\n }\n\n return resolved\n}\n</script>\n\n<template>\n <!-- Properties -->\n <template v-if=\"isTypeObject(schema) && schema.properties\">\n <SchemaProperty\n v-for=\"property in sortedProperties\"\n :key=\"property\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :compositionPathSegment=\"property\"\n :description=\"getPropertyDescription(schema.properties[property])\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :name=\"property\"\n :options=\"options\"\n :required=\"schema.required?.includes(property)\"\n :schema=\"getPropertySchema(schema.properties[property])\"\n :schemaContext=\"schemaContext\" />\n </template>\n\n <!-- patternProperties -->\n <template v-if=\"isTypeObject(schema) && schema.patternProperties\">\n <SchemaProperty\n v-for=\"[key, property] in Object.entries(schema.patternProperties)\"\n :key=\"key\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :compositionPathSegment=\"key\"\n :description=\"getPropertyDescription(property)\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames=\"hideModelNames\"\n :level\n :name=\"key\"\n :options=\"options\"\n :schema=\"getPropertySchema(property)\"\n :schemaContext=\"schemaContext\" />\n </template>\n\n <!-- additionalProperties -->\n <template v-if=\"isTypeObject(schema) && schema.additionalProperties\">\n <SchemaProperty\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :compositionPathSegment=\"\n getAdditionalPropertiesName(\n schema.additionalProperties,\n schema.propertyNames,\n )\n \"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :name=\"\n getAdditionalPropertiesName(\n schema.additionalProperties,\n schema.propertyNames,\n )\n \"\n noncollapsible\n :options=\"options\"\n :propertyNamesEnum=\"additionalPropertiesEnum\"\n :schema=\"getAdditionalPropertiesValue(schema.additionalProperties)\"\n :schemaContext=\"schemaContext\"\n variant=\"additionalProperties\" />\n </template>\n</template>\n"],"mappings":""}
|
|
@@ -2,7 +2,6 @@ import { isTypeObject } from "./helpers/is-type-object.js";
|
|
|
2
2
|
import { sortPropertyNames } from "./helpers/sort-property-names.js";
|
|
3
3
|
import SchemaProperty_default from "./SchemaProperty.vue.js";
|
|
4
4
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, defineComponent, openBlock, renderList, unref } from "vue";
|
|
5
|
-
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
6
5
|
import { resolve } from "@scalar/workspace-store/resolve";
|
|
7
6
|
//#region src/components/Content/Schema/SchemaObjectProperties.vue?vue&type=script&setup=true&lang.ts
|
|
8
7
|
var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
@@ -67,7 +66,6 @@ var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__P
|
|
|
67
66
|
*/
|
|
68
67
|
const getPropertySchema = (property) => {
|
|
69
68
|
if (!property) return;
|
|
70
|
-
if ("$ref" in property && typeof property.$ref === "string") return getResolvedRef(property);
|
|
71
69
|
return resolve.schema(property);
|
|
72
70
|
};
|
|
73
71
|
const getPropertyDescription = (property) => {
|
|
@@ -97,6 +95,7 @@ var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__P
|
|
|
97
95
|
compact: __props.compact,
|
|
98
96
|
compositionPath: __props.compositionPath,
|
|
99
97
|
compositionPathSegment: property,
|
|
98
|
+
description: getPropertyDescription(__props.schema.properties[property]),
|
|
100
99
|
discriminator: __props.discriminator,
|
|
101
100
|
eventBus: __props.eventBus,
|
|
102
101
|
hideHeading: __props.hideHeading,
|
|
@@ -105,7 +104,6 @@ var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__P
|
|
|
105
104
|
name: property,
|
|
106
105
|
options: __props.options,
|
|
107
106
|
required: __props.schema.required?.includes(property),
|
|
108
|
-
description: getPropertyDescription(__props.schema.properties[property]),
|
|
109
107
|
schema: getPropertySchema(__props.schema.properties[property]),
|
|
110
108
|
schemaContext: __props.schemaContext
|
|
111
109
|
}, null, 8, [
|
|
@@ -113,6 +111,7 @@ var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__P
|
|
|
113
111
|
"compact",
|
|
114
112
|
"compositionPath",
|
|
115
113
|
"compositionPathSegment",
|
|
114
|
+
"description",
|
|
116
115
|
"discriminator",
|
|
117
116
|
"eventBus",
|
|
118
117
|
"hideHeading",
|
|
@@ -121,7 +120,6 @@ var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__P
|
|
|
121
120
|
"name",
|
|
122
121
|
"options",
|
|
123
122
|
"required",
|
|
124
|
-
"description",
|
|
125
123
|
"schema",
|
|
126
124
|
"schemaContext"
|
|
127
125
|
]);
|
|
@@ -133,6 +131,7 @@ var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__P
|
|
|
133
131
|
compact: __props.compact,
|
|
134
132
|
compositionPath: __props.compositionPath,
|
|
135
133
|
compositionPathSegment: key,
|
|
134
|
+
description: getPropertyDescription(property),
|
|
136
135
|
discriminator: __props.discriminator,
|
|
137
136
|
eventBus: __props.eventBus,
|
|
138
137
|
hideHeading: __props.hideHeading,
|
|
@@ -140,7 +139,6 @@ var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__P
|
|
|
140
139
|
level: __props.level,
|
|
141
140
|
name: key,
|
|
142
141
|
options: __props.options,
|
|
143
|
-
description: getPropertyDescription(property),
|
|
144
142
|
schema: getPropertySchema(property),
|
|
145
143
|
schemaContext: __props.schemaContext
|
|
146
144
|
}, null, 8, [
|
|
@@ -148,6 +146,7 @@ var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__P
|
|
|
148
146
|
"compact",
|
|
149
147
|
"compositionPath",
|
|
150
148
|
"compositionPathSegment",
|
|
149
|
+
"description",
|
|
151
150
|
"discriminator",
|
|
152
151
|
"eventBus",
|
|
153
152
|
"hideHeading",
|
|
@@ -155,7 +154,6 @@ var SchemaObjectProperties_vue_vue_type_script_setup_true_lang_default = /* @__P
|
|
|
155
154
|
"level",
|
|
156
155
|
"name",
|
|
157
156
|
"options",
|
|
158
|
-
"description",
|
|
159
157
|
"schema",
|
|
160
158
|
"schemaContext"
|
|
161
159
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaObjectProperties.vue.script.js","names":[],"sources":["../../../../src/components/Content/Schema/SchemaObjectProperties.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n SchemaReferenceType,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { sortPropertyNames } from '@/components/Content/Schema/helpers/sort-property-names'\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\n\nimport SchemaProperty from './SchemaProperty.vue'\n\nconst { schema, discriminator, options, schemaContext, compositionPath } =\n defineProps<{\n schema: SchemaObject\n discriminator?: DiscriminatorObject\n compact?: boolean\n hideHeading?: boolean\n level?: number\n hideModelNames?: boolean\n breadcrumb?: string[]\n eventBus: WorkspaceEventBus | null\n options: SchemaOptions\n schemaContext?: string\n compositionPath?: string[]\n }>()\n\n/**\n * Sorts properties by required status first, then alphabetically.\n * Required properties appear first, followed by optional properties.\n */\nconst sortedProperties = computed(() =>\n sortPropertyNames(schema, discriminator, options),\n)\n\n/**\n * Get the display name for additional properties.\n *\n * Checks x-additionalPropertiesName extension first, then falls back to the\n * propertyNames schema title if available.\n */\nconst getAdditionalPropertiesName = (\n _additionalProperties: Extract<\n SchemaObject,\n { type: 'object' }\n >['additionalProperties'],\n _propertyNames?: Extract<SchemaObject, { type: 'object' }>['propertyNames'],\n) => {\n const additionalProperties =\n typeof _additionalProperties === 'boolean'\n ? _additionalProperties\n : resolve.schema(_additionalProperties)\n\n if (\n typeof additionalProperties === 'object' &&\n typeof additionalProperties['x-additionalPropertiesName'] === 'string' &&\n additionalProperties['x-additionalPropertiesName'].trim().length > 0\n ) {\n return `${additionalProperties['x-additionalPropertiesName'].trim()}`\n }\n\n // Fall back to the propertyNames title when available\n if (_propertyNames) {\n const resolved = resolve.schema(_propertyNames)\n if (resolved?.title) {\n return resolved.title\n }\n }\n\n return 'propertyName'\n}\n\n/**\n * Extract enum values from the propertyNames schema.\n *\n * JSON Schema's propertyNames keyword constrains which keys are valid\n * in an object with additionalProperties. When it contains an enum,\n * these are the allowed key names.\n */\nconst getPropertyNamesEnum = (\n _propertyNames?: Extract<SchemaObject, { type: 'object' }>['propertyNames'],\n): string[] | undefined => {\n if (!_propertyNames) {\n return undefined\n }\n\n const resolved = resolve.schema(_propertyNames)\n if (\n resolved &&\n 'enum' in resolved &&\n Array.isArray(resolved.enum) &&\n resolved.enum.length > 0\n ) {\n return resolved.enum as string[]\n }\n\n return undefined\n}\n\n/** Enum values for the property keys, derived from propertyNames if present. */\nconst additionalPropertiesEnum = computed(() => {\n if (!isTypeObject(schema) || !schema.additionalProperties) {\n return undefined\n }\n return getPropertyNamesEnum(schema.propertyNames)\n})\n\n/**\n * Keep sibling property descriptions separate from the referenced schema.\n *\n * This allows us to render both:\n * - the property-specific description written next to the $ref, and\n * - the referenced schema's own description (for example discriminator parent docs)\n */\nconst getPropertySchema = (\n property: SchemaReferenceType<SchemaObject> | undefined,\n): SchemaObject | undefined => {\n if (!property) {\n return undefined\n }\n\n if ('$ref' in property && typeof property.$ref === 'string') {\n return getResolvedRef(property) as SchemaObject\n }\n\n return resolve.schema(property)\n}\n\nconst getPropertyDescription = (\n property: SchemaReferenceType<SchemaObject> | undefined,\n): string | undefined => {\n if (!property) {\n return undefined\n }\n\n return typeof property.description === 'string'\n ? property.description\n : undefined\n}\n\n/**\n * Get the value for additional properties.\n *\n * When additionalProperties is true or an empty object, it should render as { type: 'anything' }.\n * $ref values are resolved before the type check so the referenced schema is rendered correctly.\n */\nconst getAdditionalPropertiesValue = (\n additionalProperties: Extract<\n SchemaObject,\n { type: 'object' }\n >['additionalProperties'],\n): SchemaObject => {\n // Resolve $ref first so the type check below works on the actual schema\n const resolved =\n typeof additionalProperties === 'boolean'\n ? additionalProperties\n : resolve.schema(additionalProperties)\n\n if (\n resolved === true ||\n (typeof resolved === 'object' && Object.keys(resolved).length === 0) ||\n typeof resolved !== 'object' ||\n !('type' in resolved)\n ) {\n return {\n // @ts-expect-error - ask hans\n type: 'anything',\n ...(typeof resolved === 'object' ? resolved : {}),\n }\n }\n\n return resolved\n}\n</script>\n\n<template>\n <!-- Properties -->\n <template v-if=\"isTypeObject(schema) && schema.properties\">\n <SchemaProperty\n v-for=\"property in sortedProperties\"\n :key=\"property\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :compositionPathSegment=\"property\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :name=\"property\"\n :options=\"options\"\n :required=\"schema.required?.includes(property)\"\n :description=\"getPropertyDescription(schema.properties[property])\"\n :schema=\"getPropertySchema(schema.properties[property])\"\n :schemaContext=\"schemaContext\" />\n </template>\n\n <!-- patternProperties -->\n <template v-if=\"isTypeObject(schema) && schema.patternProperties\">\n <SchemaProperty\n v-for=\"[key, property] in Object.entries(schema.patternProperties)\"\n :key=\"key\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :compositionPathSegment=\"key\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames=\"hideModelNames\"\n :level\n :name=\"key\"\n :options=\"options\"\n :description=\"getPropertyDescription(property)\"\n :schema=\"getPropertySchema(property)\"\n :schemaContext=\"schemaContext\" />\n </template>\n\n <!-- additionalProperties -->\n <template v-if=\"isTypeObject(schema) && schema.additionalProperties\">\n <SchemaProperty\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :compositionPathSegment=\"\n getAdditionalPropertiesName(\n schema.additionalProperties,\n schema.propertyNames,\n )\n \"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :name=\"\n getAdditionalPropertiesName(\n schema.additionalProperties,\n schema.propertyNames,\n )\n \"\n noncollapsible\n :options=\"options\"\n :propertyNamesEnum=\"additionalPropertiesEnum\"\n :schema=\"getAdditionalPropertiesValue(schema.additionalProperties)\"\n :schemaContext=\"schemaContext\"\n variant=\"additionalProperties\" />\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCA,MAAM,mBAAmB,eACvB,kBAAkB,QAAA,QAAQ,QAAA,eAAe,QAAA,QAAQ,CACnD;;;;;;;EAQA,MAAM,+BACJ,uBAIA,mBACG;GACH,MAAM,uBACJ,OAAO,0BAA0B,YAC7B,wBACA,QAAQ,OAAO,sBAAqB;AAE1C,OACE,OAAO,yBAAyB,YAChC,OAAO,qBAAqB,kCAAkC,YAC9D,qBAAqB,8BAA8B,MAAM,CAAC,SAAS,EAEnE,QAAO,GAAG,qBAAqB,8BAA8B,MAAM;AAIrE,OAAI,gBAAgB;IAClB,MAAM,WAAW,QAAQ,OAAO,eAAc;AAC9C,QAAI,UAAU,MACZ,QAAO,SAAS;;AAIpB,UAAO;;;;;;;;;EAUT,MAAM,wBACJ,mBACyB;AACzB,OAAI,CAAC,eACH;GAGF,MAAM,WAAW,QAAQ,OAAO,eAAc;AAC9C,OACE,YACA,UAAU,YACV,MAAM,QAAQ,SAAS,KAAK,IAC5B,SAAS,KAAK,SAAS,EAEvB,QAAO,SAAS;;;EAOpB,MAAM,2BAA2B,eAAe;AAC9C,OAAI,CAAC,aAAa,QAAA,OAAO,IAAI,CAAC,QAAA,OAAO,qBACnC;AAEF,UAAO,qBAAqB,QA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AAA,GAAA,EAAA,WAfP,OAAO,QAAQ,QAAA,OAAO,kBAAiB,GAAA,CAAzD,KAAK,cAAQ;yBADvB,YAgBmC,wBAAA;MAd3B;MACL,YAAA,QAAA;MACA,SAAA,QAAA;MACA,iBAAiB,QAAA;MACjB,wBAAwB;MACxB,eAAA,QAAA;MACA,UAAU,QAAA;MACV,aAAA,QAAA;MACA,gBAAgB,QAAA;MAChB,OAAA,QAAA;MACA,MAAM;MACN,SAAS,QAAA;MACT,aAAa,uBAAuB,SAAQ;MAC5C,QAAQ,kBAAkB,SAAQ;MAClC,eAAe,QAAA;;;;;;;;;;;;;;;;;;IAIJ,MAAA,aAAY,CAAC,QAAA,OAAM,IAAK,QAAA,OAAO,wBAAA,WAAA,EAC7C,YA0BmC,wBAAA;;KAzBhC,YAAA,QAAA;KACA,SAAA,QAAA;KACA,iBAAiB,QAAA;KACjB,wBAAiC,4BAAuC,QAAA,OAAO,sBAAgC,QAAA,OAAO,cAAA;KAMtH,eAAA,QAAA;KACA,UAAU,QAAA;KACV,aAAA,QAAA;KACA,gBAAA,QAAA;KACA,OAAA,QAAA;KACA,MAAe,4BAAuC,QAAA,OAAO,sBAAgC,QAAA,OAAO,cAAA;KAMrG,gBAAA;KACC,SAAS,QAAA;KACT,mBAAmB,yBAAA;KACnB,QAAQ,6BAA6B,QAAA,OAAO,qBAAoB;KAChE,eAAe,QAAA;KAChB,SAAQ"}
|
|
1
|
+
{"version":3,"file":"SchemaObjectProperties.vue.script.js","names":[],"sources":["../../../../src/components/Content/Schema/SchemaObjectProperties.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n DiscriminatorObject,\n SchemaObject,\n SchemaReferenceType,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { sortPropertyNames } from '@/components/Content/Schema/helpers/sort-property-names'\nimport type { SchemaOptions } from '@/components/Content/Schema/types'\n\nimport SchemaProperty from './SchemaProperty.vue'\n\nconst { schema, discriminator, options, schemaContext, compositionPath } =\n defineProps<{\n schema: SchemaObject\n discriminator?: DiscriminatorObject\n compact?: boolean\n hideHeading?: boolean\n level?: number\n hideModelNames?: boolean\n breadcrumb?: string[]\n eventBus: WorkspaceEventBus | null\n options: SchemaOptions\n schemaContext?: string\n compositionPath?: string[]\n }>()\n\n/**\n * Sorts properties by required status first, then alphabetically.\n * Required properties appear first, followed by optional properties.\n */\nconst sortedProperties = computed(() =>\n sortPropertyNames(schema, discriminator, options),\n)\n\n/**\n * Get the display name for additional properties.\n *\n * Checks x-additionalPropertiesName extension first, then falls back to the\n * propertyNames schema title if available.\n */\nconst getAdditionalPropertiesName = (\n _additionalProperties: Extract<\n SchemaObject,\n { type: 'object' }\n >['additionalProperties'],\n _propertyNames?: Extract<SchemaObject, { type: 'object' }>['propertyNames'],\n) => {\n const additionalProperties =\n typeof _additionalProperties === 'boolean'\n ? _additionalProperties\n : resolve.schema(_additionalProperties)\n\n if (\n typeof additionalProperties === 'object' &&\n typeof additionalProperties['x-additionalPropertiesName'] === 'string' &&\n additionalProperties['x-additionalPropertiesName'].trim().length > 0\n ) {\n return `${additionalProperties['x-additionalPropertiesName'].trim()}`\n }\n\n // Fall back to the propertyNames title when available\n if (_propertyNames) {\n const resolved = resolve.schema(_propertyNames)\n if (resolved?.title) {\n return resolved.title\n }\n }\n\n return 'propertyName'\n}\n\n/**\n * Extract enum values from the propertyNames schema.\n *\n * JSON Schema's propertyNames keyword constrains which keys are valid\n * in an object with additionalProperties. When it contains an enum,\n * these are the allowed key names.\n */\nconst getPropertyNamesEnum = (\n _propertyNames?: Extract<SchemaObject, { type: 'object' }>['propertyNames'],\n): string[] | undefined => {\n if (!_propertyNames) {\n return undefined\n }\n\n const resolved = resolve.schema(_propertyNames)\n if (\n resolved &&\n 'enum' in resolved &&\n Array.isArray(resolved.enum) &&\n resolved.enum.length > 0\n ) {\n return resolved.enum as string[]\n }\n\n return undefined\n}\n\n/** Enum values for the property keys, derived from propertyNames if present. */\nconst additionalPropertiesEnum = computed(() => {\n if (!isTypeObject(schema) || !schema.additionalProperties) {\n return undefined\n }\n return getPropertyNamesEnum(schema.propertyNames)\n})\n\n/**\n * Keep sibling property descriptions separate from the referenced schema.\n *\n * This allows us to render both:\n * - the property-specific description written next to the $ref, and\n * - the referenced schema's own description (for example discriminator parent docs)\n */\nconst getPropertySchema = (\n property: SchemaReferenceType<SchemaObject> | undefined,\n): SchemaObject | undefined => {\n if (!property) {\n return undefined\n }\n return resolve.schema(property)\n}\n\nconst getPropertyDescription = (\n property: SchemaReferenceType<SchemaObject> | undefined,\n): string | undefined => {\n if (!property) {\n return undefined\n }\n\n return typeof property.description === 'string'\n ? property.description\n : undefined\n}\n\n/**\n * Get the value for additional properties.\n *\n * When additionalProperties is true or an empty object, it should render as { type: 'anything' }.\n * $ref values are resolved before the type check so the referenced schema is rendered correctly.\n */\nconst getAdditionalPropertiesValue = (\n additionalProperties: Extract<\n SchemaObject,\n { type: 'object' }\n >['additionalProperties'],\n): SchemaObject => {\n // Resolve $ref first so the type check below works on the actual schema\n const resolved =\n typeof additionalProperties === 'boolean'\n ? additionalProperties\n : resolve.schema(additionalProperties)\n\n if (\n resolved === true ||\n (typeof resolved === 'object' && Object.keys(resolved).length === 0) ||\n typeof resolved !== 'object' ||\n !('type' in resolved)\n ) {\n return {\n // @ts-expect-error - ask hans\n type: 'anything',\n ...(typeof resolved === 'object' ? resolved : {}),\n }\n }\n\n return resolved\n}\n</script>\n\n<template>\n <!-- Properties -->\n <template v-if=\"isTypeObject(schema) && schema.properties\">\n <SchemaProperty\n v-for=\"property in sortedProperties\"\n :key=\"property\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :compositionPathSegment=\"property\"\n :description=\"getPropertyDescription(schema.properties[property])\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :name=\"property\"\n :options=\"options\"\n :required=\"schema.required?.includes(property)\"\n :schema=\"getPropertySchema(schema.properties[property])\"\n :schemaContext=\"schemaContext\" />\n </template>\n\n <!-- patternProperties -->\n <template v-if=\"isTypeObject(schema) && schema.patternProperties\">\n <SchemaProperty\n v-for=\"[key, property] in Object.entries(schema.patternProperties)\"\n :key=\"key\"\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :compositionPathSegment=\"key\"\n :description=\"getPropertyDescription(property)\"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames=\"hideModelNames\"\n :level\n :name=\"key\"\n :options=\"options\"\n :schema=\"getPropertySchema(property)\"\n :schemaContext=\"schemaContext\" />\n </template>\n\n <!-- additionalProperties -->\n <template v-if=\"isTypeObject(schema) && schema.additionalProperties\">\n <SchemaProperty\n :breadcrumb\n :compact\n :compositionPath=\"compositionPath\"\n :compositionPathSegment=\"\n getAdditionalPropertiesName(\n schema.additionalProperties,\n schema.propertyNames,\n )\n \"\n :discriminator\n :eventBus=\"eventBus\"\n :hideHeading\n :hideModelNames\n :level\n :name=\"\n getAdditionalPropertiesName(\n schema.additionalProperties,\n schema.propertyNames,\n )\n \"\n noncollapsible\n :options=\"options\"\n :propertyNamesEnum=\"additionalPropertiesEnum\"\n :schema=\"getAdditionalPropertiesValue(schema.additionalProperties)\"\n :schemaContext=\"schemaContext\"\n variant=\"additionalProperties\" />\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAmCA,MAAM,mBAAmB,eACvB,kBAAkB,QAAA,QAAQ,QAAA,eAAe,QAAA,QAAQ,CACnD;;;;;;;EAQA,MAAM,+BACJ,uBAIA,mBACG;GACH,MAAM,uBACJ,OAAO,0BAA0B,YAC7B,wBACA,QAAQ,OAAO,sBAAqB;AAE1C,OACE,OAAO,yBAAyB,YAChC,OAAO,qBAAqB,kCAAkC,YAC9D,qBAAqB,8BAA8B,MAA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A6B,QAAA,OAAO,qBAAoB;KAChE,eAAe,QAAA;KAChB,SAAQ"}
|
|
@@ -5,7 +5,8 @@ import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/o
|
|
|
5
5
|
*
|
|
6
6
|
* @param schemas - Array of OpenAPI schema objects to merge
|
|
7
7
|
* @param rootSchema - Optional root schema to merge with the result
|
|
8
|
+
* @param seenRefs - `$ref` strings already being merged higher in the call stack
|
|
8
9
|
* @returns Merged schema object
|
|
9
10
|
*/
|
|
10
|
-
export declare const mergeAllOfSchemas: (schemas: SchemaObject | undefined, rootSchema?: SchemaObject) => SchemaObject;
|
|
11
|
+
export declare const mergeAllOfSchemas: (schemas: SchemaObject | undefined, rootSchema?: SchemaObject, seenRefs?: Set<string>) => SchemaObject;
|
|
11
12
|
//# sourceMappingURL=merge-all-of-schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-all-of-schemas.d.ts","sourceRoot":"","sources":["../../../../../src/components/Content/Schema/helpers/merge-all-of-schemas.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAGhG
|
|
1
|
+
{"version":3,"file":"merge-all-of-schemas.d.ts","sourceRoot":"","sources":["../../../../../src/components/Content/Schema/helpers/merge-all-of-schemas.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAGhG;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,YAAY,GAAG,SAAS,EACjC,aAAa,YAAY,EACzB,WAAU,GAAG,CAAC,MAAM,CAAa,KAChC,YA+CF,CAAA"}
|
|
@@ -9,9 +9,10 @@ import { objectKeys } from "@scalar/helpers/object/object-keys";
|
|
|
9
9
|
*
|
|
10
10
|
* @param schemas - Array of OpenAPI schema objects to merge
|
|
11
11
|
* @param rootSchema - Optional root schema to merge with the result
|
|
12
|
+
* @param seenRefs - `$ref` strings already being merged higher in the call stack
|
|
12
13
|
* @returns Merged schema object
|
|
13
14
|
*/
|
|
14
|
-
var mergeAllOfSchemas = (schemas, rootSchema) => {
|
|
15
|
+
var mergeAllOfSchemas = (schemas, rootSchema, seenRefs = /* @__PURE__ */ new Set()) => {
|
|
15
16
|
if (!schemas?.allOf?.length || !Array.isArray(schemas.allOf)) return rootSchema || {};
|
|
16
17
|
const result = {};
|
|
17
18
|
const { allOf: _, ...baseSchema } = schemas;
|
|
@@ -19,14 +20,14 @@ var mergeAllOfSchemas = (schemas, rootSchema) => {
|
|
|
19
20
|
if (!_schema || typeof _schema !== "object") continue;
|
|
20
21
|
const schema = resolve.schema(_schema);
|
|
21
22
|
if (schema.allOf) {
|
|
22
|
-
mergeSchemaIntoResult(result, mergeAllOfSchemas(schema));
|
|
23
|
+
mergeSchemaIntoResult(result, mergeAllOfSchemas(schema, void 0, seenRefs), false, seenRefs);
|
|
23
24
|
continue;
|
|
24
25
|
}
|
|
25
|
-
mergeSchemaIntoResult(result, schema);
|
|
26
|
+
mergeSchemaIntoResult(result, schema, false, seenRefs);
|
|
26
27
|
}
|
|
27
|
-
if (Object.keys(baseSchema).length > 0) mergeSchemaIntoResult(result, baseSchema, true);
|
|
28
|
-
if (rootSchema && typeof rootSchema === "object") if (rootSchema.allOf) mergeSchemaIntoResult(result, mergeAllOfSchemas(rootSchema), true);
|
|
29
|
-
else mergeSchemaIntoResult(result, rootSchema, true);
|
|
28
|
+
if (Object.keys(baseSchema).length > 0) mergeSchemaIntoResult(result, baseSchema, true, seenRefs);
|
|
29
|
+
if (rootSchema && typeof rootSchema === "object") if (rootSchema.allOf) mergeSchemaIntoResult(result, mergeAllOfSchemas(rootSchema, void 0, seenRefs), true, seenRefs);
|
|
30
|
+
else mergeSchemaIntoResult(result, rootSchema, true, seenRefs);
|
|
30
31
|
return result;
|
|
31
32
|
};
|
|
32
33
|
/**
|
|
@@ -37,7 +38,7 @@ var mergeAllOfSchemas = (schemas, rootSchema) => {
|
|
|
37
38
|
* @param schema - The source schema object to merge from
|
|
38
39
|
* @param override - Whether to override existing properties (default: false)
|
|
39
40
|
*/
|
|
40
|
-
var mergeSchemaIntoResult = (result, schema, override = false) => {
|
|
41
|
+
var mergeSchemaIntoResult = (result, schema, override = false, seenRefs = /* @__PURE__ */ new Set()) => {
|
|
41
42
|
const schemaKeys = objectKeys(schema);
|
|
42
43
|
if (schemaKeys.length === 0) return;
|
|
43
44
|
for (const key of schemaKeys) {
|
|
@@ -49,7 +50,7 @@ var mergeSchemaIntoResult = (result, schema, override = false) => {
|
|
|
49
50
|
} else if (key === "properties") {
|
|
50
51
|
if (value && typeof value === "object") {
|
|
51
52
|
if (!result.properties) result.properties = {};
|
|
52
|
-
mergePropertiesIntoResult(result.properties, value);
|
|
53
|
+
mergePropertiesIntoResult(result.properties, value, seenRefs);
|
|
53
54
|
}
|
|
54
55
|
} else if (key === "items") {
|
|
55
56
|
const items = resolve.schema(value);
|
|
@@ -57,14 +58,14 @@ var mergeSchemaIntoResult = (result, schema, override = false) => {
|
|
|
57
58
|
if (isArraySchema(schema)) {
|
|
58
59
|
if (!result.items) result.items = {};
|
|
59
60
|
if (items.allOf) {
|
|
60
|
-
const mergedItems = mergeAllOfSchemas(items);
|
|
61
|
+
const mergedItems = mergeAllOfSchemas(items, void 0, seenRefs);
|
|
61
62
|
Object.assign(result.items, mergedItems);
|
|
62
|
-
} else mergeItemsIntoResult(getResolvedRef(result.items), items);
|
|
63
|
+
} else mergeItemsIntoResult(getResolvedRef(result.items), items, seenRefs);
|
|
63
64
|
} else if (items.allOf) {
|
|
64
|
-
const mergedItems = mergeAllOfSchemas(items);
|
|
65
|
+
const mergedItems = mergeAllOfSchemas(items, void 0, seenRefs);
|
|
65
66
|
if ("properties" in mergedItems) {
|
|
66
67
|
if (!("properties" in result)) result.properties = {};
|
|
67
|
-
"properties" in result && mergePropertiesIntoResult(result.properties, mergedItems.properties);
|
|
68
|
+
"properties" in result && mergePropertiesIntoResult(result.properties, mergedItems.properties, seenRefs);
|
|
68
69
|
}
|
|
69
70
|
} else if (!("items" in result)) result.items = items;
|
|
70
71
|
}
|
|
@@ -75,7 +76,7 @@ var mergeSchemaIntoResult = (result, schema, override = false) => {
|
|
|
75
76
|
if (!("properties" in result)) result.properties = {};
|
|
76
77
|
for (const _option of value) {
|
|
77
78
|
const option = resolve.schema(_option);
|
|
78
|
-
if (option && "properties" in option && "properties" in result) mergePropertiesIntoResult(result.properties, option.properties);
|
|
79
|
+
if (option && "properties" in option && "properties" in result) mergePropertiesIntoResult(result.properties, option.properties, seenRefs);
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
} else if (key === "allOf") continue;
|
|
@@ -85,7 +86,7 @@ var mergeSchemaIntoResult = (result, schema, override = false) => {
|
|
|
85
86
|
/**
|
|
86
87
|
* Efficiently merges properties into a result object without creating new objects.
|
|
87
88
|
*/
|
|
88
|
-
var mergePropertiesIntoResult = (result, properties) => {
|
|
89
|
+
var mergePropertiesIntoResult = (result, properties, seenRefs = /* @__PURE__ */ new Set()) => {
|
|
89
90
|
const propertyKeys = Object.keys(properties ?? {});
|
|
90
91
|
if (!properties || !result || propertyKeys.length === 0) return;
|
|
91
92
|
for (const key of propertyKeys) {
|
|
@@ -99,22 +100,28 @@ var mergePropertiesIntoResult = (result, properties) => {
|
|
|
99
100
|
continue;
|
|
100
101
|
}
|
|
101
102
|
if (!result[key]) {
|
|
102
|
-
if (schema.allOf) result[key] = mergeAllOfSchemas(schema);
|
|
103
|
+
if (schema.allOf) result[key] = mergeAllOfSchemas(schema, void 0, seenRefs);
|
|
103
104
|
else if (isArraySchema(schema) && resolve.schema(schema.items)?.allOf) result[key] = {
|
|
104
105
|
...schema,
|
|
105
|
-
items: mergeAllOfSchemas(resolve.schema(schema.items))
|
|
106
|
+
items: mergeAllOfSchemas(resolve.schema(schema.items), void 0, seenRefs)
|
|
106
107
|
};
|
|
107
108
|
else if (properties[key]) result[key] = properties[key];
|
|
108
109
|
continue;
|
|
109
110
|
}
|
|
110
111
|
const existing = resolve.schema(result[key]);
|
|
111
|
-
|
|
112
|
+
const schemaRef = schema.$ref;
|
|
113
|
+
if (typeof schemaRef === "string" && seenRefs.has(schemaRef)) {
|
|
114
|
+
result[key] = existing;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const nextSeenRefs = typeof schemaRef === "string" ? new Set(seenRefs).add(schemaRef) : seenRefs;
|
|
118
|
+
if (schema.allOf) result[key] = mergeAllOfSchemas({ allOf: [existing, ...schema.allOf] }, void 0, nextSeenRefs);
|
|
112
119
|
else if (isArraySchema(schema) && isArraySchema(existing) && schema.items) {
|
|
113
120
|
const existingItems = resolve.schema(existing.items);
|
|
114
121
|
result[key] = {
|
|
115
122
|
...existing,
|
|
116
123
|
type: "array",
|
|
117
|
-
items: existingItems ? mergeItems(existingItems, resolve.schema(schema.items)) : resolve.schema(schema.items)
|
|
124
|
+
items: existingItems ? mergeItems(existingItems, resolve.schema(schema.items), nextSeenRefs) : resolve.schema(schema.items)
|
|
118
125
|
};
|
|
119
126
|
} else if ("properties" in existing && "properties" in schema) {
|
|
120
127
|
const merged = {
|
|
@@ -122,7 +129,7 @@ var mergePropertiesIntoResult = (result, properties) => {
|
|
|
122
129
|
...schema
|
|
123
130
|
};
|
|
124
131
|
merged.properties = { ...existing.properties };
|
|
125
|
-
mergePropertiesIntoResult(merged.properties, schema.properties);
|
|
132
|
+
mergePropertiesIntoResult(merged.properties, schema.properties, nextSeenRefs);
|
|
126
133
|
result[key] = merged;
|
|
127
134
|
} else result[key] = {
|
|
128
135
|
...schema,
|
|
@@ -133,31 +140,39 @@ var mergePropertiesIntoResult = (result, properties) => {
|
|
|
133
140
|
/**
|
|
134
141
|
* Efficiently merges array items into a result object.
|
|
135
142
|
*/
|
|
136
|
-
var mergeItemsIntoResult = (result, items) => {
|
|
143
|
+
var mergeItemsIntoResult = (result, items, seenRefs = /* @__PURE__ */ new Set()) => {
|
|
137
144
|
if (items.allOf || result.allOf) {
|
|
138
145
|
const allOfSchemas = [];
|
|
139
146
|
if (result.allOf) for (const schema of result.allOf) allOfSchemas.push(resolve.schema(schema));
|
|
140
147
|
else allOfSchemas.push(result);
|
|
141
148
|
if (items.allOf) for (const schema of items.allOf) allOfSchemas.push(resolve.schema(schema));
|
|
142
149
|
else allOfSchemas.push(items);
|
|
143
|
-
const merged = mergeAllOfSchemas({ allOf: allOfSchemas });
|
|
150
|
+
const merged = mergeAllOfSchemas({ allOf: allOfSchemas }, void 0, seenRefs);
|
|
144
151
|
Object.assign(result, merged);
|
|
145
152
|
return;
|
|
146
153
|
}
|
|
147
154
|
Object.assign(result, items);
|
|
148
|
-
if ("properties" in result && "properties" in items) mergePropertiesIntoResult(result.properties, items.properties);
|
|
155
|
+
if ("properties" in result && "properties" in items) mergePropertiesIntoResult(result.properties, items.properties, seenRefs);
|
|
149
156
|
};
|
|
150
157
|
/**
|
|
151
158
|
* Helper function for merging items that returns a new object.
|
|
152
159
|
*/
|
|
153
|
-
var mergeItems = (existing, incoming) => {
|
|
160
|
+
var mergeItems = (existing, incoming, seenRefs = /* @__PURE__ */ new Set()) => {
|
|
161
|
+
const incomingRef = incoming.$ref;
|
|
162
|
+
if (typeof incomingRef === "string") {
|
|
163
|
+
if (seenRefs.has(incomingRef)) return existing;
|
|
164
|
+
return mergeItemsInner(existing, incoming, new Set(seenRefs).add(incomingRef));
|
|
165
|
+
}
|
|
166
|
+
return mergeItemsInner(existing, incoming, seenRefs);
|
|
167
|
+
};
|
|
168
|
+
var mergeItemsInner = (existing, incoming, seenRefs = /* @__PURE__ */ new Set()) => {
|
|
154
169
|
if (existing.allOf || incoming.allOf) {
|
|
155
170
|
const allOfSchemas = [];
|
|
156
171
|
if (existing.allOf) for (const schema of existing.allOf) allOfSchemas.push(resolve.schema(schema));
|
|
157
172
|
else allOfSchemas.push(existing);
|
|
158
173
|
if (incoming.allOf) for (const schema of incoming.allOf) allOfSchemas.push(resolve.schema(schema));
|
|
159
174
|
else allOfSchemas.push(incoming);
|
|
160
|
-
return mergeAllOfSchemas({ allOf: allOfSchemas });
|
|
175
|
+
return mergeAllOfSchemas({ allOf: allOfSchemas }, void 0, seenRefs);
|
|
161
176
|
}
|
|
162
177
|
const merged = {
|
|
163
178
|
...existing,
|
|
@@ -165,7 +180,7 @@ var mergeItems = (existing, incoming) => {
|
|
|
165
180
|
};
|
|
166
181
|
if ("properties" in existing && "properties" in incoming) {
|
|
167
182
|
merged.properties = { ...existing.properties };
|
|
168
|
-
mergePropertiesIntoResult(merged.properties, incoming.properties);
|
|
183
|
+
mergePropertiesIntoResult(merged.properties, incoming.properties, seenRefs);
|
|
169
184
|
}
|
|
170
185
|
return merged;
|
|
171
186
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-all-of-schemas.js","names":[],"sources":["../../../../../src/components/Content/Schema/helpers/merge-all-of-schemas.ts"],"sourcesContent":["import { objectKeys } from '@scalar/helpers/object/object-keys'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards'\n\n/**\n * Merges multiple OpenAPI schema objects into a single schema object.\n * Handles nested allOf compositions and merges properties recursively.\n *\n * @param schemas - Array of OpenAPI schema objects to merge\n * @param rootSchema - Optional root schema to merge with the result\n * @returns Merged schema object\n */\nexport const mergeAllOfSchemas = (schemas: SchemaObject | undefined, rootSchema?: SchemaObject): SchemaObject => {\n // Handle max depth, empty or invalid input\n if (!schemas?.allOf?.length || !Array.isArray(schemas.allOf)) {\n return rootSchema || ({} as SchemaObject)\n }\n\n // Initialize result object once\n const result = {} as SchemaObject\n\n // Extract base schema properties (everything except allOf)\n const { allOf: _, ...baseSchema } = schemas\n\n // Process allOf schemas first\n for (const _schema of schemas.allOf) {\n if (!_schema || typeof _schema !== 'object') {\n continue\n }\n\n // Resolve ref if present\n const schema = resolve.schema(_schema)\n\n // Handle nested allOf recursively\n if (schema.allOf) {\n const nestedMerged = mergeAllOfSchemas(schema)\n mergeSchemaIntoResult(result, nestedMerged)\n continue\n }\n\n mergeSchemaIntoResult(result, schema)\n }\n\n // Apply base schema properties with precedence over allOf properties\n if (Object.keys(baseSchema).length > 0) {\n mergeSchemaIntoResult(result, baseSchema, true)\n }\n\n // Process root schema last if provided\n if (rootSchema && typeof rootSchema === 'object') {\n if (rootSchema.allOf) {\n const nestedMerged = mergeAllOfSchemas(rootSchema)\n mergeSchemaIntoResult(result, nestedMerged, true)\n } else {\n mergeSchemaIntoResult(result, rootSchema, true)\n }\n }\n\n return result\n}\n\n/**\n * Efficiently merges a source schema into a target result object.\n * Handles all schema merging logic in a single optimized function.\n *\n * @param result - The target schema object to merge into\n * @param schema - The source schema object to merge from\n * @param override - Whether to override existing properties (default: false)\n */\nconst mergeSchemaIntoResult = (result: SchemaObject, schema: SchemaObject, override: boolean = false): void => {\n // Early return if schema is empty\n const schemaKeys = objectKeys(schema)\n if (schemaKeys.length === 0) {\n return\n }\n\n // Loop through all schema properties and handle them appropriately\n for (const key of schemaKeys) {\n const value = getResolvedRef(schema[key]) as any\n\n if (value === undefined) {\n continue\n }\n\n // Required\n if ((key as string) === 'required') {\n // Merge required fields with deduplication\n if (Array.isArray(value) && value.length > 0) {\n // @ts-expect-error\n if (result.required?.length) {\n // @ts-expect-error\n result.required = [...new Set([...result.required, ...value])]\n } else {\n // @ts-expect-error\n result.required = value.slice()\n }\n }\n }\n // Properties\n else if ((key as string) === 'properties') {\n // Merge properties recursively\n if (value && typeof value === 'object') {\n // @ts-expect-error\n if (!result.properties) {\n // @ts-expect-error\n result.properties = {}\n }\n\n // @ts-expect-error\n mergePropertiesIntoResult(result.properties, value)\n }\n }\n // Items\n else if ((key as string) === 'items') {\n // Handle items (for both arrays and objects with items)\n const items = resolve.schema(value)\n if (items) {\n if (isArraySchema(schema)) {\n // @ts-expect-error\n if (!result.items) {\n // @ts-expect-error\n result.items = {}\n }\n\n // Handle allOf within array items\n if (items.allOf) {\n const mergedItems = mergeAllOfSchemas(items)\n // @ts-expect-error\n Object.assign(result.items, mergedItems)\n } else {\n // @ts-expect-error\n mergeItemsIntoResult(getResolvedRef(result.items), items)\n }\n }\n // For non-array types with items.allOf, merge into properties\n else if (items.allOf) {\n const mergedItems = mergeAllOfSchemas(items)\n if ('properties' in mergedItems) {\n if (!('properties' in result)) {\n // @ts-expect-error\n result.properties = {}\n }\n\n 'properties' in result && mergePropertiesIntoResult(result.properties, mergedItems.properties)\n }\n }\n // For non-array types without allOf, still set items if not already set\n else if (!('items' in result)) {\n // @ts-expect-error\n result.items = items\n }\n }\n }\n // Enum\n else if (key === 'enum') {\n if (Array.isArray(value) && value.length > 0) {\n result.enum = [...new Set([...(result.enum || []), ...value])]\n }\n }\n // OneOf/AnyOf\n else if (key === 'oneOf' || key === 'anyOf') {\n // Merge oneOf/anyOf subschema\n if (Array.isArray(value)) {\n if (!('properties' in result)) {\n // @ts-expect-error\n result.properties = {}\n }\n for (const _option of value) {\n const option = resolve.schema(_option)\n if (option && 'properties' in option && 'properties' in result) {\n mergePropertiesIntoResult(result.properties, option.properties)\n }\n }\n }\n }\n // Skip allOf as it's handled at a higher level\n else if (key === 'allOf') {\n continue\n }\n // For all other properties, preserve the first occurrence or override if specified\n else {\n if (override || result[key] === undefined) {\n result[key] = value\n }\n }\n }\n}\n\n/**\n * Efficiently merges properties into a result object without creating new objects.\n */\nconst mergePropertiesIntoResult = (\n result: Extract<SchemaObject, { type: 'object' }>['properties'],\n properties: Extract<SchemaObject, { type: 'object' }>['properties'],\n): void => {\n const propertyKeys = Object.keys(properties ?? {})\n if (!properties || !result || propertyKeys.length === 0) {\n return\n }\n\n for (const key of propertyKeys) {\n const schema = resolve.schema(properties[key])\n if (!schema) {\n delete result[key]\n continue\n }\n\n if (typeof schema !== 'object') {\n result[key] = schema\n continue\n }\n\n if (!result[key]) {\n // Handle new property with allOf\n if (schema.allOf) {\n result[key] = mergeAllOfSchemas(schema)\n } else if (isArraySchema(schema) && resolve.schema(schema.items)?.allOf) {\n result[key] = {\n ...schema,\n items: mergeAllOfSchemas(resolve.schema(schema.items)),\n }\n } else if (properties[key]) {\n result[key] = properties[key]\n }\n continue\n }\n\n // Merge existing property\n const existing = resolve.schema(result[key])\n\n if (schema.allOf) {\n result[key] = mergeAllOfSchemas({ allOf: [existing, ...schema.allOf] } as SchemaObject)\n } else if (isArraySchema(schema) && isArraySchema(existing) && schema.items) {\n const existingItems = resolve.schema(existing.items)\n result[key] = {\n ...existing,\n type: 'array',\n items: existingItems ? mergeItems(existingItems, resolve.schema(schema.items)) : resolve.schema(schema.items),\n }\n } else {\n // Create merged object with properties handled separately\n if ('properties' in existing && 'properties' in schema) {\n const merged = { ...existing, ...schema }\n merged.properties = { ...existing.properties }\n mergePropertiesIntoResult(merged.properties, schema.properties)\n result[key] = merged\n }\n // Simple merge without property recursion\n else {\n result[key] = { ...schema, ...existing }\n }\n }\n }\n}\n\n/**\n * Efficiently merges array items into a result object.\n */\nconst mergeItemsIntoResult = (result: SchemaObject, items: SchemaObject): void => {\n // Handle allOf in items\n if (items.allOf || result.allOf) {\n // Build array without spreads for better performance\n const allOfSchemas: SchemaObject[] = []\n\n if (result.allOf) {\n for (const schema of result.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(result)\n }\n\n if (items.allOf) {\n for (const schema of items.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(items)\n }\n\n const merged = mergeAllOfSchemas({ allOf: allOfSchemas } as SchemaObject)\n Object.assign(result, merged)\n return\n }\n\n // Regular merge\n Object.assign(result, items)\n\n // Merge properties if both have them\n if ('properties' in result && 'properties' in items) {\n mergePropertiesIntoResult(result.properties, items.properties)\n }\n}\n\n/**\n * Helper function for merging items that returns a new object.\n */\nconst mergeItems = (existing: SchemaObject, incoming: SchemaObject): SchemaObject => {\n // Handle allOf in either schema\n if (existing.allOf || incoming.allOf) {\n // Build array without spreads for better performance\n const allOfSchemas: SchemaObject[] = []\n\n if (existing.allOf) {\n for (const schema of existing.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(existing)\n }\n\n if (incoming.allOf) {\n for (const schema of incoming.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(incoming)\n }\n\n return mergeAllOfSchemas({ allOf: allOfSchemas } as SchemaObject)\n }\n\n const merged = { ...existing, ...incoming }\n\n // Recursively merge properties if both have properties\n if ('properties' in existing && 'properties' in incoming) {\n // @ts-expect-error\n merged.properties = { ...existing.properties }\n // @ts-expect-error\n mergePropertiesIntoResult(merged.properties, incoming.properties)\n }\n\n return merged as SchemaObject\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,IAAa,qBAAqB,SAAmC,eAA4C;AAE/G,KAAI,CAAC,SAAS,OAAO,UAAU,CAAC,MAAM,QAAQ,QAAQ,MAAM,CAC1D,QAAO,cAAe,EAAE;CAI1B,MAAM,SAAS,EAAE;CAGjB,MAAM,EAAE,OAAO,GAAG,GAAG,eAAe;AAGpC,MAAK,MAAM,WAAW,QAAQ,OAAO;AACnC,MAAI,CAAC,WAAW,OAAO,YAAY,SACjC;EAIF,MAAM,SAAS,QAAQ,OAAO,QAAQ;AAGtC,MAAI,OAAO,OAAO;AAEhB,yBAAsB,QADD,kBAAkB,OAAO,CACH;AAC3C;;AAGF,wBAAsB,QAAQ,OAAO;;AAIvC,KAAI,OAAO,KAAK,WAAW,CAAC,SAAS,EACnC,uBAAsB,QAAQ,YAAY,KAAK;AAIjD,KAAI,cAAc,OAAO,eAAe,SACtC,KAAI,WAAW,MAEb,uBAAsB,QADD,kBAAkB,WAAW,EACN,KAAK;KAEjD,uBAAsB,QAAQ,YAAY,KAAK;AAInD,QAAO;;;;;;;;;;AAWT,IAAM,yBAAyB,QAAsB,QAAsB,WAAoB,UAAgB;C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,gBAAgB,YAAY,gBAAgB,UAAU;AAExD,SAAO,aAAa,EAAE,GAAG,SAAS,YAAY;AAE9C,4BAA0B,OAAO,YAAY,SAAS,WAAW;;AAGnE,QAAO"}
|
|
1
|
+
{"version":3,"file":"merge-all-of-schemas.js","names":[],"sources":["../../../../../src/components/Content/Schema/helpers/merge-all-of-schemas.ts"],"sourcesContent":["import { objectKeys } from '@scalar/helpers/object/object-keys'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards'\n\n/**\n * Merges multiple OpenAPI schema objects into a single schema object.\n * Handles nested allOf compositions and merges properties recursively.\n *\n * @param schemas - Array of OpenAPI schema objects to merge\n * @param rootSchema - Optional root schema to merge with the result\n * @param seenRefs - `$ref` strings already being merged higher in the call stack\n * @returns Merged schema object\n */\nexport const mergeAllOfSchemas = (\n schemas: SchemaObject | undefined,\n rootSchema?: SchemaObject,\n seenRefs: Set<string> = new Set(),\n): SchemaObject => {\n // Handle max depth, empty or invalid input\n if (!schemas?.allOf?.length || !Array.isArray(schemas.allOf)) {\n return rootSchema || ({} as SchemaObject)\n }\n\n // Initialize result object once\n const result = {} as SchemaObject\n\n // Extract base schema properties (everything except allOf)\n const { allOf: _, ...baseSchema } = schemas\n\n // Process allOf schemas first\n for (const _schema of schemas.allOf) {\n if (!_schema || typeof _schema !== 'object') {\n continue\n }\n\n // Resolve ref if present\n const schema = resolve.schema(_schema)\n\n // Handle nested allOf recursively\n if (schema.allOf) {\n const nestedMerged = mergeAllOfSchemas(schema, undefined, seenRefs)\n mergeSchemaIntoResult(result, nestedMerged, false, seenRefs)\n continue\n }\n\n mergeSchemaIntoResult(result, schema, false, seenRefs)\n }\n\n // Apply base schema properties with precedence over allOf properties\n if (Object.keys(baseSchema).length > 0) {\n mergeSchemaIntoResult(result, baseSchema, true, seenRefs)\n }\n\n // Process root schema last if provided\n if (rootSchema && typeof rootSchema === 'object') {\n if (rootSchema.allOf) {\n const nestedMerged = mergeAllOfSchemas(rootSchema, undefined, seenRefs)\n mergeSchemaIntoResult(result, nestedMerged, true, seenRefs)\n } else {\n mergeSchemaIntoResult(result, rootSchema, true, seenRefs)\n }\n }\n\n return result\n}\n\n/**\n * Efficiently merges a source schema into a target result object.\n * Handles all schema merging logic in a single optimized function.\n *\n * @param result - The target schema object to merge into\n * @param schema - The source schema object to merge from\n * @param override - Whether to override existing properties (default: false)\n */\nconst mergeSchemaIntoResult = (\n result: SchemaObject,\n schema: SchemaObject,\n override: boolean = false,\n seenRefs: Set<string> = new Set(),\n): void => {\n // Early return if schema is empty\n const schemaKeys = objectKeys(schema)\n if (schemaKeys.length === 0) {\n return\n }\n\n // Loop through all schema properties and handle them appropriately\n for (const key of schemaKeys) {\n const value = getResolvedRef(schema[key]) as any\n\n if (value === undefined) {\n continue\n }\n\n // Required\n if ((key as string) === 'required') {\n // Merge required fields with deduplication\n if (Array.isArray(value) && value.length > 0) {\n // @ts-expect-error\n if (result.required?.length) {\n // @ts-expect-error\n result.required = [...new Set([...result.required, ...value])]\n } else {\n // @ts-expect-error\n result.required = value.slice()\n }\n }\n }\n // Properties\n else if ((key as string) === 'properties') {\n // Merge properties recursively\n if (value && typeof value === 'object') {\n // @ts-expect-error\n if (!result.properties) {\n // @ts-expect-error\n result.properties = {}\n }\n\n // @ts-expect-error\n mergePropertiesIntoResult(result.properties, value, seenRefs)\n }\n }\n // Items\n else if ((key as string) === 'items') {\n // Handle items (for both arrays and objects with items)\n const items = resolve.schema(value)\n if (items) {\n if (isArraySchema(schema)) {\n // @ts-expect-error\n if (!result.items) {\n // @ts-expect-error\n result.items = {}\n }\n\n // Handle allOf within array items\n if (items.allOf) {\n const mergedItems = mergeAllOfSchemas(items, undefined, seenRefs)\n // @ts-expect-error\n Object.assign(result.items, mergedItems)\n } else {\n // @ts-expect-error\n mergeItemsIntoResult(getResolvedRef(result.items), items, seenRefs)\n }\n }\n // For non-array types with items.allOf, merge into properties\n else if (items.allOf) {\n const mergedItems = mergeAllOfSchemas(items, undefined, seenRefs)\n if ('properties' in mergedItems) {\n if (!('properties' in result)) {\n // @ts-expect-error\n result.properties = {}\n }\n\n 'properties' in result && mergePropertiesIntoResult(result.properties, mergedItems.properties, seenRefs)\n }\n }\n // For non-array types without allOf, still set items if not already set\n else if (!('items' in result)) {\n // @ts-expect-error\n result.items = items\n }\n }\n }\n // Enum\n else if (key === 'enum') {\n if (Array.isArray(value) && value.length > 0) {\n result.enum = [...new Set([...(result.enum || []), ...value])]\n }\n }\n // OneOf/AnyOf\n else if (key === 'oneOf' || key === 'anyOf') {\n // Merge oneOf/anyOf subschema\n if (Array.isArray(value)) {\n if (!('properties' in result)) {\n // @ts-expect-error\n result.properties = {}\n }\n for (const _option of value) {\n const option = resolve.schema(_option)\n if (option && 'properties' in option && 'properties' in result) {\n mergePropertiesIntoResult(result.properties, option.properties, seenRefs)\n }\n }\n }\n }\n // Skip allOf as it's handled at a higher level\n else if (key === 'allOf') {\n continue\n }\n // For all other properties, preserve the first occurrence or override if specified\n else {\n if (override || result[key] === undefined) {\n result[key] = value\n }\n }\n }\n}\n\n/**\n * Efficiently merges properties into a result object without creating new objects.\n */\nconst mergePropertiesIntoResult = (\n result: Extract<SchemaObject, { type: 'object' }>['properties'],\n properties: Extract<SchemaObject, { type: 'object' }>['properties'],\n seenRefs: Set<string> = new Set(),\n): void => {\n const propertyKeys = Object.keys(properties ?? {})\n if (!properties || !result || propertyKeys.length === 0) {\n return\n }\n\n for (const key of propertyKeys) {\n const schema = resolve.schema(properties[key])\n if (!schema) {\n delete result[key]\n continue\n }\n\n if (typeof schema !== 'object') {\n result[key] = schema\n continue\n }\n\n if (!result[key]) {\n // Handle new property with allOf\n if (schema.allOf) {\n result[key] = mergeAllOfSchemas(schema, undefined, seenRefs)\n } else if (isArraySchema(schema) && resolve.schema(schema.items)?.allOf) {\n result[key] = {\n ...schema,\n items: mergeAllOfSchemas(resolve.schema(schema.items), undefined, seenRefs),\n }\n } else if (properties[key]) {\n result[key] = properties[key]\n }\n continue\n }\n\n // Merge existing property\n const existing = resolve.schema(result[key])\n\n // Break self-referential cycles: when this property's `$ref` is already\n // being merged higher in the call stack, keep the partially merged existing\n // schema instead of recursing into it again. This mirrors the guard in\n // `mergeItems` and covers schemas that point back at themselves through a\n // plain object property (e.g. a tree node whose `parent` $refs the node).\n const schemaRef = (schema as { $ref?: string }).$ref\n if (typeof schemaRef === 'string' && seenRefs.has(schemaRef)) {\n result[key] = existing\n continue\n }\n const nextSeenRefs = typeof schemaRef === 'string' ? new Set(seenRefs).add(schemaRef) : seenRefs\n\n if (schema.allOf) {\n result[key] = mergeAllOfSchemas({ allOf: [existing, ...schema.allOf] } as SchemaObject, undefined, nextSeenRefs)\n } else if (isArraySchema(schema) && isArraySchema(existing) && schema.items) {\n const existingItems = resolve.schema(existing.items)\n result[key] = {\n ...existing,\n type: 'array',\n items: existingItems\n ? mergeItems(existingItems, resolve.schema(schema.items), nextSeenRefs)\n : resolve.schema(schema.items),\n }\n } else {\n // Create merged object with properties handled separately\n if ('properties' in existing && 'properties' in schema) {\n const merged = { ...existing, ...schema }\n merged.properties = { ...existing.properties }\n mergePropertiesIntoResult(merged.properties, schema.properties, nextSeenRefs)\n result[key] = merged\n }\n // Simple merge without property recursion\n else {\n result[key] = { ...schema, ...existing }\n }\n }\n }\n}\n\n/**\n * Efficiently merges array items into a result object.\n */\nconst mergeItemsIntoResult = (result: SchemaObject, items: SchemaObject, seenRefs: Set<string> = new Set()): void => {\n // Handle allOf in items\n if (items.allOf || result.allOf) {\n // Build array without spreads for better performance\n const allOfSchemas: SchemaObject[] = []\n\n if (result.allOf) {\n for (const schema of result.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(result)\n }\n\n if (items.allOf) {\n for (const schema of items.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(items)\n }\n\n const merged = mergeAllOfSchemas({ allOf: allOfSchemas } as SchemaObject, undefined, seenRefs)\n Object.assign(result, merged)\n return\n }\n\n // Regular merge\n Object.assign(result, items)\n\n // Merge properties if both have them\n if ('properties' in result && 'properties' in items) {\n mergePropertiesIntoResult(result.properties, items.properties, seenRefs)\n }\n}\n\n/**\n * Helper function for merging items that returns a new object.\n */\nconst mergeItems = (\n existing: SchemaObject,\n incoming: SchemaObject,\n seenRefs: Set<string> = new Set(),\n): SchemaObject => {\n const incomingRef = (incoming as { $ref?: string }).$ref\n\n if (typeof incomingRef === 'string') {\n if (seenRefs.has(incomingRef)) {\n return existing\n }\n return mergeItemsInner(existing, incoming, new Set(seenRefs).add(incomingRef))\n }\n\n return mergeItemsInner(existing, incoming, seenRefs)\n}\n\nconst mergeItemsInner = (\n existing: SchemaObject,\n incoming: SchemaObject,\n seenRefs: Set<string> = new Set(),\n): SchemaObject => {\n // Handle allOf in either schema\n if (existing.allOf || incoming.allOf) {\n // Build array without spreads for better performance\n const allOfSchemas: SchemaObject[] = []\n\n if (existing.allOf) {\n for (const schema of existing.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(existing)\n }\n\n if (incoming.allOf) {\n for (const schema of incoming.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(incoming)\n }\n\n return mergeAllOfSchemas({ allOf: allOfSchemas } as SchemaObject, undefined, seenRefs)\n }\n\n const merged = { ...existing, ...incoming }\n\n // Recursively merge properties if both have properties\n if ('properties' in existing && 'properties' in incoming) {\n // @ts-expect-error\n merged.properties = { ...existing.properties }\n // @ts-expect-error\n mergePropertiesIntoResult(merged.properties, incoming.properties, seenRefs)\n }\n\n return merged as SchemaObject\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,IAAa,qBACX,SACA,YACA,2BAAwB,IAAI,KAAK,KAChB;AAEjB,KAAI,CAAC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M,UAAU,SAAS,MAC5B,cAAa,KAAK,QAAQ,OAAO,OAAO,CAAC;MAG3C,cAAa,KAAK,SAAS;AAG7B,SAAO,kBAAkB,EAAE,OAAO,cAAc,EAAkB,KAAA,GAAW,SAAS;;CAGxF,MAAM,SAAS;EAAE,GAAG;EAAU,GAAG;EAAU;AAG3C,KAAI,gBAAgB,YAAY,gBAAgB,UAAU;AAExD,SAAO,aAAa,EAAE,GAAG,SAAS,YAAY;AAE9C,4BAA0B,OAAO,YAAY,SAAS,YAAY,SAAS;;AAG7E,QAAO"}
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import ClassicHeader_default from "./ClassicHeader.vue.js";
|
|
2
2
|
import SectionContainer_default from "./Section/SectionContainer.vue.js";
|
|
3
|
-
import Auth_default from "./Content/Auth/Auth.vue.js";
|
|
4
3
|
import SchemaHeading_default from "./Content/Schema/SchemaHeading.vue.js";
|
|
5
4
|
import SchemaProperty_default from "./Content/Schema/SchemaProperty.vue.js";
|
|
6
5
|
import Schema_default from "./Content/Schema/Schema.vue.js";
|
|
@@ -11,6 +10,7 @@ import HttpMethod_default from "./HttpMethod/HttpMethod.vue.js";
|
|
|
11
10
|
import OperationsList_default from "./OperationsList/OperationsList.vue.js";
|
|
12
11
|
import Tag_default from "./Content/Tags/Tag.vue.js";
|
|
13
12
|
import Lazy_default from "./Lazy/Lazy.vue.js";
|
|
13
|
+
import Auth_default from "./Content/Auth/Auth.vue.js";
|
|
14
14
|
import TraversedEntry_default from "./Content/Operations/TraversedEntry.vue.js";
|
|
15
15
|
import RenderPlugins_default from "./RenderPlugins/RenderPlugins.vue.js";
|
|
16
16
|
import SectionFlare_default from "./SectionFlare/SectionFlare.vue.js";
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { type ModelsSectionLabel } from '@scalar/types/api-reference';
|
|
2
|
+
import type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1';
|
|
1
3
|
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
2
4
|
import type { OpenApiDocument } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
3
5
|
type __VLS_Props = {
|
|
4
6
|
forceIcon?: boolean;
|
|
5
7
|
searchHotKey?: string;
|
|
6
8
|
hideModels?: boolean;
|
|
7
|
-
|
|
9
|
+
modelsSectionLabel?: ModelsSectionLabel;
|
|
10
|
+
document?: OpenApiDocument | AsyncApiDocument;
|
|
8
11
|
eventBus: WorkspaceEventBus;
|
|
9
12
|
};
|
|
10
13
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchButton.vue.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/components/SearchButton.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SearchButton.vue.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/components/SearchButton.vue"],"names":[],"mappings":"AA+GA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAKnG,KAAK,WAAW,GAAG;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC,QAAQ,CAAC,EAAE,eAAe,GAAG,gBAAgB,CAAA;IAC7C,QAAQ,EAAE,iBAAiB,CAAA;CAC5B,CAAC;AA0KF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchButton.vue.js","names":[],"sources":["../../../../src/features/Search/components/SearchButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useModal } from '@scalar/components/modal'\nimport { ScalarSidebarSearchButton } from '@scalar/components/sidebar'\nimport { isMacOS } from '@scalar/helpers/general/is-mac-os'\nimport { ScalarIconMagnifyingGlass } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { OpenApiDocument } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\n\nimport SearchModal from './SearchModal.vue'\n\nconst {
|
|
1
|
+
{"version":3,"file":"SearchButton.vue.js","names":[],"sources":["../../../../src/features/Search/components/SearchButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useModal } from '@scalar/components/modal'\nimport { ScalarSidebarSearchButton } from '@scalar/components/sidebar'\nimport { isMacOS } from '@scalar/helpers/general/is-mac-os'\nimport { ScalarIconMagnifyingGlass } from '@scalar/icons'\nimport {\n DEFAULT_MODELS_SECTION_LABEL,\n type ModelsSectionLabel,\n} from '@scalar/types/api-reference'\nimport type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { OpenApiDocument } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\n\nimport SearchModal from './SearchModal.vue'\n\nconst {\n searchHotKey = 'k',\n modelsSectionLabel = DEFAULT_MODELS_SECTION_LABEL,\n} = defineProps<{\n forceIcon?: boolean\n searchHotKey?: string\n hideModels?: boolean\n modelsSectionLabel?: ModelsSectionLabel\n document?: OpenApiDocument | AsyncApiDocument\n eventBus: WorkspaceEventBus\n}>()\n\nconst button = ref<InstanceType<typeof ScalarSidebarSearchButton>>()\nconst modalState = useModal()\n\nconst handleHotKey = (e: KeyboardEvent) => {\n if ((isMacOS() ? e.metaKey : e.ctrlKey) && e.key === searchHotKey) {\n e.preventDefault()\n e.stopPropagation()\n\n if (modalState.open) {\n modalState.hide()\n } else {\n modalState.show()\n }\n }\n}\n\nwatch(\n () => modalState.open,\n async (next, prev) => {\n // Return focus to the button when the modal is closed\n if (!next && prev) {\n await nextTick()\n button.value?.$el.focus()\n }\n },\n)\n\n// Handle keyboard shortcuts\n// TODO: we can move this to the hotkey event bus but we would need to set up a custom key from the searchHotKey config\n// and make sure it works correctly inside the references first\nonMounted(() => window.addEventListener('keydown', handleHotKey))\nonBeforeUnmount(() => window.removeEventListener('keydown', handleHotKey))\n\nfunction handleClick() {\n modalState.show()\n}\n</script>\n<template>\n <ScalarIconButton\n v-if=\"forceIcon\"\n :icon=\"ScalarIconMagnifyingGlass\"\n label=\"Search\"\n @click=\"handleClick\" />\n <ScalarSidebarSearchButton\n v-else\n ref=\"button\"\n class=\"w-full\"\n :class=\"$attrs.class\"\n @click=\"handleClick\">\n <span class=\"sr-only\">Open Search</span>\n <span\n aria-hidden=\"true\"\n class=\"sidebar-search-placeholder\">\n Search\n </span>\n <template #shortcut>\n <template v-if=\"isMacOS()\">\n <span class=\"sr-only\">Command</span>\n <span aria-hidden=\"true\">⌘</span>\n </template>\n <template v-else>\n <span class=\"sr-only\">CTRL</span>\n <span aria-hidden=\"true\">⌃</span>\n </template>\n {{ searchHotKey }}\n </template>\n </ScalarSidebarSearchButton>\n\n <SearchModal\n :document\n :eventBus=\"eventBus\"\n :modalState=\"modalState\"\n :modelsSectionLabel=\"modelsSectionLabel\" />\n</template>\n"],"mappings":""}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import SearchModal_default from "./SearchModal.vue.js";
|
|
2
2
|
import { Fragment, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, nextTick, normalizeClass, onBeforeUnmount, onMounted, openBlock, ref, toDisplayString, unref, watch, withCtx } from "vue";
|
|
3
3
|
import { ScalarSidebarSearchButton } from "@scalar/components/sidebar";
|
|
4
|
+
import { DEFAULT_MODELS_SECTION_LABEL } from "@scalar/types/api-reference";
|
|
4
5
|
import { ScalarIconMagnifyingGlass } from "@scalar/icons";
|
|
5
6
|
import { ScalarIconButton } from "@scalar/components/icon-button";
|
|
6
7
|
import { useModal } from "@scalar/components/modal";
|
|
@@ -11,10 +12,8 @@ var SearchButton_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
11
12
|
props: {
|
|
12
13
|
forceIcon: { type: Boolean },
|
|
13
14
|
searchHotKey: { default: "k" },
|
|
14
|
-
hideModels: {
|
|
15
|
-
|
|
16
|
-
default: false
|
|
17
|
-
},
|
|
15
|
+
hideModels: { type: Boolean },
|
|
16
|
+
modelsSectionLabel: { default: () => DEFAULT_MODELS_SECTION_LABEL },
|
|
18
17
|
document: {},
|
|
19
18
|
eventBus: {}
|
|
20
19
|
},
|
|
@@ -62,13 +61,13 @@ var SearchButton_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
62
61
|
}, 8, ["class"])), createVNode(SearchModal_default, {
|
|
63
62
|
document: __props.document,
|
|
64
63
|
eventBus: __props.eventBus,
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
modalState: unref(modalState),
|
|
65
|
+
modelsSectionLabel: __props.modelsSectionLabel
|
|
67
66
|
}, null, 8, [
|
|
68
67
|
"document",
|
|
69
68
|
"eventBus",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
69
|
+
"modalState",
|
|
70
|
+
"modelsSectionLabel"
|
|
72
71
|
])], 64);
|
|
73
72
|
};
|
|
74
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchButton.vue.script.js","names":["$attrs"],"sources":["../../../../src/features/Search/components/SearchButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useModal } from '@scalar/components/modal'\nimport { ScalarSidebarSearchButton } from '@scalar/components/sidebar'\nimport { isMacOS } from '@scalar/helpers/general/is-mac-os'\nimport { ScalarIconMagnifyingGlass } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { OpenApiDocument } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\n\nimport SearchModal from './SearchModal.vue'\n\nconst {
|
|
1
|
+
{"version":3,"file":"SearchButton.vue.script.js","names":["$attrs"],"sources":["../../../../src/features/Search/components/SearchButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useModal } from '@scalar/components/modal'\nimport { ScalarSidebarSearchButton } from '@scalar/components/sidebar'\nimport { isMacOS } from '@scalar/helpers/general/is-mac-os'\nimport { ScalarIconMagnifyingGlass } from '@scalar/icons'\nimport {\n DEFAULT_MODELS_SECTION_LABEL,\n type ModelsSectionLabel,\n} from '@scalar/types/api-reference'\nimport type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { OpenApiDocument } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\n\nimport SearchModal from './SearchModal.vue'\n\nconst {\n searchHotKey = 'k',\n modelsSectionLabel = DEFAULT_MODELS_SECTION_LABEL,\n} = defineProps<{\n forceIcon?: boolean\n searchHotKey?: string\n hideModels?: boolean\n modelsSectionLabel?: ModelsSectionLabel\n document?: OpenApiDocument | AsyncApiDocument\n eventBus: WorkspaceEventBus\n}>()\n\nconst button = ref<InstanceType<typeof ScalarSidebarSearchButton>>()\nconst modalState = useModal()\n\nconst handleHotKey = (e: KeyboardEvent) => {\n if ((isMacOS() ? e.metaKey : e.ctrlKey) && e.key === searchHotKey) {\n e.preventDefault()\n e.stopPropagation()\n\n if (modalState.open) {\n modalState.hide()\n } else {\n modalState.show()\n }\n }\n}\n\nwatch(\n () => modalState.open,\n async (next, prev) => {\n // Return focus to the button when the modal is closed\n if (!next && prev) {\n await nextTick()\n button.value?.$el.focus()\n }\n },\n)\n\n// Handle keyboard shortcuts\n// TODO: we can move this to the hotkey event bus but we would need to set up a custom key from the searchHotKey config\n// and make sure it works correctly inside the references first\nonMounted(() => window.addEventListener('keydown', handleHotKey))\nonBeforeUnmount(() => window.removeEventListener('keydown', handleHotKey))\n\nfunction handleClick() {\n modalState.show()\n}\n</script>\n<template>\n <ScalarIconButton\n v-if=\"forceIcon\"\n :icon=\"ScalarIconMagnifyingGlass\"\n label=\"Search\"\n @click=\"handleClick\" />\n <ScalarSidebarSearchButton\n v-else\n ref=\"button\"\n class=\"w-full\"\n :class=\"$attrs.class\"\n @click=\"handleClick\">\n <span class=\"sr-only\">Open Search</span>\n <span\n aria-hidden=\"true\"\n class=\"sidebar-search-placeholder\">\n Search\n </span>\n <template #shortcut>\n <template v-if=\"isMacOS()\">\n <span class=\"sr-only\">Command</span>\n <span aria-hidden=\"true\">⌘</span>\n </template>\n <template v-else>\n <span class=\"sr-only\">CTRL</span>\n <span aria-hidden=\"true\">⌃</span>\n </template>\n {{ searchHotKey }}\n </template>\n </ScalarSidebarSearchButton>\n\n <SearchModal\n :document\n :eventBus=\"eventBus\"\n :modalState=\"modalState\"\n :modelsSectionLabel=\"modelsSectionLabel\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EA6BA,MAAM,SAAS,KAAoD;EACnE,MAAM,aAAa,UAAS;EAE5B,MAAM,gBAAgB,MAAqB;AACzC,QAAK,SAAS,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,QAAA,cAAc;AACjE,MAAE,gBAAe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EAAC,eAAW,GAAA,GAAA,OAAA,OAAA,OAAA,KACjC,mBAIO,QAAA;KAHL,eAAY;KACZ,OAAM;OAA6B,YAErC,GAAA,EAAA,CAAA;;sBAcF,YAI6C,qBAAA;IAH1C,UAAA,QAAA;IACA,UAAU,QAAA;IACV,YAAY,MAAA,WAAU;IACtB,oBAAoB,QAAA"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type ModalState } from '@scalar/components/modal';
|
|
2
|
+
import type { ModelsSectionLabel } from '@scalar/types/api-reference';
|
|
3
|
+
import type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1';
|
|
2
4
|
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
3
5
|
import type { OpenApiDocument } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
4
6
|
type __VLS_Props = {
|
|
5
7
|
modalState: ModalState;
|
|
6
|
-
document: OpenApiDocument | undefined;
|
|
8
|
+
document: OpenApiDocument | AsyncApiDocument | undefined;
|
|
7
9
|
eventBus: WorkspaceEventBus;
|
|
10
|
+
modelsSectionLabel?: ModelsSectionLabel;
|
|
8
11
|
};
|
|
9
12
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
13
|
declare const _default: typeof __VLS_export;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchModal.vue.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/components/SearchModal.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SearchModal.vue.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/components/SearchModal.vue"],"names":[],"mappings":"AAwJA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAGvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAQnG,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,eAAe,GAAG,gBAAgB,GAAG,SAAS,CAAA;IACxD,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;CACxC,CAAC;AA4PF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|