@scalar/blocks 0.7.3 → 0.7.4

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 (201) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/_virtual/_plugin-vue_export-helper.js +1 -2
  3. package/dist/code-example/components/AsyncApiCodeExample.vue.js +1 -2
  4. package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -1
  5. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +1 -2
  6. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
  7. package/dist/code-example/components/CodeExample.vue.d.ts +2 -0
  8. package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
  9. package/dist/code-example/components/CodeExample.vue.js +4 -5
  10. package/dist/code-example/components/CodeExample.vue.js.map +1 -1
  11. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +102 -100
  12. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/code-example/components/ExamplePicker.vue.js +1 -2
  14. package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
  15. package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js +1 -2
  16. package/dist/code-example/components/HttpMethod.vue.js +1 -2
  17. package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
  18. package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js +1 -2
  19. package/dist/code-example/helpers/filter-clients-by-query.js +1 -2
  20. package/dist/code-example/helpers/find-client.js +1 -2
  21. package/dist/code-example/helpers/format-language.js +1 -2
  22. package/dist/code-example/helpers/generate-client-options.js +1 -2
  23. package/dist/code-example/helpers/generate-code-snippet.d.ts +2 -1
  24. package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
  25. package/dist/code-example/helpers/generate-code-snippet.js +11 -11
  26. package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
  27. package/dist/code-example/helpers/get-asyncapi-example-context.js +1 -2
  28. package/dist/code-example/helpers/get-clients.js +8 -9
  29. package/dist/code-example/helpers/get-custom-code-samples.js +1 -2
  30. package/dist/code-example/helpers/get-generated-payload-example.js +1 -2
  31. package/dist/code-example/helpers/get-message-example-content.js +1 -2
  32. package/dist/code-example/helpers/get-secrets.js +1 -2
  33. package/dist/code-example/helpers/get-snippet.js +1 -2
  34. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +2 -1
  35. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  36. package/dist/code-example/helpers/operation-to-har/operation-to-har.js +32 -31
  37. package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
  38. package/dist/code-example/helpers/operation-to-har/process-body.d.ts +2 -2
  39. package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
  40. package/dist/code-example/helpers/operation-to-har/process-body.js +80 -52
  41. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  42. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts +2 -1
  43. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  44. package/dist/code-example/helpers/operation-to-har/process-parameters.js +65 -58
  45. package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
  46. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js +1 -2
  47. package/dist/code-example/helpers/operation-to-har/process-server-url.js +1 -2
  48. package/dist/code-example/index.js +10 -10
  49. package/dist/code-example/mount-asyncapi.js +7 -8
  50. package/dist/code-example/mount.js +5 -6
  51. package/dist/constants.js +2 -3
  52. package/dist/schema/LinkButton.vue.js +1 -2
  53. package/dist/schema/RenderString.vue.js +1 -2
  54. package/dist/schema/RenderString.vue.js.map +1 -1
  55. package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js +1 -2
  56. package/dist/schema/Schema.vue.js +4 -5
  57. package/dist/schema/Schema.vue.js.map +1 -1
  58. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js +67 -68
  59. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js.map +1 -1
  60. package/dist/schema/SchemaCollapsedPreview.vue.js +1 -2
  61. package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -1
  62. package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js +1 -2
  63. package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js.map +1 -1
  64. package/dist/schema/SchemaComposition.vue.js +4 -5
  65. package/dist/schema/SchemaComposition.vue.js.map +1 -1
  66. package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js +26 -27
  67. package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js.map +1 -1
  68. package/dist/schema/SchemaEnumPropertyItem.vue.js +1 -2
  69. package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -1
  70. package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js +1 -2
  71. package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
  72. package/dist/schema/SchemaEnums.vue.js +4 -5
  73. package/dist/schema/SchemaEnums.vue.js.map +1 -1
  74. package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js +12 -13
  75. package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js.map +1 -1
  76. package/dist/schema/SchemaGlyphPuck.vue.js +1 -2
  77. package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -1
  78. package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js +1 -2
  79. package/dist/schema/SchemaGutterToggle.vue.js +1 -2
  80. package/dist/schema/SchemaGutterToggle.vue.js.map +1 -1
  81. package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js +1 -2
  82. package/dist/schema/SchemaHeading.vue.js +4 -5
  83. package/dist/schema/SchemaHeading.vue.js.map +1 -1
  84. package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js +1 -2
  85. package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js.map +1 -1
  86. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +1 -2
  87. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
  88. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js +1 -2
  89. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  90. package/dist/schema/SchemaObjectProperties.vue.js +1 -2
  91. package/dist/schema/SchemaObjectProperties.vue.js.map +1 -1
  92. package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js +1 -2
  93. package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js.map +1 -1
  94. package/dist/schema/SchemaProperty.vue.js +4 -5
  95. package/dist/schema/SchemaProperty.vue.js.map +1 -1
  96. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js +48 -49
  97. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js.map +1 -1
  98. package/dist/schema/SchemaPropertyDefault.vue.js +4 -5
  99. package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -1
  100. package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js +9 -10
  101. package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js.map +1 -1
  102. package/dist/schema/SchemaPropertyDetail.vue.js +4 -5
  103. package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -1
  104. package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js +1 -2
  105. package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js.map +1 -1
  106. package/dist/schema/SchemaPropertyExamples.vue.js +4 -5
  107. package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
  108. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js +18 -19
  109. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +1 -1
  110. package/dist/schema/SchemaPropertyHeading.vue.js +4 -5
  111. package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
  112. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js +101 -102
  113. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js.map +1 -1
  114. package/dist/schema/SchemaPropertyPattern.vue.js +4 -5
  115. package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -1
  116. package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js +1 -2
  117. package/dist/schema/SchemaRailPanel.vue.js +1 -2
  118. package/dist/schema/SchemaRailPanel.vue.js.map +1 -1
  119. package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js +1 -2
  120. package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
  121. package/dist/schema/components/CopyLinkButton.vue.js +1 -2
  122. package/dist/schema/components/CopyLinkButton.vue.js.map +1 -1
  123. package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js +1 -2
  124. package/dist/schema/components/WithBreadcrumb.vue.js +1 -2
  125. package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -1
  126. package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js +1 -2
  127. package/dist/schema/discriminator-metadata.js +1 -2
  128. package/dist/schema/helpers/dynamic-scope.js +1 -2
  129. package/dist/schema/helpers/format-example.js +1 -2
  130. package/dist/schema/helpers/format-value.js +1 -2
  131. package/dist/schema/helpers/get-compositions-to-render.js +19 -20
  132. package/dist/schema/helpers/get-discriminator-values.js +1 -2
  133. package/dist/schema/helpers/get-enum-values.js +1 -2
  134. package/dist/schema/helpers/get-property-description.js +1 -2
  135. package/dist/schema/helpers/get-ref-name.js +1 -2
  136. package/dist/schema/helpers/get-rendered-example.js +1 -2
  137. package/dist/schema/helpers/get-schema-type.js +1 -2
  138. package/dist/schema/helpers/get-type-signature-tokens.d.ts +2 -2
  139. package/dist/schema/helpers/get-type-signature-tokens.d.ts.map +1 -1
  140. package/dist/schema/helpers/get-type-signature-tokens.js +3 -4
  141. package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -1
  142. package/dist/schema/helpers/has-complex-array-items.js +1 -2
  143. package/dist/schema/helpers/index.js +13 -13
  144. package/dist/schema/helpers/is-empty-schema-object.js +1 -2
  145. package/dist/schema/helpers/is-model-linkable.js +1 -2
  146. package/dist/schema/helpers/is-on-schema-target-path.js +1 -2
  147. package/dist/schema/helpers/is-type-object.js +1 -2
  148. package/dist/schema/helpers/merge-all-of-schemas.js +1 -2
  149. package/dist/schema/helpers/normalize-object-composition.js +1 -2
  150. package/dist/schema/helpers/optimize-value-for-display.js +1 -2
  151. package/dist/schema/helpers/partition-all-of-compositions.js +1 -2
  152. package/dist/schema/helpers/schema-composition.js +1 -2
  153. package/dist/schema/helpers/schema-cycle.js +1 -2
  154. package/dist/schema/helpers/schema-expansion.js +1 -2
  155. package/dist/schema/helpers/schema-keyboard-nav.js +1 -2
  156. package/dist/schema/helpers/schema-name.js +2 -3
  157. package/dist/schema/helpers/schema-name.js.map +1 -1
  158. package/dist/schema/helpers/should-display-description.js +1 -2
  159. package/dist/schema/helpers/should-display-heading.js +1 -2
  160. package/dist/schema/helpers/should-render-array-item-composition.js +1 -2
  161. package/dist/schema/helpers/sort-property-names.js +1 -2
  162. package/dist/schema/helpers/unwrap-for-read.js +1 -2
  163. package/dist/schema/index.js +8 -8
  164. package/dist/schema/localization/index.js +1 -2
  165. package/dist/schema/localization/locales/ar.js +1 -2
  166. package/dist/schema/localization/locales/de.js +1 -2
  167. package/dist/schema/localization/locales/en.js +1 -2
  168. package/dist/schema/localization/locales/es.js +1 -2
  169. package/dist/schema/localization/locales/fr.js +1 -2
  170. package/dist/schema/localization/locales/pt.js +1 -2
  171. package/dist/schema/localization/locales/ru.js +1 -2
  172. package/dist/schema/localization/locales/zh-cn.js +1 -2
  173. package/dist/schema/localization/locales/zh-tw.js +1 -2
  174. package/dist/schema/localization/translations.js +1 -2
  175. package/dist/schema/protobuf-metadata.js +1 -2
  176. package/dist/schema/recursive-metadata.js +1 -2
  177. package/dist/schema/request-body-composition-index.js +1 -2
  178. package/dist/shared/Badge.vue.d.ts.map +1 -1
  179. package/dist/shared/Badge.vue.js +4 -5
  180. package/dist/shared/Badge.vue.js.map +1 -1
  181. package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js +2 -3
  182. package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js.map +1 -1
  183. package/dist/shared/ExternalDocs.vue.js +1 -2
  184. package/dist/shared/ExternalDocs.vue.js.map +1 -1
  185. package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js +1 -2
  186. package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js.map +1 -1
  187. package/dist/shared/ScreenReader.vue.js +1 -2
  188. package/dist/shared/ScreenReader.vue.js.map +1 -1
  189. package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js +1 -2
  190. package/dist/shared/index.js +4 -4
  191. package/dist/specification-extensions/ExtensionValue.vue.js +1 -2
  192. package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -1
  193. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js +5 -6
  194. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js.map +1 -1
  195. package/dist/specification-extensions/SpecificationExtensions.vue.js +1 -2
  196. package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -1
  197. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js +1 -2
  198. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js.map +1 -1
  199. package/dist/style.css +40 -20
  200. package/dist/vue-styles.css +1 -1
  201. package/package.json +22 -22
