@scalar/blocks 0.11.1 → 0.11.3

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 (325) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/code-example/components/AsyncApiCodeExample.vue.js +111 -6
  3. package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -1
  4. package/dist/code-example/components/AsyncApiCodeExample3.vue.js +8 -0
  5. package/dist/code-example/components/AsyncApiCodeExample3.vue.js.map +1 -0
  6. package/dist/code-example/components/CodeExample.vue.d.ts +10 -0
  7. package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
  8. package/dist/code-example/components/CodeExample.vue.js +297 -6
  9. package/dist/code-example/components/CodeExample.vue.js.map +1 -1
  10. package/dist/code-example/components/CodeExample3.vue.js +8 -0
  11. package/dist/code-example/components/CodeExample3.vue.js.map +1 -0
  12. package/dist/code-example/components/ExamplePicker.vue.d.ts +2 -0
  13. package/dist/code-example/components/ExamplePicker.vue.d.ts.map +1 -1
  14. package/dist/code-example/components/ExamplePicker.vue.js +50 -4
  15. package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
  16. package/dist/code-example/components/ExamplePicker2.vue.js +6 -0
  17. package/dist/code-example/components/ExamplePicker2.vue.js.map +1 -0
  18. package/dist/code-example/components/HttpMethod.vue.js +32 -4
  19. package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
  20. package/dist/code-example/components/HttpMethod2.vue.js +6 -0
  21. package/dist/code-example/components/HttpMethod2.vue.js.map +1 -0
  22. package/dist/code-example/helpers/filter-clients-by-query.js.map +1 -1
  23. package/dist/code-example/helpers/find-client.js.map +1 -1
  24. package/dist/code-example/helpers/format-language.js.map +1 -1
  25. package/dist/code-example/helpers/generate-client-options.js.map +1 -1
  26. package/dist/code-example/helpers/generate-code-snippet.d.ts +8 -2
  27. package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
  28. package/dist/code-example/helpers/generate-code-snippet.js +57 -27
  29. package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
  30. package/dist/code-example/helpers/get-asyncapi-example-context.js.map +1 -1
  31. package/dist/code-example/helpers/get-clients.js.map +1 -1
  32. package/dist/code-example/helpers/get-custom-code-samples.js.map +1 -1
  33. package/dist/code-example/helpers/get-generated-payload-example.js.map +1 -1
  34. package/dist/code-example/helpers/get-message-example-content.js.map +1 -1
  35. package/dist/code-example/helpers/get-secrets.js.map +1 -1
  36. package/dist/code-example/helpers/get-snippet.d.ts +2 -2
  37. package/dist/code-example/helpers/get-snippet.d.ts.map +1 -1
  38. package/dist/code-example/helpers/get-snippet.js +7 -9
  39. package/dist/code-example/helpers/get-snippet.js.map +1 -1
  40. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +1 -1
  41. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  42. package/dist/code-example/helpers/operation-to-har/operation-to-har.js +1 -1
  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.d.ts +2 -2
  45. package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
  46. package/dist/code-example/helpers/operation-to-har/process-body.js +102 -81
  47. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  48. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  49. package/dist/code-example/helpers/operation-to-har/process-parameters.js +110 -108
  50. package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
  51. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js +6 -6
  52. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js.map +1 -1
  53. package/dist/code-example/helpers/operation-to-har/process-server-url.js.map +1 -1
  54. package/dist/code-example/index.d.ts +1 -1
  55. package/dist/code-example/index.d.ts.map +1 -1
  56. package/dist/code-example/index.js +14 -14
  57. package/dist/code-example/mount-asyncapi.js +1 -1
  58. package/dist/code-example/mount-asyncapi.js.map +1 -1
  59. package/dist/code-example/mount.js +1 -1
  60. package/dist/code-example/mount.js.map +1 -1
  61. package/dist/constants.js +1 -1
  62. package/dist/schema/LinkButton.vue.js.map +1 -1
  63. package/dist/schema/RenderString.vue.js +11 -4
  64. package/dist/schema/RenderString.vue.js.map +1 -1
  65. package/dist/schema/RenderString2.vue.js +6 -0
  66. package/dist/schema/RenderString2.vue.js.map +1 -0
  67. package/dist/schema/Schema.vue.js +235 -6
  68. package/dist/schema/Schema.vue.js.map +1 -1
  69. package/dist/schema/Schema3.vue.js +8 -0
  70. package/dist/schema/Schema3.vue.js.map +1 -0
  71. package/dist/schema/SchemaCollapsedPreview.vue.js +25 -4
  72. package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -1
  73. package/dist/schema/SchemaCollapsedPreview2.vue.js +6 -0
  74. package/dist/schema/SchemaCollapsedPreview2.vue.js.map +1 -0
  75. package/dist/schema/SchemaComposition.vue.js +232 -6
  76. package/dist/schema/SchemaComposition.vue.js.map +1 -1
  77. package/dist/schema/SchemaComposition3.vue.js +8 -0
  78. package/dist/schema/SchemaComposition3.vue.js.map +1 -0
  79. package/dist/schema/SchemaEnumPropertyItem.vue.d.ts +1 -0
  80. package/dist/schema/SchemaEnumPropertyItem.vue.d.ts.map +1 -1
  81. package/dist/schema/SchemaEnumPropertyItem.vue.js +23 -4
  82. package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -1
  83. package/dist/schema/SchemaEnumPropertyItem2.vue.js +6 -0
  84. package/dist/schema/SchemaEnumPropertyItem2.vue.js.map +1 -0
  85. package/dist/schema/SchemaEnums.vue.d.ts.map +1 -1
  86. package/dist/schema/SchemaEnums.vue.js +74 -6
  87. package/dist/schema/SchemaEnums.vue.js.map +1 -1
  88. package/dist/schema/SchemaEnums3.vue.js +8 -0
  89. package/dist/schema/SchemaEnums3.vue.js.map +1 -0
  90. package/dist/schema/SchemaGlyphPuck.vue.js +27 -4
  91. package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -1
  92. package/dist/schema/SchemaGlyphPuck2.vue.js +6 -0
  93. package/dist/schema/SchemaGlyphPuck2.vue.js.map +1 -0
  94. package/dist/schema/SchemaGutterToggle.vue.js +40 -4
  95. package/dist/schema/SchemaGutterToggle.vue.js.map +1 -1
  96. package/dist/schema/SchemaGutterToggle2.vue.js +6 -0
  97. package/dist/schema/SchemaGutterToggle2.vue.js.map +1 -0
  98. package/dist/schema/SchemaHeading.vue.js +32 -6
  99. package/dist/schema/SchemaHeading.vue.js.map +1 -1
  100. package/dist/schema/SchemaHeading3.vue.js +8 -0
  101. package/dist/schema/SchemaHeading3.vue.js.map +1 -0
  102. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +42 -4
  103. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
  104. package/dist/schema/SchemaObjectExampleCodeBlock2.vue.js +6 -0
  105. package/dist/schema/SchemaObjectExampleCodeBlock2.vue.js.map +1 -0
  106. package/dist/schema/SchemaObjectProperties.vue.js +213 -4
  107. package/dist/schema/SchemaObjectProperties.vue.js.map +1 -1
  108. package/dist/schema/SchemaObjectProperties2.vue.js +6 -0
  109. package/dist/schema/SchemaObjectProperties2.vue.js.map +1 -0
  110. package/dist/schema/SchemaProperty.vue.d.ts +1 -1
  111. package/dist/schema/SchemaProperty.vue.d.ts.map +1 -1
  112. package/dist/schema/SchemaProperty.vue.js +472 -6
  113. package/dist/schema/SchemaProperty.vue.js.map +1 -1
  114. package/dist/schema/SchemaProperty3.vue.js +8 -0
  115. package/dist/schema/SchemaProperty3.vue.js.map +1 -0
  116. package/dist/schema/SchemaPropertyDefault.vue.js +61 -6
  117. package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -1
  118. package/dist/schema/SchemaPropertyDefault3.vue.js +8 -0
  119. package/dist/schema/SchemaPropertyDefault3.vue.js.map +1 -0
  120. package/dist/schema/SchemaPropertyDetail.vue.js +22 -6
  121. package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -1
  122. package/dist/schema/SchemaPropertyDetail3.vue.js +8 -0
  123. package/dist/schema/SchemaPropertyDetail3.vue.js.map +1 -0
  124. package/dist/schema/SchemaPropertyExamples.vue.js +133 -6
  125. package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
  126. package/dist/schema/SchemaPropertyExamples3.vue.js +8 -0
  127. package/dist/schema/SchemaPropertyExamples3.vue.js.map +1 -0
  128. package/dist/schema/SchemaPropertyHeading.vue.d.ts +1 -1
  129. package/dist/schema/SchemaPropertyHeading.vue.d.ts.map +1 -1
  130. package/dist/schema/SchemaPropertyHeading.vue.js +312 -6
  131. package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
  132. package/dist/schema/SchemaPropertyHeading3.vue.js +8 -0
  133. package/dist/schema/SchemaPropertyHeading3.vue.js.map +1 -0
  134. package/dist/schema/SchemaPropertyPattern.vue.js +42 -6
  135. package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -1
  136. package/dist/schema/SchemaPropertyPattern3.vue.js +8 -0
  137. package/dist/schema/SchemaPropertyPattern3.vue.js.map +1 -0
  138. package/dist/schema/SchemaRailPanel.vue.js +53 -4
  139. package/dist/schema/SchemaRailPanel.vue.js.map +1 -1
  140. package/dist/schema/SchemaRailPanel2.vue.js +6 -0
  141. package/dist/schema/SchemaRailPanel2.vue.js.map +1 -0
  142. package/dist/schema/components/CopyLinkButton.vue.d.ts +5 -0
  143. package/dist/schema/components/CopyLinkButton.vue.d.ts.map +1 -1
  144. package/dist/schema/components/CopyLinkButton.vue.js +24 -4
  145. package/dist/schema/components/CopyLinkButton.vue.js.map +1 -1
  146. package/dist/schema/components/CopyLinkButton2.vue.js +6 -0
  147. package/dist/schema/components/CopyLinkButton2.vue.js.map +1 -0
  148. package/dist/schema/components/WithBreadcrumb.vue.js +15 -4
  149. package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -1
  150. package/dist/schema/components/WithBreadcrumb2.vue.js +6 -0
  151. package/dist/schema/components/WithBreadcrumb2.vue.js.map +1 -0
  152. package/dist/schema/helpers/dynamic-scope.js.map +1 -1
  153. package/dist/schema/helpers/format-example.js.map +1 -1
  154. package/dist/schema/helpers/format-structured-value.d.ts +3 -0
  155. package/dist/schema/helpers/format-structured-value.d.ts.map +1 -0
  156. package/dist/schema/helpers/format-structured-value.js +6 -0
  157. package/dist/schema/helpers/format-structured-value.js.map +1 -0
  158. package/dist/schema/helpers/format-value.js.map +1 -1
  159. package/dist/schema/helpers/get-compositions-to-render.js.map +1 -1
  160. package/dist/schema/helpers/get-discriminator-values.js.map +1 -1
  161. package/dist/schema/helpers/get-enum-values.js.map +1 -1
  162. package/dist/schema/helpers/get-property-description.js.map +1 -1
  163. package/dist/schema/helpers/get-ref-name.js.map +1 -1
  164. package/dist/schema/helpers/get-rendered-example.js.map +1 -1
  165. package/dist/schema/helpers/get-schema-type.js.map +1 -1
  166. package/dist/schema/helpers/get-type-signature-tokens.d.ts.map +1 -1
  167. package/dist/schema/helpers/get-type-signature-tokens.js +37 -36
  168. package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -1
  169. package/dist/schema/helpers/has-complex-array-items.js.map +1 -1
  170. package/dist/schema/helpers/is-empty-schema-object.js.map +1 -1
  171. package/dist/schema/helpers/is-model-linkable.js.map +1 -1
  172. package/dist/schema/helpers/is-on-schema-target-path.js.map +1 -1
  173. package/dist/schema/helpers/is-type-object.js.map +1 -1
  174. package/dist/schema/helpers/merge-all-of-schemas.js.map +1 -1
  175. package/dist/schema/helpers/normalize-object-composition.js.map +1 -1
  176. package/dist/schema/helpers/optimize-value-for-display.js.map +1 -1
  177. package/dist/schema/helpers/partition-all-of-compositions.js.map +1 -1
  178. package/dist/schema/helpers/schema-cycle.js.map +1 -1
  179. package/dist/schema/helpers/schema-expansion.js.map +1 -1
  180. package/dist/schema/helpers/schema-keyboard-nav.js.map +1 -1
  181. package/dist/schema/helpers/schema-name.js.map +1 -1
  182. package/dist/schema/helpers/should-display-description.js.map +1 -1
  183. package/dist/schema/helpers/should-display-heading.js.map +1 -1
  184. package/dist/schema/helpers/should-render-array-item-composition.js.map +1 -1
  185. package/dist/schema/helpers/sort-property-names.js.map +1 -1
  186. package/dist/schema/helpers/unwrap-for-read.js.map +1 -1
  187. package/dist/schema/index.js +8 -8
  188. package/dist/schema/localization/index.d.ts +1 -1
  189. package/dist/schema/localization/index.js.map +1 -1
  190. package/dist/schema/localization/translations.js.map +1 -1
  191. package/dist/shared/Badge.vue.js +13 -6
  192. package/dist/shared/Badge.vue.js.map +1 -1
  193. package/dist/shared/Badge3.vue.js +8 -0
  194. package/dist/shared/Badge3.vue.js.map +1 -0
  195. package/dist/shared/ExternalDocs.vue.js +43 -4
  196. package/dist/shared/ExternalDocs.vue.js.map +1 -1
  197. package/dist/shared/ExternalDocs2.vue.js +6 -0
  198. package/dist/shared/ExternalDocs2.vue.js.map +1 -0
  199. package/dist/shared/ExternalExampleStatus.vue.d.ts +12 -0
  200. package/dist/shared/ExternalExampleStatus.vue.d.ts.map +1 -0
  201. package/dist/shared/ExternalExampleStatus.vue.js +26 -0
  202. package/dist/shared/ExternalExampleStatus.vue.js.map +1 -0
  203. package/dist/shared/ExternalExampleStatus2.vue.js +6 -0
  204. package/dist/shared/ExternalExampleStatus2.vue.js.map +1 -0
  205. package/dist/shared/ScreenReader.vue.js +16 -4
  206. package/dist/shared/ScreenReader.vue.js.map +1 -1
  207. package/dist/shared/ScreenReader2.vue.js +6 -0
  208. package/dist/shared/ScreenReader2.vue.js.map +1 -0
  209. package/dist/shared/external-example-localization/index.d.ts +4 -0
  210. package/dist/shared/external-example-localization/index.d.ts.map +1 -0
  211. package/dist/shared/external-example-localization/index.js +17 -0
  212. package/dist/shared/external-example-localization/index.js.map +1 -0
  213. package/dist/shared/external-example-localization/locales/ar.d.ts +8 -0
  214. package/dist/shared/external-example-localization/locales/ar.d.ts.map +1 -0
  215. package/dist/shared/external-example-localization/locales/ar.js +9 -0
  216. package/dist/shared/external-example-localization/locales/ar.js.map +1 -0
  217. package/dist/shared/external-example-localization/locales/de.d.ts +8 -0
  218. package/dist/shared/external-example-localization/locales/de.d.ts.map +1 -0
  219. package/dist/shared/external-example-localization/locales/de.js +9 -0
  220. package/dist/shared/external-example-localization/locales/de.js.map +1 -0
  221. package/dist/shared/external-example-localization/locales/en.d.ts +8 -0
  222. package/dist/shared/external-example-localization/locales/en.d.ts.map +1 -0
  223. package/dist/shared/external-example-localization/locales/en.js +9 -0
  224. package/dist/shared/external-example-localization/locales/en.js.map +1 -0
  225. package/dist/shared/external-example-localization/locales/es.d.ts +8 -0
  226. package/dist/shared/external-example-localization/locales/es.d.ts.map +1 -0
  227. package/dist/shared/external-example-localization/locales/es.js +9 -0
  228. package/dist/shared/external-example-localization/locales/es.js.map +1 -0
  229. package/dist/shared/external-example-localization/locales/fr.d.ts +8 -0
  230. package/dist/shared/external-example-localization/locales/fr.d.ts.map +1 -0
  231. package/dist/shared/external-example-localization/locales/fr.js +9 -0
  232. package/dist/shared/external-example-localization/locales/fr.js.map +1 -0
  233. package/dist/shared/external-example-localization/locales/pt.d.ts +8 -0
  234. package/dist/shared/external-example-localization/locales/pt.d.ts.map +1 -0
  235. package/dist/shared/external-example-localization/locales/pt.js +9 -0
  236. package/dist/shared/external-example-localization/locales/pt.js.map +1 -0
  237. package/dist/shared/external-example-localization/locales/ru.d.ts +8 -0
  238. package/dist/shared/external-example-localization/locales/ru.d.ts.map +1 -0
  239. package/dist/shared/external-example-localization/locales/ru.js +9 -0
  240. package/dist/shared/external-example-localization/locales/ru.js.map +1 -0
  241. package/dist/shared/external-example-localization/locales/zh-cn.d.ts +8 -0
  242. package/dist/shared/external-example-localization/locales/zh-cn.d.ts.map +1 -0
  243. package/dist/shared/external-example-localization/locales/zh-cn.js +9 -0
  244. package/dist/shared/external-example-localization/locales/zh-cn.js.map +1 -0
  245. package/dist/shared/external-example-localization/locales/zh-tw.d.ts +8 -0
  246. package/dist/shared/external-example-localization/locales/zh-tw.d.ts.map +1 -0
  247. package/dist/shared/external-example-localization/locales/zh-tw.js +9 -0
  248. package/dist/shared/external-example-localization/locales/zh-tw.js.map +1 -0
  249. package/dist/shared/external-example-localization/translations.d.ts +67 -0
  250. package/dist/shared/external-example-localization/translations.d.ts.map +1 -0
  251. package/dist/shared/external-example-localization/translations.js +24 -0
  252. package/dist/shared/external-example-localization/translations.js.map +1 -0
  253. package/dist/shared/index.d.ts +3 -0
  254. package/dist/shared/index.d.ts.map +1 -1
  255. package/dist/shared/index.js +6 -4
  256. package/dist/specification-extensions/ExtensionValue.vue.js +89 -4
  257. package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -1
  258. package/dist/specification-extensions/ExtensionValue2.vue.js +6 -0
  259. package/dist/specification-extensions/ExtensionValue2.vue.js.map +1 -0
  260. package/dist/specification-extensions/SpecificationExtensions.vue.js +76 -4
  261. package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -1
  262. package/dist/specification-extensions/SpecificationExtensions2.vue.js +6 -0
  263. package/dist/specification-extensions/SpecificationExtensions2.vue.js.map +1 -0
  264. package/dist/specification-extensions/index.js +1 -1
  265. package/dist/style.css +13 -9
  266. package/dist/vue-styles.css +1 -1
  267. package/package.json +18 -18
  268. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +0 -113
  269. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +0 -1
  270. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +0 -275
  271. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +0 -1
  272. package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js +0 -48
  273. package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js.map +0 -1
  274. package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js +0 -34
  275. package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js.map +0 -1
  276. package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js +0 -13
  277. package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js.map +0 -1
  278. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js +0 -237
  279. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js.map +0 -1
  280. package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js +0 -27
  281. package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js.map +0 -1
  282. package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js +0 -234
  283. package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js.map +0 -1
  284. package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js +0 -23
  285. package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js.map +0 -1
  286. package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js +0 -77
  287. package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js.map +0 -1
  288. package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js +0 -29
  289. package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js.map +0 -1
  290. package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js +0 -42
  291. package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js.map +0 -1
  292. package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js +0 -34
  293. package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js.map +0 -1
  294. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js +0 -44
  295. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +0 -1
  296. package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js +0 -215
  297. package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js.map +0 -1
  298. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js +0 -469
  299. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js.map +0 -1
  300. package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js +0 -63
  301. package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js.map +0 -1
  302. package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js +0 -24
  303. package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js.map +0 -1
  304. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js +0 -135
  305. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +0 -1
  306. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js +0 -314
  307. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js.map +0 -1
  308. package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js +0 -44
  309. package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js.map +0 -1
  310. package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js +0 -55
  311. package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js.map +0 -1
  312. package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js +0 -25
  313. package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js.map +0 -1
  314. package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js +0 -17
  315. package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js.map +0 -1
  316. package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js +0 -15
  317. package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js.map +0 -1
  318. package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js +0 -45
  319. package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js.map +0 -1
  320. package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js +0 -18
  321. package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js.map +0 -1
  322. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js +0 -91
  323. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js.map +0 -1
  324. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js +0 -78
  325. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"get-clients.js","names":["getClients","CODE_EXAMPLES_GROUP_LABEL","customCodeSamples","clientOptions","ids","getCustomClientIds","groups","index","sample","id","groupLabel","label","group","optionLabel","formatLanguage"],"sources":["../../../src/code-example/helpers/get-clients.ts"],"sourcesContent":["import type { TargetId } from '@scalar/types/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\n\nimport type { ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from '../types'\nimport { formatLanguage } from './format-language'\nimport { getCustomClientIds } from './generate-client-options'\nimport { CODE_EXAMPLES_GROUP_LABEL } from './get-custom-code-samples'\n\n/**\n * Merges custom code samples with the client options\n *\n * @param customCodeSamples - The custom code samples from the operation to merge with the client options\n * @param clientOptions - The client options to merge with the custom code samples\n * @param label - The label for the custom samples group (e.g. \"SDK\" or \"Code Examples\")\n * @returns A list of client option groups\n */\nexport const getClients = (\n customCodeSamples: XCodeSample[],\n clientOptions: ClientOptionGroup[],\n label: string = CODE_EXAMPLES_GROUP_LABEL,\n): CustomClientOptionGroup[] => {\n if (!customCodeSamples.length) {\n return clientOptions\n }\n\n const ids = getCustomClientIds(customCodeSamples)\n const groups = new Map<string, CustomClientOptionGroup>()\n\n for (const [index, sample] of customCodeSamples.entries()) {\n const id = ids[index]\n if (!id || ids.indexOf(id) !== index) {\n continue\n }\n\n // Empty headings retain the source extension's existing default group.\n const groupLabel = (typeof sample.group === 'string' && sample.group.trim()) || label\n const group = groups.get(groupLabel) ?? { label: groupLabel, key: 'custom', options: [] }\n const optionLabel = sample.label || formatLanguage(sample.lang) || id\n group.options.push({\n id,\n lang: (sample.lang as TargetId) || 'plaintext',\n title: optionLabel,\n label: optionLabel,\n clientKey: 'custom',\n } satisfies CustomClientOption)\n groups.set(groupLabel, group)\n }\n\n return [...groups.values(), ...clientOptions]\n}\n"],"mappings":";;;;AAgBA,IAAaA,KACX,GACA,GACA,IAAgBC,MACc;CAC9B,IAAI,CAACC,EAAkB,QACrB,OAAOC;CAGT,IAAMC,IAAMC,EAAmBH,CAAiB,GAC1CI,oBAAS,IAAI,IAAqC;CAExD,KAAK,IAAM,CAACC,GAAOC,MAAWN,EAAkB,QAAQ,GAAG;EACzD,IAAMO,IAAKL,EAAIG;EACf,IAAI,CAACE,KAAML,EAAI,QAAQK,CAAE,MAAMF,GAC7B;EAIF,IAAMG,IAAc,OAAOF,EAAO,SAAU,YAAYA,EAAO,MAAM,KAAK,KAAMG,GAC1EC,IAAQN,EAAO,IAAII,CAAU,KAAK;GAAE,OAAOA;GAAY,KAAK;GAAU,SAAS,CAAC;EAAE,GAClFG,IAAcL,EAAO,SAASM,EAAeN,EAAO,IAAI,KAAKC;EAQnE,AAPAG,EAAM,QAAQ,KAAK;GACjB;GACA,MAAOJ,EAAO,QAAqB;GACnC,OAAOK;GACP,OAAOA;GACP,WAAW;EACb,CAA8B,GAC9BP,EAAO,IAAII,GAAYE,CAAK;CAC9B;CAEA,OAAO,CAAC,GAAGN,EAAO,OAAO,GAAG,GAAGH,CAAa;AAC9C"}
