@scalar/api-reference 1.55.3 → 1.57.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/dist/blocks/scalar-info-block/components/DownloadLink.vue.d.ts +2 -0
  3. package/dist/blocks/scalar-info-block/components/DownloadLink.vue.d.ts.map +1 -1
  4. package/dist/blocks/scalar-info-block/components/DownloadLink.vue.js +1 -1
  5. package/dist/blocks/scalar-info-block/components/DownloadLink.vue.js.map +1 -1
  6. package/dist/blocks/scalar-info-block/components/DownloadLink.vue.script.js +9 -7
  7. package/dist/blocks/scalar-info-block/components/DownloadLink.vue.script.js.map +1 -1
  8. package/dist/blocks/scalar-info-block/components/InfoBlock.vue.d.ts +4 -2
  9. package/dist/blocks/scalar-info-block/components/InfoBlock.vue.d.ts.map +1 -1
  10. package/dist/blocks/scalar-info-block/components/InfoBlock.vue.js.map +1 -1
  11. package/dist/blocks/scalar-info-block/components/InfoBlock.vue.script.js +9 -4
  12. package/dist/blocks/scalar-info-block/components/InfoBlock.vue.script.js.map +1 -1
  13. package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.d.ts +2 -1
  14. package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.d.ts.map +1 -1
  15. package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.js +1 -1
  16. package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.js.map +1 -1
  17. package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.script.js +7 -3
  18. package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.script.js.map +1 -1
  19. package/dist/blocks/scalar-info-block/components/{OpenApiVersion.vue.d.ts → SpecificationVersion.vue.d.ts} +5 -2
  20. package/dist/blocks/scalar-info-block/components/SpecificationVersion.vue.d.ts.map +1 -0
  21. package/dist/blocks/scalar-info-block/components/SpecificationVersion.vue.js +7 -0
  22. package/dist/blocks/scalar-info-block/components/SpecificationVersion.vue.js.map +1 -0
  23. package/dist/blocks/scalar-info-block/components/SpecificationVersion.vue.script.js +23 -0
  24. package/dist/blocks/scalar-info-block/components/SpecificationVersion.vue.script.js.map +1 -0
  25. package/dist/browser/standalone.js +275 -261
  26. package/dist/browser/webpack-stats.json +1 -1
  27. package/dist/components/AgentScalar/AgentScalarChatInterface.vue.d.ts +1 -1
  28. package/dist/components/AgentScalar/AgentScalarChatInterface.vue.d.ts.map +1 -1
  29. package/dist/components/AgentScalar/AgentScalarChatInterface.vue.js.map +1 -1
  30. package/dist/components/AgentScalar/AgentScalarChatInterface.vue.script.js.map +1 -1
  31. package/dist/components/AgentScalar/AgentScalarDrawer.vue.d.ts +1 -1
  32. package/dist/components/AgentScalar/AgentScalarDrawer.vue.d.ts.map +1 -1
  33. package/dist/components/AgentScalar/AgentScalarDrawer.vue.js +1 -1
  34. package/dist/components/AgentScalar/AgentScalarDrawer.vue.js.map +1 -1
  35. package/dist/components/AgentScalar/AgentScalarDrawer.vue.script.js.map +1 -1
  36. package/dist/components/ApiReference.vue.d.ts.map +1 -1
  37. package/dist/components/ApiReference.vue.js +1 -1
  38. package/dist/components/ApiReference.vue.js.map +1 -1
  39. package/dist/components/ApiReference.vue.script.js +20 -8
  40. package/dist/components/ApiReference.vue.script.js.map +1 -1
  41. package/dist/components/Badge/Badge.vue.js +1 -1
  42. package/dist/components/Badge/Badge.vue.js.map +1 -1
  43. package/dist/components/Badge/Badge.vue.script.js.map +1 -1
  44. package/dist/components/Content/Auth/Auth.vue.d.ts.map +1 -1
  45. package/dist/components/Content/Auth/Auth.vue.js.map +1 -1
  46. package/dist/components/Content/Auth/Auth.vue.script.js +3 -2
  47. package/dist/components/Content/Auth/Auth.vue.script.js.map +1 -1
  48. package/dist/components/Content/Content.vue.d.ts.map +1 -1
  49. package/dist/components/Content/Content.vue.js.map +1 -1
  50. package/dist/components/Content/Content.vue.script.js +23 -9
  51. package/dist/components/Content/Content.vue.script.js.map +1 -1
  52. package/dist/components/Content/Operations/TraversedEntry.vue.d.ts +2 -3
  53. package/dist/components/Content/Operations/TraversedEntry.vue.d.ts.map +1 -1
  54. package/dist/components/Content/Operations/TraversedEntry.vue.js.map +1 -1
  55. package/dist/components/Content/Operations/TraversedEntry.vue.script.js.map +1 -1
  56. package/dist/components/Content/Schema/Schema.vue.d.ts +2 -0
  57. package/dist/components/Content/Schema/Schema.vue.d.ts.map +1 -1
  58. package/dist/components/Content/Schema/Schema.vue.js +1 -1
  59. package/dist/components/Content/Schema/Schema.vue.js.map +1 -1
  60. package/dist/components/Content/Schema/Schema.vue.script.js +5 -0
  61. package/dist/components/Content/Schema/Schema.vue.script.js.map +1 -1
  62. package/dist/components/Content/Schema/SchemaObjectProperties.vue.d.ts.map +1 -1
  63. package/dist/components/Content/Schema/SchemaObjectProperties.vue.js.map +1 -1
  64. package/dist/components/Content/Schema/SchemaObjectProperties.vue.script.js +5 -3
  65. package/dist/components/Content/Schema/SchemaObjectProperties.vue.script.js.map +1 -1
  66. package/dist/components/MobileHeader.vue.js.map +1 -1
  67. package/dist/components/MobileHeader.vue.script.js +1 -1
  68. package/dist/components/MobileHeader.vue.script.js.map +1 -1
  69. package/dist/features/Operation/components/RequestBody.vue.d.ts.map +1 -1
  70. package/dist/features/Operation/components/RequestBody.vue.js +1 -1
  71. package/dist/features/Operation/components/RequestBody.vue.js.map +1 -1
  72. package/dist/features/Operation/components/RequestBody.vue.script.js +1 -0
  73. package/dist/features/Operation/components/RequestBody.vue.script.js.map +1 -1
  74. package/dist/features/Search/helpers/create-fuse-instance.d.ts.map +1 -1
  75. package/dist/features/Search/helpers/create-fuse-instance.js +20 -12
  76. package/dist/features/Search/helpers/create-fuse-instance.js.map +1 -1
  77. package/dist/features/Search/helpers/create-search-index.d.ts.map +1 -1
  78. package/dist/features/Search/helpers/create-search-index.js +18 -8
  79. package/dist/features/Search/helpers/create-search-index.js.map +1 -1
  80. package/dist/features/Search/types.d.ts +6 -0
  81. package/dist/features/Search/types.d.ts.map +1 -1
  82. package/dist/features/developer-tools/components/ApiReferenceToolbarConfigTheme.vue.d.ts +2 -2
  83. package/dist/helpers/map-config-plugins.d.ts.map +1 -1
  84. package/dist/helpers/map-config-plugins.js +9 -1
  85. package/dist/helpers/map-config-plugins.js.map +1 -1
  86. package/dist/helpers/normalize-configurations.d.ts.map +1 -1
  87. package/dist/helpers/normalize-configurations.js +6 -6
  88. package/dist/helpers/normalize-configurations.js.map +1 -1
  89. package/dist/helpers/openapi.d.ts +34 -5
  90. package/dist/helpers/openapi.d.ts.map +1 -1
  91. package/dist/helpers/openapi.js +108 -66
  92. package/dist/helpers/openapi.js.map +1 -1
  93. package/dist/standalone/lib/html-api.d.ts.map +1 -1
  94. package/dist/standalone/lib/html-api.js +10 -4
  95. package/dist/standalone/lib/html-api.js.map +1 -1
  96. package/dist/style.css +367 -1782
  97. package/dist/vue-styles.css +83 -83
  98. package/package.json +17 -15
  99. package/dist/blocks/scalar-info-block/components/OpenApiVersion.vue.d.ts.map +0 -1
  100. package/dist/blocks/scalar-info-block/components/OpenApiVersion.vue.js +0 -7
  101. package/dist/blocks/scalar-info-block/components/OpenApiVersion.vue.js.map +0 -1
  102. package/dist/blocks/scalar-info-block/components/OpenApiVersion.vue.script.js +0 -19
  103. package/dist/blocks/scalar-info-block/components/OpenApiVersion.vue.script.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"RequestBody.vue.js","names":[],"sources":["../../../../src/features/Operation/components/RequestBody.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarMarkdown } from '@scalar/components'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport { Schema } from '@/components/Content/Schema'\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { getModelNameFromSchema } from '@/components/Content/Schema/helpers/schema-name'\nimport {\n reduceNamesToObject,\n sortPropertyNames,\n} from '@/components/Content/Schema/helpers/sort-property-names'\nimport LinkButton from '@/components/Content/Schema/LinkButton.vue'\n\nimport ContentTypeSelect from './ContentTypeSelect.vue'\n\nconst { requestBody, options } = defineProps<{\n breadcrumb?: string[]\n requestBody?: RequestBodyObject\n eventBus: WorkspaceEventBus | null\n options: {\n orderRequiredPropertiesFirst: boolean | undefined\n orderSchemaPropertiesBy: 'alpha' | 'preserve' | undefined\n hideModels: boolean | undefined\n }\n}>()\n\n/**\n * The maximum number of properties to show in the request body schema.\n */\nconst MAX_VISIBLE_PROPERTIES = 12\n\nconst availableContentTypes = computed(() =>\n Object.keys(requestBody?.content ?? {}),\n)\n\nconst selectedContentType = defineModel<string>('selectedContentType', {\n default: 'application/json',\n})\n\nif (requestBody?.content) {\n if (availableContentTypes.value[0]) {\n selectedContentType.value = availableContentTypes.value[0]\n }\n}\n\n/** Raw schema (possibly with $ref) for the selected content type */\nconst rawSchema = computed(\n () => requestBody?.content?.[selectedContentType.value]?.schema,\n)\n\nconst schema = computed(() => getResolvedRef(rawSchema.value))\n\n/** When the schema is a $ref, preserve its name so the UI can show the ref name instead of just the type. */\nconst modelLink = computed(\n () => (rawSchema.value && getModelNameFromSchema(rawSchema.value)) ?? null,\n)\n\n/**\n * Splits schema properties into visible and collapsed sections when there are more than 12 properties.\n * Returns null for schemas with fewer properties or non-object schemas.\n */\nconst partitionedSchema = computed(() => {\n // Early return if not an object schema\n if (!schema.value || !isTypeObject(schema.value)) {\n return null\n }\n\n // Lets sort the names first\n const sortedNames = sortPropertyNames(\n schema.value,\n schema.value.discriminator,\n {\n hideReadOnly: true,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n },\n )\n\n if (sortedNames.length <= MAX_VISIBLE_PROPERTIES) {\n return null\n }\n\n // Destructure everything except properties\n const { properties, ...schemaMetadata } = schema.value\n if (!properties) {\n return null\n }\n\n return {\n visibleProperties: {\n ...schemaMetadata,\n properties: reduceNamesToObject(\n sortedNames.slice(0, MAX_VISIBLE_PROPERTIES),\n properties,\n ),\n },\n collapsedProperties: {\n ...schemaMetadata,\n properties: reduceNamesToObject(\n sortedNames.slice(MAX_VISIBLE_PROPERTIES),\n properties,\n ),\n },\n }\n})\n\n/**\n * We don't want to render the request body if its completely empty\n * @example\n * {\n * \"content\": {},\n * }\n */\nconst shouldRenderRequestBody = computed(\n () =>\n Object.keys(requestBody?.content ?? {}).length > 0 ||\n requestBody?.description ||\n requestBody?.required,\n)\n</script>\n<template>\n <div\n v-if=\"requestBody && shouldRenderRequestBody\"\n aria-label=\"Request Body\"\n class=\"request-body\"\n role=\"group\">\n <div class=\"request-body-header\">\n <div class=\"request-body-title\">\n <slot name=\"title\" />\n <span\n v-if=\"modelLink\"\n class=\"text-c-2 text-xs leading-none font-normal\"\n data-testid=\"request-body-schema-name\">\n <span class=\"text-c-3 mx-1.5\">·</span>\n <LinkButton\n v-if=\"eventBus && modelLink.schemaKey\"\n @click=\"\n eventBus.emit('scroll-to:model-by-name', {\n name: modelLink.schemaKey,\n })\n \">\n {{ modelLink.label }}\n </LinkButton>\n <template v-else>{{ modelLink.label }}</template>\n </span>\n </div>\n <div class=\"flex items-center gap-2\">\n <div\n v-if=\"requestBody.required\"\n class=\"request-body-required\">\n required\n </div>\n <ContentTypeSelect\n v-model=\"selectedContentType\"\n :content=\"requestBody.content\" />\n </div>\n <div\n v-if=\"requestBody.description\"\n class=\"request-body-description\">\n <ScalarMarkdown :value=\"requestBody.description\" />\n </div>\n </div>\n\n <!-- For over 12 properties we want to show 12 and collapse the rest -->\n <div\n v-if=\"partitionedSchema\"\n class=\"request-body-schema\">\n <Schema\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n name=\"Request Body\"\n noncollapsible\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"partitionedSchema.visibleProperties\"\n schemaContext=\"requestBody\" />\n\n <Schema\n additionalProperties\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n name=\"Request Body\"\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"partitionedSchema.collapsedProperties\"\n schemaContext=\"requestBody\" />\n </div>\n\n <!-- Show em all 12 and under -->\n <div\n v-else-if=\"schema\"\n class=\"request-body-schema\">\n <Schema\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n :hideReadOnly=\"true\"\n name=\"Request Body\"\n noncollapsible\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"schema\"\n schemaContext=\"requestBody\" />\n </div>\n </div>\n</template>\n\n<style scoped>\n.request-body {\n margin-top: 24px;\n}\n.request-body-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding-bottom: 12px;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n flex-flow: wrap;\n}\n.request-body-title {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--scalar-font-size-2);\n font-weight: var(--scalar-semibold);\n color: var(--scalar-color-1);\n}\n.request-body-required {\n font-size: var(--scalar-micro);\n color: var(--scalar-color-orange);\n font-weight: normal;\n border-radius: 16px;\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 2px 8px;\n height: 20px;\n}\n.request-body-description {\n margin-top: 6px;\n font-size: var(--scalar-small);\n width: 100%;\n}\n\n.request-body-header\n + .request-body-schema:has(> .schema-card > .schema-card-description),\n.request-body-header\n + .request-body-schema:has(\n > .schema-card > .schema-properties > * > .property--level-0\n ) {\n /** Add a bit of space between the heading border and the schema description or properties */\n padding-top: 8px;\n}\n.request-body-description :deep(.markdown) * {\n color: var(--scalar-color-2) !important;\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"RequestBody.vue.js","names":[],"sources":["../../../../src/features/Operation/components/RequestBody.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarMarkdown } from '@scalar/components'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport { Schema } from '@/components/Content/Schema'\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { getModelNameFromSchema } from '@/components/Content/Schema/helpers/schema-name'\nimport {\n reduceNamesToObject,\n sortPropertyNames,\n} from '@/components/Content/Schema/helpers/sort-property-names'\nimport LinkButton from '@/components/Content/Schema/LinkButton.vue'\n\nimport ContentTypeSelect from './ContentTypeSelect.vue'\n\nconst { requestBody, options } = defineProps<{\n breadcrumb?: string[]\n requestBody?: RequestBodyObject\n eventBus: WorkspaceEventBus | null\n options: {\n orderRequiredPropertiesFirst: boolean | undefined\n orderSchemaPropertiesBy: 'alpha' | 'preserve' | undefined\n hideModels: boolean | undefined\n }\n}>()\n\n/**\n * The maximum number of properties to show in the request body schema.\n */\nconst MAX_VISIBLE_PROPERTIES = 12\n\nconst availableContentTypes = computed(() =>\n Object.keys(requestBody?.content ?? {}),\n)\n\nconst selectedContentType = defineModel<string>('selectedContentType', {\n default: 'application/json',\n})\n\nif (requestBody?.content) {\n if (availableContentTypes.value[0]) {\n selectedContentType.value = availableContentTypes.value[0]\n }\n}\n\n/** Raw schema (possibly with $ref) for the selected content type */\nconst rawSchema = computed(\n () => requestBody?.content?.[selectedContentType.value]?.schema,\n)\n\nconst schema = computed(() => getResolvedRef(rawSchema.value))\n\n/** When the schema is a $ref, preserve its name so the UI can show the ref name instead of just the type. */\nconst modelLink = computed(\n () => (rawSchema.value && getModelNameFromSchema(rawSchema.value)) ?? null,\n)\n\n/**\n * Splits schema properties into visible and collapsed sections when there are more than 12 properties.\n * Returns null for schemas with fewer properties or non-object schemas.\n */\nconst partitionedSchema = computed(() => {\n // Early return if not an object schema\n if (!schema.value || !isTypeObject(schema.value)) {\n return null\n }\n\n // Lets sort the names first\n const sortedNames = sortPropertyNames(\n schema.value,\n schema.value.discriminator,\n {\n hideReadOnly: true,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n },\n )\n\n if (sortedNames.length <= MAX_VISIBLE_PROPERTIES) {\n return null\n }\n\n // Destructure everything except properties\n const { properties, ...schemaMetadata } = schema.value\n if (!properties) {\n return null\n }\n\n return {\n visibleProperties: {\n ...schemaMetadata,\n properties: reduceNamesToObject(\n sortedNames.slice(0, MAX_VISIBLE_PROPERTIES),\n properties,\n ),\n },\n collapsedProperties: {\n ...schemaMetadata,\n properties: reduceNamesToObject(\n sortedNames.slice(MAX_VISIBLE_PROPERTIES),\n properties,\n ),\n },\n }\n})\n\n/**\n * We don't want to render the request body if its completely empty\n * @example\n * {\n * \"content\": {},\n * }\n */\nconst shouldRenderRequestBody = computed(\n () =>\n Object.keys(requestBody?.content ?? {}).length > 0 ||\n requestBody?.description ||\n requestBody?.required,\n)\n</script>\n<template>\n <div\n v-if=\"requestBody && shouldRenderRequestBody\"\n aria-label=\"Request Body\"\n class=\"request-body\"\n role=\"group\">\n <div class=\"request-body-header\">\n <div class=\"request-body-title\">\n <slot name=\"title\" />\n <span\n v-if=\"modelLink\"\n class=\"text-c-2 text-xs leading-none font-normal\"\n data-testid=\"request-body-schema-name\">\n <span class=\"text-c-3 mx-1.5\">·</span>\n <LinkButton\n v-if=\"eventBus && modelLink.schemaKey\"\n @click=\"\n eventBus.emit('scroll-to:model-by-name', {\n name: modelLink.schemaKey,\n })\n \">\n {{ modelLink.label }}\n </LinkButton>\n <template v-else>{{ modelLink.label }}</template>\n </span>\n </div>\n <div class=\"flex items-center gap-2\">\n <div\n v-if=\"requestBody.required\"\n class=\"request-body-required\">\n required\n </div>\n <ContentTypeSelect\n v-model=\"selectedContentType\"\n :content=\"requestBody.content\" />\n </div>\n <div\n v-if=\"requestBody.description\"\n class=\"request-body-description\">\n <ScalarMarkdown :value=\"requestBody.description\" />\n </div>\n </div>\n\n <!-- For over 12 properties we want to show 12 and collapse the rest -->\n <div\n v-if=\"partitionedSchema\"\n class=\"request-body-schema\">\n <Schema\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n name=\"Request Body\"\n noncollapsible\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"partitionedSchema.visibleProperties\"\n schemaContext=\"requestBody\" />\n\n <Schema\n additionalProperties\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n hideDescription\n name=\"Request Body\"\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"partitionedSchema.collapsedProperties\"\n schemaContext=\"requestBody\" />\n </div>\n\n <!-- Show em all 12 and under -->\n <div\n v-else-if=\"schema\"\n class=\"request-body-schema\">\n <Schema\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n :hideReadOnly=\"true\"\n name=\"Request Body\"\n noncollapsible\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"schema\"\n schemaContext=\"requestBody\" />\n </div>\n </div>\n</template>\n\n<style scoped>\n.request-body {\n margin-top: 24px;\n}\n.request-body-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding-bottom: 12px;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n flex-flow: wrap;\n}\n.request-body-title {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--scalar-font-size-2);\n font-weight: var(--scalar-semibold);\n color: var(--scalar-color-1);\n}\n.request-body-required {\n font-size: var(--scalar-micro);\n color: var(--scalar-color-orange);\n font-weight: normal;\n border-radius: 16px;\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 2px 8px;\n height: 20px;\n}\n.request-body-description {\n margin-top: 6px;\n font-size: var(--scalar-small);\n width: 100%;\n}\n\n.request-body-header\n + .request-body-schema:has(> .schema-card > .schema-card-description),\n.request-body-header\n + .request-body-schema:has(\n > .schema-card > .schema-properties > * > .property--level-0\n ) {\n /** Add a bit of space between the heading border and the schema description or properties */\n padding-top: 8px;\n}\n.request-body-description :deep(.markdown) * {\n color: var(--scalar-color-2) !important;\n}\n</style>\n"],"mappings":""}
@@ -138,6 +138,7 @@ var RequestBody_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
138
138
  compact: "",
139
139
  compositionPath: ["requestBody"],
140
140
  eventBus: __props.eventBus,
141
+ hideDescription: "",
141
142
  name: "Request Body",
142
143
  options: {
143
144
  hideReadOnly: true,
@@ -1 +1 @@
1
- {"version":3,"file":"RequestBody.vue.script.js","names":[],"sources":["../../../../src/features/Operation/components/RequestBody.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarMarkdown } from '@scalar/components'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport { Schema } from '@/components/Content/Schema'\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { getModelNameFromSchema } from '@/components/Content/Schema/helpers/schema-name'\nimport {\n reduceNamesToObject,\n sortPropertyNames,\n} from '@/components/Content/Schema/helpers/sort-property-names'\nimport LinkButton from '@/components/Content/Schema/LinkButton.vue'\n\nimport ContentTypeSelect from './ContentTypeSelect.vue'\n\nconst { requestBody, options } = defineProps<{\n breadcrumb?: string[]\n requestBody?: RequestBodyObject\n eventBus: WorkspaceEventBus | null\n options: {\n orderRequiredPropertiesFirst: boolean | undefined\n orderSchemaPropertiesBy: 'alpha' | 'preserve' | undefined\n hideModels: boolean | undefined\n }\n}>()\n\n/**\n * The maximum number of properties to show in the request body schema.\n */\nconst MAX_VISIBLE_PROPERTIES = 12\n\nconst availableContentTypes = computed(() =>\n Object.keys(requestBody?.content ?? {}),\n)\n\nconst selectedContentType = defineModel<string>('selectedContentType', {\n default: 'application/json',\n})\n\nif (requestBody?.content) {\n if (availableContentTypes.value[0]) {\n selectedContentType.value = availableContentTypes.value[0]\n }\n}\n\n/** Raw schema (possibly with $ref) for the selected content type */\nconst rawSchema = computed(\n () => requestBody?.content?.[selectedContentType.value]?.schema,\n)\n\nconst schema = computed(() => getResolvedRef(rawSchema.value))\n\n/** When the schema is a $ref, preserve its name so the UI can show the ref name instead of just the type. */\nconst modelLink = computed(\n () => (rawSchema.value && getModelNameFromSchema(rawSchema.value)) ?? null,\n)\n\n/**\n * Splits schema properties into visible and collapsed sections when there are more than 12 properties.\n * Returns null for schemas with fewer properties or non-object schemas.\n */\nconst partitionedSchema = computed(() => {\n // Early return if not an object schema\n if (!schema.value || !isTypeObject(schema.value)) {\n return null\n }\n\n // Lets sort the names first\n const sortedNames = sortPropertyNames(\n schema.value,\n schema.value.discriminator,\n {\n hideReadOnly: true,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n },\n )\n\n if (sortedNames.length <= MAX_VISIBLE_PROPERTIES) {\n return null\n }\n\n // Destructure everything except properties\n const { properties, ...schemaMetadata } = schema.value\n if (!properties) {\n return null\n }\n\n return {\n visibleProperties: {\n ...schemaMetadata,\n properties: reduceNamesToObject(\n sortedNames.slice(0, MAX_VISIBLE_PROPERTIES),\n properties,\n ),\n },\n collapsedProperties: {\n ...schemaMetadata,\n properties: reduceNamesToObject(\n sortedNames.slice(MAX_VISIBLE_PROPERTIES),\n properties,\n ),\n },\n }\n})\n\n/**\n * We don't want to render the request body if its completely empty\n * @example\n * {\n * \"content\": {},\n * }\n */\nconst shouldRenderRequestBody = computed(\n () =>\n Object.keys(requestBody?.content ?? {}).length > 0 ||\n requestBody?.description ||\n requestBody?.required,\n)\n</script>\n<template>\n <div\n v-if=\"requestBody && shouldRenderRequestBody\"\n aria-label=\"Request Body\"\n class=\"request-body\"\n role=\"group\">\n <div class=\"request-body-header\">\n <div class=\"request-body-title\">\n <slot name=\"title\" />\n <span\n v-if=\"modelLink\"\n class=\"text-c-2 text-xs leading-none font-normal\"\n data-testid=\"request-body-schema-name\">\n <span class=\"text-c-3 mx-1.5\">·</span>\n <LinkButton\n v-if=\"eventBus && modelLink.schemaKey\"\n @click=\"\n eventBus.emit('scroll-to:model-by-name', {\n name: modelLink.schemaKey,\n })\n \">\n {{ modelLink.label }}\n </LinkButton>\n <template v-else>{{ modelLink.label }}</template>\n </span>\n </div>\n <div class=\"flex items-center gap-2\">\n <div\n v-if=\"requestBody.required\"\n class=\"request-body-required\">\n required\n </div>\n <ContentTypeSelect\n v-model=\"selectedContentType\"\n :content=\"requestBody.content\" />\n </div>\n <div\n v-if=\"requestBody.description\"\n class=\"request-body-description\">\n <ScalarMarkdown :value=\"requestBody.description\" />\n </div>\n </div>\n\n <!-- For over 12 properties we want to show 12 and collapse the rest -->\n <div\n v-if=\"partitionedSchema\"\n class=\"request-body-schema\">\n <Schema\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n name=\"Request Body\"\n noncollapsible\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"partitionedSchema.visibleProperties\"\n schemaContext=\"requestBody\" />\n\n <Schema\n additionalProperties\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n name=\"Request Body\"\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"partitionedSchema.collapsedProperties\"\n schemaContext=\"requestBody\" />\n </div>\n\n <!-- Show em all 12 and under -->\n <div\n v-else-if=\"schema\"\n class=\"request-body-schema\">\n <Schema\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n :hideReadOnly=\"true\"\n name=\"Request Body\"\n noncollapsible\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"schema\"\n schemaContext=\"requestBody\" />\n </div>\n </div>\n</template>\n\n<style scoped>\n.request-body {\n margin-top: 24px;\n}\n.request-body-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding-bottom: 12px;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n flex-flow: wrap;\n}\n.request-body-title {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--scalar-font-size-2);\n font-weight: var(--scalar-semibold);\n color: var(--scalar-color-1);\n}\n.request-body-required {\n font-size: var(--scalar-micro);\n color: var(--scalar-color-orange);\n font-weight: normal;\n border-radius: 16px;\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 2px 8px;\n height: 20px;\n}\n.request-body-description {\n margin-top: 6px;\n font-size: var(--scalar-small);\n width: 100%;\n}\n\n.request-body-header\n + .request-body-schema:has(> .schema-card > .schema-card-description),\n.request-body-header\n + .request-body-schema:has(\n > .schema-card > .schema-properties > * > .property--level-0\n ) {\n /** Add a bit of space between the heading border and the schema description or properties */\n padding-top: 8px;\n}\n.request-body-description :deep(.markdown) * {\n color: var(--scalar-color-2) !important;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAM,yBAAyB;;;;;;;;;;;;;;;;;EAE/B,MAAM,wBAAwB,eAC5B,OAAO,KAAK,QAAA,aAAa,WAAW,EAAE,CAAC,CACzC;EAEA,MAAM,sBAAsB,SAAmB,SAAC,sBAE/C;AAED,MAAI,QAAA,aAAa;OACX,sBAAsB,MAAM,GAC9B,qBAAoB,QAAQ,sBAAsB,MAAM;;;EAK5D,MAAM,YAAY,eACV,QAAA,aAAa,UAAU,oBAAoB,QAAQ,OAC3D;EAEA,MAAM,SAAS,eAAe,eAAe,UAAU,MAAM,CAAA;;EAG7D,MAAM,YAAY,gBACT,UAAU,SAAS,uBAAuB,UAAU,MAAM,KAAK,KACxE;;;;;EAMA,MAAM,oBAAoB,eAAe;AAEvC,OAAI,CAAC,OAAO,SAAS,CAAC,aAAa,OAAO,MAAM,CAC9C,QAAO;GAIT,MAAM,cAAc,kBAClB,OAAO,OACP,OAAO,MAAM,eACb;IACE,cAAc;IACd,yBAAyB,QAAA,QAAQ;IACjC,8BAA8B,QAAA,QAAQ;IACvC,CACH;AAEA,OAAI,YAAY,UAAU,uBACxB,QAAO;GAIT,MAAM,EAAE,YAAY,GAAG,mBAAmB,OAAO;AACjD,OAAI,CAAC,WACH,QAAO;AAGT,UAAO;IACL,mBAAmB;KACjB,GAAG;KACH,YAAY,oBACV,YAAY,MAAM,GAAG,uBAAuB,EAC5C,WACD;KACF;IACD,qBAAqB;KACnB,GAAG;KACH,YAAY,oBACV,YAAY,MAAM,uBAAuB,EACzC,WACD;KACF;IACH;IACD;;;;;;;;EASD,MAAM,0BAA0B,eAE5B,OAAO,KAAK,QAAA,aAAa,WAAW,EAAE,CAAC,CAAC,SAAS,KACjD,QAAA,aAAa,eACb,QAAA,a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;IACD,SAAA;IACC,iBAAiB,CAAA,cAAe;IAChC,UAAU,QAAA;IACX,MAAK;IACL,gBAAA;IACC,SAAO;;mCAA0E,QAAA,QAAQ;8BAAiE,QAAA,QAAQ;;IAKlK,QAAQ,kBAAA,MAAkB;IAC3B,eAAc;;;;;;OAEhB,YAagC,MAAA,eAAA,EAAA;IAZ9B,sBAAA;IACC,YAAA,QAAA;IACD,SAAA;IACC,iBAAiB,CAAA,cAAe;IAChC,UAAU,QAAA;IACX,MAAK;IACJ,SAAO;;mCAA0E,QAAA,QAAQ;8BAAiE,QAAA,QAAQ;;IAKlK,QAAQ,kBAAA,MAAkB;IAC3B,eAAc;;;;;;WAKL,OAAA,SAAA,WAAA,EADb,mBAkBM,OAlBN,YAkBM,CAfJ,YAcgC,MAAA,eAAA,EAAA;IAb7B,YAAA,QAAA;IACD,SAAA;IACC,iBAAiB,CAAA,cAAe;IAChC,UAAU,QAAA;IACV,cAAc;IACf,MAAK;IACL,gBAAA;IACC,SAAO;;mCAA0E,QAAA,QAAQ;8BAAiE,QAAA,QAAQ;;IAKlK,QAAQ,OAAA;IACT,eAAc"}
1
+ {"version":3,"file":"RequestBody.vue.script.js","names":[],"sources":["../../../../src/features/Operation/components/RequestBody.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarMarkdown } from '@scalar/components'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport { Schema } from '@/components/Content/Schema'\nimport { isTypeObject } from '@/components/Content/Schema/helpers/is-type-object'\nimport { getModelNameFromSchema } from '@/components/Content/Schema/helpers/schema-name'\nimport {\n reduceNamesToObject,\n sortPropertyNames,\n} from '@/components/Content/Schema/helpers/sort-property-names'\nimport LinkButton from '@/components/Content/Schema/LinkButton.vue'\n\nimport ContentTypeSelect from './ContentTypeSelect.vue'\n\nconst { requestBody, options } = defineProps<{\n breadcrumb?: string[]\n requestBody?: RequestBodyObject\n eventBus: WorkspaceEventBus | null\n options: {\n orderRequiredPropertiesFirst: boolean | undefined\n orderSchemaPropertiesBy: 'alpha' | 'preserve' | undefined\n hideModels: boolean | undefined\n }\n}>()\n\n/**\n * The maximum number of properties to show in the request body schema.\n */\nconst MAX_VISIBLE_PROPERTIES = 12\n\nconst availableContentTypes = computed(() =>\n Object.keys(requestBody?.content ?? {}),\n)\n\nconst selectedContentType = defineModel<string>('selectedContentType', {\n default: 'application/json',\n})\n\nif (requestBody?.content) {\n if (availableContentTypes.value[0]) {\n selectedContentType.value = availableContentTypes.value[0]\n }\n}\n\n/** Raw schema (possibly with $ref) for the selected content type */\nconst rawSchema = computed(\n () => requestBody?.content?.[selectedContentType.value]?.schema,\n)\n\nconst schema = computed(() => getResolvedRef(rawSchema.value))\n\n/** When the schema is a $ref, preserve its name so the UI can show the ref name instead of just the type. */\nconst modelLink = computed(\n () => (rawSchema.value && getModelNameFromSchema(rawSchema.value)) ?? null,\n)\n\n/**\n * Splits schema properties into visible and collapsed sections when there are more than 12 properties.\n * Returns null for schemas with fewer properties or non-object schemas.\n */\nconst partitionedSchema = computed(() => {\n // Early return if not an object schema\n if (!schema.value || !isTypeObject(schema.value)) {\n return null\n }\n\n // Lets sort the names first\n const sortedNames = sortPropertyNames(\n schema.value,\n schema.value.discriminator,\n {\n hideReadOnly: true,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n },\n )\n\n if (sortedNames.length <= MAX_VISIBLE_PROPERTIES) {\n return null\n }\n\n // Destructure everything except properties\n const { properties, ...schemaMetadata } = schema.value\n if (!properties) {\n return null\n }\n\n return {\n visibleProperties: {\n ...schemaMetadata,\n properties: reduceNamesToObject(\n sortedNames.slice(0, MAX_VISIBLE_PROPERTIES),\n properties,\n ),\n },\n collapsedProperties: {\n ...schemaMetadata,\n properties: reduceNamesToObject(\n sortedNames.slice(MAX_VISIBLE_PROPERTIES),\n properties,\n ),\n },\n }\n})\n\n/**\n * We don't want to render the request body if its completely empty\n * @example\n * {\n * \"content\": {},\n * }\n */\nconst shouldRenderRequestBody = computed(\n () =>\n Object.keys(requestBody?.content ?? {}).length > 0 ||\n requestBody?.description ||\n requestBody?.required,\n)\n</script>\n<template>\n <div\n v-if=\"requestBody && shouldRenderRequestBody\"\n aria-label=\"Request Body\"\n class=\"request-body\"\n role=\"group\">\n <div class=\"request-body-header\">\n <div class=\"request-body-title\">\n <slot name=\"title\" />\n <span\n v-if=\"modelLink\"\n class=\"text-c-2 text-xs leading-none font-normal\"\n data-testid=\"request-body-schema-name\">\n <span class=\"text-c-3 mx-1.5\">·</span>\n <LinkButton\n v-if=\"eventBus && modelLink.schemaKey\"\n @click=\"\n eventBus.emit('scroll-to:model-by-name', {\n name: modelLink.schemaKey,\n })\n \">\n {{ modelLink.label }}\n </LinkButton>\n <template v-else>{{ modelLink.label }}</template>\n </span>\n </div>\n <div class=\"flex items-center gap-2\">\n <div\n v-if=\"requestBody.required\"\n class=\"request-body-required\">\n required\n </div>\n <ContentTypeSelect\n v-model=\"selectedContentType\"\n :content=\"requestBody.content\" />\n </div>\n <div\n v-if=\"requestBody.description\"\n class=\"request-body-description\">\n <ScalarMarkdown :value=\"requestBody.description\" />\n </div>\n </div>\n\n <!-- For over 12 properties we want to show 12 and collapse the rest -->\n <div\n v-if=\"partitionedSchema\"\n class=\"request-body-schema\">\n <Schema\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n name=\"Request Body\"\n noncollapsible\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"partitionedSchema.visibleProperties\"\n schemaContext=\"requestBody\" />\n\n <Schema\n additionalProperties\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n hideDescription\n name=\"Request Body\"\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"partitionedSchema.collapsedProperties\"\n schemaContext=\"requestBody\" />\n </div>\n\n <!-- Show em all 12 and under -->\n <div\n v-else-if=\"schema\"\n class=\"request-body-schema\">\n <Schema\n :breadcrumb\n compact\n :compositionPath=\"['requestBody']\"\n :eventBus=\"eventBus\"\n :hideReadOnly=\"true\"\n name=\"Request Body\"\n noncollapsible\n :options=\"{\n hideReadOnly: true,\n orderRequiredPropertiesFirst: options.orderRequiredPropertiesFirst,\n orderSchemaPropertiesBy: options.orderSchemaPropertiesBy,\n }\"\n :schema=\"schema\"\n schemaContext=\"requestBody\" />\n </div>\n </div>\n</template>\n\n<style scoped>\n.request-body {\n margin-top: 24px;\n}\n.request-body-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding-bottom: 12px;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n flex-flow: wrap;\n}\n.request-body-title {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--scalar-font-size-2);\n font-weight: var(--scalar-semibold);\n color: var(--scalar-color-1);\n}\n.request-body-required {\n font-size: var(--scalar-micro);\n color: var(--scalar-color-orange);\n font-weight: normal;\n border-radius: 16px;\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 2px 8px;\n height: 20px;\n}\n.request-body-description {\n margin-top: 6px;\n font-size: var(--scalar-small);\n width: 100%;\n}\n\n.request-body-header\n + .request-body-schema:has(> .schema-card > .schema-card-description),\n.request-body-header\n + .request-body-schema:has(\n > .schema-card > .schema-properties > * > .property--level-0\n ) {\n /** Add a bit of space between the heading border and the schema description or properties */\n padding-top: 8px;\n}\n.request-body-description :deep(.markdown) * {\n color: var(--scalar-color-2) !important;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;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Q;;IAKlK,QAAQ,kBAAA,MAAkB;IAC3B,eAAc;;;;;;OAEhB,YAcgC,MAAA,eAAA,EAAA;IAb9B,sBAAA;IACC,YAAA,QAAA;IACD,SAAA;IACC,iBAAiB,CAAA,cAAe;IAChC,UAAU,QAAA;IACX,iBAAA;IACA,MAAK;IACJ,SAAO;;mCAA0E,QAAA,QAAQ;8BAAiE,QAAA,QAAQ;;IAKlK,QAAQ,kBAAA,MAAkB;IAC3B,eAAc;;;;;;WAKL,OAAA,SAAA,WAAA,EADb,mBAkBM,OAlBN,YAkBM,CAfJ,YAcgC,MAAA,eAAA,EAAA;IAb7B,YAAA,QAAA;IACD,SAAA;IACC,iBAAiB,CAAA,cAAe;IAChC,UAAU,QAAA;IACV,cAAc;IACf,MAAK;IACL,gBAAA;IACC,SAAO;;mCAA0E,QAAA,QAAQ;8BAAiE,QAAA,QAAQ;;IAKlK,QAAQ,OAAA;IACT,eAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-fuse-instance.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/helpers/create-fuse-instance.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAA;AAE1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAAC,QAAQ,CAAC,CAiDnD"}
1
+ {"version":3,"file":"create-fuse-instance.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/helpers/create-fuse-instance.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAA;AAE1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAAC,QAAQ,CAAC,CA2DnD"}
@@ -13,24 +13,16 @@ function createFuseInstance() {
13
13
  weight: .7
14
14
  },
15
15
  {
16
- name: "description",
17
- weight: .3
16
+ name: "operationId",
17
+ weight: .6
18
18
  },
19
19
  {
20
20
  name: "parameters",
21
- weight: .2
21
+ weight: .55
22
22
  },
23
23
  {
24
24
  name: "body",
25
- weight: .2
26
- },
27
- {
28
- name: "responseExamples",
29
- weight: .25
30
- },
31
- {
32
- name: "operationId",
33
- weight: .6
25
+ weight: .55
34
26
  },
35
27
  {
36
28
  name: "path",
@@ -40,9 +32,25 @@ function createFuseInstance() {
40
32
  name: "tag",
41
33
  weight: .4
42
34
  },
35
+ {
36
+ name: "description",
37
+ weight: .3
38
+ },
43
39
  {
44
40
  name: "method",
45
41
  weight: .3
42
+ },
43
+ {
44
+ name: "responseExamples",
45
+ weight: .25
46
+ },
47
+ {
48
+ name: "parameterDescriptions",
49
+ weight: .2
50
+ },
51
+ {
52
+ name: "bodyDescriptions",
53
+ weight: .2
46
54
  }
47
55
  ],
48
56
  threshold: .3,
@@ -1 +1 @@
1
- {"version":3,"file":"create-fuse-instance.js","names":[],"sources":["../../../../src/features/Search/helpers/create-fuse-instance.ts"],"sourcesContent":["import Fuse from 'fuse.js'\n\nimport type { FuseData } from '@/features/Search/types'\n\n/**\n * Create a Fuse instance for searching the API reference.\n *\n * Doesn't have any data yet, so it's empty.\n */\nexport function createFuseInstance(): Fuse<FuseData> {\n return new Fuse([], {\n // Define searchable fields with weights to prioritize more important matches\n keys: [\n // Highest weight - titles are most descriptive\n { name: 'title', weight: 0.7 },\n // Medium weight - helpful but often verbose\n { name: 'description', weight: 0.3 },\n // Lowest weight - parameters are searchable but they can be very long and noisy\n { name: 'parameters', weight: 0.2 },\n // Lowest weight - can be very long and noisy\n { name: 'body', weight: 0.2 },\n // Low-medium weight - response examples can help full-text matching\n { name: 'responseExamples', weight: 0.25 },\n // High weight - unique identifiers for operations\n { name: 'operationId', weight: 0.6 },\n // Good weight - endpoint paths are searchable\n { name: 'path', weight: 0.5 },\n // Medium-high weight - helps with categorization\n { name: 'tag', weight: 0.4 },\n // Medium weight - useful for filtering by method\n { name: 'method', weight: 0.3 },\n ],\n\n // Threshold controls how strict the matching is (0.0 = perfect match, 1.0 = very loose)\n // 0.3 allows for some typos and partial matches while maintaining relevance\n threshold: 0.3,\n\n // Maximum distance between characters that can be matched\n // Higher values allow matches even when characters are far apart in long text\n distance: 100,\n\n // Include the match score in results for debugging and potential UI enhancements\n includeScore: true,\n\n // Include detailed match information showing which parts of the text matched\n includeMatches: true,\n\n // Don't require matches to be at the beginning of strings\n // Makes search more flexible and user-friendly\n ignoreLocation: true,\n\n // Enable advanced search syntax like 'exact' for exact matches or !exclude for exclusions\n useExtendedSearch: true,\n\n // Find all possible matches in each item, not just the first one\n // Ensures comprehensive search results\n findAllMatches: true,\n })\n}\n"],"mappings":";;;;;;;AASA,SAAgB,qBAAqC;AACnD,QAAO,IAAI,KAAK,EAAE,EAAE;EAElB,MAAM;GAEJ;IAAE,MAAM;IAAS,QAAQ;IAAK;GAE9B;IAAE,MAAM;IAAe,QAAQ;IAAK;GAEpC;IAAE,MAAM;IAAc,QAAQ;IAAK;GAEnC;IAAE,MAAM;IAAQ,QAAQ;IAAK;GAE7B;IAAE,MAAM;IAAoB,QAAQ;IAAM;GAE1C;IAAE,MAAM;IAAe,QAAQ;IAAK;GAEpC;IAAE,MAAM;IAAQ,QAAQ;IAAK;GAE7B;IAAE,MAAM;IAAO,QAAQ;IAAK;GAE5B;IAAE,MAAM;IAAU,QAAQ;IAAK;GAChC;EAID,WAAW;EAIX,UAAU;EAGV,cAAc;EAGd,gBAAgB;EAIhB,gBAAgB;EAGhB,mBAAmB;EAInB,gBAAgB;EACjB,CAAC"}
1
+ {"version":3,"file":"create-fuse-instance.js","names":[],"sources":["../../../../src/features/Search/helpers/create-fuse-instance.ts"],"sourcesContent":["import Fuse from 'fuse.js'\n\nimport type { FuseData } from '@/features/Search/types'\n\n/**\n * Create a Fuse instance for searching the API reference.\n *\n * Doesn't have any data yet, so it's empty.\n */\nexport function createFuseInstance(): Fuse<FuseData> {\n return new Fuse([], {\n // Define searchable fields with weights to prioritize more important matches.\n //\n // Field design: short, high-signal fields (`title`, `parameters`, `body`) are weighted higher than\n // long verbose fields (`description`, `parameterDescriptions`, `bodyDescriptions`). This way an\n // exact match on a parameter or body field name surfaces the right operation, even when an\n // unrelated operation happens to mention that word in its prose description.\n keys: [\n // Highest weight - titles are the most descriptive identifier of an entry.\n { name: 'title', weight: 0.7 },\n // High weight - operationIds are explicit unique identifiers.\n { name: 'operationId', weight: 0.6 },\n // Clean parameter names. Above `path` so `userId` ranks the operation that defines the param\n // higher than another operation that merely contains it in its path string.\n { name: 'parameters', weight: 0.55 },\n // Clean request-body property names same reasoning as `parameters`.\n { name: 'body', weight: 0.55 },\n // Endpoint paths.\n { name: 'path', weight: 0.5 },\n // Tag names useful for categorization.\n { name: 'tag', weight: 0.4 },\n // Verbose prose helpful but often noisy.\n { name: 'description', weight: 0.3 },\n // HTTP method - useful for filtering.\n { name: 'method', weight: 0.3 },\n // Response examples can help full-text matching.\n { name: 'responseExamples', weight: 0.25 },\n // Verbose parameter descriptions — supplementary signal only.\n { name: 'parameterDescriptions', weight: 0.2 },\n // Verbose request-body descriptions supplementary signal only.\n { name: 'bodyDescriptions', weight: 0.2 },\n ],\n\n // Threshold controls how strict the matching is (0.0 = perfect match, 1.0 = very loose)\n // 0.3 allows for some typos and partial matches while maintaining relevance\n threshold: 0.3,\n\n // Maximum distance between characters that can be matched\n // Higher values allow matches even when characters are far apart in long text\n distance: 100,\n\n // Include the match score in results for debugging and potential UI enhancements\n includeScore: true,\n\n // Include detailed match information showing which parts of the text matched\n includeMatches: true,\n\n // Don't require matches to be at the beginning of strings\n // Makes search more flexible and user-friendly\n ignoreLocation: true,\n\n // Enable advanced search syntax like 'exact' for exact matches or !exclude for exclusions\n useExtendedSearch: true,\n\n // Find all possible matches in each item, not just the first one\n // Ensures comprehensive search results\n findAllMatches: true,\n })\n}\n"],"mappings":";;;;;;;AASA,SAAgB,qBAAqC;AACnD,QAAO,IAAI,KAAK,EAAE,EAAE;EAOlB,MAAM;GAEJ;IAAE,MAAM;IAAS,QAAQ;IAAK;GAE9B;IAAE,MAAM;IAAe,QAAQ;IAAK;GAGpC;IAAE,MAAM;IAAc,QAAQ;IAAM;GAEpC;IAAE,MAAM;IAAQ,QAAQ;IAAM;GAE9B;IAAE,MAAM;IAAQ,QAAQ;IAAK;GAE7B;IAAE,MAAM;IAAO,QAAQ;IAAK;GAE5B;IAAE,MAAM;IAAe,QAAQ;IAAK;GAEpC;IAAE,MAAM;IAAU,QAAQ;IAAK;GAE/B;IAAE,MAAM;IAAoB,QAAQ;IAAM;GAE1C;IAAE,MAAM;IAAyB,QAAQ;IAAK;GAE9C;IAAE,MAAM;IAAoB,QAAQ;IAAK;GAC1C;EAID,WAAW;EAIX,UAAU;EAGV,cAAc;EAGd,gBAAgB;EAIhB,gBAAgB;EAGhB,mBAAmB;EAInB,gBAAgB;EACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-search-index.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/helpers/create-search-index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,eAAe,EAGhB,MAAM,8DAA8D,CAAA;AAErE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AA0DvD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,QAAQ,EAAE,CAoBnF"}
1
+ {"version":3,"file":"create-search-index.d.ts","sourceRoot":"","sources":["../../../../src/features/Search/helpers/create-search-index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,eAAe,EAGhB,MAAM,8DAA8D,CAAA;AAErE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAiEvD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,QAAQ,EAAE,CAoBnF"}
@@ -1,4 +1,4 @@
1
- import { extractParameters, extractRequestBody } from "../../../helpers/openapi.js";
1
+ import { extractBodyDescriptions, extractBodyFieldNames, extractParameterDescriptions, extractParameterNames, extractSchemaDescriptions, extractSchemaFieldNames } from "../../../helpers/openapi.js";
2
2
  import { combineParams } from "@scalar/workspace-store/request-example";
3
3
  import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
4
4
  //#region src/features/Search/helpers/create-search-index.ts
@@ -59,8 +59,10 @@ function addEntryToIndex(entry, index, document) {
59
59
  ...operation,
60
60
  parameters: combineParams(pathItem?.parameters, operation.parameters)
61
61
  };
62
- const parameters = extractParameters(operationWithPathParams.parameters ?? []);
63
- const body = extractRequestBody(operationWithPathParams);
62
+ const parameters = extractParameterNames(operationWithPathParams.parameters ?? []);
63
+ const parameterDescriptions = extractParameterDescriptions(operationWithPathParams.parameters ?? []);
64
+ const body = extractBodyFieldNames(operationWithPathParams);
65
+ const bodyDescriptions = extractBodyDescriptions(operationWithPathParams);
64
66
  const responseExamples = extractResponseExamples(operationWithPathParams.responses);
65
67
  index.push({
66
68
  type: "operation",
@@ -69,8 +71,10 @@ function addEntryToIndex(entry, index, document) {
69
71
  description: operationWithPathParams.description || "",
70
72
  method: entry.method,
71
73
  path: entry.path,
72
- body: body || "",
73
- parameters: parameters ?? "",
74
+ body,
75
+ bodyDescriptions,
76
+ parameters,
77
+ parameterDescriptions,
74
78
  responseExamples,
75
79
  operationId: operationWithPathParams.operationId,
76
80
  entry
@@ -79,26 +83,32 @@ function addEntryToIndex(entry, index, document) {
79
83
  }
80
84
  if (entry.type === "webhook") {
81
85
  const webhook = getResolvedRef(document?.webhooks?.[entry.name]?.[entry.method]) ?? {};
86
+ const webhookDescription = webhook.description || "";
82
87
  index.push({
83
88
  id: entry.id,
84
89
  type: "webhook",
85
90
  title: entry.title,
86
91
  description: "Webhook",
87
92
  method: entry.method,
88
- body: webhook.description || "",
93
+ body: "",
94
+ bodyDescriptions: webhookDescription ? [webhookDescription] : [],
89
95
  operationId: webhook.operationId,
90
96
  entry
91
97
  });
92
98
  return;
93
99
  }
94
100
  if (entry.type === "model") {
95
- const description = getResolvedRef(document?.components?.schemas?.[entry.name])?.description ?? "";
101
+ const schema = getResolvedRef(document?.components?.schemas?.[entry.name]);
102
+ const schemaDescription = schema?.description ?? "";
103
+ const propertyNames = extractSchemaFieldNames(schema);
104
+ const propertyDescriptions = extractSchemaDescriptions(schema);
96
105
  index.push({
97
106
  type: "model",
98
107
  title: entry.title,
99
108
  description: "Model",
100
109
  id: entry.id,
101
- body: description,
110
+ body: propertyNames,
111
+ bodyDescriptions: schemaDescription ? [schemaDescription, ...propertyDescriptions] : propertyDescriptions,
102
112
  entry
103
113
  });
104
114
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"create-search-index.js","names":[],"sources":["../../../../src/features/Search/helpers/create-search-index.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { combineParams } from '@scalar/workspace-store/request-example'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport type {\n MediaTypeObject,\n OpenApiDocument,\n OperationObject,\n ResponsesObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport type { FuseData } from '@/features/Search/types'\nimport { extractParameters, extractRequestBody } from '@/helpers/openapi'\n\nfunction responseExampleValueToString(value: unknown): string {\n if (typeof value === 'string') {\n return value\n }\n\n try {\n return JSON.stringify(value)\n } catch (_error) {\n return ''\n }\n}\n\nfunction mediaTypeExamplesToStrings(mediaType: MediaTypeObject): string[] {\n const examplesFromNamedMap = Object.values(mediaType.examples ?? {})\n .flatMap((example) => {\n const resolvedExample = getResolvedRef(example)\n\n if (!resolvedExample || !('value' in resolvedExample)) {\n return []\n }\n\n return responseExampleValueToString(resolvedExample.value)\n })\n .filter((value) => value.length > 0)\n\n const mediaTypeExample =\n 'example' in mediaType && mediaType.example !== undefined ? responseExampleValueToString(mediaType.example) : ''\n\n return mediaTypeExample ? [mediaTypeExample, ...examplesFromNamedMap] : examplesFromNamedMap\n}\n\nfunction extractResponseExamples(responses: ResponsesObject | undefined): string[] {\n if (!responses) {\n return []\n }\n\n return Object.values(responses)\n .flatMap((response) => {\n const resolvedResponse = getResolvedRef(response)\n if (!resolvedResponse?.content) {\n return []\n }\n\n return Object.values(resolvedResponse.content).flatMap((mediaType) => {\n const resolvedMediaType = getResolvedRef(mediaType)\n if (!resolvedMediaType) {\n return []\n }\n\n return mediaTypeExamplesToStrings(resolvedMediaType)\n })\n })\n .filter((value) => value.length > 0)\n}\n\n/**\n * Create a search index from a list of entries.\n */\nexport function createSearchIndex(document: OpenApiDocument | undefined): FuseData[] {\n const index: FuseData[] = []\n\n /**\n * Recursively processes entries and their children to build the search index.\n */\n function processEntries(entriesToProcess: TraversedEntry[]): void {\n entriesToProcess.forEach((entry) => {\n addEntryToIndex(entry, index, document)\n\n // Recursively process children if they exist\n if ('children' in entry && entry.children) {\n processEntries(entry.children)\n }\n })\n }\n\n processEntries(document?.['x-scalar-navigation']?.children ?? [])\n\n return index\n}\n\n/**\n * Adds a single entry to the search index, handling all entry types recursively.\n */\nfunction addEntryToIndex(entry: TraversedEntry, index: FuseData[], document?: OpenApiDocument): void {\n // Operation\n if (entry.type === 'operation') {\n const pathItem = getResolvedRef(document?.paths?.[entry.path])\n const operation = (getResolvedRef(pathItem?.[entry.method]) ?? {}) as OperationObject\n const operationWithPathParams = {\n ...operation,\n parameters: combineParams(pathItem?.parameters, operation.parameters),\n }\n\n const parameters = extractParameters(operationWithPathParams.parameters ?? [])\n const body = extractRequestBody(operationWithPathParams)\n const responseExamples = extractResponseExamples(operationWithPathParams.responses)\n\n index.push({\n type: 'operation',\n title: entry.title,\n id: entry.id,\n description: operationWithPathParams.description || '',\n method: entry.method,\n path: entry.path,\n body: body || '',\n parameters: parameters ?? '',\n responseExamples,\n operationId: operationWithPathParams.operationId,\n entry,\n })\n\n return\n }\n\n // Webhook\n if (entry.type === 'webhook') {\n const webhook = getResolvedRef(document?.webhooks?.[entry.name]?.[entry.method]) ?? {}\n\n index.push({\n id: entry.id,\n type: 'webhook',\n title: entry.title,\n description: 'Webhook',\n method: entry.method,\n body: webhook.description || '',\n operationId: webhook.operationId,\n entry,\n })\n\n return\n }\n\n // Model\n if (entry.type === 'model') {\n const schema = getResolvedRef(document?.components?.schemas?.[entry.name])\n\n const description = schema?.description ?? ''\n\n index.push({\n type: 'model',\n title: entry.title,\n description: 'Model',\n id: entry.id,\n body: description,\n entry,\n })\n\n return\n }\n\n // Models heading\n if (entry.type === 'models') {\n index.push({\n id: entry.id,\n type: 'heading',\n title: 'Models',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n\n // Tag\n if (entry.type === 'tag' && entry.isWebhooks === true) {\n index.push({\n id: entry.id,\n type: 'heading',\n title: 'Webhooks',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n\n if (entry.type === 'tag' && entry.isGroup === false) {\n index.push({\n id: entry.id,\n title: entry.title,\n description: entry.description || '',\n type: 'tag',\n body: '',\n entry,\n })\n\n return\n }\n\n // Tag group\n if (entry.type === 'tag' && entry.isGroup === true) {\n index.push({\n id: entry.id,\n title: entry.title,\n description: 'Tag Group',\n type: 'tag',\n body: '',\n entry,\n })\n\n return\n }\n\n // Headings from info.description\n if (entry.type === 'text') {\n index.push({\n id: entry.id,\n type: 'heading',\n title: entry.title ?? '',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n}\n"],"mappings":";;;;AAaA,SAAS,6BAA6B,OAAwB;AAC5D,KAAI,OAAO,UAAU,SACnB,QAAO;AAGT,KAAI;AACF,SAAO,KAAK,UAAU,MAAM;UACrB,QAAQ;AACf,SAAO;;;AAIX,SAAS,2BAA2B,WAAsC;CACxE,MAAM,uBAAuB,OAAO,OAAO,UAAU,YAAY,EAAE,CAAC,CACjE,SAAS,YAAY;EACpB,MAAM,kBAAkB,eAAe,QAAQ;AAE/C,MAAI,CAAC,mBAAmB,EAAE,WAAW,iBACnC,QAAO,EAAE;AAGX,SAAO,6BAA6B,gBAAg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T,IAAI,MAAM;GACV,OAAO,MAAM;GACb,aAAa;GACb,MAAM;GACN,MAAM;GACN;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,QAAQ;AACzB,QAAM,KAAK;GACT,IAAI,MAAM;GACV,MAAM;GACN,OAAO,MAAM,SAAS;GACtB,aAAa;GACb,MAAM;GACN;GACD,CAAC;AAEF"}
1
+ {"version":3,"file":"create-search-index.js","names":[],"sources":["../../../../src/features/Search/helpers/create-search-index.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { combineParams } from '@scalar/workspace-store/request-example'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport type {\n MediaTypeObject,\n OpenApiDocument,\n OperationObject,\n ResponsesObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport type { FuseData } from '@/features/Search/types'\nimport {\n extractBodyDescriptions,\n extractBodyFieldNames,\n extractParameterDescriptions,\n extractParameterNames,\n extractSchemaDescriptions,\n extractSchemaFieldNames,\n} from '@/helpers/openapi'\n\nfunction responseExampleValueToString(value: unknown): string {\n if (typeof value === 'string') {\n return value\n }\n\n try {\n return JSON.stringify(value)\n } catch (_error) {\n return ''\n }\n}\n\nfunction mediaTypeExamplesToStrings(mediaType: MediaTypeObject): string[] {\n const examplesFromNamedMap = Object.values(mediaType.examples ?? {})\n .flatMap((example) => {\n const resolvedExample = getResolvedRef(example)\n\n if (!resolvedExample || !('value' in resolvedExample)) {\n return []\n }\n\n return responseExampleValueToString(resolvedExample.value)\n })\n .filter((value) => value.length > 0)\n\n const mediaTypeExample =\n 'example' in mediaType && mediaType.example !== undefined ? responseExampleValueToString(mediaType.example) : ''\n\n return mediaTypeExample ? [mediaTypeExample, ...examplesFromNamedMap] : examplesFromNamedMap\n}\n\nfunction extractResponseExamples(responses: ResponsesObject | undefined): string[] {\n if (!responses) {\n return []\n }\n\n return Object.values(responses)\n .flatMap((response) => {\n const resolvedResponse = getResolvedRef(response)\n if (!resolvedResponse?.content) {\n return []\n }\n\n return Object.values(resolvedResponse.content).flatMap((mediaType) => {\n const resolvedMediaType = getResolvedRef(mediaType)\n if (!resolvedMediaType) {\n return []\n }\n\n return mediaTypeExamplesToStrings(resolvedMediaType)\n })\n })\n .filter((value) => value.length > 0)\n}\n\n/**\n * Create a search index from a list of entries.\n */\nexport function createSearchIndex(document: OpenApiDocument | undefined): FuseData[] {\n const index: FuseData[] = []\n\n /**\n * Recursively processes entries and their children to build the search index.\n */\n function processEntries(entriesToProcess: TraversedEntry[]): void {\n entriesToProcess.forEach((entry) => {\n addEntryToIndex(entry, index, document)\n\n // Recursively process children if they exist\n if ('children' in entry && entry.children) {\n processEntries(entry.children)\n }\n })\n }\n\n processEntries(document?.['x-scalar-navigation']?.children ?? [])\n\n return index\n}\n\n/**\n * Adds a single entry to the search index, handling all entry types recursively.\n */\nfunction addEntryToIndex(entry: TraversedEntry, index: FuseData[], document?: OpenApiDocument): void {\n // Operation\n if (entry.type === 'operation') {\n const pathItem = getResolvedRef(document?.paths?.[entry.path])\n const operation = (getResolvedRef(pathItem?.[entry.method]) ?? {}) as OperationObject\n const operationWithPathParams = {\n ...operation,\n parameters: combineParams(pathItem?.parameters, operation.parameters),\n }\n\n const parameters = extractParameterNames(operationWithPathParams.parameters ?? [])\n const parameterDescriptions = extractParameterDescriptions(operationWithPathParams.parameters ?? [])\n const body = extractBodyFieldNames(operationWithPathParams)\n const bodyDescriptions = extractBodyDescriptions(operationWithPathParams)\n const responseExamples = extractResponseExamples(operationWithPathParams.responses)\n\n index.push({\n type: 'operation',\n title: entry.title,\n id: entry.id,\n description: operationWithPathParams.description || '',\n method: entry.method,\n path: entry.path,\n body,\n bodyDescriptions,\n parameters,\n parameterDescriptions,\n responseExamples,\n operationId: operationWithPathParams.operationId,\n entry,\n })\n\n return\n }\n\n // Webhook\n if (entry.type === 'webhook') {\n const webhook = getResolvedRef(document?.webhooks?.[entry.name]?.[entry.method]) ?? {}\n const webhookDescription = webhook.description || ''\n\n index.push({\n id: entry.id,\n type: 'webhook',\n title: entry.title,\n description: 'Webhook',\n method: entry.method,\n body: '',\n bodyDescriptions: webhookDescription ? [webhookDescription] : [],\n operationId: webhook.operationId,\n entry,\n })\n\n return\n }\n\n // Model\n if (entry.type === 'model') {\n const schema = getResolvedRef(document?.components?.schemas?.[entry.name])\n const schemaDescription = schema?.description ?? ''\n const propertyNames = extractSchemaFieldNames(schema)\n const propertyDescriptions = extractSchemaDescriptions(schema)\n\n index.push({\n type: 'model',\n title: entry.title,\n description: 'Model',\n id: entry.id,\n body: propertyNames,\n bodyDescriptions: schemaDescription ? [schemaDescription, ...propertyDescriptions] : propertyDescriptions,\n entry,\n })\n\n return\n }\n\n // Models heading\n if (entry.type === 'models') {\n index.push({\n id: entry.id,\n type: 'heading',\n title: 'Models',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n\n // Tag\n if (entry.type === 'tag' && entry.isWebhooks === true) {\n index.push({\n id: entry.id,\n type: 'heading',\n title: 'Webhooks',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n\n if (entry.type === 'tag' && entry.isGroup === false) {\n index.push({\n id: entry.id,\n title: entry.title,\n description: entry.description || '',\n type: 'tag',\n body: '',\n entry,\n })\n\n return\n }\n\n // Tag group\n if (entry.type === 'tag' && entry.isGroup === true) {\n index.push({\n id: entry.id,\n title: entry.title,\n description: 'Tag Group',\n type: 'tag',\n body: '',\n entry,\n })\n\n return\n }\n\n // Headings from info.description\n if (entry.type === 'text') {\n index.push({\n id: entry.id,\n type: 'heading',\n title: entry.title ?? '',\n description: 'Heading',\n body: '',\n entry,\n })\n\n return\n }\n}\n"],"mappings":";;;;AAoBA,SAAS,6BAA6B,OAAwB;AAC5D,KAAI,OAAO,UAAU,SACnB,QAAO;AAGT,KAAI;AACF,SAAO,KAAK,UAAU,MAAM;UACrB,QAAQ;AACf,SAAO;;;AAIX,SAAS,2BAA2B,WAAsC;CACxE,MAAM,uBA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ACT,IAAI,MAAM;GACV,MAAM;GACN,OAAO;GACP,aAAa;GACb,MAAM;GACN;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,SAAS,MAAM,eAAe,MAAM;AACrD,QAAM,KAAK;GACT,IAAI,MAAM;GACV,MAAM;GACN,OAAO;GACP,aAAa;GACb,MAAM;GACN;GACD,CAAC;AAEF;;AAGF,KAAI,MAAM,SAAS,SAAS,MAAM,YAAY,OAAO;AACnD,QAAM,KAAK;GACT,IAAI,MAAM;GACV,OAAO,MAAM;GACb,aAAa,MAAM,eAAe;GAClC,MAAM;GACN,MAAM;GACN;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,SAAS,MAAM,YAAY,MAAM;AAClD,QAAM,KAAK;GACT,IAAI,MAAM;GACV,OAAO,MAAM;GACb,aAAa;GACb,MAAM;GACN,MAAM;GACN;GACD,CAAC;AAEF;;AAIF,KAAI,MAAM,SAAS,QAAQ;AACzB,QAAM,KAAK;GACT,IAAI,MAAM;GACV,MAAM;GACN,OAAO,MAAM,SAAS;GACtB,aAAa;GACb,MAAM;GACN;GACD,CAAC;AAEF"}
@@ -5,8 +5,14 @@ export type FuseData = {
5
5
  id: string;
6
6
  title: string;
7
7
  description: string;
8
+ /** Top-level request-body property names (e.g. `email`, `username`). High-signal field for search. */
8
9
  body?: string | string[];
10
+ /** Descriptions of request-body properties. Verbose prose, weighted lower than `body`. */
11
+ bodyDescriptions?: string[];
12
+ /** Parameter names (e.g. `userId`, `limit`). High-signal field for search. */
9
13
  parameters?: string | string[];
14
+ /** Descriptions of parameters. Verbose prose, weighted lower than `parameters`. */
15
+ parameterDescriptions?: string[];
10
16
  responseExamples?: string[];
11
17
  method?: string;
12
18
  path?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/features/Search/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAEhF,MAAM,MAAM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M,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,cAAc,CAAA;CACtB,CAAA"}
@@ -3,9 +3,9 @@ type __VLS_ModelProps = {
3
3
  modelValue?: ThemeId;
4
4
  };
5
5
  declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
- "update:modelValue": (value: "default" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "elysiajs" | "fastify" | "mars" | "laserwave" | "none" | undefined) => any;
6
+ "update:modelValue": (value: "default" | "none" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "elysiajs" | "fastify" | "mars" | "laserwave" | undefined) => any;
7
7
  }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
8
- "onUpdate:modelValue"?: ((value: "default" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "elysiajs" | "fastify" | "mars" | "laserwave" | "none" | undefined) => any) | undefined;
8
+ "onUpdate:modelValue"?: ((value: "default" | "none" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "elysiajs" | "fastify" | "mars" | "laserwave" | undefined) => any) | undefined;
9
9
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
10
  declare const _default: typeof __VLS_export;
11
11
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"map-config-plugins.d.ts","sourceRoot":"","sources":["../../src/helpers/map-config-plugins.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,EAAE,KAAK,WAAW,EAAS,MAAM,KAAK,CAAA;AAE7C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,WAAW,CAAC,yBAAyB,CAAC,EAC9C,aAAa,WAAW,CAAC,kBAAkB,CAAC,KAC3C,YAAY,EAwCd,CAAA"}
1
+ {"version":3,"file":"map-config-plugins.d.ts","sourceRoot":"","sources":["../../src/helpers/map-config-plugins.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,EAAE,KAAK,WAAW,EAAS,MAAM,KAAK,CAAA;AAE7C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,WAAW,CAAC,yBAAyB,CAAC,EAC9C,aAAa,WAAW,CAAC,kBAAkB,CAAC,KAC3C,YAAY,EAmDd,CAAA"}
@@ -27,8 +27,16 @@ var mapConfigPlugins = (config, environment) => {
27
27
  const envVariables = getEnvironmentVariables(environment);
28
28
  if (!plugin.hooks) plugin.hooks = {};
29
29
  plugin.hooks.beforeRequest = onBeforeRequest ? async (payload) => {
30
+ const built = buildRequest(payload.requestBuilder, {
31
+ envVariables,
32
+ allowMissingRequestServerBase: true
33
+ });
34
+ if (!built.ok) {
35
+ console.error("[@scalar/api-reference] onBeforeRequest was not run because the request could not be built:", built.message ?? built.error);
36
+ return;
37
+ }
30
38
  await onBeforeRequest({
31
- request: buildSafeBodyRequest(...buildRequest(payload.requestBuilder, { envVariables }).requestPayload),
39
+ request: buildSafeBodyRequest(...built.data.requestPayload),
32
40
  requestBuilder: payload.requestBuilder,
33
41
  envVariables
34
42
  });
@@ -1 +1 @@
1
- {"version":3,"file":"map-config-plugins.js","names":[],"sources":["../../src/helpers/map-config-plugins.ts"],"sourcesContent":["import { buildSafeBodyRequest } from '@scalar/helpers/http/can-method-have-body'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport { buildRequest, getEnvironmentVariables } from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { type ComputedRef, watch } from 'vue'\n\n/**\n * Maps API reference configuration callbacks to client plugins.\n *\n * This function transforms the legacy onBeforeRequest and onRequestSent callbacks\n * into the new plugin hook system. The mapping is reactive, so changes to the\n * configuration will automatically update the plugin hooks.\n *\n * Note: onRequestSent is mapped to responseReceived hook. This is not a perfect\n * one-to-one mapping, but it maintains backward compatibility with the old API.\n * The old callback receives only the URL string, while the new hook receives\n * the full response object.\n *\n * @param config - Reactive configuration object containing optional hook callbacks\n * @returns Array containing a single plugin with the mapped hooks\n */\nexport const mapConfigPlugins = (\n config: ComputedRef<ApiReferenceConfiguration>,\n environment: ComputedRef<XScalarEnvironment>,\n): ClientPlugin[] => {\n // Create a new plugin with the hooks which is going to be updated by the watcher when config changes\n const plugin: ClientPlugin = { hooks: {} }\n\n watch(\n [() => config.value.onBeforeRequest, () => config.value.onRequestSent, () => environment.value],\n ([onBeforeRequest, onRequestSent, environment]) => {\n // Get the environment variables for the current environment\n const envVariables = getEnvironmentVariables(environment)\n\n // Initialize the hooks object if it doesn't exist\n if (!plugin.hooks) {\n plugin.hooks = {}\n }\n\n plugin.hooks.beforeRequest = onBeforeRequest\n ? async (payload) => {\n await onBeforeRequest({\n // We need to build the request to get the fetch `Request`\n request: buildSafeBodyRequest(...buildRequest(payload.requestBuilder, { envVariables }).requestPayload),\n requestBuilder: payload.requestBuilder,\n envVariables,\n })\n }\n : undefined\n\n /**\n * Maps onRequestSent to responseReceived hook.\n * The old API only passed the URL string, so we extract it from the request.\n */\n plugin.hooks.responseReceived = onRequestSent\n ? (payload) => {\n onRequestSent(payload.request.url)\n }\n : undefined\n },\n { immediate: true },\n )\n\n return [plugin]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,IAAa,oBACX,QACA,gBACmB;CAEnB,MAAM,SAAuB,EAAE,OAAO,EAAE,EAAE;AAE1C,OACE;QAAO,OAAO,MAAM;QAAuB,OAAO,MAAM;QAAqB,YAAY;EAAM,GAC9F,CAAC,iBAAiB,eAAe,iBAAiB;EAEjD,MAAM,eAAe,wBAAwB,YAAY;AAGzD,MAAI,CAAC,OAAO,MACV,QAAO,QAAQ,EAAE;AAGnB,SAAO,MAAM,gBAAgB,kBACzB,OAAO,YAAY;AACjB,SAAM,gBAAgB;IAEpB,SAAS,qBAAqB,GAAG,aAAa,QAAQ,gBAAgB,EAAE,cAAc,CAAC,CAAC,eAAe;IACvG,gBAAgB,QAAQ;IACxB;IACD,CAAC;MAEJ,KAAA;;;;;AAMJ,SAAO,MAAM,mBAAmB,iBAC3B,YAAY;AACX,iBAAc,QAAQ,QAAQ,IAAI;MAEpC,KAAA;IAEN,EAAE,WAAW,MAAM,CACpB;AAED,QAAO,CAAC,OAAO"}
1
+ {"version":3,"file":"map-config-plugins.js","names":[],"sources":["../../src/helpers/map-config-plugins.ts"],"sourcesContent":["import { buildSafeBodyRequest } from '@scalar/helpers/http/can-method-have-body'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport { buildRequest, getEnvironmentVariables } from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { type ComputedRef, watch } from 'vue'\n\n/**\n * Maps API reference configuration callbacks to client plugins.\n *\n * This function transforms the legacy onBeforeRequest and onRequestSent callbacks\n * into the new plugin hook system. The mapping is reactive, so changes to the\n * configuration will automatically update the plugin hooks.\n *\n * Note: onRequestSent is mapped to responseReceived hook. This is not a perfect\n * one-to-one mapping, but it maintains backward compatibility with the old API.\n * The old callback receives only the URL string, while the new hook receives\n * the full response object.\n *\n * @param config - Reactive configuration object containing optional hook callbacks\n * @returns Array containing a single plugin with the mapped hooks\n */\nexport const mapConfigPlugins = (\n config: ComputedRef<ApiReferenceConfiguration>,\n environment: ComputedRef<XScalarEnvironment>,\n): ClientPlugin[] => {\n // Create a new plugin with the hooks which is going to be updated by the watcher when config changes\n const plugin: ClientPlugin = { hooks: {} }\n\n watch(\n [() => config.value.onBeforeRequest, () => config.value.onRequestSent, () => environment.value],\n ([onBeforeRequest, onRequestSent, environment]) => {\n // Get the environment variables for the current environment\n const envVariables = getEnvironmentVariables(environment)\n\n // Initialize the hooks object if it doesn't exist\n if (!plugin.hooks) {\n plugin.hooks = {}\n }\n\n plugin.hooks.beforeRequest = onBeforeRequest\n ? async (payload) => {\n const built = buildRequest(payload.requestBuilder, {\n envVariables,\n allowMissingRequestServerBase: true,\n })\n if (!built.ok) {\n console.error(\n '[@scalar/api-reference] onBeforeRequest was not run because the request could not be built:',\n built.message ?? built.error,\n )\n return\n }\n await onBeforeRequest({\n // We need to build the request to get the fetch `Request`\n request: buildSafeBodyRequest(...built.data.requestPayload),\n requestBuilder: payload.requestBuilder,\n envVariables,\n })\n }\n : undefined\n\n /**\n * Maps onRequestSent to responseReceived hook.\n * The old API only passed the URL string, so we extract it from the request.\n */\n plugin.hooks.responseReceived = onRequestSent\n ? (payload) => {\n onRequestSent(payload.request.url)\n }\n : undefined\n },\n { immediate: true },\n )\n\n return [plugin]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,IAAa,oBACX,QACA,gBACmB;CAEnB,MAAM,SAAuB,EAAE,OAAO,EAAE,EAAE;AAE1C,OACE;QAAO,OAAO,MAAM;QAAuB,OAAO,MAAM;QAAqB,YAAY;EAAM,GAC9F,CAAC,iBAAiB,eAAe,iBAAiB;EAEjD,MAAM,eAAe,wBAAwB,YAAY;AAGzD,MAAI,CAAC,OAAO,MACV,QAAO,QAAQ,EAAE;AAGnB,SAAO,MAAM,gBAAgB,kBACzB,OAAO,YAAY;GACjB,MAAM,QAAQ,aAAa,QAAQ,gBAAgB;IACjD;IACA,+BAA+B;IAChC,CAAC;AACF,OAAI,CAAC,MAAM,IAAI;AACb,YAAQ,MACN,+FACA,MAAM,WAAW,MAAM,MACxB;AACD;;AAEF,SAAM,gBAAgB;IAEpB,SAAS,qBAAqB,GAAG,MAAM,KAAK,eAAe;IAC3D,gBAAgB,QAAQ;IACxB;IACD,CAAC;MAEJ,KAAA;;;;;AAMJ,SAAO,MAAM,mBAAmB,iBAC3B,YAAY;AACX,iBAAc,QAAQ,QAAQ,IAAI;MAEpC,KAAA;IAEN,EAAE,WAAW,MAAM,CACpB;AAED,QAAO,CAAC,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-configurations.d.ts","sourceRoot":"","sources":["../../src/helpers/normalize-configurations.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,mCAAmC,EAGzC,MAAM,6BAA6B,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,4BAA4B,CAAA;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,mCAAmC,CAAC,OAAO,CAAC,CAAA;IACnD,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,GAAG,CAAC,EAAE,KAAK,CAAA;KAAE,CAAA;CAC7F,CAAA;AAED,KAAK,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;AAKvE;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAClC,eAAe,4BAA4B,GAAG,SAAS,KACtD,wBAoDF,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,GAC3B,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACnF,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAc5B,CAAA"}
1
+ {"version":3,"file":"normalize-configurations.d.ts","sourceRoot":"","sources":["../../src/helpers/normalize-configurations.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,mCAAmC,EAEzC,MAAM,6BAA6B,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,4BAA4B,CAAA;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,mCAAmC,CAAC,OAAO,CAAC,CAAA;IACnD,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,GAAG,CAAC,EAAE,KAAK,CAAA;KAAE,CAAA;CAC7F,CAAA;AAED,KAAK,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;AASvE;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAClC,eAAe,4BAA4B,GAAG,SAAS,KACtD,wBAgDF,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,GAC3B,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACnF,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAc5B,CAAA"}
@@ -1,7 +1,11 @@
1
- import { apiReferenceConfigurationWithSourceSchema, isConfigurationWithSources } from "@scalar/types/api-reference";
1
+ import { apiReferenceConfigurationWithSourceSchema } from "@scalar/schemas/api-reference";
2
+ import { isConfigurationWithSources } from "@scalar/types/api-reference";
2
3
  import { slugger } from "@scalar/helpers/string/slugger";
3
4
  import { parseJsonOrYaml } from "@scalar/oas-utils/helpers";
4
5
  //#region src/helpers/normalize-configurations.ts
6
+ var isConfigWithRequiredSource = (input) => {
7
+ return !!input.url?.trim() || !!input.content;
8
+ };
5
9
  /**
6
10
  * Take any configuration and return a flat array of configurations.
7
11
  */
@@ -18,11 +22,7 @@ var normalizeConfigurations = (configuration) => {
18
22
  })) ?? [];
19
23
  }
20
24
  return [c];
21
- }).map((source) => {
22
- /** Validation with migrate deprecated attributes to their new format */
23
- const validated = apiReferenceConfigurationWithSourceSchema.safeParse(source);
24
- return validated.success ? validated.data : null;
25
- }).filter((c) => !!c && (!!c.url || !!c.content)).map((source, index) => addSlugAndTitle(source, index, slug)).forEach((c) => {
25
+ }).map((source) => apiReferenceConfigurationWithSourceSchema(source)).filter(isConfigWithRequiredSource).map((source, index) => addSlugAndTitle(source, index, slug)).forEach((c) => {
26
26
  const { url, content, ...config } = c;
27
27
  normalized[c.slug] = {
28
28
  config,
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-configurations.js","names":[],"sources":["../../src/helpers/normalize-configurations.ts"],"sourcesContent":["import { slugger } from '@scalar/helpers/string/slugger'\nimport { parseJsonOrYaml } from '@scalar/oas-utils/helpers'\nimport {\n type AnyApiReferenceConfiguration,\n type ApiReferenceConfigurationRaw,\n type ApiReferenceConfigurationWithSource,\n apiReferenceConfigurationWithSourceSchema,\n isConfigurationWithSources,\n} from '@scalar/types/api-reference'\n\n/** Processed API Reference Configuration\n *\n * Creates the required title and slug for the API Reference.\n * Separate the source into a dedicated object\n * Returns the raw configuration to pass to components\n */\nexport type NormalizedConfiguration = {\n title: string\n slug: string\n config: ApiReferenceConfigurationRaw\n default: boolean\n agent: ApiReferenceConfigurationWithSource['agent']\n source: { url: string; content?: never } | { content: Record<string, unknown>; url?: never }\n}\n\ntype NormalizedConfigurations = Record<string, NormalizedConfiguration>\n\ntype ConfigWithRequiredSource = Omit<ApiReferenceConfigurationWithSource, 'url' | 'content'> &\n ({ url: string; content?: never } | { content: Record<string, unknown>; url?: never })\n\n/**\n * Take any configuration and return a flat array of configurations.\n */\nexport const normalizeConfigurations = (\n configuration: AnyApiReferenceConfiguration | undefined,\n): NormalizedConfigurations => {\n const { slug } = slugger()\n\n const normalized: NormalizedConfigurations = {}\n\n if (!configuration) {\n return normalized\n }\n\n const configList = Array.isArray(configuration) ? configuration : [configuration]\n\n configList\n /** Create a flat array of configurations with their document source data integrated. */\n .flatMap((c) => {\n // Check if this config has a 'sources' array property\n if (isConfigurationWithSources(c)) {\n // Destructure to separate sources array from other config properties\n const { sources: configSources, ...rest } = c\n\n // For each source in the array:\n // - Merge the source with the parent config properties\n // - Handle undefined sources by returning empty array via ?? []\n return configSources?.map((source) => ({ ...rest, ...source })) ?? []\n }\n\n // If config doesn't have sources array, treat the config itself as a source\n return [c]\n })\n .map((source) => {\n /** Validation with migrate deprecated attributes to their new format */\n const validated = apiReferenceConfigurationWithSourceSchema.safeParse(source)\n return validated.success ? validated.data : null\n })\n /** Filter out configurations that failed validation or don't have a url or content */\n .filter((c): c is ConfigWithRequiredSource => !!c && (!!c.url || !!c.content))\n /** Add required attributes to the source */\n .map((source, index) => addSlugAndTitle(source, index, slug))\n /** Separate the configuration and sources by slug */\n .forEach((c) => {\n const { url, content, ...config } = c\n normalized[c.slug] = {\n config,\n title: c.title,\n slug: c.slug,\n default: !!c?.default,\n agent: c.agent,\n source: content ? { content: normalizeContent(content) ?? {} } : { url },\n }\n })\n\n // Process them and return normalized\n return normalized\n}\n\n/** Normalize content into a JS object or return null if it is falsey */\nexport const normalizeContent = (\n content: string | Record<string, unknown> | (() => string | Record<string, unknown>),\n): Record<string, unknown> | null => {\n if (!content) {\n return null\n }\n\n if (typeof content === 'function') {\n return normalizeContent(content())\n }\n\n if (typeof content === 'string') {\n return parseJsonOrYaml(content)\n }\n\n return content\n}\n\n/** Process a single spec configuration so that it has a title and a slug */\nconst addSlugAndTitle = (\n source: ConfigWithRequiredSource,\n index = 0,\n slug: (v: string) => string,\n): ConfigWithRequiredSource & { slug: string; title: string } => {\n // Case 1: Title exists, generate slug from it\n if (source.title) {\n return {\n ...source,\n slug: source.slug || slug(source.title),\n title: source.title,\n }\n }\n\n // Case 2: Slug exists but no title, use slug as title\n if (source.slug) {\n return {\n ...source,\n slug: slug(source.slug),\n title: source.slug,\n }\n }\n\n // Case 3: Neither exists, use index\n return {\n ...source,\n slug: `api-${index + 1}`,\n title: `API #${index + 1}`,\n }\n}\n"],"mappings":";;;;;;;AAiCA,IAAa,2BACX,kBAC6B;CAC7B,MAAM,EAAE,SAAS,SAAS;CAE1B,MAAM,aAAuC,EAAE;AAE/C,KAAI,CAAC,cACH,QAAO;AAKT,EAFmB,MAAM,QAAQ,cAAc,GAAG,gBAAgB,CAAC,cAAc,EAI9E,SAAS,MAAM;AAEd,MAAI,2BAA2B,EAAE,EAAE;GAEjC,MAAM,EAAE,SAAS,eAAe,GAAG,SAAS;AAK5C,UAAO,eAAe,KAAK,YAAY;IAAE,GAAG;IAAM,GAAG;IAAQ,EAAE,IAAI,EAAE;;AAIvE,SAAO,CAAC,EAAE;GACV,CACD,KAAK,WAAW;;EAEf,MAAM,YAAY,0CAA0C,UAAU,OAAO;AAC7E,SAAO,UAAU,UAAU,UAAU,OAAO;GAC5C,CAED,QAAQ,MAAqC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAE7E,KAAK,QAAQ,UAAU,gBAAgB,QAAQ,OAAO,KAAK,CAAC,CAE5D,SAAS,MAAM;EACd,MAAM,EAAE,KAAK,SAAS,GAAG,WAAW;AACpC,aAAW,EAAE,QAAQ;GACnB;GACA,OAAO,EAAE;GACT,MAAM,EAAE;GACR,SAAS,CAAC,CAAC,GAAG;GACd,OAAO,EAAE;GACT,QAAQ,UAAU,EAAE,SAAS,iBAAiB,QAAQ,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK;GACzE;GACD;AAGJ,QAAO;;;AAIT,IAAa,oBACX,YACmC;AACnC,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,OAAO,YAAY,WACrB,QAAO,iBAAiB,SAAS,CAAC;AAGpC,KAAI,OAAO,YAAY,SACrB,QAAO,gBAAgB,QAAQ;AAGjC,QAAO;;;AAIT,IAAM,mBACJ,QACA,QAAQ,GACR,SAC+D;AAE/D,KAAI,OAAO,MACT,QAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ,KAAK,OAAO,MAAM;EACvC,OAAO,OAAO;EACf;AAIH,KAAI,OAAO,KACT,QAAO;EACL,GAAG;EACH,MAAM,KAAK,OAAO,KAAK;EACvB,OAAO,OAAO;EACf;AAIH,QAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ;EACrB,OAAO,QAAQ,QAAQ;EACxB"}
1
+ {"version":3,"file":"normalize-configurations.js","names":[],"sources":["../../src/helpers/normalize-configurations.ts"],"sourcesContent":["import { slugger } from '@scalar/helpers/string/slugger'\nimport { parseJsonOrYaml } from '@scalar/oas-utils/helpers'\nimport { apiReferenceConfigurationWithSourceSchema } from '@scalar/schemas/api-reference'\nimport {\n type AnyApiReferenceConfiguration,\n type ApiReferenceConfigurationRaw,\n type ApiReferenceConfigurationWithSource,\n isConfigurationWithSources,\n} from '@scalar/types/api-reference'\n\n/** Processed API Reference Configuration\n *\n * Creates the required title and slug for the API Reference.\n * Separate the source into a dedicated object\n * Returns the raw configuration to pass to components\n */\nexport type NormalizedConfiguration = {\n title: string\n slug: string\n config: ApiReferenceConfigurationRaw\n default: boolean\n agent: ApiReferenceConfigurationWithSource['agent']\n source: { url: string; content?: never } | { content: Record<string, unknown>; url?: never }\n}\n\ntype NormalizedConfigurations = Record<string, NormalizedConfiguration>\n\ntype ConfigWithRequiredSource = Omit<ApiReferenceConfigurationWithSource, 'url' | 'content'> &\n ({ url: string; content?: never } | { content: Record<string, unknown>; url?: never })\n\nconst isConfigWithRequiredSource = (input: ApiReferenceConfigurationWithSource): input is ConfigWithRequiredSource => {\n return !!input.url?.trim() || !!input.content\n}\n\n/**\n * Take any configuration and return a flat array of configurations.\n */\nexport const normalizeConfigurations = (\n configuration: AnyApiReferenceConfiguration | undefined,\n): NormalizedConfigurations => {\n const { slug } = slugger()\n\n const normalized: NormalizedConfigurations = {}\n\n if (!configuration) {\n return normalized\n }\n\n const configList = Array.isArray(configuration) ? configuration : [configuration]\n\n configList\n /** Create a flat array of configurations with their document source data integrated. */\n .flatMap((c) => {\n // Check if this config has a 'sources' array property\n if (isConfigurationWithSources(c)) {\n // Destructure to separate sources array from other config properties\n const { sources: configSources, ...rest } = c\n\n // For each source in the array:\n // - Merge the source with the parent config properties\n // - Handle undefined sources by returning empty array via ?? []\n return configSources?.map((source) => ({ ...rest, ...source })) ?? []\n }\n\n // If config doesn't have sources array, treat the config itself as a source\n return [c]\n })\n .map((source) => apiReferenceConfigurationWithSourceSchema(source) as ApiReferenceConfigurationWithSource)\n /** Filter out configurations that failed validation or don't have a url or content */\n .filter(isConfigWithRequiredSource)\n /** Add required attributes to the source */\n .map((source, index) => addSlugAndTitle(source, index, slug))\n /** Separate the configuration and sources by slug */\n .forEach((c) => {\n const { url, content, ...config } = c\n normalized[c.slug] = {\n config,\n title: c.title,\n slug: c.slug,\n default: !!c?.default,\n agent: c.agent,\n source: content ? { content: normalizeContent(content) ?? {} } : { url },\n }\n })\n\n // Process them and return normalized\n return normalized\n}\n\n/** Normalize content into a JS object or return null if it is falsey */\nexport const normalizeContent = (\n content: string | Record<string, unknown> | (() => string | Record<string, unknown>),\n): Record<string, unknown> | null => {\n if (!content) {\n return null\n }\n\n if (typeof content === 'function') {\n return normalizeContent(content())\n }\n\n if (typeof content === 'string') {\n return parseJsonOrYaml(content)\n }\n\n return content\n}\n\n/** Process a single spec configuration so that it has a title and a slug */\nconst addSlugAndTitle = (\n source: ConfigWithRequiredSource,\n index = 0,\n slug: (v: string) => string,\n): ConfigWithRequiredSource & { slug: string; title: string } => {\n // Case 1: Title exists, generate slug from it\n if (source.title) {\n return {\n ...source,\n slug: source.slug || slug(source.title),\n title: source.title,\n }\n }\n\n // Case 2: Slug exists but no title, use slug as title\n if (source.slug) {\n return {\n ...source,\n slug: slug(source.slug),\n title: source.slug,\n }\n }\n\n // Case 3: Neither exists, use index\n return {\n ...source,\n slug: `api-${index + 1}`,\n title: `API #${index + 1}`,\n }\n}\n"],"mappings":";;;;;AA8BA,IAAM,8BAA8B,UAAkF;AACpH,QAAO,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM;;;;;AAMxC,IAAa,2BACX,kBAC6B;CAC7B,MAAM,EAAE,SAAS,SAAS;CAE1B,MAAM,aAAuC,EAAE;AAE/C,KAAI,CAAC,cACH,QAAO;AAKT,EAFmB,MAAM,QAAQ,cAAc,GAAG,gBAAgB,CAAC,cAAc,EAI9E,SAAS,MAAM;AAEd,MAAI,2BAA2B,EAAE,EAAE;GAEjC,MAAM,EAAE,SAAS,eAAe,GAAG,SAAS;AAK5C,UAAO,eAAe,KAAK,YAAY;IAAE,GAAG;IAAM,GAAG;IAAQ,EAAE,IAAI,EAAE;;AAIvE,SAAO,CAAC,EAAE;GACV,CACD,KAAK,WAAW,0CAA0C,OAAO,CAAwC,CAEzG,OAAO,2BAA2B,CAElC,KAAK,QAAQ,UAAU,gBAAgB,QAAQ,OAAO,KAAK,CAAC,CAE5D,SAAS,MAAM;EACd,MAAM,EAAE,KAAK,SAAS,GAAG,WAAW;AACpC,aAAW,EAAE,QAAQ;GACnB;GACA,OAAO,EAAE;GACT,MAAM,EAAE;GACR,SAAS,CAAC,CAAC,GAAG;GACd,OAAO,EAAE;GACT,QAAQ,UAAU,EAAE,SAAS,iBAAiB,QAAQ,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK;GACzE;GACD;AAGJ,QAAO;;;AAIT,IAAa,oBACX,YACmC;AACnC,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,OAAO,YAAY,WACrB,QAAO,iBAAiB,SAAS,CAAC;AAGpC,KAAI,OAAO,YAAY,SACrB,QAAO,gBAAgB,QAAQ;AAGjC,QAAO;;;AAIT,IAAM,mBACJ,QACA,QAAQ,GACR,SAC+D;AAE/D,KAAI,OAAO,MACT,QAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ,KAAK,OAAO,MAAM;EACvC,OAAO,OAAO;EACf;AAIH,KAAI,OAAO,KACT,QAAO;EACL,GAAG;EACH,MAAM,KAAK,OAAO,KAAK;EACvB,OAAO,OAAO;EACf;AAIH,QAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ;EACrB,OAAO,QAAQ,QAAQ;EACxB"}
@@ -1,12 +1,41 @@
1
- import type { OpenApiDocument, OperationObject, ParameterObject, ReferenceType } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
1
+ import type { OpenApiDocument, OperationObject, ParameterObject, ReferenceType, SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
2
2
  /**
3
- * Extracts the request body from an operation.
3
+ * Extracts the names of every parameter on an operation.
4
+ *
5
+ * The returned strings contain only parameter names (e.g. `userId`, `limit`) so they can be indexed
6
+ * as a high-signal field for search. Filter-style metadata like `REQUIRED`, `optional`, `query` and
7
+ * the schema type are intentionally excluded — those tokens dilute fuzzy matches and produce false
8
+ * positives for queries like `query` or `integer`.
4
9
  */
5
- export declare function extractRequestBody(operation: OperationObject): string[] | null;
10
+ export declare function extractParameterNames(parameters: ReferenceType<ParameterObject>[]): string[];
6
11
  /**
7
- * Extracts parameters from an operation into searchable strings.
12
+ * Extracts the descriptions of every parameter on an operation.
13
+ *
14
+ * Kept separate from parameter names so the search index can weight each independently.
8
15
  */
9
- export declare function extractParameters(parameters: ReferenceType<ParameterObject>[]): string[] | null;
16
+ export declare function extractParameterDescriptions(parameters: ReferenceType<ParameterObject>[]): string[];
17
+ /**
18
+ * Extracts the names of properties from the request body schema(s) of an operation.
19
+ *
20
+ * Walks every media type and includes both top-level and one level of nested property names so
21
+ * common fields like `email` or `username` surface in search regardless of how the body is shaped.
22
+ */
23
+ export declare function extractBodyFieldNames(operation: OperationObject): string[];
24
+ /**
25
+ * Extracts the descriptions of properties from the request body schema(s) of an operation.
26
+ */
27
+ export declare function extractBodyDescriptions(operation: OperationObject): string[];
28
+ /**
29
+ * Extracts the property names of a schema for the search index.
30
+ *
31
+ * Same depth and composition behavior as `extractBodyFieldNames` — descends transparently through
32
+ * `oneOf`/`anyOf`/`allOf`, walks one level into nested object properties, dedupes.
33
+ */
34
+ export declare function extractSchemaFieldNames(schema: SchemaObject | undefined): string[];
35
+ /**
36
+ * Extracts the property descriptions of a schema for the search index.
37
+ */
38
+ export declare function extractSchemaDescriptions(schema: SchemaObject | undefined): string[];
10
39
  /**
11
40
  * Deep merge for objects
12
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/helpers/openapi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,aAAa,EAGd,MAAM,8DAA8D,CAAA;AAwGrE;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,EAAE,GAAG,IAAI,CAS9E;AAwBD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,CAE/F;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,M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