@@ -6,9 +6,9 @@ import { processServerUrl as i } from "./process-server-url.js";
6
6
  import { filterGlobalCookie as a, getDefaultHeaders as o, restoreConventionalDefaultHeaderNames as s } from "@scalar/workspace-store/request-example";
7
7
  import { getResolvedRef as c } from "@scalar/workspace-store/helpers/get-resolved-ref";
8
8
  import { isElectron as l } from "@scalar/helpers/general/is-electron";
9
- //#region src/code-example/helpers/operation-to-har/operation-to-har.ts
10
- var u = ({ includeDefaultHeaders: u = !1, operation: d, contentType: f, method: p, path: m, server: h = null, example: g, securitySchemes: _, globalCookies: v, openapiVersion: y, requestBodyCompositionSelection: b, defaultDisabledParameters: x = !1 }) => {
11
- let S = u ? o({
9
+ // src/code-example/helpers/operation-to-har/operation-to-har.ts
10
+ var u = ({ includeDefaultHeaders: u = !1, operation: d, contentType: f, method: p, path: m, server: h = null, example: g, securitySchemes: _, globalCookies: v, openapiVersion: y, jsonSchemaDialect: b, requestBodyCompositionSelection: x, defaultDisabledParameters: S = !1 }) => {
11
+ let C = u ? o({
12
12
  method: p,
13
13
  operation: d,
14
14
  exampleName: g ?? "default",
@@ -18,10 +18,10 @@ var u = ({ includeDefaultHeaders: u = !1, operation: d, contentType: f, method:
18
18
  isElectron: l(),
19
19
  appVersion: e
20
20
  }
21
- }) : {}, C = s(S), w = d["x-scalar-disable-parameters"]?.["global-cookies"]?.[g ?? "default"] ?? {}, T = {
21
+ }) : {}, w = s(C), T = d["x-scalar-disable-parameters"]?.["global-cookies"]?.[g ?? "default"] ?? {}, E = {
22
22
  method: p,
23
23
  url: i(h, m),
24
- headers: Object.entries(C).map(([e, t]) => ({
24
+ headers: Object.entries(w).map(([e, t]) => ({
25
25
  name: e,
26
26
  value: t
27
27
  })),
@@ -31,61 +31,62 @@ var u = ({ includeDefaultHeaders: u = !1, operation: d, contentType: f, method:
31
31
  cookies: [],
32
32
  headersSize: -1,
33
33
  bodySize: -1
34
- }, E = !1, D = !1;
34
+ }, D = !1, O = !1;
35
35
  if (d.parameters) {
36
36
  let { url: e, headers: t, queryString: r, cookies: i, hasCookieStyleEntries: o, hasSerializedQuery: s } = n({
37
- harRequest: T,
37
+ harRequest: E,
38
38
  parameters: d.parameters,
39
39
  openapiVersion: y,
40
+ jsonSchemaDialect: b,
40
41
  example: g,
41
- defaultDisabled: x
42
+ defaultDisabled: S
42
43
  }), c = v?.filter((t) => a({
43
44
  cookie: t,
44
45
  url: e,
45
- disabledGlobalCookies: w
46
+ disabledGlobalCookies: T
46
47
  }))?.map((e) => ({
47
48
  name: e.name,
48
49
  value: e.value
49
50
  })) ?? [];
50
- E = o, D = s ?? !1, T.url = e, T.headers = t, T.queryString = r, T.cookies = [...c, ...i];
51
+ D = o, O = s ?? !1, E.url = e, E.headers = t, E.queryString = r, E.cookies = [...c, ...i];
51
52
  }
52
- let O = c(d.requestBody);
53
- if (O?.content) {
53
+ let k = c(d.requestBody);
54
+ if (k?.content) {
54
55
  let e = t({
55
- requestBody: O,
56
+ requestBody: k,
56
57
  contentType: f,
57
58
  example: g,
58
59
  openapiVersion: y,
59
- requestBodyCompositionSelection: b
60
+ jsonSchemaDialect: b,
61
+ requestBodyCompositionSelection: x
60
62
  });
61
- if (e && (T.postData = e, T.bodySize = e.text?.length ?? -1, e.mimeType)) {
62
- let t = T.headers.find((e) => e.name.toLowerCase() === "content-type");
63
- t && (!t.value || e.mimeType.startsWith("multipart/") && e.mimeType.includes("boundary=") && e.text !== void 0) ? t.value = e.mimeType : t || T.headers.push({
63
+ if (e && (E.postData = e, E.bodySize = e.text?.length ?? -1, e.mimeType)) {
64
+ let t = E.headers.find((e) => e.name.toLowerCase() === "content-type");
65
+ t && (!t.value || e.mimeType.startsWith("multipart/") && e.mimeType.includes("boundary=") && e.text !== void 0) ? t.value = e.mimeType : t || E.headers.push({
64
66
  name: "Content-Type",
65
67
  value: e.mimeType
66
68
  });
67
69
  }
68
70
  }
69
- let k = D || d.parameters?.some((e) => c(e)?.in === "querystring");
71
+ let A = O || d.parameters?.some((e) => c(e)?.in === "querystring");
70
72
  if (_) {
71
73
  let { headers: e, queryString: t, cookies: n } = r(_);
72
- T.headers.push(...e), T.queryString.push(...t), T.cookies.push(...n);
74
+ E.headers.push(...e), E.queryString.push(...t), E.cookies.push(...n);
73
75
  }
74
- let A = T.headers.find((e) => e.name.toLowerCase() === "cookie");
75
- if (E && A && T.cookies.length) {
76
- let e = T.cookies.map((e) => `${encodeURIComponent(e.name)}=${encodeURIComponent(e.value)}`).join("; ");
77
- A.value = A.value ? `${A.value}; ${e}` : e, T.cookies = [];
76
+ let j = E.headers.find((e) => e.name.toLowerCase() === "cookie");
77
+ if (D && j && E.cookies.length) {
78
+ let e = E.cookies.map((e) => `${encodeURIComponent(e.name)}=${encodeURIComponent(e.value)}`).join("; ");
79
+ j.value = j.value ? `${j.value}; ${e}` : e, E.cookies = [];
78
80
  }
79
- if (k && T.queryString.length) {
80
- let e = T.url.indexOf("#"), t = e === -1 ? "" : T.url.slice(e), n = e === -1 ? T.url : T.url.slice(0, e), r = T.queryString.map(({ name: e, value: t }) => `${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&");
81
- T.url = `${n}${n.includes("?") ? "&" : "?"}${r}${t}`, T.queryString = [];
81
+ if (A && E.queryString.length) {
82
+ let e = E.url.indexOf("#"), t = e === -1 ? "" : E.url.slice(e), n = e === -1 ? E.url : E.url.slice(0, e), r = E.queryString.map(({ name: e, value: t }) => `${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&");
83
+ E.url = `${n}${n.includes("?") ? "&" : "?"}${r}${t}`, E.queryString = [];
82
84
  }
83
- T.postData?.mimeType === "multipart/form-data" && T.postData.params?.length && (T.headers = T.headers.filter((e) => e.name.toLowerCase() !== "content-type"));
84
- let j = 0;
85
- for (let e of T.headers) j += (e.name?.length ?? 0) + 2 + (e.value?.length ?? 0) + 2;
86
- return T.headersSize = j, T;
85
+ E.postData?.mimeType === "multipart/form-data" && E.postData.params?.length && (E.headers = E.headers.filter((e) => e.name.toLowerCase() !== "content-type"));
86
+ let M = 0;
87
+ for (let e of E.headers) M += (e.name?.length ?? 0) + 2 + (e.value?.length ?? 0) + 2;
88
+ return E.headersSize = M, E;
87
89
  };
88
- //#endregion
89
90
  export { u as operationToHar };
90
91
 
91
92
  //# sourceMappingURL=operation-to-har.js.map
@@ -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 { 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 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 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 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 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":";;;;;;;;;AAuFA,IAAaA,KAAkB,EAC7B,2BAAwB,IACxB,cACA,gBACA,WACA,SACA,YAAS,MACT,YACA,oBACA,kBACA,mBACA,oCACA,+BAA4B,SACS;CACrC,IAAMC,IAAiBC,IACnBC,EAAkB;EAChB;EACA;EACA,aAAaC,KAAW;EACxB,qBAAqB;EACrB,uBAAuB;EACvB,SAAS;GAAE,YAAYC,EAAW;GAAG,YAAYC;EAAY;CAC/D,CAAC,IACD,CAAC,GACCC,IAAsCC,EAAsCP,CAAc,GAE1FQ,IACJC,EAAU,8BAA8B,GAAG,iBAAiB,GAAGN,KAAW,cAAc,CAAC,GAKrFO,IAAyB;EAC7B;EACA,KALgBC,EAAiBC,GAAQC,CAKpC;EACL,SAAS,OAAO,QAAQP,CAAmC,CAAC,CAAC,KAAK,CAACQ,GAAMC,QAAY;GAAE;GAAM;EAAM,EAAE;EACrG,aAAa,CAAC;EACd,UAAU,KAAA;EACV,aAAa;EACb,SAAS,CAAC;EACV,aAAa;EACb,UAAU;CACZ,GAEIC,IAAwB,IACxBC,IAAqB;CAGzB,IAAIR,EAAU,YAAY;EACxB,IAAM,EACJ,QACA,YACA,gBACA,YACA,uBAAuBS,GACvB,oBAAoBC,MAClBC,EAAkB;GACpB;GACA,YAAYX,EAAU;GACtB;GACA;GACA,iBAAiBY;EACnB,CAAC,GAGKC,IACJC,GACI,QAAQ,MAAWC,EAAmB;GAAE;GAAQ;GAAK;EAAsB,CAAC,CAAC,CAAC,EAC9E,KAAK,OAAY;GAAE,MAAMC,EAAO;GAAM,OAAOA,EAAO;EAAM,EAAE,KAAK,CAAC;EAOxE,AALA,IAAwBP,GACxB,IAAqBC,KAA4B,IACjD,EA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AEZ,AADA,EAAa,QAAQe,EAAa,QAAQ,GAAGA,EAAa,MAAM,IAAIC,MAAiBA,GACrF,EAAW,UAAU,CAAC;CACxB;CAIA,IAAIL,KAAoB1B,EAAW,YAAY,QAAQ;EACrD,IAAMgC,IAAYhC,EAAW,IAAI,QAAQ,GAAG,GACtCiC,IAAOD,MAAc,KAAK,KAAKhC,EAAW,IAAI,MAAMgC,CAAS,GAC7DhB,IAAMgB,MAAc,KAAKhC,EAAW,MAAMA,EAAW,IAAI,MAAM,GAAGgC,CAAS,GAC3EE,IAAQlC,EAAW,YACtB,KAAK,EAAE,SAAM,eAAY,GAAG,mBAAmBI,CAAI,EAAE,GAAG,mBAAmBC,CAAK,GAAG,CAAC,CACpF,KAAK,GAAG;EAEX,AADA,EAAW,MAAM,GAAGW,IAAMA,EAAI,SAAS,GAAG,IAAI,MAAM,MAAMkB,IAAQD,KAClE,EAAW,cAAc,CAAC;CAC5B;CAIA,AAAIjC,EAAW,UAAU,aAAa,yBAAyBA,EAAW,SAAS,QAAQ,WACzF,EAAW,UAAUA,EAAW,QAAQ,QAAQ,MAAWyB,EAAO,KAAK,YAAY,MAAM,cAAc;CAIzG,IAAIU,IAAc;CAClB,KAAK,IAAMC,KAAKpC,EAAW,SAEzB,MAAgBoC,EAAE,MAAM,UAAU,KAAK,KAAKA,EAAE,OAAO,UAAU,KAAK;CAItE,OAFA,EAAW,cAAcD,GAElBnC;AACT"}
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 { 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 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 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 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":";;;;;;;;;AAwFA,IAAaA,KAAkB,EAC7B,2BAAwB,IACxB,cACA,gBACA,WACA,SACA,YAAS,MACT,YACA,oBACA,kBACA,mBACA,sBACA,oCACA,+BAA4B,SACS;CACrC,IAAMC,IAAiBC,IACnBC,EAAkB;EAChB;EACA;EACA,aAAaC,KAAW;EACxB,qBAAqB;EACrB,uBAAuB;EACv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I,CAAI,EAAE,GAAG,mBAAmBC,CAAK,GAAG,CAAC,CACpF,KAAK,GAAG;EAEX,AADA,EAAW,MAAM,GAAGW,IAAMA,EAAI,SAAS,GAAG,IAAI,MAAM,MAAMkB,IAAQD,KAClE,EAAW,cAAc,CAAC;CAC5B;CAIA,AAAIjC,EAAW,UAAU,aAAa,yBAAyBA,EAAW,SAAS,QAAQ,WACzF,EAAW,UAAUA,EAAW,QAAQ,QAAQ,MAAWyB,EAAO,KAAK,YAAY,MAAM,cAAc;CAIzG,IAAIU,IAAc;CAClB,KAAK,IAAMC,KAAKpC,EAAW,SAEzB,MAAgBoC,EAAE,MAAM,UAAU,KAAK,KAAKA,EAAE,OAAO,UAAU,KAAK;CAItE,OAFA,EAAW,cAAcD,GAElBnC;AACT"}
@@ -1,13 +1,13 @@
1
1
  import type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
2
2
  import type { PostData } from 'har-format';
3
3
  import type { OperationToHarProps } from './operation-to-har';
4
- type ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'example' | 'requestBodyCompositionSelection' | 'openapiVersion'> & {
4
+ type ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'example' | 'requestBodyCompositionSelection' | 'openapiVersion' | 'jsonSchemaDialect'> & {
5
5
  requestBody: RequestBodyObject;
6
6
  };
7
7
  /**
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, requestBodyCompositionSelection, }: ProcessBodyProps) => PostData | undefined;
11
+ export declare const processBody: ({ requestBody, contentType, example, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, }: ProcessBodyProps) => PostData | undefined;
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":"AAkBA,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,KAAK,gBAAgB,GAAG,IAAI,CAC1B,mBAAmB,EACnB,aAAa,GAAG,SAAS,GAAG,iCAAiC,GAAG,gBAAgB,CACjF,GAAG;IACF,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AA0LD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,yFAMzB,gBAAgB,KAAG,QAAQ,GAAG,SAmIhC,CAAA"}
1
+ {"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAqBA,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,EACnB,aAAa,GAAG,SAAS,GAAG,iCAAiC,GAAG,gBAAgB,GAAG,mBAAmB,CACvG,GAAG;IACF,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AA0LD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,4GAOzB,gBAAgB,KAAG,QAAQ,GAAG,SA0KhC,CAAA"}
@@ -3,15 +3,19 @@ import { buildRequestBody as t, coerceLeafValueToSchemaType as n, getExample as
3
3
  import { isXmlMediaType as d } from "@scalar/helpers/http/is-xml-media-type";
4
4
  import { getExampleValue as f, getExplicitExampleText as p } from "@scalar/workspace-store/helpers/get-example-value";
5
5
  import { getResolvedRef as m, mergeSiblingReferences as h } from "@scalar/workspace-store/helpers/get-resolved-ref";
6
- import { serializeStreamExample as g } from "@scalar/workspace-store/helpers/serialize-stream-example";
7
- import { unpackProxyObject as _ } from "@scalar/workspace-store/helpers/unpack-proxy";
8
- //#region src/code-example/helpers/operation-to-har/process-body.ts
9
- var v = (e, t, n) => ({
6
+ import { getStreamFormat as g } from "@scalar/helpers/http/is-streaming-content-type";
7
+ import { isFileSchema as _ } from "@scalar/workspace-store/helpers/is-file-schema";
8
+ import { serializeStreamExample as v } from "@scalar/workspace-store/helpers/serialize-stream-example";
9
+ import { unpackProxyObject as y } from "@scalar/workspace-store/helpers/unpack-proxy";
10
+ import { resolve as b } from "@scalar/workspace-store/resolve";
11
+ import { isArraySchema as x, isObjectSchema as S } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
12
+ // src/code-example/helpers/operation-to-har/process-body.ts
13
+ var C = (e, t, n) => ({
10
14
  name: e,
11
15
  value: `@${t}`,
12
16
  fileName: t,
13
17
  ...n ? { contentType: n } : {}
14
- }), y = (e) => !!e && "type" in e && e.type === "string" && "format" in e && e.format === "binary", b = (e, t) => typeof e == "string" && e.startsWith("@") && y(t) ? e.slice(1) : void 0, x = (e, t, r, i = !1, a) => {
18
+ }), w = (e) => !!e && "type" in e && e.type === "string" && "format" in e && e.format === "binary", T = (e, t) => typeof e == "string" && e.startsWith("@") && w(t) ? e.slice(1) : void 0, E = (e, t, r, i = !1, a) => {
15
19
  let o = [], u = Array.isArray(e) ? e.filter((e) => !e.isDisabled).map((e) => [String(e.name), e.value]) : Object.entries(e);
16
20
  for (let [d, f] of u) {
17
21
  if (f == null) continue;
@@ -19,7 +23,7 @@ var v = (e, t, n) => ({
19
23
  if (i && !r) {
20
24
  let t = Array.isArray(e) ? n(f, s(a, [d])) : f, r = l(d, Array.isArray(t) ? t : f, u);
21
25
  if (r) {
22
- for (let e of r) e.value instanceof File ? o.push(v(e.key, e.value.name, e.contentType ?? e.value.type)) : o.push({
26
+ for (let e of r) e.value instanceof File ? o.push(C(e.key, e.value.name, e.contentType ?? e.value.type)) : o.push({
23
27
  name: e.key,
24
28
  value: e.value,
25
29
  ...e.contentType ? { contentType: e.contentType } : {}
@@ -27,34 +31,34 @@ var v = (e, t, n) => ({
27
31
  continue;
28
32
  }
29
33
  }
30
- 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 ? b(f, s(a, [d])) : void 0, g = r ? null : c(d, f, u);
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 ? T(f, s(a, [d])) : void 0, g = r ? null : c(d, f, u);
31
35
  if (g) for (let e of g) o.push({
32
36
  name: e.key,
33
37
  value: e.value
34
38
  });
35
39
  else if (f instanceof File) {
36
- let e = _(f);
37
- o.push(v(d, e.name, m ?? (i ? e.type : void 0)));
38
- } else if (h !== void 0) o.push(v(d, h, m));
40
+ let e = y(f);
41
+ o.push(C(d, e.name, m ?? (i ? e.type : void 0)));
42
+ } else if (h !== void 0) o.push(C(d, h, m));
39
43
  else if (m && typeof f == "object") o.push({
40
44
  name: d,
41
- value: JSON.stringify(_(f)),
45
+ value: JSON.stringify(y(f)),
42
46
  contentType: m
43
47
  });
44
48
  else if (i && !r && !p && typeof f == "object" && !Array.isArray(f)) o.push({
45
49
  name: d,
46
- value: JSON.stringify(_(f)),
50
+ value: JSON.stringify(y(f)),
47
51
  contentType: "application/json"
48
52
  });
49
53
  else if (Array.isArray(f)) for (let e of f) if (e instanceof File) {
50
- let t = _(e);
51
- o.push(v(d, t.name, i ? t.type : void 0));
54
+ let t = y(e);
55
+ o.push(C(d, t.name, i ? t.type : void 0));
52
56
  } else o.push({
53
57
  name: d,
54
58
  value: String(e)
55
59
  });
56
60
  else if (typeof f == "object") {
57
- let e = x(f, void 0, d);
61
+ let e = E(f, void 0, d);
58
62
  for (let t of e) o.push({
59
63
  name: `${d}.${t.name}`,
60
64
  value: t.value
@@ -66,65 +70,89 @@ var v = (e, t, n) => ({
66
70
  });
67
71
  }
68
72
  return o;
69
- }, S = ({ requestBody: n, contentType: s, example: c, openapiVersion: l, requestBodyCompositionSelection: v }) => {
70
- let y = s || Object.keys(n.content)[0] || "", b = y === "other" ? "" : y, S = (e) => `@${_(e).name || "filename"}`, C = n.content[y]?.encoding, w = n.content[y];
71
- if (w && o(y, w)) {
72
- let e = c ?? Object.keys(w.examples ?? {})[0] ?? "default", r = t({
73
+ }, D = ({ requestBody: n, contentType: s, example: c, openapiVersion: l, jsonSchemaDialect: C, requestBodyCompositionSelection: w }) => {
74
+ let T = s || Object.keys(n.content)[0] || "", D = T === "other" ? "" : T, O = (e) => `@${y(e).name || "filename"}`, k = n.content[T]?.encoding, A = n.content[T];
75
+ if (A && o(T, A)) {
76
+ let e = c ?? Object.keys(A.examples ?? {})[0] ?? "default", r = t({
73
77
  ...n,
74
- "x-scalar-selected-content-type": { [e]: y }
75
- }, e, v);
78
+ "x-scalar-selected-content-type": { [e]: T }
79
+ }, e, w, l, C);
76
80
  if (r?.mode === "multipart") {
77
81
  let e = u(r.value, r.contentType);
78
82
  return {
79
83
  mimeType: e.contentType,
80
- text: e.chunks.map((e) => e instanceof File ? S(e) : e instanceof Blob ? "BINARY" : String(e)).join("")
84
+ text: e.chunks.map((e) => e instanceof File ? O(e) : e instanceof Blob ? "BINARY" : String(e)).join("")
81
85
  };
82
86
  }
83
87
  }
84
- let T = y === "multipart/form-data" || y === "application/x-www-form-urlencoded";
85
- if (d(y)) {
86
- let e = i(n, y, c ?? "", v, l);
88
+ let j = T === "multipart/form-data" || T === "application/x-www-form-urlencoded";
89
+ if (d(T)) {
90
+ let e = i(n, T, c ?? "", w, l, C);
87
91
  return e ? {
88
- mimeType: b,
92
+ mimeType: D,
89
93
  text: e.value
90
94
  } : void 0;
91
95
  }
92
- let E = f(r(n, c, s)), D = p(E, y);
93
- if (D !== void 0) return {
94
- mimeType: b,
95
- text: D
96
+ let M = f(r(n, c, s)), N = p(M, T);
97
+ if (N !== void 0) return {
98
+ mimeType: D,
99
+ text: N
96
100
  };
97
- let O = E?.value;
98
- if (O !== void 0) {
99
- let e = typeof O == "object" && O ? _(O) : O;
100
- return T && typeof e == "object" && e ? {
101
- mimeType: b,
102
- params: x(e, C, void 0, y === "multipart/form-data", m(n.content[y]?.schema, h))
101
+ let P = M?.value;
102
+ if (P !== void 0) {
103
+ let e = typeof P == "object" && P ? y(P) : P;
104
+ return j && typeof e == "object" && e ? {
105
+ mimeType: D,
106
+ params: E(e, k, void 0, T === "multipart/form-data", m(n.content[T]?.schema, h))
103
107
  } : e instanceof File ? {
104
- mimeType: b,
105
- text: S(e)
108
+ mimeType: D,
109
+ text: O(e)
106
110
  } : {
107
- mimeType: b,
108
- text: typeof e == "string" ? e : g(e, y, !1) ?? JSON.stringify(e)
111
+ mimeType: D,
112
+ text: typeof e == "string" ? e : v(e, T, !1) ?? JSON.stringify(e)
109
113
  };
110
114
  }
111
- let k = n.content[y], A = m(k?.schema ?? k?.itemSchema);
112
- if (A !== void 0) {
113
- let t = a(e(A), {
114
- compositionSelection: v,
115
+ let F = n.content[T], I = m(F?.schema ?? F?.itemSchema);
116
+ if (I !== void 0) {
117
+ let t = e(I);
118
+ if (T === "multipart/form-data" && S(t)) for (let [e, n] of Object.entries(t.properties ?? {})) {
119
+ let r = b.schema(n), i = r && x(r) ? b.schema(r.items) : r;
120
+ if (i && !("type" in i) && !("properties" in i) && !i.allOf && !i.oneOf && !i.anyOf && !i.contentSchema && _(i, !1)) {
121
+ let n = {
122
+ ...i,
123
+ type: "string",
124
+ format: "binary"
125
+ };
126
+ t.properties[e] = r && x(r) ? {
127
+ ...r,
128
+ items: n
129
+ } : n;
130
+ }
131
+ }
132
+ if (!j && F?.schema !== void 0 && Object.keys(t).every((e) => [
133
+ "__scalar_",
134
+ "title",
135
+ "description"
136
+ ].includes(e)) && !g(T) && _(t, !1, T)) return {
137
+ mimeType: D,
138
+ text: "@filename"
139
+ };
140
+ let n = a(t, {
141
+ compositionSelection: w,
115
142
  mode: "write",
116
- binaryAsFile: y === "multipart/form-data"
143
+ openapiVersion: l,
144
+ jsonSchemaDialect: C,
145
+ binaryAsFile: T === "multipart/form-data"
117
146
  }, { schemaPath: ["requestBody"] });
118
- if (t !== void 0) return T && typeof t == "object" && t ? {
119
- mimeType: b,
120
- params: x(t, C, void 0, y === "multipart/form-data", A)
147
+ if (n !== void 0) return j && typeof n == "object" && n ? {
148
+ mimeType: D,
149
+ params: E(n, k, void 0, T === "multipart/form-data", I)
121
150
  } : {
122
- mimeType: b,
123
- text: g(t, y, k?.schema === void 0) ?? (typeof t == "string" ? t : JSON.stringify(t))
151
+ mimeType: D,
152
+ text: v(n, T, F?.schema === void 0) ?? (typeof n == "string" ? n : JSON.stringify(n))
124
153
  };
125
154
  }
126
155
  };
127
- //#endregion
128
- export { S as processBody };
156
+ export { D as processBody };
129
157
 
130
158
  //# sourceMappingURL=process-body.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-body.js","names":["buildFileParam","fileName","contentType","isBinarySchema","schema","getBinaryPlaceholderFileName","value","objectToFormParams","params","entries","obj","item","key","partEncoding","parentKey","encoding","isMultipart","restored","coerceLeafValueToSchemaType","resolveLeafSchema","arrayParts","serializeMultipartArray","part","hasFormStyle","explicitContentType","binaryPlaceholderFileName","styleParams","serializeFormPropertyWithEncoding","param","file","unpackProxyObject","nestedParams","processBody","_contentType","requestBody","harMimeType","formatBinaryFile","media","needsMultipartEncoding","exampleName","example","body","buildRequestBody","requestBodyCompositionSelection","encoded","serializeMultipartBody","chunk","isFormData","isXmlMediaType","xmlExample","getExampleFromBody","openapiVersion","selected","getExampleValue","getExample","explicitText","getExplicitExampleText","_example","exampleValue","getResolvedRef","mergeSiblingReferences","serializeStreamExample","mediaType","contentSchema","extractedExample","getExampleFromSchema","snapshotSchema"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { getExampleValue, getExplicitExampleText } from '@scalar/workspace-store/helpers/get-example-value'\nimport { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { serializeStreamExample } from '@scalar/workspace-store/helpers/serialize-stream-example'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n buildRequestBody,\n coerceLeafValueToSchemaType,\n getExample,\n getExampleFromBody,\n getExampleFromSchema,\n needsMultipartEncoding,\n resolveLeafSchema,\n serializeFormPropertyWithEncoding,\n serializeMultipartArray,\n serializeMultipartBody,\n} from '@scalar/workspace-store/request-example'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Param, PostData } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<\n OperationToHarProps,\n 'contentType' | 'example' | 'requestBodyCompositionSelection' | 'openapiVersion'\n> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Builds a HAR param for an uploaded file. `fileName` is what snippet generators read to emit real\n * file handling (for example `files=` in Python or `new Blob` in fetch). `value` keeps the\n * `@filename` placeholder for consumers that only read the text value.\n */\nconst buildFileParam = (name: string, fileName: string, contentType?: string): Param => ({\n name,\n value: `@${fileName}`,\n fileName,\n ...(contentType ? { contentType } : {}),\n})\n\n/** True when the schema describes a binary file (`type: string, format: binary`). */\nconst isBinarySchema = (schema: SchemaObject | undefined): boolean =>\n !!schema && 'type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary'\n\n/**\n * Example generation turns a binary property into the `@filename` placeholder string.\n * Use the schema to tell that apart from a normal text field that happens to start with `@`.\n */\nconst getBinaryPlaceholderFileName = (value: unknown, schema: SchemaObject | undefined): string | undefined =>\n typeof value === 'string' && value.startsWith('@') && isBinarySchema(schema) ? value.slice(1) : undefined\n\n/**\n * Converts a form-data body into HAR `Param[]` entries for `multipart/form-data`\n * and `application/x-www-form-urlencoded` requests.\n *\n * Per OpenAPI 3.1.x Encoding Object, each property's serialization is governed\n * by an optional Encoding entry. When `style` / `explode` / `allowReserved` is\n * set, the value is serialized RFC6570-style and `contentType` is ignored.\n * Multipart arrays apply the encoding to each item and repeat the property name.\n * Object items default to JSON, and uploaded files retain their filename references.\n *\n * @param obj - The form-data payload, either an object keyed by property name\n * or a HAR-style `{ name, value, isDisabled }[]` array.\n * @param encoding - The `encoding` map from the Media Type Object, if any.\n * Used only at the top level (`parentKey` undefined).\n * @param parentKey - When set, we are flattening a nested object inside another\n * property; encoding is ignored and keys are joined with `.` (legacy default).\n * @param isMultipart - True for `multipart/form-data`. Gates the spec defaults\n * for object properties and array items. Urlencoded bodies retain their existing\n * serialization and flattening behavior.\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n isMultipart = false,\n schema?: SchemaObject,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries: [string, unknown][] = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [String(item.name), item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partEncoding = parentKey ? undefined : encoding?.[key]\n\n if (isMultipart && !parentKey) {\n const restored = Array.isArray(obj) ? coerceLeafValueToSchemaType(value, resolveLeafSchema(schema, [key])) : value\n const arrayParts = serializeMultipartArray(key, Array.isArray(restored) ? restored : value, partEncoding)\n if (arrayParts) {\n for (const part of arrayParts) {\n if (part.value instanceof File) {\n params.push(buildFileParam(part.key, part.value.name, part.contentType ?? part.value.type))\n continue\n }\n params.push({\n name: part.key,\n value: part.value,\n ...(part.contentType ? { contentType: part.contentType } : {}),\n })\n }\n continue\n }\n }\n /**\n * Per OpenAPI 3.1.1: when style, explode, or allowReserved is explicitly set on the\n * encoding entry, contentType (implicit or explicit) is ignored and the value is\n * serialized as if it were a query-style parameter.\n */\n const hasFormStyle =\n partEncoding &&\n (partEncoding.style !== undefined ||\n partEncoding.explode !== undefined ||\n partEncoding.allowReserved !== undefined)\n /**\n * Per OAS 3.1.x Encoding Object: `contentType` SHALL be ignored if the request body\n * media type is not a multipart. For `application/x-www-form-urlencoded` we still\n * honor `style`/`explode`/`allowReserved` (handled above), but a `contentType`-only\n * entry has no effect — values fall through to the dotted-key flattening default.\n */\n const explicitContentType = hasFormStyle || !isMultipart ? undefined : partEncoding?.contentType\n\n /**\n * When the encoding sets style/explode/allowReserved, serialize the value RFC6570-style\n * (bracket/exploded notation) and ignore contentType. See `serializeFormPropertyWithEncoding`\n * for the per-style rules; it returns null for primitives, Files, and arrays of Files, which\n * then fall through to the dedicated branches below. HAR represents multipart and urlencoded\n * the same way via `PostData.params`, so the resulting parts work for both.\n */\n const binaryPlaceholderFileName =\n isMultipart && !parentKey ? getBinaryPlaceholderFileName(value, resolveLeafSchema(schema, [key])) : undefined\n const styleParams = parentKey ? null : serializeFormPropertyWithEncoding(key, value, partEncoding)\n if (styleParams) {\n for (const param of styleParams) {\n params.push({ name: param.key, value: param.value })\n }\n } else if (value instanceof File) {\n /**\n * File values render as `@filename` references, the conventional cURL syntax for an\n * attached file. Picked up by snippet renderers downstream (e.g. `--form 'x=@file.png'`).\n */\n const file = unpackProxyObject(value)\n params.push(buildFileParam(key, file.name, explicitContentType ?? (isMultipart ? file.type : undefined)))\n } else if (binaryPlaceholderFileName !== undefined) {\n /** A binary property filled in by example generation, so it is a file and not a text field. */\n params.push(buildFileParam(key, binaryPlaceholderFileName, explicitContentType))\n } else if (explicitContentType && typeof value === 'object') {\n /**\n * Per OAS 3.1.x Encoding Object: an explicit `encoding[key].contentType` on a\n * complex value overrides the default and emits a single part containing the value\n * JSON-stringified into that media type. Only reachable when style/explode/allowReserved\n * are unset (otherwise contentType is ignored — see the style branch above).\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: explicitContentType,\n })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof value === 'object' && !Array.isArray(value)) {\n /**\n * Per OpenAPI 3.x: a top-level multipart property whose value is an object (and not a File)\n * defaults to a single part encoded as application/json, rather than being flattened\n * into multiple parts with dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: 'application/json',\n })\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push(buildFileParam(key, file.name, isMultipart ? file.type : undefined))\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n } else if (typeof value === 'object') {\n /**\n * Legacy fallback: flatten nested objects into dotted-key parts. Reached when the\n * multipart JSON-default branches above don't apply — i.e. either inside a recursive\n * call (`parentKey` set) or on `application/x-www-form-urlencoded` bodies without an\n * explicit encoding entry. Strict OAS 3.1.x would use `style: form, explode: true` as\n * the urlencoded default (inner keys become top-level params); we keep dotted keys for\n * backwards compatibility with consumers that already parse this shape.\n */\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({\n name: key,\n value: String(value),\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n openapiVersion,\n requestBodyCompositionSelection,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n /** Empty when \"Other\" is selected so snippets do not inject `Content-Type: other`. */\n const harMimeType = _contentType === 'other' ? '' : _contentType\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n const media = requestBody.content[_contentType]\n if (media && needsMultipartEncoding(_contentType, media)) {\n const exampleName = example ?? Object.keys(media.examples ?? {})[0] ?? 'default'\n const body = buildRequestBody(\n { ...requestBody, 'x-scalar-selected-content-type': { [exampleName]: _contentType } },\n exampleName,\n requestBodyCompositionSelection,\n )\n if (body?.mode === 'multipart') {\n const encoded = serializeMultipartBody(body.value, body.contentType)\n return {\n mimeType: encoded.contentType,\n // HAR text cannot embed file bytes synchronously. Keep visible file placeholders.\n text: encoded.chunks\n .map((chunk) => {\n if (chunk instanceof File) {\n return formatBinaryFile(chunk)\n }\n return chunk instanceof Blob ? 'BINARY' : String(chunk)\n })\n .join(''),\n }\n }\n }\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n if (isXmlMediaType(_contentType)) {\n const xmlExample = getExampleFromBody(\n requestBody,\n _contentType,\n example ?? '',\n requestBodyCompositionSelection,\n openapiVersion,\n )\n return xmlExample ? { mimeType: harMimeType, text: xmlExample.value as string } : undefined\n }\n\n // Get the example value\n const selected = getExampleValue(getExample(requestBody, example, contentType))\n const explicitText = getExplicitExampleText(selected, _contentType)\n if (explicitText !== undefined) {\n return { mimeType: harMimeType, text: explicitText }\n }\n const _example = selected?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n exampleValue,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n getResolvedRef(requestBody.content[_contentType]?.schema, mergeSiblingReferences),\n ),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: harMimeType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n typeof exampleValue === 'string'\n ? exampleValue\n : (serializeStreamExample(exampleValue, _contentType, false) ?? JSON.stringify(exampleValue)),\n }\n }\n\n // Try to extract examples from the schema\n const mediaType = requestBody.content[_contentType]\n const contentSchema = getResolvedRef(mediaType?.schema ?? mediaType?.itemSchema)\n if (typeof contentSchema !== 'undefined') {\n const extractedExample = getExampleFromSchema(\n snapshotSchema(contentSchema),\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n binaryAsFile: _contentType === 'multipart/form-data',\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n extractedExample,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n contentSchema,\n ),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n serializeStreamExample(extractedExample, _contentType, mediaType?.schema === undefined) ??\n (typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample)),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;AAyCA,IAAMA,KAAkB,GAAc,GAAkB,OAAiC;CACvF;CACA,OAAO,IAAIC;CACX;CACA,GAAIC,IAAc,EAAE,eAAY,IAAI,CAAC;AACvC,IAGMC,KAAkB,MACtB,CAAC,CAACC,KAAU,UAAUA,KAAUA,EAAO,SAAS,YAAY,YAAYA,KAAUA,EAAO,WAAW,UAMhGC,KAAgC,GAAgB,MACpD,OAAOC,KAAU,YAAYA,EAAM,WAAW,GAAG,KAAKH,EAAeC,CAAM,IAAIE,EAAM,MAAM,CAAC,IAAI,KAAA,GAsB5FC,KACJ,GACA,GACA,GACA,IAAc,IACd,MACY;CACZ,IAAMC,IAAkB,CAAC,GAGnBC,IAA+B,MAAM,QAAQC,CAAG,IAClDA,EAAI,QAAQ,MAAS,CAACC,EAAK,UAAU,CAAC,CAAC,KAAK,MAAS,CAAC,OAAOA,EAAK,IAAI,GAAGA,EAAK,KAAK,CAAC,IACpF,OAAO,QAAQD,CAAG;CAEtB,KAAK,IAAM,CAACE,GAAKN,MAAUG,GAAS;EAClC,IAAIH,KAAiC,MACnC;EAGF,IAAMO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ACF,IAGEF,aAAwB,OACnB;GACL,UAAUvB;GACV,MAAMC,EAAiBsB,CAAY;EACrC,IAGK;GACL,UAAUvB;GACV,MACE,OAAOuB,KAAiB,WACpBA,IACCG,EAAuBH,GAAczB,GAAc,EAAK,KAAK,KAAK,UAAUyB,CAAY;EACjG;CACF;CAGA,IAAMI,IAAY5B,EAAY,QAAQD,IAChC8B,IAAgBJ,EAAeG,GAAW,UAAUA,GAAW,UAAU;CAC/E,IAAWC,MAAkB,QAAa;EACxC,IAAMC,IAAmBC,EACvBC,EAAeH,CAAa,GAC5B;GACE,sBAAsBpB;GACtB,MAAM;GACN,cAAcV,MAAiB;EACjC,GACA,EACE,YAAY,CAAC,aAAa,EAC5B,CACF;EAEA,IAAI+B,MAAqB,KAAA,GAcvB,OAbIjB,KAAc,OAAOiB,KAAqB,YAAYA,IACjD;GACL,UAAU7B;GACV,QAAQ5B,EACNyD,GACAjD,GACA,KAAA,GACAkB,MAAiB,uBACjB8B,CACF;EACF,IAGK;GACL,UAAU5B;GACV,MACE0B,EAAuBG,GAAkB/B,GAAc6B,GAAW,WAAW,KAAA,CAAS,MACrF,OAAOE,KAAqB,WAAWA,IAAmB,KAAK,UAAUA,CAAgB;EAC9F;CAEJ;AAGF"}
1
+ {"version":3,"file":"process-body.js","names":["buildFileParam","fileName","contentType","isBinarySchema","schema","getBinaryPlaceholderFileName","value","objectToFormParams","params","entries","obj","item","key","partEncoding","parentKey","encoding","isMultipart","restored","coerceLeafValueToSchemaType","resolveLeafSchema","arrayParts","serializeMultipartArray","part","hasFormStyle","explicitContentType","binaryPlaceholderFileName","styleParams","serializeFormPropertyWithEncoding","param","file","unpackProxyObject","nestedParams","processBody","_contentType","requestBody","harMimeType","formatBinaryFile","media","needsMultipartEncoding","exampleName","example","body","buildRequestBody","requestBodyCompositionSelection","openapiVersion","jsonSchemaDialect","encoded","serializeMultipartBody","chunk","isFormData","isXmlMediaType","xmlExample","getExampleFromBody","selected","getExampleValue","getExample","explicitText","getExplicitExampleText","_example","exampleValue","getResolvedRef","mergeSiblingReferences","serializeStreamExample","mediaType","contentSchema","exampleSchema","snapshotSchema","isObjectSchema","name","property","resolved","resolve","isArraySchema","isFileSchema","binary","getStreamFormat","extractedExample","getExampleFromSchema"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { getStreamFormat } from '@scalar/helpers/http/is-streaming-content-type'\nimport { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { getExampleValue, getExplicitExampleText } from '@scalar/workspace-store/helpers/get-example-value'\nimport { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { isFileSchema } from '@scalar/workspace-store/helpers/is-file-schema'\nimport { serializeStreamExample } from '@scalar/workspace-store/helpers/serialize-stream-example'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n buildRequestBody,\n coerceLeafValueToSchemaType,\n getExample,\n getExampleFromBody,\n getExampleFromSchema,\n needsMultipartEncoding,\n resolveLeafSchema,\n serializeFormPropertyWithEncoding,\n serializeMultipartArray,\n serializeMultipartBody,\n} from '@scalar/workspace-store/request-example'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema, isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\nimport type { Param, PostData } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<\n OperationToHarProps,\n 'contentType' | 'example' | 'requestBodyCompositionSelection' | 'openapiVersion' | 'jsonSchemaDialect'\n> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Builds a HAR param for an uploaded file. `fileName` is what snippet generators read to emit real\n * file handling (for example `files=` in Python or `new Blob` in fetch). `value` keeps the\n * `@filename` placeholder for consumers that only read the text value.\n */\nconst buildFileParam = (name: string, fileName: string, contentType?: string): Param => ({\n name,\n value: `@${fileName}`,\n fileName,\n ...(contentType ? { contentType } : {}),\n})\n\n/** True when the schema describes a binary file (`type: string, format: binary`). */\nconst isBinarySchema = (schema: SchemaObject | undefined): boolean =>\n !!schema && 'type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary'\n\n/**\n * Example generation turns a binary property into the `@filename` placeholder string.\n * Use the schema to tell that apart from a normal text field that happens to start with `@`.\n */\nconst getBinaryPlaceholderFileName = (value: unknown, schema: SchemaObject | undefined): string | undefined =>\n typeof value === 'string' && value.startsWith('@') && isBinarySchema(schema) ? value.slice(1) : undefined\n\n/**\n * Converts a form-data body into HAR `Param[]` entries for `multipart/form-data`\n * and `application/x-www-form-urlencoded` requests.\n *\n * Per OpenAPI 3.1.x Encoding Object, each property's serialization is governed\n * by an optional Encoding entry. When `style` / `explode` / `allowReserved` is\n * set, the value is serialized RFC6570-style and `contentType` is ignored.\n * Multipart arrays apply the encoding to each item and repeat the property name.\n * Object items default to JSON, and uploaded files retain their filename references.\n *\n * @param obj - The form-data payload, either an object keyed by property name\n * or a HAR-style `{ name, value, isDisabled }[]` array.\n * @param encoding - The `encoding` map from the Media Type Object, if any.\n * Used only at the top level (`parentKey` undefined).\n * @param parentKey - When set, we are flattening a nested object inside another\n * property; encoding is ignored and keys are joined with `.` (legacy default).\n * @param isMultipart - True for `multipart/form-data`. Gates the spec defaults\n * for object properties and array items. Urlencoded bodies retain their existing\n * serialization and flattening behavior.\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n isMultipart = false,\n schema?: SchemaObject,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries: [string, unknown][] = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [String(item.name), item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partEncoding = parentKey ? undefined : encoding?.[key]\n\n if (isMultipart && !parentKey) {\n const restored = Array.isArray(obj) ? coerceLeafValueToSchemaType(value, resolveLeafSchema(schema, [key])) : value\n const arrayParts = serializeMultipartArray(key, Array.isArray(restored) ? restored : value, partEncoding)\n if (arrayParts) {\n for (const part of arrayParts) {\n if (part.value instanceof File) {\n params.push(buildFileParam(part.key, part.value.name, part.contentType ?? part.value.type))\n continue\n }\n params.push({\n name: part.key,\n value: part.value,\n ...(part.contentType ? { contentType: part.contentType } : {}),\n })\n }\n continue\n }\n }\n /**\n * Per OpenAPI 3.1.1: when style, explode, or allowReserved is explicitly set on the\n * encoding entry, contentType (implicit or explicit) is ignored and the value is\n * serialized as if it were a query-style parameter.\n */\n const hasFormStyle =\n partEncoding &&\n (partEncoding.style !== undefined ||\n partEncoding.explode !== undefined ||\n partEncoding.allowReserved !== undefined)\n /**\n * Per OAS 3.1.x Encoding Object: `contentType` SHALL be ignored if the request body\n * media type is not a multipart. For `application/x-www-form-urlencoded` we still\n * honor `style`/`explode`/`allowReserved` (handled above), but a `contentType`-only\n * entry has no effect — values fall through to the dotted-key flattening default.\n */\n const explicitContentType = hasFormStyle || !isMultipart ? undefined : partEncoding?.contentType\n\n /**\n * When the encoding sets style/explode/allowReserved, serialize the value RFC6570-style\n * (bracket/exploded notation) and ignore contentType. See `serializeFormPropertyWithEncoding`\n * for the per-style rules; it returns null for primitives, Files, and arrays of Files, which\n * then fall through to the dedicated branches below. HAR represents multipart and urlencoded\n * the same way via `PostData.params`, so the resulting parts work for both.\n */\n const binaryPlaceholderFileName =\n isMultipart && !parentKey ? getBinaryPlaceholderFileName(value, resolveLeafSchema(schema, [key])) : undefined\n const styleParams = parentKey ? null : serializeFormPropertyWithEncoding(key, value, partEncoding)\n if (styleParams) {\n for (const param of styleParams) {\n params.push({ name: param.key, value: param.value })\n }\n } else if (value instanceof File) {\n /**\n * File values render as `@filename` references, the conventional cURL syntax for an\n * attached file. Picked up by snippet renderers downstream (e.g. `--form 'x=@file.png'`).\n */\n const file = unpackProxyObject(value)\n params.push(buildFileParam(key, file.name, explicitContentType ?? (isMultipart ? file.type : undefined)))\n } else if (binaryPlaceholderFileName !== undefined) {\n /** A binary property filled in by example generation, so it is a file and not a text field. */\n params.push(buildFileParam(key, binaryPlaceholderFileName, explicitContentType))\n } else if (explicitContentType && typeof value === 'object') {\n /**\n * Per OAS 3.1.x Encoding Object: an explicit `encoding[key].contentType` on a\n * complex value overrides the default and emits a single part containing the value\n * JSON-stringified into that media type. Only reachable when style/explode/allowReserved\n * are unset (otherwise contentType is ignored — see the style branch above).\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: explicitContentType,\n })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof value === 'object' && !Array.isArray(value)) {\n /**\n * Per OpenAPI 3.x: a top-level multipart property whose value is an object (and not a File)\n * defaults to a single part encoded as application/json, rather than being flattened\n * into multiple parts with dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: 'application/json',\n })\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push(buildFileParam(key, file.name, isMultipart ? file.type : undefined))\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n } else if (typeof value === 'object') {\n /**\n * Legacy fallback: flatten nested objects into dotted-key parts. Reached when the\n * multipart JSON-default branches above don't apply — i.e. either inside a recursive\n * call (`parentKey` set) or on `application/x-www-form-urlencoded` bodies without an\n * explicit encoding entry. Strict OAS 3.1.x would use `style: form, explode: true` as\n * the urlencoded default (inner keys become top-level params); we keep dotted keys for\n * backwards compatibility with consumers that already parse this shape.\n */\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({\n name: key,\n value: String(value),\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n /** Empty when \"Other\" is selected so snippets do not inject `Content-Type: other`. */\n const harMimeType = _contentType === 'other' ? '' : _contentType\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n const media = requestBody.content[_contentType]\n if (media && needsMultipartEncoding(_contentType, media)) {\n const exampleName = example ?? Object.keys(media.examples ?? {})[0] ?? 'default'\n const body = buildRequestBody(\n { ...requestBody, 'x-scalar-selected-content-type': { [exampleName]: _contentType } },\n exampleName,\n requestBodyCompositionSelection,\n openapiVersion,\n jsonSchemaDialect,\n )\n if (body?.mode === 'multipart') {\n const encoded = serializeMultipartBody(body.value, body.contentType)\n return {\n mimeType: encoded.contentType,\n // HAR text cannot embed file bytes synchronously. Keep visible file placeholders.\n text: encoded.chunks\n .map((chunk) => {\n if (chunk instanceof File) {\n return formatBinaryFile(chunk)\n }\n return chunk instanceof Blob ? 'BINARY' : String(chunk)\n })\n .join(''),\n }\n }\n }\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n if (isXmlMediaType(_contentType)) {\n const xmlExample = getExampleFromBody(\n requestBody,\n _contentType,\n example ?? '',\n requestBodyCompositionSelection,\n openapiVersion,\n jsonSchemaDialect,\n )\n return xmlExample ? { mimeType: harMimeType, text: xmlExample.value as string } : undefined\n }\n\n // Get the example value\n const selected = getExampleValue(getExample(requestBody, example, contentType))\n const explicitText = getExplicitExampleText(selected, _contentType)\n if (explicitText !== undefined) {\n return { mimeType: harMimeType, text: explicitText }\n }\n const _example = selected?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n exampleValue,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n getResolvedRef(requestBody.content[_contentType]?.schema, mergeSiblingReferences),\n ),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: harMimeType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n typeof exampleValue === 'string'\n ? exampleValue\n : (serializeStreamExample(exampleValue, _contentType, false) ?? JSON.stringify(exampleValue)),\n }\n }\n\n // Try to extract examples from the schema\n const mediaType = requestBody.content[_contentType]\n const contentSchema = getResolvedRef(mediaType?.schema ?? mediaType?.itemSchema)\n if (typeof contentSchema !== 'undefined') {\n const exampleSchema = snapshotSchema(contentSchema)\n if (_contentType === 'multipart/form-data' && isObjectSchema(exampleSchema)) {\n // Adapt upgraded upload fields only on the code example's private snapshot.\n // The generator already supports the legacy binary shape, including file arrays.\n for (const [name, property] of Object.entries(exampleSchema.properties ?? {})) {\n const resolved = resolve.schema(property)\n const file = resolved && isArraySchema(resolved) ? resolve.schema(resolved.items) : resolved\n if (\n file &&\n !('type' in file) &&\n !('properties' in file) &&\n !file.allOf &&\n !file.oneOf &&\n !file.anyOf &&\n !file.contentSchema &&\n isFileSchema(file, false)\n ) {\n const binary: SchemaObject = { ...file, type: 'string', format: 'binary' }\n exampleSchema.properties![name] =\n resolved && isArraySchema(resolved) ? { ...resolved, items: binary } : binary\n }\n }\n }\n // A migrated whole-body binary schema is empty. Do not infer files from\n // declared values, constraints, compositions, or schemas for individual stream items.\n const isEmptyBinaryBody =\n !isFormData &&\n mediaType?.schema !== undefined &&\n Object.keys(exampleSchema).every((key) => ['__scalar_', 'title', 'description'].includes(key)) &&\n !getStreamFormat(_contentType) &&\n isFileSchema(exampleSchema, false, _contentType)\n if (isEmptyBinaryBody) {\n return { mimeType: harMimeType, text: '@filename' }\n }\n const extractedExample = getExampleFromSchema(\n exampleSchema,\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n openapiVersion,\n jsonSchemaDialect,\n binaryAsFile: _contentType === 'multipart/form-data',\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n extractedExample,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n contentSchema,\n ),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n serializeStreamExample(extractedExample, _contentType, mediaType?.schema === undefined) ??\n (typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample)),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;AA6CA,IAAMA,KAAkB,GAAc,GAAkB,OAAiC;CACvF;CACA,OAAO,IAAIC;CACX;CACA,GAAIC,IAAc,EAAE,eAAY,IAAI,CAAC;AACvC,IAGMC,KAAkB,MACtB,CAAC,CAACC,KAAU,UAAUA,KAAUA,EAAO,SAAS,YAAY,YAAYA,KAAUA,EAAO,WAAW,UAMhGC,KAAgC,GAAgB,MACpD,OAAOC,KAAU,YAAYA,EAAM,WAAW,GAAG,KAAKH,EAAeC,CAAM,IAAIE,EAAM,MAAM,CAAC,IAAI,KAAA,GAsB5FC,KACJ,GACA,GACA,GACA,IAAc,IACd,MACY;CACZ,IAAMC,IAAkB,CAAC,GAGnBC,IAA+B,MAAM,QAAQC,CAAG,IAClDA,EAAI,QAAQ,MAAS,CAACC,EAAK,UAAU,CAAC,CAAC,KAAK,MAAS,CAAC,OAAOA,EAAK,IAAI,GAAGA,EAAK,KAAK,CAAC,IACpF,OAAO,QAAQD,CAAG;CAEtB,K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IAAOhC,CAAY,GAE/C,OAAO;GAAE,UAAUE;GAAa,MAAM;EAAY;EAEpD,IAAMyC,IAAmBC,EACvBZ,GACA;GACE,sBAAsBtB;GACtB,MAAM;GACN;GACA;GACA,cAAcV,MAAiB;EACjC,GACA,EACE,YAAY,CAAC,aAAa,EAC5B,CACF;EAEA,IAAI2C,MAAqB,KAAA,GAcvB,OAbI3B,KAAc,OAAO2B,KAAqB,YAAYA,IACjD;GACL,UAAUzC;GACV,QAAQ5B,EACNqE,GACA7D,GACA,KAAA,GACAkB,MAAiB,uBACjB+B,CACF;EACF,IAGK;GACL,UAAU7B;GACV,MACE2B,EAAuBc,GAAkB3C,GAAc8B,GAAW,WAAW,KAAA,CAAS,MACrF,OAAOa,KAAqB,WAAWA,IAAmB,KAAK,UAAUA,CAAgB;EAC9F;CAEJ;AAGF"}
@@ -19,7 +19,7 @@ type ProcessedParameters = {
19
19
  *
20
20
  * @see https://spec.openapis.org/oas/latest.html#style-values
21
21
  */
22
- export declare const processParameters: ({ harRequest, parameters, example, defaultDisabled, openapiVersion, }: {
22
+ export declare const processParameters: ({ harRequest, parameters, example, defaultDisabled, openapiVersion, jsonSchemaDialect, }: {
23
23
  harRequest: HarRequest;
24
24
  parameters: OperationObject["parameters"];
25
25
  /** The name of the example to use */
@@ -28,6 +28,7 @@ export declare const processParameters: ({ harRequest, parameters, example, defa
28
28
  defaultDisabled: boolean;
29
29
  /** Originating API description version. */
30
30
  openapiVersion?: string;
31
+ jsonSchemaDialect?: string;
31
32
  }) => ProcessedParameters;
32
33
  export {};
33
34
  //# sourceMappingURL=process-parameters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AACpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvD,wFAAwF;AACxF,qBAAa,wBAAyB,SAAQ,KAAK;CAAG;AAEtD,KAAK,mBAAmB,GAAG;IACzB,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,+EAA+E;IAC/E,qBAAqB,EAAE,OAAO,CAAA;CAC/B,CAAA;AA6FD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,uEAM/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,gDAAgD;IAChD,eAAe,EAAE,OAAO,CAAA;IACxB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,KAAG,mBAwPH,CAAA"}
1
+ {"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AACpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvD,wFAAwF;AACxF,qBAAa,wBAAyB,SAAQ,KAAK;CAAG;AAEtD,KAAK,mBAAmB,GAAG;IACzB,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,+EAA+E;IAC/E,qBAAqB,EAAE,OAAO,CAAA;CAC/B,CAAA;AAuGD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,0FAO/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,gDAAgD;IAChD,eAAe,EAAE,OAAO,CAAA;IACxB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,KAAG,mBA4PH,CAAA"}