1
+ {"version":3,"file":"get-clients.js","names":["formatLanguage","getCustomClientIds","CODE_EXAMPLES_GROUP_LABEL","getClients","customCodeSamples","clientOptions","label","ids","groups","index","sample","id","groupLabel","group","optionLabel"],"sources":["../../../src/code-example/helpers/get-clients.ts"],"sourcesContent":["import type { TargetId } from '@scalar/types/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\n\nimport type { ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from '../types'\nimport { formatLanguage } from './format-language'\nimport { getCustomClientIds } from './generate-client-options'\nimport { CODE_EXAMPLES_GROUP_LABEL } from './get-custom-code-samples'\n\n/**\n * Merges custom code samples with the client options\n *\n * @param customCodeSamples - The custom code samples from the operation to merge with the client options\n * @param clientOptions - The client options to merge with the custom code samples\n * @param label - The label for the custom samples group (e.g. \"SDK\" or \"Code Examples\")\n * @returns A list of client option groups\n */\nexport const getClients = (\n customCodeSamples: XCodeSample[],\n clientOptions: ClientOptionGroup[],\n label: string = CODE_EXAMPLES_GROUP_LABEL,\n): CustomClientOptionGroup[] => {\n if (!customCodeSamples.length) {\n return clientOptions\n }\n\n const ids = getCustomClientIds(customCodeSamples)\n const groups = new Map<string, CustomClientOptionGroup>()\n\n for (const [index, sample] of customCodeSamples.entries()) {\n const id = ids[index]\n if (!id || ids.indexOf(id) !== index) {\n continue\n }\n\n // Empty headings retain the source extension's existing default group.\n const groupLabel = (typeof sample.group === 'string' && sample.group.trim()) || label\n const group = groups.get(groupLabel) ?? { label: groupLabel, key: 'custom', options: [] }\n const optionLabel = sample.label || formatLanguage(sample.lang) || id\n group.options.push({\n id,\n lang: (sample.lang as TargetId) || 'plaintext',\n title: optionLabel,\n label: optionLabel,\n clientKey: 'custom',\n } satisfies CustomClientOption)\n groups.set(groupLabel, group)\n }\n\n return [...groups.values(), ...clientOptions]\n}\n"],"mappings":";;;;AAgBA,IAAaG,KACXC,GACAC,GACAC,IAAgBJ,MACc;CAC9B,IAAI,CAACE,EAAkB,QACrB,OAAOC;CAGT,IAAME,IAAMN,EAAmBG,CAAiB,GAC1CI,oBAAS,IAAI,IAAqC;CAExD,KAAK,IAAM,CAACC,GAAOC,MAAWN,EAAkB,QAAQ,GAAG;EACzD,IAAMO,IAAKJ,EAAIE;EACf,IAAI,CAACE,KAAMJ,EAAI,QAAQI,CAAE,MAAMF,GAC7B;EAIF,IAAMG,IAAc,OAAOF,EAAO,SAAU,YAAYA,EAAO,MAAM,KAAK,KAAMJ,GAC1EO,IAAQL,EAAO,IAAII,CAAU,KAAK;GAAE,OAAOA;GAAY,KAAK;GAAU,SAAS,CAAC;EAAE,GAClFE,IAAcJ,EAAO,SAASV,EAAeU,EAAO,IAAI,KAAKC;EACnEE,EAAM,QAAQ,KAAK;GACjBF;GACA,MAAOD,EAAO,QAAqB;GACnC,OAAOI;GACP,OAAOA;GACP,WAAW;EACb,CAA8B,GAC9BN,EAAO,IAAII,GAAYC,CAAK;CAC9B;CAEA,OAAO,CAAC,GAAGL,EAAO,OAAO,GAAG,GAAGH,CAAa;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-custom-code-samples.js","names":["fromSnippetMap","snippets","lang","source","label","fromLanguageExamples","examples","example","fromReadmeSamples","samples","sample","SDK_GROUP_LABEL","CODE_EXAMPLES_GROUP_LABEL","getCustomCodeSamples","scalarExamples","operation","stainlessSnippets","stainlessExamples","readmeSamples","key"],"sources":["../../../src/code-example/helpers/get-custom-code-samples.ts"],"sourcesContent":["import type {\n XCodeSample,\n XLanguageExample,\n XReadmeCodeSample,\n} from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/** Turns a `{ language: source }` map (x-stainless-snippets) into code samples. */\nconst fromSnippetMap = (snippets: Record<string, string> | undefined, label?: string): XCodeSample[] =>\n Object.entries(snippets ?? {}).map(([lang, source]) => ({ lang, source, ...(label ? { label } : {}) }))\n\n/**\n * Turns `x-stainless-examples` / `x-scalar-examples` into code samples.\n *\n * Each example carries per-language request snippets and an optional title that\n * we surface as the picker label. The response is only used for documentation,\n * so it is ignored here.\n */\nconst fromLanguageExamples = (examples: XLanguageExample | XLanguageExample[] | undefined): XCodeSample[] => {\n if (!examples) {\n return []\n }\n\n return (Array.isArray(examples) ? examples : [examples]).flatMap((example) =>\n fromSnippetMap(example.request, example.title),\n )\n}\n\n/** Turns ReadMe's `x-readme.code-samples` into code samples. */\nconst fromReadmeSamples = (samples: XReadmeCodeSample[] | undefined): XCodeSample[] =>\n (samples ?? []).map((sample) => ({\n lang: sample.language,\n source: sample.code,\n ...(sample.name ? { label: sample.name } : {}),\n }))\n\n/** Picker group label for samples generated by an SDK provider (Scalar, Stainless, …). */\nconst SDK_GROUP_LABEL = 'SDK'\n\n/** Picker group label for generic or docs-platform samples (the standard `x-codeSamples` family, ReadMe, …). */\nexport const CODE_EXAMPLES_GROUP_LABEL = 'Code Examples'\n\ntype CustomCodeSampleGroupLabel = typeof SDK_GROUP_LABEL | typeof CODE_EXAMPLES_GROUP_LABEL\n\ntype CustomCodeSamples = {\n /**\n * Group label for the code sample picker.\n *\n * Samples that come from an SDK provider extension (`x-scalar-examples`,\n * `x-stainless-snippets`, `x-stainless-examples`) surface under \"SDK\". Generic\n * or docs-platform samples (`x-readme`, the `x-codeSamples` family) surface\n * under \"Code Examples\".\n */\n label: CustomCodeSampleGroupLabel\n /** The custom code samples, in picker order. */\n samples: XCodeSample[]\n}\n\n/**\n * Grabs any custom code samples from the operation.\n *\n * Several tools write code samples into OpenAPI under different extensions. When\n * more than one is present we use the highest-priority source only, rather than\n * showing duplicates from every tool. Priority, highest first:\n *\n * 1. `x-scalar-examples` (SDK)\n * 2. `x-stainless-snippets` (SDK, overrides `x-stainless-examples`)\n * 3. `x-stainless-examples` (SDK)\n * 4. `x-readme.code-samples` (Code Examples)\n * 5. `x-codeSamples` / `x-code-samples` / `x-custom-examples` (Code Examples)\n *\n * The winning source also determines the picker group label: SDK-provider\n * extensions surface under \"SDK\", everything else under \"Code Examples\".\n *\n * Note that Speakeasy does not have its own extension — it writes into the\n * standard `x-codeSamples`, so its snippets surface under \"Code Examples\".\n *\n * @param operation - The operation to get the custom code samples from\n * @returns The picker group label and the custom code samples which exist in the operation\n */\nexport const getCustomCodeSamples = (operation: OperationObject): CustomCodeSamples => {\n const scalarExamples = operation['x-scalar-examples'] ?? []\n if (scalarExamples.length) {\n return { label: SDK_GROUP_LABEL, samples: scalarExamples }\n }\n\n const stainlessSnippets = fromSnippetMap(operation['x-stainless-snippets'])\n if (stainlessSnippets.length) {\n return { label: SDK_GROUP_LABEL, samples: stainlessSnippets }\n }\n\n const stainlessExamples = fromLanguageExamples(operation['x-stainless-examples'])\n if (stainlessExamples.length) {\n return { label: SDK_GROUP_LABEL, samples: stainlessExamples }\n }\n\n const readmeSamples = fromReadmeSamples(operation['x-readme']?.['code-samples'])\n if (readmeSamples.length) {\n return { label: CODE_EXAMPLES_GROUP_LABEL, samples: readmeSamples }\n }\n\n const customCodeKeys = ['x-custom-examples', 'x-codeSamples', 'x-code-samples'] as const\n return { label: CODE_EXAMPLES_GROUP_LABEL, samples: customCodeKeys.flatMap((key) => operation[key] ?? []) }\n}\n"],"mappings":";AAQA,IAAMA,KAAkB,GAA8C,MACpE,OAAO,QAAQC,KAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAACC,GAAMC,QAAa;CAAE;CAAM;CAAQ,GAAIC,IAAQ,EAAE,SAAM,IAAI,CAAC;AAAG,EAAE,GASlGC,KAAwB,MACvBC,KAIG,MAAM,QAAQA,CAAQ,IAAIA,IAAW,CAACA,CAAQ,EAAA,CAAG,SAAS,MAChEN,EAAeO,EAAQ,SAASA,EAAQ,KAAK,CAC/C,IALS,CAAC,GASNC,KAAqB,OACxBC,KAAW,CAAC,EAAA,CAAG,KAAK,OAAY;CAC/B,MAAMC,EAAO;CACb,QAAQA,EAAO;CACf,GAAIA,EAAO,OAAO,EAAE,OAAOA,EAAO,KAAK,IAAI,CAAC;AAC9C,EAAE,GAGEC,IAAkB,OAGXC,IAA4B,iBAwC5BC,KAAwB,MAAkD;CACrF,IAAMC,IAAiBC,EAAU,wBAAwB,CAAC;CAC1D,IAAID,EAAe,QACjB,OAAO;EAAE,OAAOH;EAAiB,SAASG;CAAe;CAG3D,IAAME,IAAoBhB,EAAee,EAAU,uBAAuB;CAC1E,IAAIC,EAAkB,QACpB,OAAO;EAAE,OAAOL;EAAiB,SAASK;CAAkB;CAG9D,IAAMC,IAAoBZ,EAAqBU,EAAU,uBAAuB;CAChF,IAAIE,EAAkB,QACpB,OAAO;EAAE,OAAON;EAAiB,SAASM;CAAkB;CAG9D,IAAMC,IAAgBV,EAAkBO,EAAU,WAAW,GAAG,eAAe;CAM/E,OALIG,EAAc,SACT;EAAE,OAAON;EAA2B,SAASM;CAAc,IAI7D;EAAE,OAAON;EAA2B,SAAS;GAD5B;GAAqB;GAAiB;EACV,CAAA,CAAe,SAAS,MAAQG,EAAUI,MAAQ,CAAC,CAAC;CAAE;AAC5G"}
1
+ {"version":3,"file":"get-custom-code-samples.js","names":["fromSnippetMap","snippets","label","lang","source","fromLanguageExamples","examples","example","fromReadmeSamples","samples","sample","SDK_GROUP_LABEL","CODE_EXAMPLES_GROUP_LABEL","getCustomCodeSamples","operation","scalarExamples","stainlessSnippets","stainlessExamples","readmeSamples","key"],"sources":["../../../src/code-example/helpers/get-custom-code-samples.ts"],"sourcesContent":["import type {\n XCodeSample,\n XLanguageExample,\n XReadmeCodeSample,\n} from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/** Turns a `{ language: source }` map (x-stainless-snippets) into code samples. */\nconst fromSnippetMap = (snippets: Record<string, string> | undefined, label?: string): XCodeSample[] =>\n Object.entries(snippets ?? {}).map(([lang, source]) => ({ lang, source, ...(label ? { label } : {}) }))\n\n/**\n * Turns `x-stainless-examples` / `x-scalar-examples` into code samples.\n *\n * Each example carries per-language request snippets and an optional title that\n * we surface as the picker label. The response is only used for documentation,\n * so it is ignored here.\n */\nconst fromLanguageExamples = (examples: XLanguageExample | XLanguageExample[] | undefined): XCodeSample[] => {\n if (!examples) {\n return []\n }\n\n return (Array.isArray(examples) ? examples : [examples]).flatMap((example) =>\n fromSnippetMap(example.request, example.title),\n )\n}\n\n/** Turns ReadMe's `x-readme.code-samples` into code samples. */\nconst fromReadmeSamples = (samples: XReadmeCodeSample[] | undefined): XCodeSample[] =>\n (samples ?? []).map((sample) => ({\n lang: sample.language,\n source: sample.code,\n ...(sample.name ? { label: sample.name } : {}),\n }))\n\n/** Picker group label for samples generated by an SDK provider (Scalar, Stainless, …). */\nconst SDK_GROUP_LABEL = 'SDK'\n\n/** Picker group label for generic or docs-platform samples (the standard `x-codeSamples` family, ReadMe, …). */\nexport const CODE_EXAMPLES_GROUP_LABEL = 'Code Examples'\n\ntype CustomCodeSampleGroupLabel = typeof SDK_GROUP_LABEL | typeof CODE_EXAMPLES_GROUP_LABEL\n\ntype CustomCodeSamples = {\n /**\n * Group label for the code sample picker.\n *\n * Samples that come from an SDK provider extension (`x-scalar-examples`,\n * `x-stainless-snippets`, `x-stainless-examples`) surface under \"SDK\". Generic\n * or docs-platform samples (`x-readme`, the `x-codeSamples` family) surface\n * under \"Code Examples\".\n */\n label: CustomCodeSampleGroupLabel\n /** The custom code samples, in picker order. */\n samples: XCodeSample[]\n}\n\n/**\n * Grabs any custom code samples from the operation.\n *\n * Several tools write code samples into OpenAPI under different extensions. When\n * more than one is present we use the highest-priority source only, rather than\n * showing duplicates from every tool. Priority, highest first:\n *\n * 1. `x-scalar-examples` (SDK)\n * 2. `x-stainless-snippets` (SDK, overrides `x-stainless-examples`)\n * 3. `x-stainless-examples` (SDK)\n * 4. `x-readme.code-samples` (Code Examples)\n * 5. `x-codeSamples` / `x-code-samples` / `x-custom-examples` (Code Examples)\n *\n * The winning source also determines the picker group label: SDK-provider\n * extensions surface under \"SDK\", everything else under \"Code Examples\".\n *\n * Note that Speakeasy does not have its own extension — it writes into the\n * standard `x-codeSamples`, so its snippets surface under \"Code Examples\".\n *\n * @param operation - The operation to get the custom code samples from\n * @returns The picker group label and the custom code samples which exist in the operation\n */\nexport const getCustomCodeSamples = (operation: OperationObject): CustomCodeSamples => {\n const scalarExamples = operation['x-scalar-examples'] ?? []\n if (scalarExamples.length) {\n return { label: SDK_GROUP_LABEL, samples: scalarExamples }\n }\n\n const stainlessSnippets = fromSnippetMap(operation['x-stainless-snippets'])\n if (stainlessSnippets.length) {\n return { label: SDK_GROUP_LABEL, samples: stainlessSnippets }\n }\n\n const stainlessExamples = fromLanguageExamples(operation['x-stainless-examples'])\n if (stainlessExamples.length) {\n return { label: SDK_GROUP_LABEL, samples: stainlessExamples }\n }\n\n const readmeSamples = fromReadmeSamples(operation['x-readme']?.['code-samples'])\n if (readmeSamples.length) {\n return { label: CODE_EXAMPLES_GROUP_LABEL, samples: readmeSamples }\n }\n\n const customCodeKeys = ['x-custom-examples', 'x-codeSamples', 'x-code-samples'] as const\n return { label: CODE_EXAMPLES_GROUP_LABEL, samples: customCodeKeys.flatMap((key) => operation[key] ?? []) }\n}\n"],"mappings":";AAQA,IAAMA,KAAkBC,GAA8CC,MACpE,OAAO,QAAQD,KAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAACE,GAAMC,QAAa;CAAED;CAAMC;CAAQ,GAAIF,IAAQ,EAAEA,SAAM,IAAI,CAAC;AAAG,EAAE,GASlGG,KAAwBC,MACvBA,KAIG,MAAM,QAAQA,CAAQ,IAAIA,IAAW,CAACA,CAAQ,EAAA,CAAG,SAASC,MAChEP,EAAeO,EAAQ,SAASA,EAAQ,KAAK,CAC/C,IALS,CAAC,GASNC,KAAqBC,OACxBA,KAAW,CAAC,EAAA,CAAG,KAAKC,OAAY;CAC/B,MAAMA,EAAO;CACb,QAAQA,EAAO;CACf,GAAIA,EAAO,OAAO,EAAE,OAAOA,EAAO,KAAK,IAAI,CAAC;AAC9C,EAAE,GAGEC,IAAkB,OAGXC,IAA4B,iBAwC5BC,KAAwBC,MAAkD;CACrF,IAAMC,IAAiBD,EAAU,wBAAwB,CAAC;CAC1D,IAAIC,EAAe,QACjB,OAAO;EAAE,OAAOJ;EAAiB,SAASI;CAAe;CAG3D,IAAMC,IAAoBhB,EAAec,EAAU,uBAAuB;CAC1E,IAAIE,EAAkB,QACpB,OAAO;EAAE,OAAOL;EAAiB,SAASK;CAAkB;CAG9D,IAAMC,IAAoBZ,EAAqBS,EAAU,uBAAuB;CAChF,IAAIG,EAAkB,QACpB,OAAO;EAAE,OAAON;EAAiB,SAASM;CAAkB;CAG9D,IAAMC,IAAgBV,EAAkBM,EAAU,WAAW,GAAG,eAAe;CAM/E,OALII,EAAc,SACT;EAAE,OAAON;EAA2B,SAASM;CAAc,IAI7D;EAAE,OAAON;EAA2B,SAAS;GAD5B;GAAqB;GAAiB;EACV,CAAA,CAAe,SAASO,MAAQL,EAAUK,MAAQ,CAAC,CAAC;CAAE;AAC5G"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-generated-payload-example.js","names":["hasFalseAllOfMember","schema","getResolvedAsyncApiRef","source","isObject","seen","member","getGeneratedPayloadExample","message","example","payload","resolved","resolveAsyncApiSchema","snapshot","snapshotSchema","getExampleFromSchema"],"sources":["../../../src/code-example/helpers/get-generated-payload-example.ts"],"sourcesContent":["import { isObject } from '@scalar/helpers/object/is-object'\nimport type { AsyncApiMessageObject } from '@scalar/types/asyncapi/3.1'\nimport { getResolvedAsyncApiRef } from '@scalar/workspace-store/helpers/get-resolved-async-api-ref'\nimport { resolveAsyncApiSchema } from '@scalar/workspace-store/helpers/resolve-async-api-schema'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { getExampleFromSchema } from '@scalar/workspace-store/request-example'\n\n/** An allOf containing a false schema cannot have a valid example. */\nconst hasFalseAllOfMember = (source: unknown, seen = new Set<unknown>()): boolean => {\n const schema = getResolvedAsyncApiRef(source)\n if (schema === false) {\n return true\n }\n if (!isObject(schema) || seen.has(schema)) {\n return false\n }\n seen.add(schema)\n return Array.isArray(schema.allOf) && schema.allOf.some((member) => hasFalseAllOfMember(member, seen))\n}\n\n/** Generate a payload only when the document does not already provide one. */\nexport const getGeneratedPayloadExample = (message: AsyncApiMessageObject): unknown => {\n if (message.examples?.some((example) => getResolvedAsyncApiRef(example)?.payload !== undefined)) {\n return undefined\n }\n\n const payload = getResolvedAsyncApiRef(message.payload)\n // Boolean schemas describe validation, but do not suggest a representative payload.\n if (\n typeof payload === 'boolean' ||\n (isObject(payload) && 'schemaFormat' in payload && typeof getResolvedAsyncApiRef(payload.schema) === 'boolean')\n ) {\n return undefined\n }\n\n const resolved = resolveAsyncApiSchema(message.payload)\n const schema = resolved?.kind === 'schema' ? resolved.schema : undefined\n if (!schema || hasFalseAllOfMember(schema)) {\n return undefined\n }\n\n // Snapshot reactive schemas so in-place edits do not reuse the generator's identity cache.\n // The generator resolves schema references itself, preserving literal $ref fields in payload data.\n const snapshot = snapshotSchema(schema)\n return getExampleFromSchema(snapshot, {\n emptyString: 'string',\n })\n}\n"],"mappings":";;;;;;AAQA,IAAMA,KAAuB,GAAiB,oBAAO,IAAI,IAAa,MAAe;CACnF,IAAMC,IAASC,EAAuBC,CAAM;CAQ5C,OAPIF,MAAW,KACN,KAEL,CAACG,EAASH,CAAM,KAAKI,EAAK,IAAIJ,CAAM,IAC/B,MAETI,EAAK,IAAIJ,CAAM,GACR,MAAM,QAAQA,EAAO,KAAK,KAAKA,EAAO,MAAM,MAAM,MAAWD,EAAoBM,GAAQD,CAAI,CAAC;AACvG,GAGaE,KAA8B,MAA4C;CACrF,IAAIC,EAAQ,UAAU,MAAM,MAAYN,EAAuBO,CAAO,CAAC,EAAE,YAAY,KAAA,CAAS,GAC5F;CAGF,IAAMC,IAAUR,EAAuBM,EAAQ,OAAO;CAEtD,IACE,OAAOE,KAAY,aAClBN,EAASM,CAAO,KAAK,kBAAkBA,KAAW,OAAOR,EAAuBQ,EAAQ,MAAM,KAAM,WAErG;CAGF,IAAMC,IAAWC,EAAsBJ,EAAQ,OAAO,GAChDP,IAASU,GAAU,SAAS,WAAWA,EAAS,SAAS,KAAA;CAC/D,IAAI,CAACV,KAAUD,EAAoBC,CAAM,GACvC;CAKF,IAAMY,IAAWC,EAAeb,CAAM;CACtC,OAAOc,EAAqBF,GAAU,EACpC,aAAa,SACf,CAAC;AACH"}
1
+ {"version":3,"file":"get-generated-payload-example.js","names":["getResolvedAsyncApiRef","isObject","resolveAsyncApiSchema","snapshotSchema","getExampleFromSchema","hasFalseAllOfMember","source","seen","schema","member","getGeneratedPayloadExample","message","example","payload","resolved","snapshot"],"sources":["../../../src/code-example/helpers/get-generated-payload-example.ts"],"sourcesContent":["import { isObject } from '@scalar/helpers/object/is-object'\nimport type { AsyncApiMessageObject } from '@scalar/types/asyncapi/3.1'\nimport { getResolvedAsyncApiRef } from '@scalar/workspace-store/helpers/get-resolved-async-api-ref'\nimport { resolveAsyncApiSchema } from '@scalar/workspace-store/helpers/resolve-async-api-schema'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { getExampleFromSchema } from '@scalar/workspace-store/request-example'\n\n/** An allOf containing a false schema cannot have a valid example. */\nconst hasFalseAllOfMember = (source: unknown, seen = new Set<unknown>()): boolean => {\n const schema = getResolvedAsyncApiRef(source)\n if (schema === false) {\n return true\n }\n if (!isObject(schema) || seen.has(schema)) {\n return false\n }\n seen.add(schema)\n return Array.isArray(schema.allOf) && schema.allOf.some((member) => hasFalseAllOfMember(member, seen))\n}\n\n/** Generate a payload only when the document does not already provide one. */\nexport const getGeneratedPayloadExample = (message: AsyncApiMessageObject): unknown => {\n if (message.examples?.some((example) => getResolvedAsyncApiRef(example)?.payload !== undefined)) {\n return undefined\n }\n\n const payload = getResolvedAsyncApiRef(message.payload)\n // Boolean schemas describe validation, but do not suggest a representative payload.\n if (\n typeof payload === 'boolean' ||\n (isObject(payload) && 'schemaFormat' in payload && typeof getResolvedAsyncApiRef(payload.schema) === 'boolean')\n ) {\n return undefined\n }\n\n const resolved = resolveAsyncApiSchema(message.payload)\n const schema = resolved?.kind === 'schema' ? resolved.schema : undefined\n if (!schema || hasFalseAllOfMember(schema)) {\n return undefined\n }\n\n // Snapshot reactive schemas so in-place edits do not reuse the generator's identity cache.\n // The generator resolves schema references itself, preserving literal $ref fields in payload data.\n const snapshot = snapshotSchema(schema)\n return getExampleFromSchema(snapshot, {\n emptyString: 'string',\n })\n}\n"],"mappings":";;;;;;AAQA,IAAMK,KAAuBC,GAAiBC,oBAAO,IAAI,IAAa,MAAe;CACnF,IAAMC,IAASR,EAAuBM,CAAM;CAQ5C,OAPIE,MAAW,KACN,KAEL,CAACP,EAASO,CAAM,KAAKD,EAAK,IAAIC,CAAM,IAC/B,MAETD,EAAK,IAAIC,CAAM,GACR,MAAM,QAAQA,EAAO,KAAK,KAAKA,EAAO,MAAM,MAAMC,MAAWJ,EAAoBI,GAAQF,CAAI,CAAC;AACvG,GAGaG,KAA8BC,MAA4C;CACrF,IAAIA,EAAQ,UAAU,MAAMC,MAAYZ,EAAuBY,CAAO,CAAC,EAAE,YAAY,KAAA,CAAS,GAC5F;CAGF,IAAMC,IAAUb,EAAuBW,EAAQ,OAAO;CAEtD,IACE,OAAOE,KAAY,aAClBZ,EAASY,CAAO,KAAK,kBAAkBA,KAAW,OAAOb,EAAuBa,EAAQ,MAAM,KAAM,WAErG;CAGF,IAAMC,IAAWZ,EAAsBS,EAAQ,OAAO,GAChDH,IAASM,GAAU,SAAS,WAAWA,EAAS,SAAS,KAAA;CAC/D,IAAI,CAACN,KAAUH,EAAoBG,CAAM,GACvC;CAKF,IAAMO,IAAWZ,EAAeK,CAAM;CACtC,OAAOJ,EAAqBW,GAAU,EACpC,aAAa,SACf,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-message-example-content.js","names":["getMessageExampleContent","value","json","contentType","isJsonMediaType","structured","isObject","structural","parseMimeType","lang","isXmlMediaType","subtype","prettyPrintJson"],"sources":["../../../src/code-example/helpers/get-message-example-content.ts"],"sourcesContent":["import { isJsonMediaType } from '@scalar/helpers/http/is-json-media-type'\nimport { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { parseMimeType } from '@scalar/helpers/http/mime-type'\nimport { prettyPrintJson } from '@scalar/helpers/json/pretty-print-json'\nimport { isObject } from '@scalar/helpers/object/is-object'\n\n/** Keep the displayed sample, language, and clipboard representation together. */\ntype MessageExampleContent = {\n content: string\n lang: 'json' | 'xml' | 'yaml' | 'plaintext'\n structural: boolean\n}\n\n/** Format payload values without interpreting non-JSON text as JSON or inventing wire encodings. */\nexport const getMessageExampleContent = (value: unknown, contentType?: string): MessageExampleContent | undefined => {\n if (value === undefined) {\n return undefined\n }\n const json = contentType === undefined || isJsonMediaType(contentType)\n const structured = Array.isArray(value) || isObject(value)\n const structural = !json && structured\n const { subtype } = parseMimeType(contentType)\n const lang =\n json || structural\n ? 'json'\n : isXmlMediaType(contentType)\n ? 'xml'\n : subtype === 'yaml' || subtype === 'x-yaml' || subtype.endsWith('+yaml')\n ? 'yaml'\n : 'plaintext'\n\n if (value === null || typeof value === 'boolean') {\n return { content: String(value), lang, structural }\n }\n if (typeof value === 'string') {\n return { content: json ? prettyPrintJson(value) : value, lang, structural }\n }\n if (typeof value === 'number' || Array.isArray(value) || isObject(value)) {\n return { content: prettyPrintJson(value), lang, structural }\n }\n return undefined\n}\n"],"mappings":";;;;;;AAcA,IAAaA,KAA4B,GAAgB,MAA4D;CACnH,IAAIC,MAAU,KAAA,GACZ;CAEF,IAAMC,IAAOC,MAAgB,KAAA,KAAaC,EAAgBD,CAAW,GAC/DE,IAAa,MAAM,QAAQJ,CAAK,KAAKK,EAASL,CAAK,GACnDM,IAAa,CAACL,KAAQG,GACtB,EAAE,eAAYG,EAAcL,CAAW,GACvCM,IACJP,KAAQK,IACJ,SACAG,EAAeP,CAAW,IACxB,QACAQ,MAAY,UAAUA,MAAY,YAAYA,EAAQ,SAAS,OAAO,IACpE,SACA;CAEV,IAAIV,MAAU,QAAQ,OAAOA,KAAU,WACrC,OAAO;EAAE,SAAS,OAAOA,CAAK;EAAG;EAAM;CAAW;CAEpD,IAAI,OAAOA,KAAU,UACnB,OAAO;EAAE,SAASC,IAAOU,EAAgBX,CAAK,IAAIA;EAAO;EAAM;CAAW;CAE5E,IAAI,OAAOA,KAAU,YAAY,MAAM,QAAQA,CAAK,KAAKK,EAASL,CAAK,GACrE,OAAO;EAAE,SAASW,EAAgBX,CAAK;EAAG;EAAM;CAAW;AAG/D"}
1
+ {"version":3,"file":"get-message-example-content.js","names":["isObject","isJsonMediaType","isXmlMediaType","parseMimeType","prettyPrintJson","getMessageExampleContent","value","contentType","json","structured","structural","subtype","lang"],"sources":["../../../src/code-example/helpers/get-message-example-content.ts"],"sourcesContent":["import { isJsonMediaType } from '@scalar/helpers/http/is-json-media-type'\nimport { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { parseMimeType } from '@scalar/helpers/http/mime-type'\nimport { prettyPrintJson } from '@scalar/helpers/json/pretty-print-json'\nimport { isObject } from '@scalar/helpers/object/is-object'\n\n/** Keep the displayed sample, language, and clipboard representation together. */\ntype MessageExampleContent = {\n content: string\n lang: 'json' | 'xml' | 'yaml' | 'plaintext'\n structural: boolean\n}\n\n/** Format payload values without interpreting non-JSON text as JSON or inventing wire encodings. */\nexport const getMessageExampleContent = (value: unknown, contentType?: string): MessageExampleContent | undefined => {\n if (value === undefined) {\n return undefined\n }\n const json = contentType === undefined || isJsonMediaType(contentType)\n const structured = Array.isArray(value) || isObject(value)\n const structural = !json && structured\n const { subtype } = parseMimeType(contentType)\n const lang =\n json || structural\n ? 'json'\n : isXmlMediaType(contentType)\n ? 'xml'\n : subtype === 'yaml' || subtype === 'x-yaml' || subtype.endsWith('+yaml')\n ? 'yaml'\n : 'plaintext'\n\n if (value === null || typeof value === 'boolean') {\n return { content: String(value), lang, structural }\n }\n if (typeof value === 'string') {\n return { content: json ? prettyPrintJson(value) : value, lang, structural }\n }\n if (typeof value === 'number' || Array.isArray(value) || isObject(value)) {\n return { content: prettyPrintJson(value), lang, structural }\n }\n return undefined\n}\n"],"mappings":";;;;;;AAcA,IAAaK,KAA4BC,GAAgBC,MAA4D;CACnH,IAAID,MAAU,KAAA,GACZ;CAEF,IAAME,IAAOD,MAAgB,KAAA,KAAaN,EAAgBM,CAAW,GAC/DE,IAAa,MAAM,QAAQH,CAAK,KAAKN,EAASM,CAAK,GACnDI,IAAa,CAACF,KAAQC,GACtB,EAAEE,eAAYR,EAAcI,CAAW,GACvCK,IACJJ,KAAQE,IACJ,SACAR,EAAeK,CAAW,IACxB,QACAI,MAAY,UAAUA,MAAY,YAAYA,EAAQ,SAAS,OAAO,IACpE,SACA;CAEV,IAAIL,MAAU,QAAQ,OAAOA,KAAU,WACrC,OAAO;EAAE,SAAS,OAAOA,CAAK;EAAGM;EAAMF;CAAW;CAEpD,IAAI,OAAOJ,KAAU,UACnB,OAAO;EAAE,SAASE,IAAOJ,EAAgBE,CAAK,IAAIA;EAAOM;EAAMF;CAAW;CAE5E,IAAI,OAAOJ,KAAU,YAAY,MAAM,QAAQA,CAAK,KAAKN,EAASM,CAAK,GACrE,OAAO;EAAE,SAASF,EAAgBE,CAAK;EAAGM;EAAMF;CAAW;AAG/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-secrets.js","names":["getSecrets","securitySchemes","scheme","encode","flow"],"sources":["../../../src/code-example/helpers/get-secrets.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport { encode } from 'js-base64'\n\n/** Extract secrets from security schemes */\nexport const getSecrets = (securitySchemes: SecuritySchemeObjectSecret[]): string[] =>\n securitySchemes\n .flatMap((scheme) => {\n if (scheme.type === 'apiKey') {\n return scheme['x-scalar-secret-token']\n }\n if (scheme?.type === 'http') {\n return [\n scheme['x-scalar-secret-token'],\n scheme['x-scalar-secret-username'],\n scheme['x-scalar-secret-password'],\n encode(`${scheme['x-scalar-secret-username']}:${scheme['x-scalar-secret-password']}`),\n ]\n }\n if (scheme.type === 'oauth2') {\n const flows = Object.values(scheme.flows)\n return flows.map((flow) => flow['x-scalar-secret-token'])\n }\n\n return []\n })\n .filter(Boolean)\n"],"mappings":";;AAIA,IAAaA,KAAc,MACzBC,EACG,SAAS,MACJC,EAAO,SAAS,WACXA,EAAO,2BAEZA,GAAQ,SAAS,SACZ;CACLA,EAAO;CACPA,EAAO;CACPA,EAAO;CACPC,EAAO,GAAGD,EAAO,4BAA4B,GAAGA,EAAO,6BAA6B;AACtF,IAEEA,EAAO,SAAS,WACJ,OAAO,OAAOA,EAAO,KAC5B,CAAA,CAAM,KAAK,MAASE,EAAK,wBAAwB,IAGnD,CAAC,CACT,CAAC,CACD,OAAO,OAAO"}
1
+ {"version":3,"file":"get-secrets.js","names":["encode","getSecrets","securitySchemes","scheme","flow"],"sources":["../../../src/code-example/helpers/get-secrets.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport { encode } from 'js-base64'\n\n/** Extract secrets from security schemes */\nexport const getSecrets = (securitySchemes: SecuritySchemeObjectSecret[]): string[] =>\n securitySchemes\n .flatMap((scheme) => {\n if (scheme.type === 'apiKey') {\n return scheme['x-scalar-secret-token']\n }\n if (scheme?.type === 'http') {\n return [\n scheme['x-scalar-secret-token'],\n scheme['x-scalar-secret-username'],\n scheme['x-scalar-secret-password'],\n encode(`${scheme['x-scalar-secret-username']}:${scheme['x-scalar-secret-password']}`),\n ]\n }\n if (scheme.type === 'oauth2') {\n const flows = Object.values(scheme.flows)\n return flows.map((flow) => flow['x-scalar-secret-token'])\n }\n\n return []\n })\n .filter(Boolean)\n"],"mappings":";;AAIA,IAAaC,KAAcC,MACzBA,EACG,SAASC,MACJA,EAAO,SAAS,WACXA,EAAO,2BAEZA,GAAQ,SAAS,SACZ;CACLA,EAAO;CACPA,EAAO;CACPA,EAAO;CACPH,EAAO,GAAGG,EAAO,4BAA4B,GAAGA,EAAO,6BAA6B;AACtF,IAEEA,EAAO,SAAS,WACJ,OAAO,OAAOA,EAAO,KAC5B,CAAA,CAAM,KAAKC,MAASA,EAAK,wBAAwB,IAGnD,CAAC,CACT,CAAC,CACD,OAAO,OAAO"}
@@ -1,8 +1,8 @@
1
1
  import type { ErrorResponse } from '@scalar/helpers/errors/normalize-error';
2
- import { type ClientId, type TargetId } from '@scalar/snippetz';
2
+ import { type ClientId, type PluginConfiguration, type TargetId } from '@scalar/snippetz';
3
3
  import type { Request as HarRequest } from 'har-format';
4
4
  /**
5
5
  * Returns a code example for given operation
6
6
  */
7
- export declare const getSnippet: <T extends TargetId>(target: T, client: ClientId<T>, harRequest: HarRequest) => ErrorResponse<string>;
7
+ export declare const getSnippet: <T extends TargetId>(target: T, client: ClientId<T>, harRequest: HarRequest, configuration?: PluginConfiguration) => ErrorResponse<string>;
8
8
  //# sourceMappingURL=get-snippet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-snippet.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/get-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAY,MAAM,kBAAkB,CAAA;AACzE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAKvD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,QAAQ,EAC3C,QAAQ,CAAC,EACT,QAAQ,QAAQ,CAAC,CAAC,CAAC,EACnB,YAAY,UAAU,KACrB,aAAa,CAAC,MAAM,CAsCtB,CAAA"}
1
+ {"version":3,"file":"get-snippet.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/get-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAY,MAAM,kBAAkB,CAAA;AACnG,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAKvD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,QAAQ,EAC3C,QAAQ,CAAC,EACT,QAAQ,QAAQ,CAAC,CAAC,CAAC,EACnB,YAAY,UAAU,EACtB,gBAAgB,mBAAmB,KAClC,aAAa,CAAC,MAAM,CAkCtB,CAAA"}
@@ -1,22 +1,20 @@
1
1
  import { snippetz as e } from "@scalar/snippetz";
2
2
  // src/code-example/helpers/get-snippet.ts
3
- var t = "ws://replace.me", n = (n, r, i) => {
3
+ var t = "ws://replace.me", n = (n, r, i, a) => {
4
4
  try {
5
5
  if (!i.url) return [/* @__PURE__ */ Error("Please enter a URL to see a code snippet"), null];
6
- let a = i.url.startsWith("/") ? "" : "/";
7
- try {
8
- new URL(i.url);
9
- } catch {
10
- i.url = `${t}${a}${i.url}`;
11
- }
6
+ let o = i.url.startsWith("/") ? "" : "/", s = URL.canParse(i.url) ? "" : `${t}${o}`, c = `${s}${i.url}`;
12
7
  if (i.postData?.mimeType === "application/json") try {
13
8
  JSON.parse(i.postData.text || "{}");
14
9
  } catch (e) {
15
10
  return console.error("[getSnippet] Invalid JSON body", e), [/* @__PURE__ */ Error("Invalid JSON body"), null];
16
11
  }
17
12
  if (e().hasPlugin(n, r)) {
18
- let o = e().print(n, r, i);
19
- return o ? [null, o.replace(`${t}${a}`, "")] : [/* @__PURE__ */ Error("Error generating snippet"), null];
13
+ let t = e().print(n, r, {
14
+ ...i,
15
+ url: c
16
+ }, a);
17
+ return t ? [null, s ? t.replace(s, "") : t] : [/* @__PURE__ */ Error("Error generating snippet"), null];
20
18
  }
21
19
  } catch (e) {
22
20
  return console.error("[getSnippet] Error generating snippet", e), [/* @__PURE__ */ Error("Error generating snippet"), null];
@@ -1 +1 @@
1
- {"version":3,"file":"get-snippet.js","names":["INVALID_URLS_PREFIX","getSnippet","harRequest","separator","error","snippetz","target","client","payload"],"sources":["../../../src/code-example/helpers/get-snippet.ts"],"sourcesContent":["import type { ErrorResponse } from '@scalar/helpers/errors/normalize-error'\nimport { type ClientId, type TargetId, snippetz } from '@scalar/snippetz'\nimport type { Request as HarRequest } from 'har-format'\n\n/** Key used to hack around the invalid urls */\nconst INVALID_URLS_PREFIX = 'ws://replace.me'\n\n/**\n * Returns a code example for given operation\n */\nexport const getSnippet = <T extends TargetId>(\n target: T,\n client: ClientId<T>,\n harRequest: HarRequest,\n): ErrorResponse<string> => {\n try {\n if (!harRequest.url) {\n return [new Error('Please enter a URL to see a code snippet'), null]\n }\n\n const separator = harRequest.url.startsWith('/') ? '' : '/'\n\n // Hack to get around invalid URLS until we update the snippets lib\n try {\n new URL(harRequest.url)\n } catch {\n harRequest.url = `${INVALID_URLS_PREFIX}${separator}${harRequest.url}`\n }\n\n // Ensure we have valid JSON\n if (harRequest.postData?.mimeType === 'application/json') {\n try {\n JSON.parse(harRequest.postData.text || '{}')\n } catch (error) {\n console.error('[getSnippet] Invalid JSON body', error)\n return [new Error('Invalid JSON body'), null]\n }\n }\n if (snippetz().hasPlugin(target, client)) {\n const payload = snippetz().print(target, client, harRequest)\n if (!payload) {\n return [new Error('Error generating snippet'), null]\n }\n\n return [null, payload.replace(`${INVALID_URLS_PREFIX}${separator}`, '')]\n }\n } catch (error) {\n console.error('[getSnippet] Error generating snippet', error)\n return [new Error('Error generating snippet'), null]\n }\n\n return [new Error('No snippet found'), null]\n}\n"],"mappings":";;AAKA,IAAMA,IAAsB,mBAKfC,KACX,GACA,GACA,MAC0B;CAC1B,IAAI;EACF,IAAI,CAACC,EAAW,KACd,OAAO,CAAC,gBAAI,MAAM,0CAA0C,GAAG,IAAI;EAGrE,IAAMC,IAAYD,EAAW,IAAI,WAAW,GAAG,IAAI,KAAK;EAGxD,IAAI;GACF,IAAI,IAAIA,EAAW,GAAG;EACxB,QAAQ;GACN,EAAW,MAAM,GAAGF,IAAsBG,IAAYD,EAAW;EACnE;EAGA,IAAIA,EAAW,UAAU,aAAa,oBACpC,IAAI;GACF,KAAK,MAAMA,EAAW,SAAS,QAAQ,IAAI;EAC7C,SAASE,GAAO;GAEd,OADA,QAAQ,MAAM,kCAAkCA,CAAK,GAC9C,CAAC,gBAAI,MAAM,mBAAmB,GAAG,IAAI;EAC9C;EAEF,IAAIC,EAAS,CAAC,CAAC,UAAUC,GAAQC,CAAM,GAAG;GACxC,IAAMC,IAAUH,EAAS,CAAC,CAAC,MAAMC,GAAQC,GAAQL,CAAU;GAK3D,OAJKM,IAIE,CAAC,MAAMA,EAAQ,QAAQ,GAAGR,IAAsBG,KAAa,EAAE,CAAC,IAH9D,CAAC,gBAAI,MAAM,0BAA0B,GAAG,IAAI;EAIvD;CACF,SAASC,GAAO;EAEd,OADA,QAAQ,MAAM,yCAAyCA,CAAK,GACrD,CAAC,gBAAI,MAAM,0BAA0B,GAAG,IAAI;CACrD;CAEA,OAAO,CAAC,gBAAI,MAAM,kBAAkB,GAAG,IAAI;AAC7C"}
1
+ {"version":3,"file":"get-snippet.js","names":["snippetz","INVALID_URLS_PREFIX","getSnippet","target","client","harRequest","configuration","separator","prefix","url","error","payload"],"sources":["../../../src/code-example/helpers/get-snippet.ts"],"sourcesContent":["import type { ErrorResponse } from '@scalar/helpers/errors/normalize-error'\nimport { type ClientId, type PluginConfiguration, type TargetId, snippetz } from '@scalar/snippetz'\nimport type { Request as HarRequest } from 'har-format'\n\n/** Key used to hack around the invalid urls */\nconst INVALID_URLS_PREFIX = 'ws://replace.me'\n\n/**\n * Returns a code example for given operation\n */\nexport const getSnippet = <T extends TargetId>(\n target: T,\n client: ClientId<T>,\n harRequest: HarRequest,\n configuration?: PluginConfiguration,\n): ErrorResponse<string> => {\n try {\n if (!harRequest.url) {\n return [new Error('Please enter a URL to see a code snippet'), null]\n }\n\n // Hack to get around invalid URLS until we update the snippets lib\n const separator = harRequest.url.startsWith('/') ? '' : '/'\n const prefix = URL.canParse(harRequest.url) ? '' : `${INVALID_URLS_PREFIX}${separator}`\n const url = `${prefix}${harRequest.url}`\n\n // Ensure we have valid JSON\n if (harRequest.postData?.mimeType === 'application/json') {\n try {\n JSON.parse(harRequest.postData.text || '{}')\n } catch (error) {\n console.error('[getSnippet] Invalid JSON body', error)\n return [new Error('Invalid JSON body'), null]\n }\n }\n if (snippetz().hasPlugin(target, client)) {\n const payload = snippetz().print(target, client, { ...harRequest, url }, configuration)\n if (!payload) {\n return [new Error('Error generating snippet'), null]\n }\n\n return [null, prefix ? payload.replace(prefix, '') : payload]\n }\n } catch (error) {\n console.error('[getSnippet] Error generating snippet', error)\n return [new Error('Error generating snippet'), null]\n }\n\n return [new Error('No snippet found'), null]\n}\n"],"mappings":";;AAKA,IAAMC,IAAsB,mBAKfC,KACXC,GACAC,GACAC,GACAC,MAC0B;CAC1B,IAAI;EACF,IAAI,CAACD,EAAW,KACd,OAAO,CAAC,gBAAI,MAAM,0CAA0C,GAAG,IAAI;EAIrE,IAAME,IAAYF,EAAW,IAAI,WAAW,GAAG,IAAI,KAAK,KAClDG,IAAS,IAAI,SAASH,EAAW,GAAG,IAAI,KAAK,GAAGJ,IAAsBM,KACtEE,IAAM,GAAGD,IAASH,EAAW;EAGnC,IAAIA,EAAW,UAAU,aAAa,oBACpC,IAAI;GACF,KAAK,MAAMA,EAAW,SAAS,QAAQ,IAAI;EAC7C,SAASK,GAAO;GAEd,OADA,QAAQ,MAAM,kCAAkCA,CAAK,GAC9C,CAAC,gBAAI,MAAM,mBAAmB,GAAG,IAAI;EAC9C;EAEF,IAAIV,EAAS,CAAC,CAAC,UAAUG,GAAQC,CAAM,GAAG;GACxC,IAAMO,IAAUX,EAAS,CAAC,CAAC,MAAMG,GAAQC,GAAQ;IAAE,GAAGC;IAAYI;GAAI,GAAGH,CAAa;GAKtF,OAJKK,IAIE,CAAC,MAAMH,IAASG,EAAQ,QAAQH,GAAQ,EAAE,IAAIG,CAAO,IAHnD,CAAC,gBAAI,MAAM,0BAA0B,GAAG,IAAI;EAIvD;CACF,SAASD,GAAO;EAEd,OADA,QAAQ,MAAM,yCAAyCA,CAAK,GACrD,CAAC,gBAAI,MAAM,0BAA0B,GAAG,IAAI;CACrD;CAEA,OAAO,CAAC,gBAAI,MAAM,kBAAkB,GAAG,IAAI;AAC7C"}
@@ -1,8 +1,8 @@
1
1
  import type { MultipartNaming } from '@scalar/types/api-reference';
2
+ import type { HarRequest } from '@scalar/types/snippetz';
2
3
  import { type SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
3
4
  import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
4
5
  import type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
5
- import type { Request as HarRequest } from 'har-format';
6
6
  export type OperationToHarProps = {
7
7
  /** OpenAPI Operation object */
8
8
  operation: OperationObject;
@@ -1 +1 @@
1
- {"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACjH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AASvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;;OAGG;IACH,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,mOAe5B,mBAAmB,KAAG,UAgKxB,CAAA"}
1
+ {"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AASjH,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;;OAGG;IACH,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,mOAe5B,mBAAmB,KAAG,UAkKxB,CAAA"}
@@ -61,7 +61,7 @@ var u = ({ includeDefaultHeaders: u = !1, operation: d, contentType: f, method:
61
61
  multipartNaming: x,
62
62
  requestBodyCompositionSelection: S
63
63
  });
64
- if (e && (D.postData = e, D.bodySize = e.text?.length ?? -1, e.mimeType)) {
64
+ if (e && (D.postData = e, e._fileName === void 0 && (D.bodySize = e.text?.length ?? -1), e.mimeType)) {
65
65
  let t = D.headers.find((e) => e.name.toLowerCase() === "content-type");
66
66
  t && (!t.value || e.mimeType.startsWith("multipart/") && e.mimeType.includes("boundary=") && e.text !== void 0) ? t.value = e.mimeType : t || D.headers.push({
67
67
  name: "Content-Type",
@@ -1 +1 @@
1
- {"version":3,"file":"operation-to-har.js","names":["operationToHar","defaultHeaders","includeDefaultHeaders","getDefaultHeaders","example","isElectron","APP_VERSION","defaultHeadersWithConventionalNames","restoreConventionalDefaultHeaderNames","disabledGlobalCookies","operation","harRequest","processServerUrl","server","path","name","value","hasCookieStyleEntries","hasSerializedQuery","processedCookieStyleEntries","processedSerializedQuery","processParameters","defaultDisabledParameters","filteredGlobalCookies","globalCookies","filterGlobalCookie","cookie","url","headers","queryString","cookies","body","getResolvedRef","postData","processBody","existingContentTypeHeader","header","hasUriReadyQuery","parameter","securitySchemes","processSecuritySchemes","cookieHeader","extraCookies","hashIndex","hash","query","headersSize","h"],"sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"sourcesContent":["import { isElectron } from '@scalar/helpers/general/is-electron'\nimport type { MultipartNaming } from '@scalar/types/api-reference'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type SecuritySchemeObjectSecret,\n filterGlobalCookie,\n getDefaultHeaders,\n restoreConventionalDefaultHeaderNames,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { APP_VERSION } from '@/constants'\n\nimport { processBody } from './process-body'\nimport { processParameters } from './process-parameters'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport { processServerUrl } from './process-server-url'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OperationObject\n /** HTTP method of the operation */\n method: string\n /** Path of the operation */\n path: string\n /**\n * Name of the currently selected operation example\n *\n * Applies to both the body and the parameters\n */\n example?: string\n /**\n * Content type of the operation\n *\n * Applies to both the body and the parameters (if applicable)\n * @defaults to the first content type in the MediaTypeObject\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | null\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /**\n * Whether to include default headers (e.g., Accept, Content-Type) automatically.\n * If false, default headers will be omitted from the HAR request.\n * @default true\n */\n includeDefaultHeaders?: boolean\n /**\n * Selected oneOf/anyOf variants for nested request body example generation\n * (e.g. from the schema dropdowns in the API reference).\n */\n /** Originating OpenAPI version, used for version-specific serialization. */\n openapiVersion?: string\n jsonSchemaDialect?: string\n multipartNaming?: MultipartNaming\n requestBodyCompositionSelection?: Record<string, number>\n /**\n * Whether to disable parameters by default.\n * @default false\n */\n defaultDisabledParameters?: boolean\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n includeDefaultHeaders = false,\n operation,\n contentType,\n method,\n path,\n server = null,\n example,\n securitySchemes,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n multipartNaming,\n requestBodyCompositionSelection,\n defaultDisabledParameters = false,\n}: OperationToHarProps): HarRequest => {\n const defaultHeaders = includeDefaultHeaders\n ? getDefaultHeaders({\n method,\n operation,\n exampleName: example ?? 'default',\n hideDisabledHeaders: true,\n hideOverriddenHeaders: true,\n options: { isElectron: isElectron(), appVersion: APP_VERSION },\n })\n : {}\n const defaultHeadersWithConventionalNames = restoreConventionalDefaultHeaderNames(defaultHeaders)\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[example ?? 'default'] ?? {}\n\n const serverUrl = processServerUrl(server, path)\n\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: serverUrl,\n headers: Object.entries(defaultHeadersWithConventionalNames).map(([name, value]) => ({ name, value })),\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n let hasCookieStyleEntries = false\n let hasSerializedQuery = false\n\n // Handle parameters\n if (operation.parameters) {\n const {\n url,\n headers,\n queryString,\n cookies,\n hasCookieStyleEntries: processedCookieStyleEntries,\n hasSerializedQuery: processedSerializedQuery,\n } = processParameters({\n harRequest,\n parameters: operation.parameters,\n openapiVersion,\n jsonSchemaDialect,\n example,\n defaultDisabled: defaultDisabledParameters,\n })\n\n // Correctly filter the global cookies by the processed url\n const filteredGlobalCookies =\n globalCookies\n ?.filter((cookie) => filterGlobalCookie({ cookie, url, disabledGlobalCookies }))\n ?.map((cookie) => ({ name: cookie.name, value: cookie.value })) ?? []\n\n hasCookieStyleEntries = processedCookieStyleEntries\n hasSerializedQuery = processedSerializedQuery ?? false\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = [...filteredGlobalCookies, ...cookies]\n }\n\n const body = getResolvedRef(operation.requestBody)\n\n // Handle request body\n if (body?.content) {\n const postData = processBody({\n requestBody: body,\n contentType,\n example,\n openapiVersion,\n jsonSchemaDialect,\n multipartNaming,\n requestBodyCompositionSelection,\n })\n\n if (postData) {\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n\n // Add or update Content-Type header\n if (postData.mimeType) {\n const existingContentTypeHeader = harRequest.headers.find(\n (header) => header.name.toLowerCase() === 'content-type',\n )\n // Update existing header if it has an empty value\n if (\n existingContentTypeHeader &&\n (!existingContentTypeHeader.value ||\n (postData.mimeType.startsWith('multipart/') &&\n postData.mimeType.includes('boundary=') &&\n postData.text !== undefined))\n ) {\n existingContentTypeHeader.value = postData.mimeType\n }\n // Add new header if none exists\n else if (!existingContentTypeHeader) {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n }\n }\n\n const hasUriReadyQuery =\n hasSerializedQuery || operation.parameters?.some((parameter) => getResolvedRef(parameter)?.in === 'querystring')\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n harRequest.queryString.push(...queryString)\n harRequest.cookies.push(...cookies)\n }\n\n // Keep authentication and global cookies in the explicit header as well, so\n // snippet generators cannot replace cookie-style parameters with their own header.\n const cookieHeader = harRequest.headers.find((header) => header.name.toLowerCase() === 'cookie')\n if (hasCookieStyleEntries && cookieHeader && harRequest.cookies.length) {\n const extraCookies = harRequest.cookies\n .map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`)\n .join('; ')\n cookieHeader.value = cookieHeader.value ? `${cookieHeader.value}; ${extraCookies}` : extraCookies\n harRequest.cookies = []\n }\n\n // Whole-query content and serialized examples must retain their authored URI encoding.\n // Keeping all query data in the URL avoids snippet generators introducing a second question mark.\n if (hasUriReadyQuery && harRequest.queryString.length) {\n const hashIndex = harRequest.url.indexOf('#')\n const hash = hashIndex === -1 ? '' : harRequest.url.slice(hashIndex)\n const url = hashIndex === -1 ? harRequest.url : harRequest.url.slice(0, hashIndex)\n const query = harRequest.queryString\n .map(({ name, value }) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`)\n .join('&')\n harRequest.url = `${url}${url.includes('?') ? '&' : '?'}${query}${hash}`\n harRequest.queryString = []\n }\n\n // Structured multipart parts (with or without files) are encoded by the HTTP client, which owns the boundary.\n // Raw multipart text already has its boundary and must retain its Content-Type.\n if (harRequest.postData?.mimeType === 'multipart/form-data' && harRequest.postData.params?.length) {\n harRequest.headers = harRequest.headers.filter((header) => header.name.toLowerCase() !== 'content-type')\n }\n\n // Calculate headers size without allocating a large joined string\n let headersSize = 0\n for (const h of harRequest.headers) {\n // name + \": \" + value + \"\\r\\n\"\n headersSize += (h.name?.length ?? 0) + 2 + (h.value?.length ?? 0) + 2\n }\n harRequest.headersSize = headersSize\n\n return harRequest\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"operation-to-har.js","names":["APP_VERSION","processBody","processParameters","processSecuritySchemes","processServerUrl","filterGlobalCookie","getDefaultHeaders","restoreConventionalDefaultHeaderNames","getResolvedRef","isElectron","operationToHar","includeDefaultHeaders","operation","contentType","method","path","server","example","securitySchemes","globalCookies","openapiVersion","jsonSchemaDialect","multipartNaming","requestBodyCompositionSelection","defaultDisabledParameters","defaultHeaders","defaultHeadersWithConventionalNames","disabledGlobalCookies","harRequest","name","value","hasCookieStyleEntries","hasSerializedQuery","url","headers","queryString","cookies","processedCookieStyleEntries","processedSerializedQuery","filteredGlobalCookies","cookie","body","postData","existingContentTypeHeader","header","hasUriReadyQuery","parameter","cookieHeader","extraCookies","hashIndex","hash","query","headersSize","h"],"sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"sourcesContent":["import { isElectron } from '@scalar/helpers/general/is-electron'\nimport type { MultipartNaming } from '@scalar/types/api-reference'\nimport type { HarRequest } from '@scalar/types/snippetz'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type SecuritySchemeObjectSecret,\n filterGlobalCookie,\n getDefaultHeaders,\n restoreConventionalDefaultHeaderNames,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { APP_VERSION } from '@/constants'\n\nimport { processBody } from './process-body'\nimport { processParameters } from './process-parameters'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport { processServerUrl } from './process-server-url'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OperationObject\n /** HTTP method of the operation */\n method: string\n /** Path of the operation */\n path: string\n /**\n * Name of the currently selected operation example\n *\n * Applies to both the body and the parameters\n */\n example?: string\n /**\n * Content type of the operation\n *\n * Applies to both the body and the parameters (if applicable)\n * @defaults to the first content type in the MediaTypeObject\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | null\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /**\n * Whether to include default headers (e.g., Accept, Content-Type) automatically.\n * If false, default headers will be omitted from the HAR request.\n * @default true\n */\n includeDefaultHeaders?: boolean\n /**\n * Selected oneOf/anyOf variants for nested request body example generation\n * (e.g. from the schema dropdowns in the API reference).\n */\n /** Originating OpenAPI version, used for version-specific serialization. */\n openapiVersion?: string\n jsonSchemaDialect?: string\n multipartNaming?: MultipartNaming\n requestBodyCompositionSelection?: Record<string, number>\n /**\n * Whether to disable parameters by default.\n * @default false\n */\n defaultDisabledParameters?: boolean\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n includeDefaultHeaders = false,\n operation,\n contentType,\n method,\n path,\n server = null,\n example,\n securitySchemes,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n multipartNaming,\n requestBodyCompositionSelection,\n defaultDisabledParameters = false,\n}: OperationToHarProps): HarRequest => {\n const defaultHeaders = includeDefaultHeaders\n ? getDefaultHeaders({\n method,\n operation,\n exampleName: example ?? 'default',\n hideDisabledHeaders: true,\n hideOverriddenHeaders: true,\n options: { isElectron: isElectron(), appVersion: APP_VERSION },\n })\n : {}\n const defaultHeadersWithConventionalNames = restoreConventionalDefaultHeaderNames(defaultHeaders)\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[example ?? 'default'] ?? {}\n\n const serverUrl = processServerUrl(server, path)\n\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: serverUrl,\n headers: Object.entries(defaultHeadersWithConventionalNames).map(([name, value]) => ({ name, value })),\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n let hasCookieStyleEntries = false\n let hasSerializedQuery = false\n\n // Handle parameters\n if (operation.parameters) {\n const {\n url,\n headers,\n queryString,\n cookies,\n hasCookieStyleEntries: processedCookieStyleEntries,\n hasSerializedQuery: processedSerializedQuery,\n } = processParameters({\n harRequest,\n parameters: operation.parameters,\n openapiVersion,\n jsonSchemaDialect,\n example,\n defaultDisabled: defaultDisabledParameters,\n })\n\n // Correctly filter the global cookies by the processed url\n const filteredGlobalCookies =\n globalCookies\n ?.filter((cookie) => filterGlobalCookie({ cookie, url, disabledGlobalCookies }))\n ?.map((cookie) => ({ name: cookie.name, value: cookie.value })) ?? []\n\n hasCookieStyleEntries = processedCookieStyleEntries\n hasSerializedQuery = processedSerializedQuery ?? false\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = [...filteredGlobalCookies, ...cookies]\n }\n\n const body = getResolvedRef(operation.requestBody)\n\n // Handle request body\n if (body?.content) {\n const postData = processBody({\n requestBody: body,\n contentType,\n example,\n openapiVersion,\n jsonSchemaDialect,\n multipartNaming,\n requestBodyCompositionSelection,\n })\n\n if (postData) {\n harRequest.postData = postData\n if (postData._fileName === undefined) {\n harRequest.bodySize = postData.text?.length ?? -1\n }\n\n // Add or update Content-Type header\n if (postData.mimeType) {\n const existingContentTypeHeader = harRequest.headers.find(\n (header) => header.name.toLowerCase() === 'content-type',\n )\n // Update existing header if it has an empty value\n if (\n existingContentTypeHeader &&\n (!existingContentTypeHeader.value ||\n (postData.mimeType.startsWith('multipart/') &&\n postData.mimeType.includes('boundary=') &&\n postData.text !== undefined))\n ) {\n existingContentTypeHeader.value = postData.mimeType\n }\n // Add new header if none exists\n else if (!existingContentTypeHeader) {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n }\n }\n\n const hasUriReadyQuery =\n hasSerializedQuery || operation.parameters?.some((parameter) => getResolvedRef(parameter)?.in === 'querystring')\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n harRequest.queryString.push(...queryString)\n harRequest.cookies.push(...cookies)\n }\n\n // Keep authentication and global cookies in the explicit header as well, so\n // snippet generators cannot replace cookie-style parameters with their own header.\n const cookieHeader = harRequest.headers.find((header) => header.name.toLowerCase() === 'cookie')\n if (hasCookieStyleEntries && cookieHeader && harRequest.cookies.length) {\n const extraCookies = harRequest.cookies\n .map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`)\n .join('; ')\n cookieHeader.value = cookieHeader.value ? `${cookieHeader.value}; ${extraCookies}` : extraCookies\n harRequest.cookies = []\n }\n\n // Whole-query content and serialized examples must retain their authored URI encoding.\n // Keeping all query data in the URL avoids snippet generators introducing a second question mark.\n if (hasUriReadyQuery && harRequest.queryString.length) {\n const hashIndex = harRequest.url.indexOf('#')\n const hash = hashIndex === -1 ? '' : harRequest.url.slice(hashIndex)\n const url = hashIndex === -1 ? harRequest.url : harRequest.url.slice(0, hashIndex)\n const query = harRequest.queryString\n .map(({ name, value }) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`)\n .join('&')\n harRequest.url = `${url}${url.includes('?') ? '&' : '?'}${query}${hash}`\n harRequest.queryString = []\n }\n\n // Structured multipart parts (with or without files) are encoded by the HTTP client, which owns the boundary.\n // Raw multipart text already has its boundary and must retain its Content-Type.\n if (harRequest.postData?.mimeType === 'multipart/form-data' && harRequest.postData.params?.length) {\n harRequest.headers = harRequest.headers.filter((header) => header.name.toLowerCase() !== 'content-type')\n }\n\n // Calculate headers size without allocating a large joined string\n let headersSize = 0\n for (const h of harRequest.headers) {\n // name + \": \" + value + \"\\r\\n\"\n headersSize += (h.name?.length ?? 0) + 2 + (h.value?.length ?? 0) + 2\n }\n harRequest.headersSize = headersSize\n\n return harRequest\n}\n"],"mappings":"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"}
@@ -1,5 +1,5 @@
1
+ import type { HarRequest } from '@scalar/types/snippetz';
1
2
  import type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
2
- import type { PostData } from 'har-format';
3
3
  import type { OperationToHarProps } from './operation-to-har';
4
4
  type ProcessBodyProps = Pick<OperationToHarProps, 'multipartNaming' | 'contentType' | 'example' | 'requestBodyCompositionSelection' | 'openapiVersion' | 'jsonSchemaDialect'> & {
5
5
  requestBody: RequestBodyObject;
@@ -8,6 +8,6 @@ type ProcessBodyProps = Pick<OperationToHarProps, 'multipartNaming' | 'contentTy
8
8
  * Processes the request body and returns the processed data
9
9
  * Returns undefined if no example is found
10
10
  */
11
- export declare const processBody: ({ requestBody, contentType, example, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, multipartNaming, }: ProcessBodyProps) => PostData | undefined;
11
+ export declare const processBody: ({ requestBody, contentType, example, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, multipartNaming, }: ProcessBodyProps) => HarRequest["postData"];
12
12
  export {};
13
13
  //# sourceMappingURL=process-body.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AAErE,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,KAAK,gBAAgB,GAAG,IAAI,CAC1B,mBAAmB,EACjB,iBAAiB,GACjB,aAAa,GACb,SAAS,GACT,iCAAiC,GACjC,gBAAgB,GAChB,mBAAmB,CACtB,GAAG;IACF,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AA0LD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,6HAQzB,gBAAgB,KAAG,QAAQ,GAAG,SA6LhC,CAAA"}
1
+ {"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAqBxD,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AAIrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAsB7D,KAAK,gBAAgB,GAAG,IAAI,CAC1B,mBAAmB,EACjB,iBAAiB,GACjB,aAAa,GACb,SAAS,GACT,iCAAiC,GACjC,gBAAgB,GAChB,mBAAmB,CACtB,GAAG;IACF,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AA0LD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,6HAQzB,gBAAgB,KAAG,UAAU,CAAC,UAAU,CA2N1C,CAAA"}
@@ -1,21 +1,40 @@
1
1
  import { snapshotSchema as e } from "@scalar/workspace-store/helpers/snapshot-schema";
2
2
  import { buildRequestBody as t, coerceLeafValueToSchemaType as n, getExample as r, getExampleFromBody as i, getExampleFromSchema as a, needsMultipartEncoding as o, resolveLeafSchema as s, serializeFormPropertyWithEncoding as c, serializeMultipartArray as l, serializeMultipartBody as u, usesAspNetFormNaming as d } from "@scalar/workspace-store/request-example";
3
3
  import { isXmlMediaType as f } from "@scalar/helpers/http/is-xml-media-type";
4
- import { getExampleValue as p, getExplicitExampleText as m } from "@scalar/workspace-store/helpers/get-example-value";
5
- import { getResolvedRef as h, mergeSiblingReferences as g } from "@scalar/workspace-store/helpers/get-resolved-ref";
6
- import { getStreamFormat as _ } from "@scalar/helpers/http/is-streaming-content-type";
7
- import { isFileSchema as v } from "@scalar/workspace-store/helpers/is-file-schema";
8
- import { serializeStreamExample as y } from "@scalar/workspace-store/helpers/serialize-stream-example";
9
- import { unpackProxyObject as b } from "@scalar/workspace-store/helpers/unpack-proxy";
10
- import { resolve as x } from "@scalar/workspace-store/resolve";
11
- import { isArraySchema as S, isObjectSchema as C } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
4
+ import { parseMimeType as p } from "@scalar/helpers/http/mime-type";
5
+ import { getExampleValue as m, getExplicitExampleText as h } from "@scalar/workspace-store/helpers/get-example-value";
6
+ import { getResolvedRef as g, mergeSiblingReferences as _ } from "@scalar/workspace-store/helpers/get-resolved-ref";
7
+ import { getStreamFormat as v } from "@scalar/helpers/http/is-streaming-content-type";
8
+ import { isYamlMediaType as y } from "@scalar/helpers/http/is-yaml-media-type";
9
+ import { isFileSchema as b } from "@scalar/workspace-store/helpers/is-file-schema";
10
+ import { serializeStreamExample as x } from "@scalar/workspace-store/helpers/serialize-stream-example";
11
+ import { unpackProxyObject as S } from "@scalar/workspace-store/helpers/unpack-proxy";
12
+ import { resolve as C } from "@scalar/workspace-store/resolve";
13
+ import { isArraySchema as w, isObjectSchema as T } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
12
14
  // src/code-example/helpers/operation-to-har/process-body.ts
13
- var w = (e, t, n) => ({
15
+ var E = /* @__PURE__ */ new Set([
16
+ "__scalar_",
17
+ "$schema",
18
+ "$id",
19
+ "$anchor",
20
+ "$dynamicAnchor",
21
+ "$comment",
22
+ "$defs",
23
+ "$vocabulary",
24
+ "definitions",
25
+ "title",
26
+ "description",
27
+ "deprecated",
28
+ "readOnly",
29
+ "writeOnly",
30
+ "externalDocs",
31
+ "xml"
32
+ ]), D = (e, t, n) => ({
14
33
  name: e,
15
34
  value: `@${t}`,
16
35
  fileName: t,
17
36
  ...n ? { contentType: n } : {}
18
- }), T = (e) => !!e && "type" in e && e.type === "string" && "format" in e && e.format === "binary", E = (e, t) => typeof e == "string" && e.startsWith("@") && T(t) ? e.slice(1) : void 0, D = (e, t, r, i = !1, a) => {
37
+ }), O = (e) => !!e && "type" in e && e.type === "string" && "format" in e && e.format === "binary", k = (e, t) => typeof e == "string" && e.startsWith("@") && O(t) ? e.slice(1) : void 0, A = (e, t, r, i = !1, a) => {
19
38
  let o = [], u = Array.isArray(e) ? e.filter((e) => !e.isDisabled).map((e) => [String(e.name), e.value]) : Object.entries(e);
20
39
  for (let [d, f] of u) {
21
40
  if (f == null) continue;
@@ -23,7 +42,7 @@ var w = (e, t, n) => ({
23
42
  if (i && !r) {
24
43
  let t = Array.isArray(e) ? n(f, s(a, [d])) : f, r = l(d, Array.isArray(t) ? t : f, u);
25
44
  if (r) {
26
- for (let e of r) e.value instanceof File ? o.push(w(e.key, e.value.name, e.contentType ?? e.value.type)) : o.push({
45
+ for (let e of r) e.value instanceof File ? o.push(D(e.key, e.value.name, e.contentType ?? e.value.type)) : o.push({
27
46
  name: e.key,
28
47
  value: e.value,
29
48
  ...e.contentType ? { contentType: e.contentType } : {}
@@ -31,34 +50,34 @@ var w = (e, t, n) => ({
31
50
  continue;
32
51
  }
33
52
  }
34
- let p = u && (u.style !== void 0 || u.explode !== void 0 || u.allowReserved !== void 0), m = p || !i ? void 0 : u?.contentType, h = i && !r ? E(f, s(a, [d])) : void 0, g = r ? null : c(d, f, u);
53
+ let p = u && (u.style !== void 0 || u.explode !== void 0 || u.allowReserved !== void 0), m = p || !i ? void 0 : u?.contentType, h = i && !r ? k(f, s(a, [d])) : void 0, g = r ? null : c(d, f, u);
35
54
  if (g) for (let e of g) o.push({
36
55
  name: e.key,
37
56
  value: e.value
38
57
  });
39
58
  else if (f instanceof File) {
40
- let e = b(f);
41
- o.push(w(d, e.name, m ?? (i ? e.type : void 0)));
42
- } else if (h !== void 0) o.push(w(d, h, m));
59
+ let e = S(f);
60
+ o.push(D(d, e.name, m ?? (i ? e.type : void 0)));
61
+ } else if (h !== void 0) o.push(D(d, h, m));
43
62
  else if (m && typeof f == "object") o.push({
44
63
  name: d,
45
- value: JSON.stringify(b(f)),
64
+ value: JSON.stringify(S(f)),
46
65
  contentType: m
47
66
  });
48
67
  else if (i && !r && !p && typeof f == "object" && !Array.isArray(f)) o.push({
49
68
  name: d,
50
- value: JSON.stringify(b(f)),
69
+ value: JSON.stringify(S(f)),
51
70
  contentType: "application/json"
52
71
  });
53
72
  else if (Array.isArray(f)) for (let e of f) if (e instanceof File) {
54
- let t = b(e);
55
- o.push(w(d, t.name, i ? t.type : void 0));
73
+ let t = S(e);
74
+ o.push(D(d, t.name, i ? t.type : void 0));
56
75
  } else o.push({
57
76
  name: d,
58
77
  value: String(e)
59
78
  });
60
79
  else if (typeof f == "object") {
61
- let e = D(f, void 0, d);
80
+ let e = A(f, void 0, d);
62
81
  for (let t of e) o.push({
63
82
  name: `${d}.${t.name}`,
64
83
  value: t.value
@@ -70,26 +89,30 @@ var w = (e, t, n) => ({
70
89
  });
71
90
  }
72
91
  return o;
73
- }, O = ({ requestBody: n, contentType: s, example: c, openapiVersion: l, jsonSchemaDialect: T, requestBodyCompositionSelection: E, multipartNaming: O }) => {
74
- let k = s || Object.keys(n.content)[0] || "", A = k === "other" ? "" : k, j = (e) => `@${b(e).name || "filename"}`, M = n.content[k]?.encoding, N = n.content[k], P = d(k, N, O);
75
- if (N && (P || o(k, N))) {
76
- let e = c ?? Object.keys(N.examples ?? {})[0] ?? "default", r = t({
92
+ }, j = ({ requestBody: n, contentType: s, example: c, openapiVersion: l, jsonSchemaDialect: O, requestBodyCompositionSelection: k, multipartNaming: j }) => {
93
+ let M = s || Object.keys(n.content)[0] || "", N = M === "other" ? "" : M, P = (e) => S(e).name || "filename", F = (e) => ({
94
+ mimeType: N,
95
+ text: `@${e}`,
96
+ _fileName: e
97
+ }), I = n.content[M]?.encoding, L = n.content[M], R = d(M, L, j);
98
+ if (L && (R || o(M, L))) {
99
+ let e = c ?? Object.keys(L.examples ?? {})[0] ?? "default", r = t({
77
100
  ...n,
78
- "x-scalar-selected-content-type": { [e]: k }
79
- }, e, E, l, T, {
80
- multipartNaming: O,
81
- aspNetFilePlaceholders: P && k === "multipart/form-data"
101
+ "x-scalar-selected-content-type": { [e]: M }
102
+ }, e, k, l, O, {
103
+ multipartNaming: j,
104
+ aspNetFilePlaceholders: R && M === "multipart/form-data"
82
105
  });
83
- if (P && r?.mode === "urlencoded") return {
84
- mimeType: A,
106
+ if (R && r?.mode === "urlencoded") return {
107
+ mimeType: N,
85
108
  params: r.value.map(({ key: e, value: t }) => ({
86
109
  name: e,
87
110
  value: t
88
111
  }))
89
112
  };
90
- if (P && r?.mode === "formdata") return {
91
- mimeType: A,
92
- params: r.value.flatMap((e) => e.type === "file" ? [w(e.key, e.value.name, e.contentType ?? e.value.type)] : e.type === "text" ? [{
113
+ if (R && r?.mode === "formdata") return {
114
+ mimeType: N,
115
+ params: r.value.flatMap((e) => e.type === "file" ? [D(e.key, e.value.name, e.contentType ?? e.value.type)] : e.type === "text" ? [{
93
116
  name: e.key,
94
117
  value: e.value,
95
118
  ...e.contentType ? { contentType: e.contentType } : {}
@@ -99,78 +122,76 @@ var w = (e, t, n) => ({
99
122
  let e = u(r.value, r.contentType);
100
123
  return {
101
124
  mimeType: e.contentType,
102
- text: e.chunks.map((e) => e instanceof File ? j(e) : e instanceof Blob ? "BINARY" : String(e)).join("")
125
+ text: e.chunks.map((e) => e instanceof File ? `@${P(e)}` : e instanceof Blob ? "BINARY" : String(e)).join("")
103
126
  };
104
127
  }
105
128
  }
106
- let F = k === "multipart/form-data" || k === "application/x-www-form-urlencoded";
107
- if (f(k)) {
108
- let e = i(n, k, c ?? "", E, l, T);
129
+ let z = M === "multipart/form-data" || M === "application/x-www-form-urlencoded";
130
+ if (f(M)) {
131
+ let e = i(n, M, c ?? "", k, l, O);
109
132
  return e ? {
110
- mimeType: A,
133
+ mimeType: N,
111
134
  text: e.value
112
135
  } : void 0;
113
136
  }
114
- let I = p(r(n, c, s)), L = m(I, k);
115
- if (L !== void 0) return {
116
- mimeType: A,
117
- text: L
137
+ let B = m(r(n, c, s)), V = h(B, M);
138
+ if (V !== void 0) return {
139
+ mimeType: N,
140
+ text: V
118
141
  };
119
- let R = I?.value;
120
- if (R !== void 0) {
121
- let e = typeof R == "object" && R ? b(R) : R;
122
- return F && typeof e == "object" && e ? {
123
- mimeType: A,
124
- params: D(e, M, void 0, k === "multipart/form-data", h(n.content[k]?.schema, g))
125
- } : e instanceof File ? {
126
- mimeType: A,
127
- text: j(e)
128
- } : {
129
- mimeType: A,
130
- text: typeof e == "string" ? e : y(e, k, !1) ?? JSON.stringify(e)
142
+ let H = B?.value;
143
+ if (H !== void 0) {
144
+ let e = typeof H == "object" && H ? S(H) : H;
145
+ return z && typeof e == "object" && e ? {
146
+ mimeType: N,
147
+ params: A(e, I, void 0, M === "multipart/form-data", g(n.content[M]?.schema, _))
148
+ } : e instanceof File ? F(P(e)) : {
149
+ mimeType: N,
150
+ text: typeof e == "string" ? e : x(e, M, !1) ?? JSON.stringify(e)
131
151
  };
132
152
  }
133
- let z = n.content[k], B = h(z?.schema ?? z?.itemSchema);
134
- if (B !== void 0) {
135
- let t = e(B);
136
- if (k === "multipart/form-data" && C(t)) for (let [e, n] of Object.entries(t.properties ?? {})) {
137
- let r = x.schema(n), i = r && S(r) ? x.schema(r.items) : r;
138
- if (i && !("type" in i) && !("properties" in i) && !i.allOf && !i.oneOf && !i.anyOf && !i.contentSchema && v(i, !1)) {
153
+ let U = v(M), { essence: W } = p(M), G = !z && !U && !y(W) && ![
154
+ "application/x-www-form-urlencoded",
155
+ "application/edn",
156
+ "application/graphql",
157
+ "application/javascript"
158
+ ].includes(W), K = l === void 0 || /^3\.[1-9]\d*(?:\.|$)/.test(l);
159
+ if (L && L.schema === void 0 && L.itemSchema === void 0 && K && G && !W.includes("*") && b({ __scalar_: "" }, !1, M)) return F("filename");
160
+ let q = g(L?.schema ?? L?.itemSchema);
161
+ if (q !== void 0) {
162
+ let t = e(q);
163
+ if (M === "multipart/form-data" && T(t)) for (let [e, n] of Object.entries(t.properties ?? {})) {
164
+ let r = C.schema(n), i = r && w(r) ? C.schema(r.items) : r;
165
+ if (i && !("type" in i) && !("properties" in i) && !i.allOf && !i.oneOf && !i.anyOf && !i.contentSchema && b(i, !1)) {
139
166
  let n = {
140
167
  ...i,
141
168
  type: "string",
142
169
  format: "binary"
143
170
  };
144
- t.properties[e] = r && S(r) ? {
171
+ t.properties[e] = r && w(r) ? {
145
172
  ...r,
146
173
  items: n
147
174
  } : n;
148
175
  }
149
176
  }
150
- if (!F && z?.schema !== void 0 && Object.keys(t).every((e) => [
151
- "__scalar_",
152
- "title",
153
- "description"
154
- ].includes(e)) && !_(k) && v(t, !1, k)) return {
155
- mimeType: A,
156
- text: "@filename"
157
- };
158
- let n = a(t, {
159
- compositionSelection: E,
177
+ if (G && L?.schema !== void 0 && !t.readOnly && Object.keys(t).every((e) => E.has(e) || K && e === "contentMediaType") && b(t, !1, M)) return F("filename");
178
+ let n = ["requestBody"], r = !U || U === "multipart" && L?.schema !== void 0, i = a(t, {
179
+ compositionSelection: k,
160
180
  mode: "write",
161
181
  openapiVersion: l,
162
- jsonSchemaDialect: T,
163
- binaryAsFile: k === "multipart/form-data"
164
- }, { schemaPath: ["requestBody"] });
165
- if (n !== void 0) return F && typeof n == "object" && n ? {
166
- mimeType: A,
167
- params: D(n, M, void 0, k === "multipart/form-data", B)
168
- } : {
169
- mimeType: A,
170
- text: y(n, k, z?.schema === void 0) ?? (typeof n == "string" ? n : JSON.stringify(n))
182
+ jsonSchemaDialect: O,
183
+ binaryAsFile: M === "multipart/form-data",
184
+ generatedBinaryFilePath: !z && r ? n : void 0
185
+ }, { schemaPath: n });
186
+ if (i !== void 0) return z && typeof i == "object" && i ? {
187
+ mimeType: N,
188
+ params: A(i, I, void 0, M === "multipart/form-data", q)
189
+ } : i instanceof File ? F(P(i)) : {
190
+ mimeType: N,
191
+ text: x(i, M, L?.schema === void 0) ?? (typeof i == "string" ? i : JSON.stringify(i))
171
192
  };
172
193
  }
173
194
  };
174
- export { O as processBody };
195
+ export { j as processBody };
175
196
 
176
197
  //# sourceMappingURL=process-body.js.map