@scalar/blocks 0.5.4 → 0.6.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 (249) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +13 -29
  3. package/dist/code-example/components/AsyncApiCodeExample.vue.d.ts +19 -0
  4. package/dist/code-example/components/AsyncApiCodeExample.vue.d.ts.map +1 -0
  5. package/dist/code-example/components/AsyncApiCodeExample.vue.js +9 -0
  6. package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -0
  7. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +114 -0
  8. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -0
  9. package/dist/code-example/components/CodeExample.vue.js +4 -4
  10. package/dist/code-example/components/CodeExample.vue.js.map +1 -1
  11. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +258 -0
  12. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -0
  13. package/dist/code-example/components/ExamplePicker.vue.js +1 -1
  14. package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
  15. package/dist/code-example/components/{ExamplePicker.vue.script.js → ExamplePicker.vue_vue_type_script_setup_true_lang.js} +5 -5
  16. package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js.map +1 -0
  17. package/dist/code-example/components/HttpMethod.vue.js +1 -1
  18. package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
  19. package/dist/code-example/components/{HttpMethod.vue.script.js → HttpMethod.vue_vue_type_script_setup_true_lang.js} +1 -1
  20. package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js.map +1 -0
  21. package/dist/code-example/helpers/filter-clients-by-query.js.map +1 -1
  22. package/dist/code-example/helpers/find-client.js.map +1 -1
  23. package/dist/code-example/helpers/format-language.js.map +1 -1
  24. package/dist/code-example/helpers/generate-client-options.js.map +1 -1
  25. package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
  26. package/dist/code-example/helpers/get-asyncapi-example-context.d.ts +12 -0
  27. package/dist/code-example/helpers/get-asyncapi-example-context.d.ts.map +1 -0
  28. package/dist/code-example/helpers/get-asyncapi-example-context.js +33 -0
  29. package/dist/code-example/helpers/get-asyncapi-example-context.js.map +1 -0
  30. package/dist/code-example/helpers/get-clients.js.map +1 -1
  31. package/dist/code-example/helpers/get-custom-code-samples.js.map +1 -1
  32. package/dist/code-example/helpers/get-generated-payload-example.d.ts +4 -0
  33. package/dist/code-example/helpers/get-generated-payload-example.d.ts.map +1 -0
  34. package/dist/code-example/helpers/get-generated-payload-example.js +25 -0
  35. package/dist/code-example/helpers/get-generated-payload-example.js.map +1 -0
  36. package/dist/code-example/helpers/get-message-example-content.d.ts +10 -0
  37. package/dist/code-example/helpers/get-message-example-content.d.ts.map +1 -0
  38. package/dist/code-example/helpers/get-message-example-content.js +29 -0
  39. package/dist/code-example/helpers/get-message-example-content.js.map +1 -0
  40. package/dist/code-example/helpers/get-secrets.js.map +1 -1
  41. package/dist/code-example/helpers/get-snippet.js.map +1 -1
  42. package/dist/code-example/helpers/operation-to-har/operation-to-har.js +32 -32
  43. package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
  44. package/dist/code-example/helpers/operation-to-har/process-body.js +41 -47
  45. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  46. package/dist/code-example/helpers/operation-to-har/process-parameters.js +51 -55
  47. package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
  48. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js +30 -38
  49. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js.map +1 -1
  50. package/dist/code-example/helpers/operation-to-har/process-server-url.js +5 -1
  51. package/dist/code-example/helpers/operation-to-har/process-server-url.js.map +1 -1
  52. package/dist/code-example/index.d.ts +4 -0
  53. package/dist/code-example/index.d.ts.map +1 -1
  54. package/dist/code-example/index.js +17 -14
  55. package/dist/code-example/mount-asyncapi.d.ts +14 -0
  56. package/dist/code-example/mount-asyncapi.d.ts.map +1 -0
  57. package/dist/code-example/mount-asyncapi.js +27 -0
  58. package/dist/code-example/mount-asyncapi.js.map +1 -0
  59. package/dist/code-example/mount.d.ts +4 -2
  60. package/dist/code-example/mount.d.ts.map +1 -1
  61. package/dist/code-example/mount.js +39 -37
  62. package/dist/code-example/mount.js.map +1 -1
  63. package/dist/constants.js +1 -1
  64. package/dist/constants.js.map +1 -1
  65. package/dist/schema/LinkButton.vue.js.map +1 -1
  66. package/dist/schema/RenderString.vue.js +1 -1
  67. package/dist/schema/RenderString.vue.js.map +1 -1
  68. package/dist/schema/{RenderString.vue.script.js → RenderString.vue_vue_type_script_setup_true_lang.js} +1 -1
  69. package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js.map +1 -0
  70. package/dist/schema/Schema.vue.js +2 -2
  71. package/dist/schema/Schema.vue.js.map +1 -1
  72. package/dist/schema/{Schema.vue.script.js → Schema.vue_vue_type_script_setup_true_lang.js} +1 -1
  73. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js.map +1 -0
  74. package/dist/schema/SchemaCollapsedPreview.vue.js +1 -1
  75. package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -1
  76. package/dist/schema/{SchemaCollapsedPreview.vue.script.js → SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js} +1 -1
  77. package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js.map +1 -0
  78. package/dist/schema/SchemaComposition.vue.js +2 -2
  79. package/dist/schema/SchemaComposition.vue.js.map +1 -1
  80. package/dist/schema/{SchemaComposition.vue.script.js → SchemaComposition.vue_vue_type_script_setup_true_lang.js} +5 -5
  81. package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js.map +1 -0
  82. package/dist/schema/SchemaEnumPropertyItem.vue.js +1 -1
  83. package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -1
  84. package/dist/schema/{SchemaEnumPropertyItem.vue.script.js → SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js} +1 -1
  85. package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js.map +1 -0
  86. package/dist/schema/SchemaEnums.vue.js +2 -2
  87. package/dist/schema/SchemaEnums.vue.js.map +1 -1
  88. package/dist/schema/{SchemaEnums.vue.script.js → SchemaEnums.vue_vue_type_script_setup_true_lang.js} +1 -1
  89. package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js.map +1 -0
  90. package/dist/schema/SchemaGlyphPuck.vue.js +1 -1
  91. package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -1
  92. package/dist/schema/{SchemaGlyphPuck.vue.script.js → SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js} +1 -1
  93. package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js.map +1 -0
  94. package/dist/schema/SchemaGutterToggle.vue.js +1 -1
  95. package/dist/schema/SchemaGutterToggle.vue.js.map +1 -1
  96. package/dist/schema/{SchemaGutterToggle.vue.script.js → SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js} +1 -1
  97. package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js.map +1 -0
  98. package/dist/schema/SchemaHeading.vue.js +2 -2
  99. package/dist/schema/SchemaHeading.vue.js.map +1 -1
  100. package/dist/schema/{SchemaHeading.vue.script.js → SchemaHeading.vue_vue_type_script_setup_true_lang.js} +1 -1
  101. package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js.map +1 -0
  102. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +1 -1
  103. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
  104. package/dist/schema/{SchemaObjectExampleCodeBlock.vue.script.js → SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js} +1 -1
  105. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -0
  106. package/dist/schema/SchemaObjectProperties.vue.js +1 -1
  107. package/dist/schema/SchemaObjectProperties.vue.js.map +1 -1
  108. package/dist/schema/{SchemaObjectProperties.vue.script.js → SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js} +3 -3
  109. package/dist/schema/{SchemaObjectProperties.vue.script.js.map → SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js.map} +1 -1
  110. package/dist/schema/SchemaProperty.vue.js +2 -2
  111. package/dist/schema/SchemaProperty.vue.js.map +1 -1
  112. package/dist/schema/{SchemaProperty.vue.script.js → SchemaProperty.vue_vue_type_script_setup_true_lang.js} +3 -7
  113. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js.map +1 -0
  114. package/dist/schema/SchemaPropertyDefault.vue.js +2 -2
  115. package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -1
  116. package/dist/schema/{SchemaPropertyDefault.vue.script.js → SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js} +1 -1
  117. package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js.map +1 -0
  118. package/dist/schema/SchemaPropertyDetail.vue.js +2 -2
  119. package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -1
  120. package/dist/schema/{SchemaPropertyDetail.vue.script.js → SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js} +1 -1
  121. package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js.map +1 -0
  122. package/dist/schema/SchemaPropertyExamples.vue.d.ts +2 -0
  123. package/dist/schema/SchemaPropertyExamples.vue.d.ts.map +1 -1
  124. package/dist/schema/SchemaPropertyExamples.vue.js +3 -3
  125. package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
  126. package/dist/schema/{SchemaPropertyExamples.vue.script.js → SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js} +10 -3
  127. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +1 -0
  128. package/dist/schema/SchemaPropertyHeading.vue.js +2 -2
  129. package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
  130. package/dist/schema/{SchemaPropertyHeading.vue.script.js → SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js} +1 -1
  131. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js.map +1 -0
  132. package/dist/schema/SchemaPropertyPattern.vue.js +2 -2
  133. package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -1
  134. package/dist/schema/{SchemaPropertyPattern.vue.script.js → SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js} +1 -1
  135. package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js.map +1 -0
  136. package/dist/schema/SchemaRailPanel.vue.js +1 -1
  137. package/dist/schema/SchemaRailPanel.vue.js.map +1 -1
  138. package/dist/schema/{SchemaRailPanel.vue.script.js → SchemaRailPanel.vue_vue_type_script_setup_true_lang.js} +1 -1
  139. package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  140. package/dist/schema/components/CopyLinkButton.vue.js +1 -1
  141. package/dist/schema/components/CopyLinkButton.vue.js.map +1 -1
  142. package/dist/schema/components/{CopyLinkButton.vue.script.js → CopyLinkButton.vue_vue_type_script_setup_true_lang.js} +1 -1
  143. package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  144. package/dist/schema/components/WithBreadcrumb.vue.js +1 -1
  145. package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -1
  146. package/dist/schema/components/{WithBreadcrumb.vue.script.js → WithBreadcrumb.vue_vue_type_script_setup_true_lang.js} +1 -1
  147. package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js.map +1 -0
  148. package/dist/schema/discriminator-metadata.js.map +1 -1
  149. package/dist/schema/expansion/index.js +1 -2
  150. package/dist/schema/helpers/dynamic-scope.js.map +1 -1
  151. package/dist/schema/helpers/format-example.js.map +1 -1
  152. package/dist/schema/helpers/format-value.js.map +1 -1
  153. package/dist/schema/helpers/get-compositions-to-render.js.map +1 -1
  154. package/dist/schema/helpers/get-discriminator-values.js.map +1 -1
  155. package/dist/schema/helpers/get-enum-values.js.map +1 -1
  156. package/dist/schema/helpers/get-property-description.js.map +1 -1
  157. package/dist/schema/helpers/get-ref-name.js.map +1 -1
  158. package/dist/schema/helpers/get-schema-type.js.map +1 -1
  159. package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -1
  160. package/dist/schema/helpers/has-complex-array-items.js.map +1 -1
  161. package/dist/schema/helpers/is-empty-schema-object.js.map +1 -1
  162. package/dist/schema/helpers/is-model-linkable.js.map +1 -1
  163. package/dist/schema/helpers/is-on-schema-target-path.js.map +1 -1
  164. package/dist/schema/helpers/is-type-object.js.map +1 -1
  165. package/dist/schema/helpers/merge-all-of-schemas.js +24 -25
  166. package/dist/schema/helpers/merge-all-of-schemas.js.map +1 -1
  167. package/dist/schema/helpers/normalize-object-composition.js.map +1 -1
  168. package/dist/schema/helpers/optimize-value-for-display.js +5 -12
  169. package/dist/schema/helpers/optimize-value-for-display.js.map +1 -1
  170. package/dist/schema/helpers/partition-all-of-compositions.js.map +1 -1
  171. package/dist/schema/helpers/schema-composition.js.map +1 -1
  172. package/dist/schema/helpers/schema-cycle.js.map +1 -1
  173. package/dist/schema/helpers/schema-expansion.js +4 -5
  174. package/dist/schema/helpers/schema-expansion.js.map +1 -1
  175. package/dist/schema/helpers/schema-keyboard-nav.js.map +1 -1
  176. package/dist/schema/helpers/schema-name.js.map +1 -1
  177. package/dist/schema/helpers/should-display-description.js.map +1 -1
  178. package/dist/schema/helpers/should-display-heading.js.map +1 -1
  179. package/dist/schema/helpers/should-render-array-item-composition.js.map +1 -1
  180. package/dist/schema/helpers/sort-property-names.js.map +1 -1
  181. package/dist/schema/helpers/unwrap-for-read.js.map +1 -1
  182. package/dist/schema/index.d.ts +1 -0
  183. package/dist/schema/index.d.ts.map +1 -1
  184. package/dist/schema/index.js +6 -5
  185. package/dist/schema/localization/index.d.ts +1 -1
  186. package/dist/schema/localization/index.js.map +1 -1
  187. package/dist/schema/localization/locales/ar.js.map +1 -1
  188. package/dist/schema/localization/locales/de.js.map +1 -1
  189. package/dist/schema/localization/locales/en.js.map +1 -1
  190. package/dist/schema/localization/locales/es.js.map +1 -1
  191. package/dist/schema/localization/locales/fr.js.map +1 -1
  192. package/dist/schema/localization/locales/pt.js.map +1 -1
  193. package/dist/schema/localization/locales/ru.js.map +1 -1
  194. package/dist/schema/localization/locales/zh-cn.js.map +1 -1
  195. package/dist/schema/localization/locales/zh-tw.js.map +1 -1
  196. package/dist/schema/localization/translations.js.map +1 -1
  197. package/dist/schema/request-body-composition-index.js.map +1 -1
  198. package/dist/shared/Badge.vue.js +2 -2
  199. package/dist/shared/Badge.vue.js.map +1 -1
  200. package/dist/shared/{Badge.vue.script.js → Badge.vue_vue_type_script_setup_true_lang.js} +1 -1
  201. package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js.map +1 -0
  202. package/dist/shared/ExternalDocs.vue.js +1 -1
  203. package/dist/shared/ExternalDocs.vue.js.map +1 -1
  204. package/dist/shared/{ExternalDocs.vue.script.js → ExternalDocs.vue_vue_type_script_setup_true_lang.js} +1 -1
  205. package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js.map +1 -0
  206. package/dist/shared/ScreenReader.vue.js +1 -1
  207. package/dist/shared/ScreenReader.vue.js.map +1 -1
  208. package/dist/shared/{ScreenReader.vue.script.js → ScreenReader.vue_vue_type_script_setup_true_lang.js} +1 -1
  209. package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js.map +1 -0
  210. package/dist/specification-extensions/ExtensionValue.vue.js +1 -1
  211. package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -1
  212. package/dist/specification-extensions/{ExtensionValue.vue.script.js → ExtensionValue.vue_vue_type_script_setup_true_lang.js} +1 -1
  213. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js.map +1 -0
  214. package/dist/specification-extensions/SpecificationExtensions.vue.js +1 -1
  215. package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -1
  216. package/dist/specification-extensions/{SpecificationExtensions.vue.script.js → SpecificationExtensions.vue_vue_type_script_setup_true_lang.js} +1 -1
  217. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js.map +1 -0
  218. package/dist/specification-extensions/index.js +1 -2
  219. package/dist/style.css +68 -31
  220. package/dist/vue-styles.css +1 -1
  221. package/package.json +23 -23
  222. package/dist/code-example/components/CodeExample.vue.script.js +0 -258
  223. package/dist/code-example/components/CodeExample.vue.script.js.map +0 -1
  224. package/dist/code-example/components/ExamplePicker.vue.script.js.map +0 -1
  225. package/dist/code-example/components/HttpMethod.vue.script.js.map +0 -1
  226. package/dist/schema/RenderString.vue.script.js.map +0 -1
  227. package/dist/schema/Schema.vue.script.js.map +0 -1
  228. package/dist/schema/SchemaCollapsedPreview.vue.script.js.map +0 -1
  229. package/dist/schema/SchemaComposition.vue.script.js.map +0 -1
  230. package/dist/schema/SchemaEnumPropertyItem.vue.script.js.map +0 -1
  231. package/dist/schema/SchemaEnums.vue.script.js.map +0 -1
  232. package/dist/schema/SchemaGlyphPuck.vue.script.js.map +0 -1
  233. package/dist/schema/SchemaGutterToggle.vue.script.js.map +0 -1
  234. package/dist/schema/SchemaHeading.vue.script.js.map +0 -1
  235. package/dist/schema/SchemaObjectExampleCodeBlock.vue.script.js.map +0 -1
  236. package/dist/schema/SchemaProperty.vue.script.js.map +0 -1
  237. package/dist/schema/SchemaPropertyDefault.vue.script.js.map +0 -1
  238. package/dist/schema/SchemaPropertyDetail.vue.script.js.map +0 -1
  239. package/dist/schema/SchemaPropertyExamples.vue.script.js.map +0 -1
  240. package/dist/schema/SchemaPropertyHeading.vue.script.js.map +0 -1
  241. package/dist/schema/SchemaPropertyPattern.vue.script.js.map +0 -1
  242. package/dist/schema/SchemaRailPanel.vue.script.js.map +0 -1
  243. package/dist/schema/components/CopyLinkButton.vue.script.js.map +0 -1
  244. package/dist/schema/components/WithBreadcrumb.vue.script.js.map +0 -1
  245. package/dist/shared/Badge.vue.script.js.map +0 -1
  246. package/dist/shared/ExternalDocs.vue.script.js.map +0 -1
  247. package/dist/shared/ScreenReader.vue.script.js.map +0 -1
  248. package/dist/specification-extensions/ExtensionValue.vue.script.js.map +0 -1
  249. package/dist/specification-extensions/SpecificationExtensions.vue.script.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"process-body.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { getExampleValue, getExplicitExampleText } from '@scalar/workspace-store/helpers/get-example-value'\nimport { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { serializeStreamExample } from '@scalar/workspace-store/helpers/serialize-stream-example'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n buildRequestBody,\n coerceLeafValueToSchemaType,\n getExample,\n getExampleFromBody,\n getExampleFromSchema,\n needsMultipartEncoding,\n resolveLeafSchema,\n serializeFormPropertyWithEncoding,\n serializeMultipartArray,\n serializeMultipartBody,\n} from '@scalar/workspace-store/request-example'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Param, PostData } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<\n OperationToHarProps,\n 'contentType' | 'example' | 'requestBodyCompositionSelection' | 'openapiVersion'\n> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Builds a HAR param for an uploaded file. `fileName` is what snippet generators read to emit real\n * file handling (for example `files=` in Python or `new Blob` in fetch). `value` keeps the\n * `@filename` placeholder for consumers that only read the text value.\n */\nconst buildFileParam = (name: string, fileName: string, contentType?: string): Param => ({\n name,\n value: `@${fileName}`,\n fileName,\n ...(contentType ? { contentType } : {}),\n})\n\n/** True when the schema describes a binary file (`type: string, format: binary`). */\nconst isBinarySchema = (schema: SchemaObject | undefined): boolean =>\n !!schema && 'type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary'\n\n/**\n * Example generation turns a binary property into the `@filename` placeholder string.\n * Use the schema to tell that apart from a normal text field that happens to start with `@`.\n */\nconst getBinaryPlaceholderFileName = (value: unknown, schema: SchemaObject | undefined): string | undefined =>\n typeof value === 'string' && value.startsWith('@') && isBinarySchema(schema) ? value.slice(1) : undefined\n\n/**\n * Converts a form-data body into HAR `Param[]` entries for `multipart/form-data`\n * and `application/x-www-form-urlencoded` requests.\n *\n * Per OpenAPI 3.1.x Encoding Object, each property's serialization is governed\n * by an optional Encoding entry. When `style` / `explode` / `allowReserved` is\n * set, the value is serialized RFC6570-style and `contentType` is ignored.\n * Multipart arrays apply the encoding to each item and repeat the property name.\n * Object items default to JSON, and uploaded files retain their filename references.\n *\n * @param obj - The form-data payload, either an object keyed by property name\n * or a HAR-style `{ name, value, isDisabled }[]` array.\n * @param encoding - The `encoding` map from the Media Type Object, if any.\n * Used only at the top level (`parentKey` undefined).\n * @param parentKey - When set, we are flattening a nested object inside another\n * property; encoding is ignored and keys are joined with `.` (legacy default).\n * @param isMultipart - True for `multipart/form-data`. Gates the spec defaults\n * for object properties and array items. Urlencoded bodies retain their existing\n * serialization and flattening behavior.\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n isMultipart = false,\n schema?: SchemaObject,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries: [string, unknown][] = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [String(item.name), item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partEncoding = parentKey ? undefined : encoding?.[key]\n\n if (isMultipart && !parentKey) {\n const restored = Array.isArray(obj) ? coerceLeafValueToSchemaType(value, resolveLeafSchema(schema, [key])) : value\n const arrayParts = serializeMultipartArray(key, Array.isArray(restored) ? restored : value, partEncoding)\n if (arrayParts) {\n for (const part of arrayParts) {\n if (part.value instanceof File) {\n params.push(buildFileParam(part.key, part.value.name, part.contentType ?? part.value.type))\n continue\n }\n params.push({\n name: part.key,\n value: part.value,\n ...(part.contentType ? { contentType: part.contentType } : {}),\n })\n }\n continue\n }\n }\n /**\n * Per OpenAPI 3.1.1: when style, explode, or allowReserved is explicitly set on the\n * encoding entry, contentType (implicit or explicit) is ignored and the value is\n * serialized as if it were a query-style parameter.\n */\n const hasFormStyle =\n partEncoding &&\n (partEncoding.style !== undefined ||\n partEncoding.explode !== undefined ||\n partEncoding.allowReserved !== undefined)\n /**\n * Per OAS 3.1.x Encoding Object: `contentType` SHALL be ignored if the request body\n * media type is not a multipart. For `application/x-www-form-urlencoded` we still\n * honor `style`/`explode`/`allowReserved` (handled above), but a `contentType`-only\n * entry has no effect — values fall through to the dotted-key flattening default.\n */\n const explicitContentType = hasFormStyle || !isMultipart ? undefined : partEncoding?.contentType\n\n /**\n * When the encoding sets style/explode/allowReserved, serialize the value RFC6570-style\n * (bracket/exploded notation) and ignore contentType. See `serializeFormPropertyWithEncoding`\n * for the per-style rules; it returns null for primitives, Files, and arrays of Files, which\n * then fall through to the dedicated branches below. HAR represents multipart and urlencoded\n * the same way via `PostData.params`, so the resulting parts work for both.\n */\n const binaryPlaceholderFileName =\n isMultipart && !parentKey ? getBinaryPlaceholderFileName(value, resolveLeafSchema(schema, [key])) : undefined\n const styleParams = parentKey ? null : serializeFormPropertyWithEncoding(key, value, partEncoding)\n if (styleParams) {\n for (const param of styleParams) {\n params.push({ name: param.key, value: param.value })\n }\n } else if (value instanceof File) {\n /**\n * File values render as `@filename` references, the conventional cURL syntax for an\n * attached file. Picked up by snippet renderers downstream (e.g. `--form 'x=@file.png'`).\n */\n const file = unpackProxyObject(value)\n params.push(buildFileParam(key, file.name, explicitContentType ?? (isMultipart ? file.type : undefined)))\n } else if (binaryPlaceholderFileName !== undefined) {\n /** A binary property filled in by example generation, so it is a file and not a text field. */\n params.push(buildFileParam(key, binaryPlaceholderFileName, explicitContentType))\n } else if (explicitContentType && typeof value === 'object') {\n /**\n * Per OAS 3.1.x Encoding Object: an explicit `encoding[key].contentType` on a\n * complex value overrides the default and emits a single part containing the value\n * JSON-stringified into that media type. Only reachable when style/explode/allowReserved\n * are unset (otherwise contentType is ignored — see the style branch above).\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: explicitContentType,\n })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof value === 'object' && !Array.isArray(value)) {\n /**\n * Per OpenAPI 3.x: a top-level multipart property whose value is an object (and not a File)\n * defaults to a single part encoded as application/json, rather than being flattened\n * into multiple parts with dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: 'application/json',\n })\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push(buildFileParam(key, file.name, isMultipart ? file.type : undefined))\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n } else if (typeof value === 'object') {\n /**\n * Legacy fallback: flatten nested objects into dotted-key parts. Reached when the\n * multipart JSON-default branches above don't apply — i.e. either inside a recursive\n * call (`parentKey` set) or on `application/x-www-form-urlencoded` bodies without an\n * explicit encoding entry. Strict OAS 3.1.x would use `style: form, explode: true` as\n * the urlencoded default (inner keys become top-level params); we keep dotted keys for\n * backwards compatibility with consumers that already parse this shape.\n */\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({\n name: key,\n value: String(value),\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n openapiVersion,\n requestBodyCompositionSelection,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n /** Empty when \"Other\" is selected so snippets do not inject `Content-Type: other`. */\n const harMimeType = _contentType === 'other' ? '' : _contentType\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n const media = requestBody.content[_contentType]\n if (media && needsMultipartEncoding(_contentType, media)) {\n const exampleName = example ?? Object.keys(media.examples ?? {})[0] ?? 'default'\n const body = buildRequestBody(\n { ...requestBody, 'x-scalar-selected-content-type': { [exampleName]: _contentType } },\n exampleName,\n requestBodyCompositionSelection,\n )\n if (body?.mode === 'multipart') {\n const encoded = serializeMultipartBody(body.value, body.contentType)\n return {\n mimeType: encoded.contentType,\n // HAR text cannot embed file bytes synchronously. Keep visible file placeholders.\n text: encoded.chunks\n .map((chunk) => {\n if (chunk instanceof File) {\n return formatBinaryFile(chunk)\n }\n return chunk instanceof Blob ? 'BINARY' : String(chunk)\n })\n .join(''),\n }\n }\n }\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n if (isXmlMediaType(_contentType)) {\n const xmlExample = getExampleFromBody(\n requestBody,\n _contentType,\n example ?? '',\n requestBodyCompositionSelection,\n openapiVersion,\n )\n return xmlExample ? { mimeType: harMimeType, text: xmlExample.value as string } : undefined\n }\n\n // Get the example value\n const selected = getExampleValue(getExample(requestBody, example, contentType))\n const explicitText = getExplicitExampleText(selected, _contentType)\n if (explicitText !== undefined) {\n return { mimeType: harMimeType, text: explicitText }\n }\n const _example = selected?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n exampleValue,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n getResolvedRef(requestBody.content[_contentType]?.schema, mergeSiblingReferences),\n ),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: harMimeType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n typeof exampleValue === 'string'\n ? exampleValue\n : (serializeStreamExample(exampleValue, _contentType, false) ?? JSON.stringify(exampleValue)),\n }\n }\n\n // Try to extract examples from the schema\n const mediaType = requestBody.content[_contentType]\n const contentSchema = getResolvedRef(mediaType?.schema ?? mediaType?.itemSchema)\n if (typeof contentSchema !== 'undefined') {\n const extractedExample = getExampleFromSchema(\n snapshotSchema(contentSchema),\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n binaryAsFile: _contentType === 'multipart/form-data',\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n extractedExample,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n contentSchema,\n ),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n serializeStreamExample(extractedExample, _contentType, mediaType?.schema === undefined) ??\n (typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample)),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;AAyCA,IAAM,KAAkB,GAAc,GAAkB,OAAiC;CACvF;CACA,OAAO,IAAI;CACX;CACA,GAAI,IAAc,EAAE,eAAY,IAAI,CAAC;AACvC,IAGM,KAAkB,MACtB,CAAC,CAAC,KAAU,UAAU,KAAU,EAAO,SAAS,YAAY,YAAY,KAAU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AAO,KAAa,YAAzC,IAAoD,EAAkB,CAAQ,IAAI;EAsBvG,OApBI,KAAc,OAAO,KAAiB,YAAY,IAC7C;GACL,UAAU;GACV,QAAQ,EACN,GACA,GACA,KAAA,GACA,MAAiB,uBACjB,EAAe,EAAY,QAAQ,EAAa,EAAE,QAAQ,CAAsB,CAClF;EACF,IAGE,aAAwB,OACnB;GACL,UAAU;GACV,MAAM,EAAiB,CAAY;EACrC,IAGK;GACL,UAAU;GACV,MACE,OAAO,KAAiB,WACpB,IACC,EAAuB,GAAc,GAAc,EAAK,KAAK,KAAK,UAAU,CAAY;EACjG;CACF;CAGA,IAAM,IAAY,EAAY,QAAQ,IAChC,IAAgB,EAAe,GAAW,UAAU,GAAW,UAAU;CAC/E,IAAW,MAAkB,QAAa;EACxC,IAAM,IAAmB,EACvB,EAAe,CAAa,GAC5B;GACE,sBAAsB;GACtB,MAAM;GACN,cAAc,MAAiB;EACjC,GACA,EACE,YAAY,CAAC,aAAa,EAC5B,CACF;EAEA,IAAI,MAAqB,KAAA,GAcvB,OAbI,KAAc,OAAO,KAAqB,YAAY,IACjD;GACL,UAAU;GACV,QAAQ,EACN,GACA,GACA,KAAA,GACA,MAAiB,uBACjB,CACF;EACF,IAGK;GACL,UAAU;GACV,MACE,EAAuB,GAAkB,GAAc,GAAW,WAAW,KAAA,CAAS,MACrF,OAAO,KAAqB,WAAW,IAAmB,KAAK,UAAU,CAAgB;EAC9F;CAEJ;AAGF"}
1
+ {"version":3,"file":"process-body.js","names":["buildFileParam","fileName","contentType","isBinarySchema","schema","getBinaryPlaceholderFileName","value","objectToFormParams","params","entries","obj","item","key","partEncoding","parentKey","encoding","isMultipart","restored","coerceLeafValueToSchemaType","resolveLeafSchema","arrayParts","serializeMultipartArray","part","hasFormStyle","explicitContentType","binaryPlaceholderFileName","styleParams","serializeFormPropertyWithEncoding","param","file","unpackProxyObject","nestedParams","processBody","_contentType","requestBody","harMimeType","formatBinaryFile","media","needsMultipartEncoding","exampleName","example","body","buildRequestBody","requestBodyCompositionSelection","encoded","serializeMultipartBody","chunk","isFormData","isXmlMediaType","xmlExample","getExampleFromBody","openapiVersion","selected","getExampleValue","getExample","explicitText","getExplicitExampleText","_example","exampleValue","getResolvedRef","mergeSiblingReferences","serializeStreamExample","mediaType","contentSchema","extractedExample","getExampleFromSchema","snapshotSchema"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { getExampleValue, getExplicitExampleText } from '@scalar/workspace-store/helpers/get-example-value'\nimport { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { serializeStreamExample } from '@scalar/workspace-store/helpers/serialize-stream-example'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n buildRequestBody,\n coerceLeafValueToSchemaType,\n getExample,\n getExampleFromBody,\n getExampleFromSchema,\n needsMultipartEncoding,\n resolveLeafSchema,\n serializeFormPropertyWithEncoding,\n serializeMultipartArray,\n serializeMultipartBody,\n} from '@scalar/workspace-store/request-example'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Param, PostData } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<\n OperationToHarProps,\n 'contentType' | 'example' | 'requestBodyCompositionSelection' | 'openapiVersion'\n> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Builds a HAR param for an uploaded file. `fileName` is what snippet generators read to emit real\n * file handling (for example `files=` in Python or `new Blob` in fetch). `value` keeps the\n * `@filename` placeholder for consumers that only read the text value.\n */\nconst buildFileParam = (name: string, fileName: string, contentType?: string): Param => ({\n name,\n value: `@${fileName}`,\n fileName,\n ...(contentType ? { contentType } : {}),\n})\n\n/** True when the schema describes a binary file (`type: string, format: binary`). */\nconst isBinarySchema = (schema: SchemaObject | undefined): boolean =>\n !!schema && 'type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary'\n\n/**\n * Example generation turns a binary property into the `@filename` placeholder string.\n * Use the schema to tell that apart from a normal text field that happens to start with `@`.\n */\nconst getBinaryPlaceholderFileName = (value: unknown, schema: SchemaObject | undefined): string | undefined =>\n typeof value === 'string' && value.startsWith('@') && isBinarySchema(schema) ? value.slice(1) : undefined\n\n/**\n * Converts a form-data body into HAR `Param[]` entries for `multipart/form-data`\n * and `application/x-www-form-urlencoded` requests.\n *\n * Per OpenAPI 3.1.x Encoding Object, each property's serialization is governed\n * by an optional Encoding entry. When `style` / `explode` / `allowReserved` is\n * set, the value is serialized RFC6570-style and `contentType` is ignored.\n * Multipart arrays apply the encoding to each item and repeat the property name.\n * Object items default to JSON, and uploaded files retain their filename references.\n *\n * @param obj - The form-data payload, either an object keyed by property name\n * or a HAR-style `{ name, value, isDisabled }[]` array.\n * @param encoding - The `encoding` map from the Media Type Object, if any.\n * Used only at the top level (`parentKey` undefined).\n * @param parentKey - When set, we are flattening a nested object inside another\n * property; encoding is ignored and keys are joined with `.` (legacy default).\n * @param isMultipart - True for `multipart/form-data`. Gates the spec defaults\n * for object properties and array items. Urlencoded bodies retain their existing\n * serialization and flattening behavior.\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n isMultipart = false,\n schema?: SchemaObject,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries: [string, unknown][] = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [String(item.name), item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partEncoding = parentKey ? undefined : encoding?.[key]\n\n if (isMultipart && !parentKey) {\n const restored = Array.isArray(obj) ? coerceLeafValueToSchemaType(value, resolveLeafSchema(schema, [key])) : value\n const arrayParts = serializeMultipartArray(key, Array.isArray(restored) ? restored : value, partEncoding)\n if (arrayParts) {\n for (const part of arrayParts) {\n if (part.value instanceof File) {\n params.push(buildFileParam(part.key, part.value.name, part.contentType ?? part.value.type))\n continue\n }\n params.push({\n name: part.key,\n value: part.value,\n ...(part.contentType ? { contentType: part.contentType } : {}),\n })\n }\n continue\n }\n }\n /**\n * Per OpenAPI 3.1.1: when style, explode, or allowReserved is explicitly set on the\n * encoding entry, contentType (implicit or explicit) is ignored and the value is\n * serialized as if it were a query-style parameter.\n */\n const hasFormStyle =\n partEncoding &&\n (partEncoding.style !== undefined ||\n partEncoding.explode !== undefined ||\n partEncoding.allowReserved !== undefined)\n /**\n * Per OAS 3.1.x Encoding Object: `contentType` SHALL be ignored if the request body\n * media type is not a multipart. For `application/x-www-form-urlencoded` we still\n * honor `style`/`explode`/`allowReserved` (handled above), but a `contentType`-only\n * entry has no effect — values fall through to the dotted-key flattening default.\n */\n const explicitContentType = hasFormStyle || !isMultipart ? undefined : partEncoding?.contentType\n\n /**\n * When the encoding sets style/explode/allowReserved, serialize the value RFC6570-style\n * (bracket/exploded notation) and ignore contentType. See `serializeFormPropertyWithEncoding`\n * for the per-style rules; it returns null for primitives, Files, and arrays of Files, which\n * then fall through to the dedicated branches below. HAR represents multipart and urlencoded\n * the same way via `PostData.params`, so the resulting parts work for both.\n */\n const binaryPlaceholderFileName =\n isMultipart && !parentKey ? getBinaryPlaceholderFileName(value, resolveLeafSchema(schema, [key])) : undefined\n const styleParams = parentKey ? null : serializeFormPropertyWithEncoding(key, value, partEncoding)\n if (styleParams) {\n for (const param of styleParams) {\n params.push({ name: param.key, value: param.value })\n }\n } else if (value instanceof File) {\n /**\n * File values render as `@filename` references, the conventional cURL syntax for an\n * attached file. Picked up by snippet renderers downstream (e.g. `--form 'x=@file.png'`).\n */\n const file = unpackProxyObject(value)\n params.push(buildFileParam(key, file.name, explicitContentType ?? (isMultipart ? file.type : undefined)))\n } else if (binaryPlaceholderFileName !== undefined) {\n /** A binary property filled in by example generation, so it is a file and not a text field. */\n params.push(buildFileParam(key, binaryPlaceholderFileName, explicitContentType))\n } else if (explicitContentType && typeof value === 'object') {\n /**\n * Per OAS 3.1.x Encoding Object: an explicit `encoding[key].contentType` on a\n * complex value overrides the default and emits a single part containing the value\n * JSON-stringified into that media type. Only reachable when style/explode/allowReserved\n * are unset (otherwise contentType is ignored — see the style branch above).\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: explicitContentType,\n })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof value === 'object' && !Array.isArray(value)) {\n /**\n * Per OpenAPI 3.x: a top-level multipart property whose value is an object (and not a File)\n * defaults to a single part encoded as application/json, rather than being flattened\n * into multiple parts with dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: 'application/json',\n })\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push(buildFileParam(key, file.name, isMultipart ? file.type : undefined))\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n } else if (typeof value === 'object') {\n /**\n * Legacy fallback: flatten nested objects into dotted-key parts. Reached when the\n * multipart JSON-default branches above don't apply — i.e. either inside a recursive\n * call (`parentKey` set) or on `application/x-www-form-urlencoded` bodies without an\n * explicit encoding entry. Strict OAS 3.1.x would use `style: form, explode: true` as\n * the urlencoded default (inner keys become top-level params); we keep dotted keys for\n * backwards compatibility with consumers that already parse this shape.\n */\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({\n name: key,\n value: String(value),\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n openapiVersion,\n requestBodyCompositionSelection,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n /** Empty when \"Other\" is selected so snippets do not inject `Content-Type: other`. */\n const harMimeType = _contentType === 'other' ? '' : _contentType\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n const media = requestBody.content[_contentType]\n if (media && needsMultipartEncoding(_contentType, media)) {\n const exampleName = example ?? Object.keys(media.examples ?? {})[0] ?? 'default'\n const body = buildRequestBody(\n { ...requestBody, 'x-scalar-selected-content-type': { [exampleName]: _contentType } },\n exampleName,\n requestBodyCompositionSelection,\n )\n if (body?.mode === 'multipart') {\n const encoded = serializeMultipartBody(body.value, body.contentType)\n return {\n mimeType: encoded.contentType,\n // HAR text cannot embed file bytes synchronously. Keep visible file placeholders.\n text: encoded.chunks\n .map((chunk) => {\n if (chunk instanceof File) {\n return formatBinaryFile(chunk)\n }\n return chunk instanceof Blob ? 'BINARY' : String(chunk)\n })\n .join(''),\n }\n }\n }\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n if (isXmlMediaType(_contentType)) {\n const xmlExample = getExampleFromBody(\n requestBody,\n _contentType,\n example ?? '',\n requestBodyCompositionSelection,\n openapiVersion,\n )\n return xmlExample ? { mimeType: harMimeType, text: xmlExample.value as string } : undefined\n }\n\n // Get the example value\n const selected = getExampleValue(getExample(requestBody, example, contentType))\n const explicitText = getExplicitExampleText(selected, _contentType)\n if (explicitText !== undefined) {\n return { mimeType: harMimeType, text: explicitText }\n }\n const _example = selected?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n exampleValue,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n getResolvedRef(requestBody.content[_contentType]?.schema, mergeSiblingReferences),\n ),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: harMimeType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n typeof exampleValue === 'string'\n ? exampleValue\n : (serializeStreamExample(exampleValue, _contentType, false) ?? JSON.stringify(exampleValue)),\n }\n }\n\n // Try to extract examples from the schema\n const mediaType = requestBody.content[_contentType]\n const contentSchema = getResolvedRef(mediaType?.schema ?? mediaType?.itemSchema)\n if (typeof contentSchema !== 'undefined') {\n const extractedExample = getExampleFromSchema(\n snapshotSchema(contentSchema),\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n binaryAsFile: _contentType === 'multipart/form-data',\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n extractedExample,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n contentSchema,\n ),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n serializeStreamExample(extractedExample, _contentType, mediaType?.schema === undefined) ??\n (typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample)),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;AAyCA,IAAMA,KAAkB,GAAc,GAAkB,OAAiC;CACvF;CACA,OAAO,IAAIC;CACX;CACA,GAAIC,IAAc,EAAE,eAAY,IAAI,CAAC;AACvC,IAGMC,KAAkB,MACtB,CAAC,CAACC,KAAU,UAAUA,KAAUA,EAAO,SAAS,YAAY,YAAYA,KAAUA,EAAO,WAAW,UAMhGC,KAAgC,GAAgB,MACpD,OAAOC,KAAU,YAAYA,EAAM,WAAW,GAAG,KAAKH,EAAeC,CAAM,IAAIE,EAAM,M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GACnB,OAAO;EAAE,UAAUpB;EAAa,MAAMoB;CAAa;CAErD,IAAME,IAAWL,GAAU;CAG3B,IAAWK,MAAa,QAAa;EACnC,IAAMC,IAAoC,OAAOD,KAAa,YAAzCA,IAAoD3B,EAAkB2B,CAAQ,IAAIA;EAsBvG,OApBIV,KAAc,OAAOW,KAAiB,YAAYA,IAC7C;GACL,UAAUvB;GACV,QAAQ5B,EACNmD,GACA3C,GACA,KAAA,GACAkB,MAAiB,uBACjB0B,EAAezB,EAAY,QAAQD,EAAa,EAAE,QAAQ2B,CAAsB,CAClF;EACF,IAGEF,aAAwB,OACnB;GACL,UAAUvB;GACV,MAAMC,EAAiBsB,CAAY;EACrC,IAGK;GACL,UAAUvB;GACV,MACE,OAAOuB,KAAiB,WACpBA,IACCG,EAAuBH,GAAczB,GAAc,EAAK,KAAK,KAAK,UAAUyB,CAAY;EACjG;CACF;CAGA,IAAMI,IAAY5B,EAAY,QAAQD,IAChC8B,IAAgBJ,EAAeG,GAAW,UAAUA,GAAW,UAAU;CAC/E,IAAWC,MAAkB,QAAa;EACxC,IAAMC,IAAmBC,EACvBC,EAAeH,CAAa,GAC5B;GACE,sBAAsBpB;GACtB,MAAM;GACN,cAAcV,MAAiB;EACjC,GACA,EACE,YAAY,CAAC,aAAa,EAC5B,CACF;EAEA,IAAI+B,MAAqB,KAAA,GAcvB,OAbIjB,KAAc,OAAOiB,KAAqB,YAAYA,IACjD;GACL,UAAU7B;GACV,QAAQ5B,EACNyD,GACAjD,GACA,KAAA,GACAkB,MAAiB,uBACjB8B,CACF;EACF,IAGK;GACL,UAAU5B;GACV,MACE0B,EAAuBG,GAAkB/B,GAAc6B,GAAW,WAAW,KAAA,CAAS,MACrF,OAAOE,KAAqB,WAAWA,IAAmB,KAAK,UAAUA,CAAgB;EAC9F;CAEJ;AAGF"}
@@ -1,12 +1,12 @@
1
- import { getResolvedRef as e } from "@scalar/workspace-store/helpers/get-resolved-ref";
1
+ import { isObjectLike as e } from "@scalar/helpers/object/is-object";
2
2
  import { deSerializeParameter as t, filterDisabledProperties as n, getExampleFromSchema as r, isParamDisabled as i, serializeContentValue as a, serializeCookieStyle as o, serializeDeepObjectStyle as s, serializeFormStyle as c, serializeFormStyleForCookies as l, serializePipeDelimitedStyle as u, serializeSimpleStyle as d, serializeSpaceDelimitedStyle as f } from "@scalar/workspace-store/request-example";
3
- import { getCookieSerializationError as p } from "@scalar/helpers/http/get-cookie-serialization-error";
4
- import { isObjectLike as m } from "@scalar/helpers/object/is-object";
3
+ import { getResolvedRef as p } from "@scalar/workspace-store/helpers/get-resolved-ref";
4
+ import { getCookieSerializationError as m } from "@scalar/helpers/http/get-cookie-serialization-error";
5
5
  import { assertReservedPathUrl as h, serializeReservedPathParameter as g } from "@scalar/workspace-store/helpers/encode-path-parameter";
6
6
  import { getParameterExample as _ } from "@scalar/workspace-store/helpers/get-parameter-example";
7
7
  import { getQuerystringParameter as v, serializeQuerystringParameter as y } from "@scalar/workspace-store/helpers/querystring-parameter";
8
8
  //#region src/code-example/helpers/operation-to-har/process-parameters.ts
9
- var b = class extends Error {}, x = (t) => (t ?? []).map((t) => e(t)).filter((e) => e !== void 0), S = (e) => "allowReserved" in e && e.allowReserved !== void 0 ? e.allowReserved : "schema" in e && e.schema && typeof e.schema == "object" && "allowReserved" in e.schema ? e.schema.allowReserved === !0 : !1, C = (e) => {
9
+ var b = class extends Error {}, x = (e) => (e ?? []).map((e) => p(e)).filter((e) => e !== void 0), S = (e) => "allowReserved" in e && e.allowReserved !== void 0 ? e.allowReserved : "schema" in e && e.schema && typeof e.schema == "object" && "allowReserved" in e.schema ? e.schema.allowReserved === !0 : !1, C = (e) => {
10
10
  if (e.in === "header") return {
11
11
  style: "simple",
12
12
  explode: "explode" in e && e.explode !== void 0 && e.explode
@@ -29,15 +29,15 @@ var b = class extends Error {}, x = (t) => (t ?? []).map((t) => e(t)).filter((e)
29
29
  style: n,
30
30
  explode: "explode" in e && e.explode !== void 0 ? e.explode : n === "form"
31
31
  };
32
- }, w = (a, o, s) => {
33
- let c = _(a, o), l = c.example, u = a.in === "query" && !c.serialized && !c.mediaSerialized ? l?.["x-scalar-disabled-properties"] : void 0;
34
- if (u) return n(t(c.value, a), u, i(a, l, s));
35
- if (i(a, l, s)) return;
36
- if (c.value !== void 0) return t(c.value, a);
37
- if (!("schema" in a) || !a.schema) return;
38
- let d = a.in === "path" ? { emptyString: `{${a.name}}` } : {}, f = e(a.schema);
39
- return f ? r(f, d) : void 0;
40
- }, T = ({ harRequest: e, parameters: t, example: n, defaultDisabled: r, openapiVersion: m }) => {
32
+ }, w = (e, a, o) => {
33
+ let s = _(e, a), c = s.example, l = e.in === "query" && !s.serialized && !s.mediaSerialized ? c?.["x-scalar-disabled-properties"] : void 0;
34
+ if (l) return n(t(s.value, e), l, i(e, c, o));
35
+ if (i(e, c, o)) return;
36
+ if (s.value !== void 0) return t(s.value, e);
37
+ if (!("schema" in e) || !e.schema) return;
38
+ let u = e.in === "path" ? { emptyString: `{${e.name}}` } : {}, d = p(e.schema);
39
+ return d ? r(d, u) : void 0;
40
+ }, T = ({ harRequest: e, parameters: t, example: n, defaultDisabled: r, openapiVersion: p }) => {
41
41
  let T = [...e.headers], D = [...e.queryString], O = [...e.cookies], k = [], A = e.url, j = !1, M = [], N = [], P = (e, t, n) => {
42
42
  S(n) ? M.push(`${encodeURIComponent(e)}=${t}`) : D.push({
43
43
  name: e,
@@ -70,9 +70,7 @@ var b = class extends Error {}, x = (t) => (t ?? []).map((t) => e(t)).filter((e)
70
70
  value: n
71
71
  });
72
72
  break;
73
- case "cookie":
74
- N.push(n);
75
- break;
73
+ case "cookie": N.push(n);
76
74
  }
77
75
  continue;
78
76
  }
@@ -91,12 +89,10 @@ var b = class extends Error {}, x = (t) => (t ?? []).map((t) => e(t)).filter((e)
91
89
  case "path":
92
90
  A = A.replaceAll(`{${e.name}}`, () => encodeURIComponent(n));
93
91
  break;
94
- case "cookie":
95
- O.push({
96
- name: e.name,
97
- value: n
98
- });
99
- break;
92
+ case "cookie": O.push({
93
+ name: e.name,
94
+ value: n
95
+ });
100
96
  }
101
97
  continue;
102
98
  }
@@ -105,7 +101,7 @@ var b = class extends Error {}, x = (t) => (t ?? []).map((t) => e(t)).filter((e)
105
101
  let { style: x, explode: S } = C(e);
106
102
  switch (e.in) {
107
103
  case "path": {
108
- let t = m?.startsWith("3.2.") && "schema" in e && e.allowReserved === !0;
104
+ let t = p?.startsWith("3.2.") && "schema" in e && e.allowReserved === !0;
109
105
  j ||= !!t;
110
106
  let n = t ? g(e.name, {
111
107
  value: h,
@@ -117,8 +113,8 @@ var b = class extends Error {}, x = (t) => (t ?? []).map((t) => e(t)).filter((e)
117
113
  }
118
114
  case "query":
119
115
  if ("content" in e && e.content) {
120
- let t = a(h, Object.keys(e.content)[0] ?? "application/json");
121
- P(e.name, t, e);
116
+ let t = Object.keys(e.content)[0] ?? "application/json", n = a(h, t);
117
+ P(e.name, n, e);
122
118
  break;
123
119
  }
124
120
  switch (x) {
@@ -160,7 +156,7 @@ var b = class extends Error {}, x = (t) => (t ?? []).map((t) => e(t)).filter((e)
160
156
  break;
161
157
  }
162
158
  case "cookie": {
163
- let [t, n] = (m ?? "").split("."), r = t === "3" && n === "2" && !("content" in e) ? p(e, h) : void 0;
159
+ let [t, n] = (p ?? "").split("."), r = t === "3" && n === "2" && !("content" in e) ? m(e, h) : void 0;
164
160
  if (r) throw new b(r);
165
161
  if (x === "cookie") {
166
162
  k.push(...o(e.name, h, S));
@@ -211,46 +207,46 @@ var b = class extends Error {}, x = (t) => (t ?? []).map((t) => e(t)).filter((e)
211
207
  hasCookieStyleEntries: k.length > 0 || N.length > 0,
212
208
  ...M.length ? { hasSerializedQuery: !0 } : {}
213
209
  };
214
- }, E = (e, t, n, r, i) => {
215
- switch (r) {
210
+ }, E = (t, n, r, i, a) => {
211
+ switch (i) {
216
212
  case "matrix":
217
- if (i) {
218
- if (Array.isArray(n)) {
219
- let r = n.map((e) => `${t.name}=${e}`).join(";");
220
- return e.replace(`{;${t.name}}`, `;${r}`);
213
+ if (a) {
214
+ if (Array.isArray(r)) {
215
+ let e = r.map((e) => `${n.name}=${e}`).join(";");
216
+ return t.replace(`{;${n.name}}`, `;${e}`);
221
217
  }
222
- if (m(n)) {
223
- let r = Object.entries(n).map(([e, t]) => `${e}=${t}`).join(";");
224
- return e.replace(`{;${t.name}}`, `;${r}`);
218
+ if (e(r)) {
219
+ let e = Object.entries(r).map(([e, t]) => `${e}=${t}`).join(";");
220
+ return t.replace(`{;${n.name}}`, `;${e}`);
225
221
  }
226
- return e.replace(`{;${t.name}}`, `;${t.name}=${n}`);
222
+ return t.replace(`{;${n.name}}`, `;${n.name}=${r}`);
227
223
  }
228
- if (Array.isArray(n)) return e.replace(`{;${t.name}}`, `;${t.name}=${n.join(",")}`);
229
- if (m(n)) {
230
- let r = Object.entries(n).map(([e, t]) => `${e},${t}`).join(",");
231
- return e.replace(`{;${t.name}}`, `;${t.name}=${r}`);
224
+ if (Array.isArray(r)) return t.replace(`{;${n.name}}`, `;${n.name}=${r.join(",")}`);
225
+ if (e(r)) {
226
+ let e = Object.entries(r).map(([e, t]) => `${e},${t}`).join(",");
227
+ return t.replace(`{;${n.name}}`, `;${n.name}=${e}`);
232
228
  }
233
- return e.replace(`{;${t.name}}`, `;${t.name}=${n}`);
229
+ return t.replace(`{;${n.name}}`, `;${n.name}=${r}`);
234
230
  case "label":
235
- if (i) {
236
- if (Array.isArray(n)) return e.replace(`{.${t.name}}`, `.${n.join(".")}`);
237
- if (m(n)) {
238
- let r = Object.entries(n).map(([e, t]) => `${e}=${t}`).join(".");
239
- return e.replace(`{.${t.name}}`, `.${r}`);
231
+ if (a) {
232
+ if (Array.isArray(r)) return t.replace(`{.${n.name}}`, `.${r.join(".")}`);
233
+ if (e(r)) {
234
+ let e = Object.entries(r).map(([e, t]) => `${e}=${t}`).join(".");
235
+ return t.replace(`{.${n.name}}`, `.${e}`);
240
236
  }
241
- return e.replace(`{.${t.name}}`, `.${n}`);
237
+ return t.replace(`{.${n.name}}`, `.${r}`);
242
238
  }
243
- if (Array.isArray(n)) return e.replace(`{.${t.name}}`, `.${n.join(",")}`);
244
- if (m(n)) {
245
- let r = Object.entries(n).map(([e, t]) => `${e},${t}`).join(",");
246
- return e.replace(`{.${t.name}}`, `.${r}`);
239
+ if (Array.isArray(r)) return t.replace(`{.${n.name}}`, `.${r.join(",")}`);
240
+ if (e(r)) {
241
+ let e = Object.entries(r).map(([e, t]) => `${e},${t}`).join(",");
242
+ return t.replace(`{.${n.name}}`, `.${e}`);
247
243
  }
248
- return e.replace(`{.${t.name}}`, `.${n}`);
244
+ return t.replace(`{.${n.name}}`, `.${r}`);
249
245
  case "simple": {
250
- let r = d(n, i);
251
- return e.replace(`{${t.name}}`, String(r));
246
+ let e = d(r, a);
247
+ return t.replace(`{${n.name}}`, String(e));
252
248
  }
253
- default: return e.replace(`{${t.name}}`, String(n));
249
+ default: return t.replace(`{${n.name}}`, String(r));
254
250
  }
255
251
  };
256
252
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { getCookieSerializationError } from '@scalar/helpers/http/get-cookie-serialization-error'\nimport { isObjectLike } from '@scalar/helpers/object/is-object'\nimport {\n assertReservedPathUrl,\n serializeReservedPathParameter,\n} from '@scalar/workspace-store/helpers/encode-path-parameter'\nimport { getParameterExample } from '@scalar/workspace-store/helpers/get-parameter-example'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getQuerystringParameter,\n serializeQuerystringParameter,\n} from '@scalar/workspace-store/helpers/querystring-parameter'\nimport {\n deSerializeParameter,\n filterDisabledProperties,\n getExampleFromSchema,\n isParamDisabled,\n serializeContentValue,\n serializeCookieStyle,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\n/** An invalid cookie declaration that authors can repair before generating a sample. */\nexport class CookieSerializationError extends Error {}\n\ntype ProcessedParameters = {\n /** Named serialized examples already embedded in the URL. */\n hasSerializedQuery?: boolean\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n /** Whether serialized cookie-style values require a complete Cookie header. */\n hasCookieStyleEntries: boolean\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param)).filter((param) => param !== undefined)\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies default to form for compatibility and also support cookie style.\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'style' in param && param.style === 'cookie' ? 'cookie' : 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n querystring: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (param: ParameterObject, example: string | undefined, defaultDisabled: boolean): unknown => {\n // Try to get value from example first\n const selected = getParameterExample(param, example)\n const exampleValue = selected.example\n\n const propertyStates =\n param.in === 'query' && !selected.serialized && !selected.mediaSerialized\n ? exampleValue?.['x-scalar-disabled-properties']\n : undefined\n if (propertyStates) {\n return filterDisabledProperties(\n deSerializeParameter(selected.value, param),\n propertyStates,\n isParamDisabled(param, exampleValue, defaultDisabled),\n )\n }\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (selected.value !== undefined) {\n return deSerializeParameter(selected.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n const schema = getResolvedRef(param.schema)\n return schema ? getExampleFromSchema(schema, options) : undefined\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n openapiVersion,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n /** Originating API description version. */\n openapiVersion?: string\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n const newCookies = [...harRequest.cookies]\n const cookieStyleEntries: HarRequest['cookies'] = []\n let newUrl = harRequest.url\n let hasReservedPathParameter = false\n const serializedQuery: string[] = []\n const serializedCookies: string[] = []\n\n const appendQueryParameter = (name: string, value: string, param: ParameterObject): void => {\n if (isAllowReserved(param)) {\n // HTTP clients cannot infer reserved expansion from a HAR name/value pair.\n serializedQuery.push(`${encodeURIComponent(name)}=${value}`)\n } else {\n newQueryString.push({ name, value })\n }\n }\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n if (param.in === 'querystring') {\n const querystring = getQuerystringParameter(param, example, { defaultDisabled })\n if (querystring) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex === -1 ? '' : newUrl.slice(hashIndex)\n const base = (hashIndex === -1 ? newUrl : newUrl.slice(0, hashIndex)).split('?')[0]\n const query = serializeQuerystringParameter(querystring)\n newUrl = `${base}${query ? `?${query}` : ''}${hash}`\n }\n continue\n }\n\n const selected = getParameterExample(param, example)\n if (selected.serialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const wireValue = String(selected.value)\n switch (param.in) {\n case 'path':\n newUrl = newUrl.replaceAll(`{${param.name}}`, () => wireValue)\n break\n case 'query':\n serializedQuery.push(wireValue)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: wireValue })\n break\n case 'cookie':\n serializedCookies.push(wireValue)\n break\n }\n continue\n }\n if (selected.mediaSerialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const text = String(selected.value)\n switch (param.in) {\n case 'query':\n appendQueryParameter(param.name, text, param)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: text })\n break\n case 'path':\n newUrl = newUrl.replaceAll(`{${param.name}}`, () => encodeURIComponent(text))\n break\n case 'cookie':\n newCookies.push({ name: param.name, value: text })\n break\n }\n continue\n }\n const paramValue = getParameterValue(param, example, defaultDisabled)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n const allowReserved = openapiVersion?.startsWith('3.2.') && 'schema' in param && param.allowReserved === true\n hasReservedPathParameter ||= Boolean(allowReserved)\n const pathValue = allowReserved\n ? serializeReservedPathParameter(param.name, { value: paramValue, style, explode })\n : undefined\n newUrl =\n pathValue === undefined\n ? processPathParameters(newUrl, param, paramValue, style, explode)\n : newUrl.replaceAll(`{${param.name}}`, () => pathValue)\n break\n }\n\n case 'query': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n appendQueryParameter(param.name, serializedValue, param)\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n appendQueryParameter(key, String(entry.value), param)\n }\n }\n // Otherwise, convert to string\n else {\n appendQueryParameter(param.name, String(serialized), param)\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n appendQueryParameter(param.name, serialized, param)\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n appendQueryParameter(param.name, serialized, param)\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n appendQueryParameter(key, String(entry.value), param)\n }\n } else {\n appendQueryParameter(param.name, String(serialized), param)\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n appendQueryParameter(entry.key, entry.value, param)\n }\n }\n break\n }\n\n // Default to form style\n default:\n appendQueryParameter(param.name, String(paramValue), param)\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Keep cookie style separate so snippet generators cannot percent-encode it.\n case 'cookie': {\n const [major, minor] = (openapiVersion ?? '').split('.')\n const error =\n major === '3' && minor === '2' && !('content' in param)\n ? getCookieSerializationError(param, paramValue)\n : undefined\n if (error) {\n throw new CookieSerializationError(error)\n }\n if (style === 'cookie') {\n cookieStyleEntries.push(...serializeCookieStyle(param.name, paramValue, explode))\n break\n }\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n newCookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n newCookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n // HAR cookie entries are encoded by snippet generators. Use a complete header\n // when cookie style is present, preserving legacy encoding for other cookies.\n if (cookieStyleEntries.length || serializedCookies.length) {\n const cookieValue = [\n ...newCookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`),\n ...cookieStyleEntries.map((cookie) => `${cookie.name}=${cookie.value}`),\n ...serializedCookies,\n ].join('; ')\n const existing = newHeaders.find((header) => header.name.toLowerCase() === 'cookie')\n if (existing) {\n newHeaders.splice(newHeaders.indexOf(existing), 1, {\n ...existing,\n value: existing.value ? `${existing.value}; ${cookieValue}` : cookieValue,\n })\n } else {\n newHeaders.push({ name: 'Cookie', value: cookieValue })\n }\n }\n\n if (serializedQuery.length) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex < 0 ? '' : newUrl.slice(hashIndex)\n const base = hashIndex < 0 ? newUrl : newUrl.slice(0, hashIndex)\n newUrl = `${base}${base.includes('?') ? '&' : '?'}${serializedQuery.join('&')}${hash}`\n }\n\n if (hasReservedPathParameter) {\n assertReservedPathUrl(newUrl)\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: cookieStyleEntries.length || serializedCookies.length ? [] : newCookies,\n hasCookieStyleEntries: cookieStyleEntries.length > 0 || serializedCookies.length > 0,\n ...(serializedQuery.length ? { hasSerializedQuery: true } : {}),\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = paramValue.map((v: unknown) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue.join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;;;;;AA8BA,IAAa,IAAb,cAA8C,MAAM,CAAC,GAc/C,KAAqB,OACxB,KAAU,CAAC,EAAA,CAAG,KAAK,MAAU,EAAe,CAAK,CAAC,CAAC,CAAC,QAAQ,MAAU,MAAU,KAAA,CAAS,GAGtF,KAAmB,MACnB,mBAAmB,KAAS,EAAM,kBAAkB,KAAA,IAC/C,EAAM,gBAEX,YAAY,KAAS,EAAM,UAAU,OAAO,EAAM,UAAW,YAAY,mBAAmB,EAAM,SAC5F,EAAM,OAAuC,kBAAkB,KAElE,IAOH,KAA+B,MAAgE;CAEnG,IAAI,EAAM,OAAO,UAEf,OAAO;EAAE,OAAO;EAAU,SADV,aAAa,KAAS,EAAM,YAAY,KAAA,KAAY,EAAM;CACxC;CAIpC,IAAI,EAAM,OAAO,UAAU;EACzB,IAAM,IAAU,aAA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CAAU,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,CAC5B,KAAK,GAAG;KAEX,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAQ;IACrD;IAGA,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAY;GACzD;GAGA,IAAI,MAAM,QAAQ,CAAU,GAC1B,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,EAAW,KAAK,GAAG,GAAG;GAInE,IAAI,EAAa,CAAU,GAAG;IAC5B,IAAM,IAAS,OAAO,QAAQ,CAAU,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,CAC5B,KAAK,GAAG;IAEX,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAQ;GACrD;GAGA,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAY;EAGzD,KAAK,UAAU;GACb,IAAM,IAAa,EAAqB,GAAY,CAAO;GAC3D,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;EAC1D;EAGA,SACE,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;CAC5D;AACF"}
1
+ {"version":3,"file":"process-parameters.js","names":["CookieSerializationError","deReferenceParams","params","getResolvedRef","param","isAllowReserved","getParameterStyleAndExplode","explode","defaultStyle","style","getParameterValue","selected","getParameterExample","example","exampleValue","propertyStates","filterDisabledProperties","deSerializeParameter","isParamDisabled","defaultDisabled","options","schema","getExampleFromSchema","processParameters","newHeaders","harRequest","newQueryString","newCookies","cookieStyleEntries","newUrl","hasReservedPathParameter","serializedQuery","serializedCookies","appendQueryParameter","name","value","deReferencedParams","parameters","querystring","getQuerystringParameter","hashIndex","hash","base","query","serializeQuerystringParameter","wireValue","text","paramValue","allowReserved","openapiVersion","pathValue","serializeReservedPathParameter","processPathParameters","paramContentType","serializedValue","serializeContentValue","serialized","serializeFormStyle","entry","serializeSpaceDelimitedStyle","serializePipeDelimitedStyle","entries","serializeDeepObjectStyle","serializeSimpleStyle","major","minor","error","getCookieSerializationError","serializeCookieStyle","serializeFormStyleForCookies","key","cookieValue","cookie","existing","header","assertReservedPathUrl","values","v","url","isObjectLike","k"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { getCookieSerializationError } from '@scalar/helpers/http/get-cookie-serialization-error'\nimport { isObjectLike } from '@scalar/helpers/object/is-object'\nimport {\n assertReservedPathUrl,\n serializeReservedPathParameter,\n} from '@scalar/workspace-store/helpers/encode-path-parameter'\nimport { getParameterExample } from '@scalar/workspace-store/helpers/get-parameter-example'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getQuerystringParameter,\n serializeQuerystringParameter,\n} from '@scalar/workspace-store/helpers/querystring-parameter'\nimport {\n deSerializeParameter,\n filterDisabledProperties,\n getExampleFromSchema,\n isParamDisabled,\n serializeContentValue,\n serializeCookieStyle,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\n/** An invalid cookie declaration that authors can repair before generating a sample. */\nexport class CookieSerializationError extends Error {}\n\ntype ProcessedParameters = {\n /** Named serialized examples already embedded in the URL. */\n hasSerializedQuery?: boolean\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n /** Whether serialized cookie-style values require a complete Cookie header. */\n hasCookieStyleEntries: boolean\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param)).filter((param) => param !== undefined)\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies default to form for compatibility and also support cookie style.\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'style' in param && param.style === 'cookie' ? 'cookie' : 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n querystring: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (param: ParameterObject, example: string | undefined, defaultDisabled: boolean): unknown => {\n // Try to get value from example first\n const selected = getParameterExample(param, example)\n const exampleValue = selected.example\n\n const propertyStates =\n param.in === 'query' && !selected.serialized && !selected.mediaSerialized\n ? exampleValue?.['x-scalar-disabled-properties']\n : undefined\n if (propertyStates) {\n return filterDisabledProperties(\n deSerializeParameter(selected.value, param),\n propertyStates,\n isParamDisabled(param, exampleValue, defaultDisabled),\n )\n }\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (selected.value !== undefined) {\n return deSerializeParameter(selected.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n const schema = getResolvedRef(param.schema)\n return schema ? getExampleFromSchema(schema, options) : undefined\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n openapiVersion,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n /** Originating API description version. */\n openapiVersion?: string\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n const newCookies = [...harRequest.cookies]\n const cookieStyleEntries: HarRequest['cookies'] = []\n let newUrl = harRequest.url\n let hasReservedPathParameter = false\n const serializedQuery: string[] = []\n const serializedCookies: string[] = []\n\n const appendQueryParameter = (name: string, value: string, param: ParameterObject): void => {\n if (isAllowReserved(param)) {\n // HTTP clients cannot infer reserved expansion from a HAR name/value pair.\n serializedQuery.push(`${encodeURIComponent(name)}=${value}`)\n } else {\n newQueryString.push({ name, value })\n }\n }\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n if (param.in === 'querystring') {\n const querystring = getQuerystringParameter(param, example, { defaultDisabled })\n if (querystring) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex === -1 ? '' : newUrl.slice(hashIndex)\n const base = (hashIndex === -1 ? newUrl : newUrl.slice(0, hashIndex)).split('?')[0]\n const query = serializeQuerystringParameter(querystring)\n newUrl = `${base}${query ? `?${query}` : ''}${hash}`\n }\n continue\n }\n\n const selected = getParameterExample(param, example)\n if (selected.serialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const wireValue = String(selected.value)\n switch (param.in) {\n case 'path':\n newUrl = newUrl.replaceAll(`{${param.name}}`, () => wireValue)\n break\n case 'query':\n serializedQuery.push(wireValue)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: wireValue })\n break\n case 'cookie':\n serializedCookies.push(wireValue)\n break\n }\n continue\n }\n if (selected.mediaSerialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const text = String(selected.value)\n switch (param.in) {\n case 'query':\n appendQueryParameter(param.name, text, param)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: text })\n break\n case 'path':\n newUrl = newUrl.replaceAll(`{${param.name}}`, () => encodeURIComponent(text))\n break\n case 'cookie':\n newCookies.push({ name: param.name, value: text })\n break\n }\n continue\n }\n const paramValue = getParameterValue(param, example, defaultDisabled)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n const allowReserved = openapiVersion?.startsWith('3.2.') && 'schema' in param && param.allowReserved === true\n hasReservedPathParameter ||= Boolean(allowReserved)\n const pathValue = allowReserved\n ? serializeReservedPathParameter(param.name, { value: paramValue, style, explode })\n : undefined\n newUrl =\n pathValue === undefined\n ? processPathParameters(newUrl, param, paramValue, style, explode)\n : newUrl.replaceAll(`{${param.name}}`, () => pathValue)\n break\n }\n\n case 'query': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n appendQueryParameter(param.name, serializedValue, param)\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n appendQueryParameter(key, String(entry.value), param)\n }\n }\n // Otherwise, convert to string\n else {\n appendQueryParameter(param.name, String(serialized), param)\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n appendQueryParameter(param.name, serialized, param)\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n appendQueryParameter(param.name, serialized, param)\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n appendQueryParameter(key, String(entry.value), param)\n }\n } else {\n appendQueryParameter(param.name, String(serialized), param)\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n appendQueryParameter(entry.key, entry.value, param)\n }\n }\n break\n }\n\n // Default to form style\n default:\n appendQueryParameter(param.name, String(paramValue), param)\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Keep cookie style separate so snippet generators cannot percent-encode it.\n case 'cookie': {\n const [major, minor] = (openapiVersion ?? '').split('.')\n const error =\n major === '3' && minor === '2' && !('content' in param)\n ? getCookieSerializationError(param, paramValue)\n : undefined\n if (error) {\n throw new CookieSerializationError(error)\n }\n if (style === 'cookie') {\n cookieStyleEntries.push(...serializeCookieStyle(param.name, paramValue, explode))\n break\n }\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n newCookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n newCookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n // HAR cookie entries are encoded by snippet generators. Use a complete header\n // when cookie style is present, preserving legacy encoding for other cookies.\n if (cookieStyleEntries.length || serializedCookies.length) {\n const cookieValue = [\n ...newCookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`),\n ...cookieStyleEntries.map((cookie) => `${cookie.name}=${cookie.value}`),\n ...serializedCookies,\n ].join('; ')\n const existing = newHeaders.find((header) => header.name.toLowerCase() === 'cookie')\n if (existing) {\n newHeaders.splice(newHeaders.indexOf(existing), 1, {\n ...existing,\n value: existing.value ? `${existing.value}; ${cookieValue}` : cookieValue,\n })\n } else {\n newHeaders.push({ name: 'Cookie', value: cookieValue })\n }\n }\n\n if (serializedQuery.length) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex < 0 ? '' : newUrl.slice(hashIndex)\n const base = hashIndex < 0 ? newUrl : newUrl.slice(0, hashIndex)\n newUrl = `${base}${base.includes('?') ? '&' : '?'}${serializedQuery.join('&')}${hash}`\n }\n\n if (hasReservedPathParameter) {\n assertReservedPathUrl(newUrl)\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: cookieStyleEntries.length || serializedCookies.length ? [] : newCookies,\n hasCookieStyleEntries: cookieStyleEntries.length > 0 || serializedCookies.length > 0,\n ...(serializedQuery.length ? { hasSerializedQuery: true } : {}),\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = paramValue.map((v: unknown) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue.join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;;;;;AA8BA,IAAaA,IAAb,cAA8C,MAAM,CAAC,GAc/CC,KAAqB,OACxBC,KAAU,CAAC,EAAA,CAAG,KAAK,MAAUC,EAAeC,CAAK,CAAC,CAAC,CAAC,QAAQ,MAAUA,MAAU,KAAA,CAAS,GAGtFC,KAAmB,MACnB,mBAAmBD,KAASA,EAAM,kBAAkB,KAAA,IAC/CA,EAAM,gBAEX,YAAYA,KAASA,EAAM,UAAU,OAAOA,EAAM,UAAW,YAAY,mBAAmBA,EAAM,SAC5FA,EAAM,OAAuC,kBAAkB,KAElE,IAOHE,KAA+B,MAAgE;CAEnG,IAAIF,EAAM,OAAO,UAEf,OAAO;EAAE,OAAO;EAAU,SADV,aAAaA,KAASA,EAAM,YAAY,KAAA,KAAYA,EAAM;CACxC;CAIpC,IAAIA,EAAM,OAAO,UAAU;EACzB,IAAMG,IAAU,aAAaH,KAASA,EAAM,YAAY,KAAA,IAAYA,EAAM,UAAU;EACpF,OAAO;GAAE,OAAO,WAAWA,KAASA,EAAM,UAAU,WAAW,WAAW;GAAQ;EAAQ;CAC5F;CAEA,IAAMI,IAAe;EACnB,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,QAAQ;CACV,EAAEJ,EAAM,KAGFK,IAAQ,WAAWL,KAASA,EAAM,QAAQA,EAAM,QAAQI;CAK9D,OAAO;EAAE;EAAO,SAFA,aAAaJ,KAASA,EAAM,YAAY,KAAA,IAAYA,EAAM,UAAUK,MAAU;CAEtE;AAC1B,GAOMC,KAAqB,GAA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-token"] || "YOUR_SECRET_TOKEN";
12
- if (!r.name) continue;
13
- let t = {
14
- name: r.name,
15
- value: e
16
- };
17
- switch (r.in) {
18
- case "header":
19
- n.headers.push(t);
20
- break;
21
- case "query":
22
- n.queryString.push(t);
23
- break;
24
- case "cookie":
25
- n.cookies.push(t);
26
- break;
27
- }
28
- continue;
29
- }
30
- if (r.type === "http") {
31
- if (r.scheme === "basic") {
32
- let t = `${r["x-scalar-secret-username"] || ""}:${r["x-scalar-secret-password"] || ""}`, i = t === ":" ? "username:password" : e(t);
33
- n.headers.push({
34
- name: "Authorization",
35
- value: `Basic ${i}`
36
- });
37
- } else if (r.scheme === "bearer") {
38
- let e = r["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
39
- n.headers.push({
40
- name: "Authorization",
41
- value: `Bearer ${e}`
42
- });
43
- }
44
- continue;
9
+ for (let r of t) if (r.type === "apiKey") {
10
+ let e = r["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
11
+ if (!r.name) continue;
12
+ let t = {
13
+ name: r.name,
14
+ value: e
15
+ };
16
+ switch (r.in) {
17
+ case "header":
18
+ n.headers.push(t);
19
+ break;
20
+ case "query":
21
+ n.queryString.push(t);
22
+ break;
23
+ case "cookie": n.cookies.push(t);
45
24
  }
46
- if (r.type === "oauth2" && r.flows) {
47
- let e = Object.values(r.flows).find((e) => e["x-scalar-secret-token"])?.["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
25
+ } else if (r.type === "http") {
26
+ if (r.scheme === "basic") {
27
+ let t = `${r["x-scalar-secret-username"] || ""}:${r["x-scalar-secret-password"] || ""}`, i = t === ":" ? "username:password" : e(t);
28
+ n.headers.push({
29
+ name: "Authorization",
30
+ value: `Basic ${i}`
31
+ });
32
+ } else if (r.scheme === "bearer") {
33
+ let e = r["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
48
34
  n.headers.push({
49
35
  name: "Authorization",
50
36
  value: `Bearer ${e}`
51
37
  });
52
38
  }
39
+ } else if (r.type === "oauth2" && r.flows) {
40
+ let e = Object.values(r.flows).find((e) => e["x-scalar-secret-token"])?.["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
41
+ n.headers.push({
42
+ name: "Authorization",
43
+ value: `Bearer ${e}`
44
+ });
53
45
  }
54
46
  return n;
55
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"process-security-schemes.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push(param)\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;AAeA,IAAa,KACX,MACmC;CACnC,IAAM,IAAyC;EAC7C,SAAS,CAAC;EACV,aAAa,CAAC;EACd,SAAS,CAAC;CACZ;CAEA,KAAK,IAAM,KAAU,GAAiB;EAEpC,IAAI,EAAO,SAAS,UAAU;GAC5B,IAAM,IAAQ,EAAO,4BAA4B;GACjD,IAAI,CAAC,EAAO,MACV;GAGF,IAAM,IAAQ;IAAE,MAAM,EAAO;IAAM;GAAM;GAEzC,QAAQ,EAAO,IAAf;IACE,KAAK;KACH,EAAO,QAAQ,KAAK,CAAK;KACzB;IACF,KAAK;KACH,EAAO,YAAY,KAAK,CAAK;KAC7B;IACF,KAAK;KACH,EAAO,QAAQ,KAAK,CAAK;KACzB;GACJ;GACA;EACF;EAGA,IAAI,EAAO,SAAS,QAAQ;GAC1B,IAAI,EAAO,WAAW,SAAS;IAQ7B,IAAM,IAAQ,GAPG,EAAO,+BAA+B,GAO7B,GANT,EAAO,+BAA+B,MAOjD,IAAO,MAAU,MAAM,sBAAsB,EAAO,CAAK;IAE/D,EAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,SAAS;IAClB,CAAC;GACH,OAAO,IAAI,EAAO,WAAW,UAAU;IACrC,IAAM,IAAQ,EAAO,4BAA4B;IAEjD,EAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,UAAU;IACnB,CAAC;GACH;GACA;EACF;EAGA,IAAI,EAAO,SAAS,YAAY,EAAO,OAAO;GAK5C,IAAM,IAJQ,OAAO,OAAO,EAAO,KAGtB,CAAA,CAAM,MAAM,MAAM,EAAE,wBACnB,CAAA,GAAO,4BAA4B;GAEjD,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAU;GACnB,CAAC;EACH;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"process-security-schemes.js","names":["processSecuritySchemes","result","scheme","securitySchemes","value","param","auth","encode","token","f"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push(param)\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;AAeA,IAAaA,KACX,MACmC;CACnC,IAAMC,IAAyC;EAC7C,SAAS,CAAC;EACV,aAAa,CAAC;EACd,SAAS,CAAC;CACZ;CAEA,KAAK,IAAMC,KAAUC,GAEnB,IAAID,EAAO,SAAS,UAAU;EAC5B,IAAME,IAAQF,EAAO,4BAA4B;EACjD,IAAI,CAACA,EAAO,MACV;EAGF,IAAMG,IAAQ;GAAE,MAAMH,EAAO;GAAM;EAAM;EAEzC,QAAQA,EAAO,IAAf;GACE,KAAK;IACH,EAAO,QAAQ,KAAKG,CAAK;IACzB;GACF,KAAK;IACH,EAAO,YAAY,KAAKA,CAAK;IAC7B;GACF,KAAK,UACH,EAAO,QAAQ,KAAKA,CAAK;EAE7B;CAEF,OAGA,IAAIH,EAAO,SAAS,QAAQ;EAC1B,IAAIA,EAAO,WAAW,SAAS;GAQ7B,IAAME,IAAQ,GAPGF,EAAO,+BAA+B,GAO7B,GANTA,EAAO,+BAA+B,MAOjDI,IAAOF,MAAU,MAAM,sBAAsBG,EAAOH,CAAK;GAE/D,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,SAASE;GAClB,CAAC;EACH,OAAO,IAAIJ,EAAO,WAAW,UAAU;GACrC,IAAMM,IAAQN,EAAO,4BAA4B;GAEjD,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAUM;GACnB,CAAC;EACH;CAEF,OAGA,IAAIN,EAAO,SAAS,YAAYA,EAAO,OAAO;EAK5C,IAAMM,IAJQ,OAAO,OAAON,EAAO,KAGtB,CAAA,CAAM,MAAM,MAAMO,EAAE,wBACnB,CAAA,GAAO,4BAA4B;EAEjD,EAAO,QAAQ,KAAK;GAClB,MAAM;GACN,OAAO,UAAUD;EACnB,CAAC;CACH;CAGF,OAAOP;AACT"}
@@ -4,7 +4,11 @@ import { mergeUrls as t } from "@scalar/helpers/url/merge-urls";
4
4
  var n = (n, r) => {
5
5
  if (!n?.url) return r;
6
6
  let i = n.url;
7
- return n.variables ? t(e(i, Object.entries(n.variables).reduce((e, [t, n]) => (n.default !== void 0 && (e[t] = n.default), e), {})), r) : t(i, r);
7
+ if (n.variables) {
8
+ let a = Object.entries(n.variables).reduce((e, [t, n]) => (n.default !== void 0 && (e[t] = n.default), e), {}), o = e(i, a);
9
+ return t(o, r);
10
+ }
11
+ return t(i, r);
8
12
  };
9
13
  //#endregion
10
14
  export { n as processServerUrl };
@@ -1 +1 @@
1
- {"version":3,"file":"process-server-url.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-server-url.ts"],"sourcesContent":["import { replaceVariables } from '@scalar/helpers/regex/replace-variables'\nimport { mergeUrls } from '@scalar/helpers/url/merge-urls'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/**\n * Processes a server URL by replacing variables with their default values and merging with the path\n */\nexport const processServerUrl = (server: ServerObject | null, path: string): string => {\n if (!server?.url) {\n return path\n }\n const serverUrl = server.url\n\n // Replace server variables with their default values\n if (server.variables) {\n const variables = Object.entries(server.variables)\n\n // Extract default values from server variables\n const defaultValues = variables.reduce<Record<string, string | number>>(\n (defaults, [variableName, variableConfig]) => {\n if (variableConfig.default !== undefined) {\n defaults[variableName] = variableConfig.default\n }\n return defaults\n },\n {},\n )\n\n // Replace variables in the server URL with their default values\n const serverUrlWithVars = replaceVariables(serverUrl, defaultValues)\n\n return mergeUrls(serverUrlWithVars, path)\n }\n\n return mergeUrls(serverUrl, path)\n}\n"],"mappings":";;;AAOA,IAAa,KAAoB,GAA6B,MAAyB;CACrF,IAAI,CAAC,GAAQ,KACX,OAAO;CAET,IAAM,IAAY,EAAO;CAuBzB,OApBI,EAAO,YAiBF,EAFmB,EAAiB,GAdzB,OAAO,QAAQ,EAAO,SAGlB,CAAA,CAAU,QAC7B,GAAU,CAAC,GAAc,QACpB,EAAe,YAAY,KAAA,MAC7B,EAAS,KAAgB,EAAe,UAEnC,IAET,CAAC,CAImD,CAErC,GAAmB,CAAI,IAGnC,EAAU,GAAW,CAAI;AAClC"}
1
+ {"version":3,"file":"process-server-url.js","names":["processServerUrl","server","path","serverUrl","defaultValues","variableName","variableConfig","defaults","serverUrlWithVars","replaceVariables","mergeUrls"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-server-url.ts"],"sourcesContent":["import { replaceVariables } from '@scalar/helpers/regex/replace-variables'\nimport { mergeUrls } from '@scalar/helpers/url/merge-urls'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/**\n * Processes a server URL by replacing variables with their default values and merging with the path\n */\nexport const processServerUrl = (server: ServerObject | null, path: string): string => {\n if (!server?.url) {\n return path\n }\n const serverUrl = server.url\n\n // Replace server variables with their default values\n if (server.variables) {\n const variables = Object.entries(server.variables)\n\n // Extract default values from server variables\n const defaultValues = variables.reduce<Record<string, string | number>>(\n (defaults, [variableName, variableConfig]) => {\n if (variableConfig.default !== undefined) {\n defaults[variableName] = variableConfig.default\n }\n return defaults\n },\n {},\n )\n\n // Replace variables in the server URL with their default values\n const serverUrlWithVars = replaceVariables(serverUrl, defaultValues)\n\n return mergeUrls(serverUrlWithVars, path)\n }\n\n return mergeUrls(serverUrl, path)\n}\n"],"mappings":";;;AAOA,IAAaA,KAAoB,GAA6B,MAAyB;CACrF,IAAI,CAACC,GAAQ,KACX,OAAOC;CAET,IAAMC,IAAYF,EAAO;CAGzB,IAAIA,EAAO,WAAW;EAIpB,IAAMG,IAHY,OAAO,QAAQH,EAAO,SAGlB,CAAA,CAAU,QAC7B,GAAU,CAACI,GAAcC,QACpBA,EAAe,YAAY,KAAA,MAC7B,EAASD,KAAgBC,EAAe,UAEnCC,IAET,CAAC,CACH,GAGMC,IAAoBC,EAAiBN,GAAWC,CAAa;EAEnE,OAAOM,EAAUF,GAAmBN,CAAI;CAC1C;CAEA,OAAOQ,EAAUP,GAAWD,CAAI;AAClC"}
@@ -1,4 +1,5 @@
1
1
  export { getResolvedRefDeep } from '@scalar/workspace-store/helpers/get-resolved-ref-deep';
2
+ export { default as AsyncApiCodeExample } from './components/AsyncApiCodeExample.vue';
2
3
  export type { CodeExampleProps } from './components/CodeExample.vue';
3
4
  export { default as CodeExample } from './components/CodeExample.vue';
4
5
  export { default as ExamplePicker } from './components/ExamplePicker.vue';
@@ -9,9 +10,12 @@ export { generateClientOptions, getCustomClientIds } from './helpers/generate-cl
9
10
  export { generateCodeSnippet } from './helpers/generate-code-snippet';
10
11
  export { getClients } from './helpers/get-clients';
11
12
  export { getCustomCodeSamples } from './helpers/get-custom-code-samples';
13
+ export { getGeneratedPayloadExample } from './helpers/get-generated-payload-example';
14
+ export { getMessageExampleContent } from './helpers/get-message-example-content';
12
15
  export { getSecrets } from './helpers/get-secrets';
13
16
  export type { OperationToHarProps } from './helpers/operation-to-har/operation-to-har';
14
17
  export { operationToHar } from './helpers/operation-to-har/operation-to-har';
15
18
  export { type CreateCodeExampleOptions, createCodeExample } from './mount';
19
+ export type { CreateAsyncApiCodeExampleOptions } from './mount-asyncapi';
16
20
  export type { ClientOption, ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from './types';
17
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/code-example/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAA;AAE1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACrH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,EAAE,KAAK,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC1E,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/code-example/index.ts"],"names":[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