@scalar/workspace-store 0.66.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/events/definitions/operation.d.ts +2 -0
  3. package/dist/events/definitions/operation.d.ts.map +1 -1
  4. package/dist/helpers/encode-chunk-name.d.ts.map +1 -1
  5. package/dist/helpers/encode-chunk-name.js +6 -1
  6. package/dist/helpers/merge-object.d.ts.map +1 -1
  7. package/dist/helpers/merge-object.js +9 -3
  8. package/dist/request-example/builder/body/build-request-body.d.ts +1 -1
  9. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
  10. package/dist/request-example/builder/body/build-request-body.js +2 -2
  11. package/dist/request-example/builder/body/get-request-body-example.d.ts +4 -4
  12. package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
  13. package/dist/request-example/builder/body/get-request-body-example.js +29 -5
  14. package/dist/request-example/builder/helpers/example-evaluation.d.ts +19 -0
  15. package/dist/request-example/builder/helpers/example-evaluation.d.ts.map +1 -0
  16. package/dist/request-example/builder/helpers/example-evaluation.js +2 -0
  17. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +11 -3
  18. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  19. package/dist/request-example/builder/helpers/get-example-from-schema.js +66 -17
  20. package/dist/request-example/builder/request-factory.d.ts +3 -1
  21. package/dist/request-example/builder/request-factory.d.ts.map +1 -1
  22. package/dist/request-example/builder/request-factory.js +2 -2
  23. package/dist/request-example/index.d.ts +4 -0
  24. package/dist/request-example/index.d.ts.map +1 -1
  25. package/dist/request-example/index.js +3 -0
  26. package/dist/request-example/xml/get-xml-body-example.d.ts +8 -0
  27. package/dist/request-example/xml/get-xml-body-example.d.ts.map +1 -0
  28. package/dist/request-example/xml/get-xml-body-example.js +21 -0
  29. package/dist/request-example/xml/get-xml-example.d.ts +21 -0
  30. package/dist/request-example/xml/get-xml-example.d.ts.map +1 -0
  31. package/dist/request-example/xml/get-xml-example.js +352 -0
  32. package/dist/request-example/xml/match-xml-property-pattern.d.ts +10 -0
  33. package/dist/request-example/xml/match-xml-property-pattern.d.ts.map +1 -0
  34. package/dist/request-example/xml/match-xml-property-pattern.js +48 -0
  35. package/dist/request-example/xml/serialize-xml-part.d.ts +4 -5
  36. package/dist/request-example/xml/serialize-xml-part.d.ts.map +1 -1
  37. package/dist/request-example/xml/serialize-xml-part.js +14 -8
  38. package/dist/request-example/xml/write-xml.d.ts +9 -0
  39. package/dist/request-example/xml/write-xml.d.ts.map +1 -0
  40. package/dist/request-example/xml/write-xml.js +119 -0
  41. package/dist/request-example/xml/xml-node.d.ts +32 -0
  42. package/dist/request-example/xml/xml-node.d.ts.map +1 -0
  43. package/dist/request-example/xml/xml-node.js +1 -0
  44. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.67.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#10192](https://github.com/scalar/scalar/pull/10192): Mock-server XML response bytes now use the shared schema-aware serializer instead of `json2xml`, including attributes, namespaces, and root naming. Existing XML response snapshots may need updating. Supplied serialized XML remains unchanged.
8
+
9
+ Generate XML examples from schema metadata, preserving attributes, namespaces, array wrappers, repeated elements, and OpenAPI 3.2 text and CDATA nodes. Use the same XML serialization for request bodies, code snippets, response examples, mock responses, and Markdown documentation. Preserve serialized media examples and escape schema string examples as element text.
10
+
11
+ Explain XML generation failures in response example panels, including the serialized-example escape hatch for large payloads. Expose XML generation failures in mock response headers with `X-Scalar-XML-Error`, containing the first error diagnostic code. Report diagnostics to other consumers through a callback or the developer console, and format element-only descendants within mixed content without changing text values.
12
+
13
+ ### Patch Changes
14
+
15
+ - [#10341](https://github.com/scalar/scalar/pull/10341): Avoid excessive processing time when encoding chunk names with long runs of dots.
16
+ - [#10342](https://github.com/scalar/scalar/pull/10342): Prevent prototype pollution when merging documents and writing nested values or JSON references, while preserving prototype-named JSON data properties.
17
+
18
+ Dot-separated mutations now reject new `constructor` and `prototype` keys, as well as `__proto__`, instead of creating these keys through inherited properties.
19
+
20
+ - [#10334](https://github.com/scalar/scalar/pull/10334): Include optional form fields when selecting files or editing values, while preserving explicitly unchecked fields.
21
+ - [#10192](https://github.com/scalar/scalar/pull/10192): Apply edited XML bodies instead of their original serialized or data examples, render schema-free XML examples in Markdown, and share reference decoding and response provenance selection.
22
+
3
23
  ## 0.66.0
4
24
 
5
25
  ### Minor Changes
@@ -257,6 +257,8 @@ export type OperationEvents = {
257
257
  name: string;
258
258
  value: string | File | unknown[] | undefined;
259
259
  isDisabled: boolean;
260
+ /** Distinguishes untouched optional fields from deliberate checkbox choices. */
261
+ isDisabledByDefault?: boolean;
260
262
  isArray?: boolean;
261
263
  }[];
262
264
  /** The content type of the request body */
@@ -1 +1 @@
1
- {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE9F;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG;IAK5B;;;OAGG;IACH,+BAA+B,EAAE,SAAS,CAAA;IAE1C,qCAAqC;IACrC,0BAA0B,EAAE,SAAS,CAAA;IAMrC;;;OAGG;IACH,4BAA4B,EAAE;QAC5B,8DAA8D;QAC9D,YAAY,EAAE,MAAM,CAAA;QACpB,4CAA4C;QAC5C,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,0EAA0E;QAC1E,IAAI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AAO,KAAK,IAAI,CAAA;KAChD,CAAA;CACF,CAAA"}
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE9F;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG;IAK5B;;;OAGG;IACH,+BAA+B,EAAE,SAAS,CAAA;IAE1C,qCAAqC;IACrC,0BAA0B,EAAE,SAAS,CAAA;IAMrC;;;OAGG;IACH,4BAA4B,EAAE;QAC5B,8DAA8D;QAC9D,YAAY,EAAE,MAAM,CAAA;QACpB,4CAA4C;QAC5C,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,0EAA0E;QAC1E,IAAI,EAAE,MAAM,CAAA;QACZ,wCAAwC;QACxC,MAAM,EAAE,MAAM,CAAA;QACd,qCAAqC;QACrC,SAAS,EAAE,eAAe,CAAA;QAC1B,yDAAyD;QACzD,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;KACtC,CAAA;IAED;;;;OAIG;IACH,uBAAuB,EAAE;QACvB,gDAAgD;QAChD,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC,CAAA;QACjF,+EAA+E;QAC/E,IAAI,EAAE,aAAa,CAAA;KACpB,CAAA;IAED;;;;OAIG;IACH,6BAA6B,EAAE;QAC7B,OAAO,EAAE;YACP,8CAA8C;YAC9C,MAAM,EAAE,MAAM,CAAA;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;QACpC,iDAAiD;QACjD,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;QAClC,2CAA2C;QAC3C,WAAW,EAAE,MAAM,CAAA;QACnB,6FAA6F;QAC7F,IAAI,EAAE,oBAAoB,CAAA;KAC3B,CAAA;IAED;;;;OAIG;IACH,wCAAwC,EAAE;QACxC,iDAAiD;QACjD,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAA;YACZ,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,SAAS,CAAA;YAC5C,UAAU,EAAE,OAAO,CAAA;YACnB,gFAAgF;YAChF,mBAAmB,CAAC,EAAE,OAAO,CAAA;YAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;SAClB,EAAE,CAAA;QACH,2CAA2C;QAC3C,WAAW,EAAE,MAAM,CAAA;QACnB,6FAA6F;QAC7F,IAAI,EAAE,oBAAoB,CAAA;KAC3B,CAAA;IACD;;OAEG;IACH,0BAA0B,EAAE;QAC1B,6DAA6D;QAC7D,IAAI,EAAE,aAAa,CAAA;QACnB,8CAA8C;QAC9C,KAAK,EAAE,MAAM,CAAA;QACb,wDAAwD;QACxD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,KAAK,IAAI,CAAA;KAChD,CAAA;CACF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"encode-chunk-name.d.ts","sourceRoot":"","sources":["../../src/helpers/encode-chunk-name.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAU9C,CAAA"}
1
+ {"version":3,"file":"encode-chunk-name.d.ts","sourceRoot":"","sources":["../../src/helpers/encode-chunk-name.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAe9C,CAAA"}
@@ -3,7 +3,12 @@ import { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointe
3
3
  export const encodeChunkName = (name) => {
4
4
  // JSON Pointer escaping preserves existing names and reserves ~x for filesystem escapes.
5
5
  const escaped = escapeJsonPointer(name).replace(/[^a-zA-Z0-9_.~{}-]/gu, (character) => `~x${character.codePointAt(0)?.toString(16)}~`);
6
- const portable = escaped.replace(/\.+$/, (dots) => dots.replaceAll('.', '~x2e~'));
6
+ // Scan once from the end to avoid regex backtracking over long runs of interior dots.
7
+ let trailingDotsStart = escaped.length;
8
+ while (trailingDotsStart > 0 && escaped[trailingDotsStart - 1] === '.') {
9
+ trailingDotsStart--;
10
+ }
11
+ const portable = escaped.slice(0, trailingDotsStart) + '~x2e~'.repeat(escaped.length - trailingDotsStart);
7
12
  // Windows device names remain reserved even when followed by a file extension.
8
13
  return /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(portable) || portable === '' ? `~x~${portable}` : portable;
9
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"merge-object.d.ts","sourceRoot":"","sources":["../../src/helpers/merge-object.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY,GACvB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;AAC1B;;;GAGG;AACH,uBAAqB,EACrB,QAAO,GAAG,CAAC,OAAO,CAAa,KAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAsCxB,CAAA"}
1
+ {"version":3,"file":"merge-object.d.ts","sourceRoot":"","sources":["../../src/helpers/merge-object.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY,GACvB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;AAC1B;;;GAGG;AACH,uBAAqB,EACrB,QAAO,GAAG,CAAC,OAAO,CAAa,KAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CA2CxB,CAAA"}
@@ -35,9 +35,15 @@ export const mergeObjects = (a, b,
35
35
  * Alternatively we may want to prevent this behaviour when merging with defaults and replace the whole array instead
36
36
  */
37
37
  replaceArrays = false, cache = new Set()) => {
38
- for (const key in b) {
39
- if (!(key in a)) {
40
- a[key] = b[key];
38
+ for (const key of Object.keys(b)) {
39
+ if (!Object.hasOwn(a, key)) {
40
+ // A JSON property named __proto__ is data, not an instruction to replace the prototype.
41
+ if (key === '__proto__') {
42
+ Object.defineProperty(a, key, { value: b[key], enumerable: true, configurable: true, writable: true });
43
+ }
44
+ else {
45
+ a[key] = b[key];
46
+ }
41
47
  }
42
48
  else {
43
49
  const aValue = a[key];
@@ -43,6 +43,6 @@ export declare const buildRequestBody: (requestBody: RequestBodyObject | undefin
43
43
  /** The key of the current example */
44
44
  exampleName?: string,
45
45
  /** Selected anyOf/oneOf request-body variants keyed by schema path */
46
- requestBodyCompositionSelection?: Record<string, number>) => RequestBody | null;
46
+ requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string) => RequestBody | null;
47
47
  export {};
48
48
  //# sourceMappingURL=build-request-body.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAKjG,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,mBAAmB,CAAA;AAO1B,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,CACH;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CACJ,EAAE,CAAA;CACJ,CAAA;AAwBD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ,CAAA;AAED,KAAK,GAAG,GAAG;IACT,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,UAAU,GACV,GAAG,GACH;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,CAAA;AA2CtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;AACrC,oBAAuB;AACvB,sEAAsE;AACtE,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,WAAW,GAAG,IA8WhB,CAAA"}
1
+ {"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAKjG,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,mBAAmB,CAAA;AAO1B,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,CACH;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CACJ,EAAE,CAAA;CACJ,CAAA;AAwBD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ,CAAA;AAED,KAAK,GAAG,GAAG;IACT,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,UAAU,GACV,GAAG,GACH;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,CAAA;AA2CtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;AACrC,oBAAuB;AACvB,sEAAsE;AACtE,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxD,iBAAiB,MAAM,KACtB,WAAW,GAAG,IAoXhB,CAAA"}
@@ -67,7 +67,7 @@ export const buildRequestBody = (requestBody,
67
67
  /** The key of the current example */
68
68
  exampleName = 'default',
69
69
  /** Selected anyOf/oneOf request-body variants keyed by schema path */
70
- requestBodyCompositionSelection) => {
70
+ requestBodyCompositionSelection, openapiVersion) => {
71
71
  if (!requestBody) {
72
72
  return null;
73
73
  }
@@ -77,7 +77,7 @@ requestBodyCompositionSelection) => {
77
77
  return null;
78
78
  }
79
79
  /** An example value */
80
- const example = getExampleFromBody(requestBody, bodyContentType, exampleName, requestBodyCompositionSelection);
80
+ const example = getExampleFromBody(requestBody, bodyContentType, exampleName, requestBodyCompositionSelection, openapiVersion);
81
81
  if (!example) {
82
82
  return null;
83
83
  }
@@ -5,14 +5,14 @@ import type { ExampleObject, RequestBodyObject } from '@scalar/workspace-store/s
5
5
  * This is the schema-generation half of {@link getExampleFromBody}. It is exposed on its own so
6
6
  * callers that need to regenerate a body for a freshly selected composition branch (rather than the
7
7
  * edited example that would otherwise shadow it) produce the exact same value the initial example
8
- * does. The schema is deep-resolved first so nested `$ref` members (common for composition branches)
9
- * are materialized instead of emitting `null` for referenced sub-objects.
8
+ * does. Data generation deep-resolves nested `$ref` members. XML retains reference sites so node
9
+ * naming and version-specific wrappers survive serialization.
10
10
  *
11
11
  * Returns `undefined` when there is no schema for the content type.
12
12
  */
13
- export declare const getSchemaExampleFromBody: (requestBody: RequestBodyObject, contentType: string, requestBodyCompositionSelection?: Record<string, number>) => unknown;
13
+ export declare const getSchemaExampleFromBody: (requestBody: RequestBodyObject, contentType: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string) => unknown;
14
14
  /**
15
15
  * Basically getExample + we generate an example from the schema if no example is found
16
16
  */
17
- export declare const getExampleFromBody: (requestBody: RequestBodyObject, contentType: string, exampleName: string, requestBodyCompositionSelection?: Record<string, number>) => ExampleObject | null;
17
+ export declare const getExampleFromBody: (requestBody: RequestBodyObject, contentType: string, exampleName: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string) => ExampleObject | null;
18
18
  //# sourceMappingURL=get-request-body-example.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/get-request-body-example.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AAQrE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,OAwBF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,aAAa,GAAG,IAwBlB,CAAA"}
1
+ {"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/get-request-body-example.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AASrE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxD,iBAAiB,MAAM,KACtB,OAgCF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxD,iBAAiB,MAAM,KACtB,aAAa,GAAG,IA0ClB,CAAA"}
@@ -1,26 +1,36 @@
1
+ import { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type';
1
2
  import { parseMimeType } from '@scalar/helpers/http/mime-type';
2
3
  import { getExampleValue } from '../../../helpers/get-example-value.js';
3
4
  import { getResolvedRefDeep } from '../../../helpers/get-resolved-ref-deep.js';
4
5
  import { serializeStreamExample } from '../../../helpers/serialize-stream-example.js';
5
6
  import { getExample } from '../../../request-example/builder/helpers/get-example.js';
6
7
  import { getExampleFromSchema } from '../../../request-example/builder/helpers/get-example-from-schema.js';
8
+ import { getXmlBodyExample } from '../../../request-example/xml/get-xml-body-example.js';
7
9
  /**
8
10
  * Generate a write-mode example directly from a request body's schema, ignoring any stored example.
9
11
  *
10
12
  * This is the schema-generation half of {@link getExampleFromBody}. It is exposed on its own so
11
13
  * callers that need to regenerate a body for a freshly selected composition branch (rather than the
12
14
  * edited example that would otherwise shadow it) produce the exact same value the initial example
13
- * does. The schema is deep-resolved first so nested `$ref` members (common for composition branches)
14
- * are materialized instead of emitting `null` for referenced sub-objects.
15
+ * does. Data generation deep-resolves nested `$ref` members. XML retains reference sites so node
16
+ * naming and version-specific wrappers survive serialization.
15
17
  *
16
18
  * Returns `undefined` when there is no schema for the content type.
17
19
  */
18
- export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCompositionSelection) => {
20
+ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCompositionSelection, openapiVersion) => {
19
21
  const mediaType = requestBody.content?.[contentType];
20
22
  const schema = mediaType?.schema ??
21
23
  (mediaType?.itemSchema && parseMimeType(contentType).type === 'multipart'
22
24
  ? { type: 'array', items: mediaType.itemSchema }
23
25
  : mediaType?.itemSchema);
26
+ if (isXmlMediaType(contentType)) {
27
+ return getXmlBodyExample(mediaType?.schema, undefined, {
28
+ openapiVersion,
29
+ mode: 'write',
30
+ compositionSelection: requestBodyCompositionSelection,
31
+ schemaPath: ['requestBody'],
32
+ }).xml;
33
+ }
24
34
  if (!schema) {
25
35
  return undefined;
26
36
  }
@@ -36,11 +46,25 @@ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCo
36
46
  /**
37
47
  * Basically getExample + we generate an example from the schema if no example is found
38
48
  */
39
- export const getExampleFromBody = (requestBody, contentType, exampleName, requestBodyCompositionSelection) => {
49
+ export const getExampleFromBody = (requestBody, contentType, exampleName, requestBodyCompositionSelection, openapiVersion) => {
40
50
  // Return the existing example when it carries a usable value. An example that only has an
41
51
  // `externalValue` (not yet resolved to a `value`) is treated as missing, so we fall back to a
42
52
  // schema-generated example instead of building an empty request body.
43
53
  const example = getExample(requestBody, exampleName, contentType);
54
+ if (isXmlMediaType(contentType)) {
55
+ const result = getXmlBodyExample(requestBody.content?.[contentType]?.schema, example, {
56
+ openapiVersion,
57
+ mode: 'write',
58
+ compositionSelection: requestBodyCompositionSelection,
59
+ schemaPath: ['requestBody'],
60
+ });
61
+ if (result.xml === undefined)
62
+ return null;
63
+ // Consumers select dataValue before value, so retain the serialized result for editor and wire output.
64
+ return example?.dataValue !== undefined
65
+ ? { ...example, value: result.xml, serializedValue: result.xml }
66
+ : { ...example, value: result.xml };
67
+ }
44
68
  const selected = getExampleValue(example);
45
69
  if (example && selected) {
46
70
  const stream = typeof selected.value === 'string' ? undefined : serializeStreamExample(selected.value, contentType, false);
@@ -52,7 +76,7 @@ export const getExampleFromBody = (requestBody, contentType, exampleName, reques
52
76
  return selected.source === 'value' ? example : { ...example, value: selected.value };
53
77
  }
54
78
  // Generate an example from the schema
55
- const schemaExample = getSchemaExampleFromBody(requestBody, contentType, requestBodyCompositionSelection);
79
+ const schemaExample = getSchemaExampleFromBody(requestBody, contentType, requestBodyCompositionSelection, openapiVersion);
56
80
  if (schemaExample === undefined || schemaExample === null) {
57
81
  return null;
58
82
  }
@@ -0,0 +1,19 @@
1
+ import type { DynamicScope } from '../../../helpers/dynamic-ref.js';
2
+ import type { SchemaObject } from '../../../schemas/v3.1/strict/openapi-document.js';
3
+ /** Schema provenance collected only when a format needs more than the generated data. */
4
+ export type ExampleEvaluation = {
5
+ schema: SchemaObject;
6
+ value: unknown;
7
+ path: string[];
8
+ name?: string;
9
+ dynamicScope: DynamicScope;
10
+ children: ExampleEvaluation[];
11
+ };
12
+ /** Per-call capture state; never shared with the JSON result cache. */
13
+ export type ExampleEvaluationState = {
14
+ stack: ExampleEvaluation[];
15
+ root?: ExampleEvaluation;
16
+ };
17
+ /** Internal option: keep the default JSON generation path free of provenance allocations. */
18
+ export declare const EXAMPLE_EVALUATION: unique symbol;
19
+ //# sourceMappingURL=example-evaluation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example-evaluation.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/example-evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,yFAAyF;AACzF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,YAAY,CAAA;IACpB,KAAK,EAAE,OAAO,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;IAC1B,QAAQ,EAAE,iBAAiB,EAAE,CAAA;CAC9B,CAAA;AAED,uEAAuE;AACvE,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,iBAAiB,EAAE,CAAA;IAC1B,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB,CAAA;AAED,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,eAA+B,CAAA"}
@@ -0,0 +1,2 @@
1
+ /** Internal option: keep the default JSON generation path free of provenance allocations. */
2
+ export const EXAMPLE_EVALUATION = Symbol('example-evaluation');
@@ -1,9 +1,15 @@
1
1
  import { type DynamicScope } from '../../../helpers/dynamic-ref.js';
2
2
  import type { SchemaObject } from '../../../schemas/v3.2/strict/openapi-document.js';
3
- type GetExampleFromSchemaOptions = {
3
+ import { EXAMPLE_EVALUATION, type ExampleEvaluationState } from './example-evaluation.js';
4
+ /** Select a composition branch once for both generated values and supplied example metadata. */
5
+ export declare const selectExampleComposition: (schema: SchemaObject, schemaPath: string[], options?: GetExampleFromSchemaOptions, arrayItem?: boolean, value?: Record<string, unknown>) => SchemaObject | undefined;
6
+ /** Options shared by data generation and schema-aware serializers. */
7
+ export type GetExampleFromSchemaOptions = {
8
+ /** Internal provenance capture, excluded from persistent result caches. */
9
+ [EXAMPLE_EVALUATION]?: ExampleEvaluationState;
4
10
  /** Fallback string for empty string values. */
5
11
  emptyString?: string;
6
- /** Whether to use XML tag names as keys. */
12
+ /** @deprecated Use getXmlExampleFromSchema for schema-aware XML serialization. */
7
13
  xml?: boolean;
8
14
  /** Whether to show read-only/write-only properties. */
9
15
  mode?: 'read' | 'write';
@@ -37,7 +43,7 @@ type GetExampleFromSchemaOptions = {
37
43
  * @param name - The name of the property being processed.
38
44
  * @returns An example value for the given schema.
39
45
  */
40
- export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, { level, parentSchema, name, seen, schemaPath, dynamicScope, }?: Partial<{
46
+ declare const generateExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, { level, parentSchema, name, seen, schemaPath, dynamicScope, }?: Partial<{
41
47
  level: number;
42
48
  parentSchema: SchemaObject;
43
49
  name: string;
@@ -47,5 +53,7 @@ export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetE
47
53
  /** Chain of schema resources entered so far, used to resolve `$dynamicRef` (JSON Schema 2020-12). */
48
54
  dynamicScope: DynamicScope;
49
55
  }>) => unknown;
56
+ /** Generate data, optionally retaining the exact schema decisions for another output format. */
57
+ export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, context?: Parameters<typeof generateExampleFromSchema>[2]) => unknown;
50
58
  export {};
51
59
  //# sourceMappingURL=get-example-from-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAiyB1E,KAAK,2BAA2B,GAAG;IACjC,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,qDAAqD;IACrD,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9C,CAAA;AAuPD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,YAAY,EACpB,UAAU,2BAA2B,EACrC,iEAOG,OAAO,CAAC;IACT,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACrB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,qGAAqG;IACrG,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAM,KACN,OAuPF,CAAA"}
1
+ {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAoZ9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,GACnC,QAAQ,YAAY,EACpB,YAAY,MAAM,EAAE,EACp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}
@@ -3,6 +3,7 @@ import { escapeJsonPointer } from '@scalar/helpers/json/escape-json-pointer';
3
3
  import { isDynamicRef, pushDynamicScope, resolveDynamicRef } from '../../../helpers/dynamic-ref.js';
4
4
  import { unpackProxyObject } from '../../../helpers/unpack-proxy.js';
5
5
  import { resolve } from '../../../resolve.js';
6
+ import { EXAMPLE_EVALUATION } from './example-evaluation.js';
6
7
  /** Maximum recursion depth to prevent infinite loops in circular references */
7
8
  const MAX_LEVELS_DEEP = 10;
8
9
  /** Default name used for additional properties when no custom name is provided */
@@ -317,6 +318,25 @@ const consumeCompositionSelection = (options, schemaPath, composition) => {
317
318
  const { [key]: _selection, ...compositionSelection } = options.compositionSelection;
318
319
  return { ...options, compositionSelection };
319
320
  };
321
+ /** Select a composition branch once for both generated values and supplied example metadata. */
322
+ export const selectExampleComposition = (schema, schemaPath, options, arrayItem = false, value) => {
323
+ const keyword = schema.oneOf ? 'oneOf' : schema.anyOf ? 'anyOf' : undefined;
324
+ const members = keyword ? schema[keyword] : undefined;
325
+ if (!keyword || !members?.length) {
326
+ return undefined;
327
+ }
328
+ const index = getCompositionSelectionIndex(schemaPath, keyword, options, members.length) ??
329
+ getDiscriminatorSelectionIndex(schema, members, options, value);
330
+ const isObject = 'properties' in schema || ('type' in schema && schema.type === 'object');
331
+ const candidate = index !== undefined || isObject || arrayItem
332
+ ? members[index ?? 0]
333
+ : members.find((item) => {
334
+ const resolved = resolve.schema(item);
335
+ return resolved && (!('type' in resolved) || resolved.type !== 'null');
336
+ });
337
+ // The generator resolves the value at its entry point; serializers also need the reference site.
338
+ return candidate;
339
+ };
320
340
  /**
321
341
  * Use the discriminator as a generation hint. Only referenced variants have
322
342
  * implicit names; inline titles are display labels, not discriminator mappings.
@@ -393,7 +413,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
393
413
  const response = {};
394
414
  // Children are evaluated with this schema added to the dynamic scope so nested `$dynamicRef`s bind here.
395
415
  const childScope = pushDynamicScope(dynamicScope, schema);
396
- const skipCache = dynamicScope.length > 0;
416
+ const skipCache = dynamicScope.length > 0 || !!options?.[EXAMPLE_EVALUATION];
397
417
  if ('properties' in schema && schema.properties) {
398
418
  const properties = schema.properties;
399
419
  const propertyNames = sortPropertyNamesByXOrder(properties);
@@ -469,10 +489,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
469
489
  const compositionKeyword = schema.oneOf ? 'oneOf' : schema.anyOf ? 'anyOf' : undefined;
470
490
  const oneOfAnyOf = compositionKeyword ? schema[compositionKeyword] : undefined;
471
491
  if (compositionKeyword && oneOfAnyOf?.length) {
472
- const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, oneOfAnyOf.length) ??
473
- getDiscriminatorSelectionIndex(schema, oneOfAnyOf, options, response) ??
474
- 0;
475
- const chosen = resolve.schema(oneOfAnyOf[index]);
492
+ const chosen = selectExampleComposition(schema, schemaPath, options, false, response);
476
493
  if (chosen) {
477
494
  Object.assign(response, getExampleFromSchema(chosen, consumeCompositionSelection(options, schemaPath, compositionKeyword), {
478
495
  level: level + 1,
@@ -516,7 +533,16 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
516
533
  /** Build an example for an array schema, including items, allOf, oneOf/anyOf, and XML wrapping */
517
534
  const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath, dynamicScope) => {
518
535
  const childScope = pushDynamicScope(dynamicScope, schema);
519
- const skipCache = dynamicScope.length > 0;
536
+ const skipCache = dynamicScope.length > 0 || !!options?.[EXAMPLE_EVALUATION];
537
+ if ('prefixItems' in schema && Array.isArray(schema.prefixItems)) {
538
+ const values = schema.prefixItems.map((item, index) => getExampleFromSchema(item, options, {
539
+ level: level + 1,
540
+ schemaPath: [...schemaPath, 'prefixItems', String(index)],
541
+ seen,
542
+ dynamicScope: childScope,
543
+ }));
544
+ return cache(schema, values, cacheKey, skipCache);
545
+ }
520
546
  let items = 'items' in schema ? resolve.schema(schema.items) : undefined;
521
547
  // Bind a dynamic item type (e.g. the generic `PaginatedResponse<T>` pattern) before inspecting it.
522
548
  // Crossing a `$dynamicRef` leaves the static schema graph, so the cycle guard built up by the outer
@@ -856,7 +882,7 @@ const getMaxDepthValue = (schema, options, schemaPath, seen = new Set()) => {
856
882
  * @param name - The name of the property being processed.
857
883
  * @returns An example value for the given schema.
858
884
  */
859
- export const getExampleFromSchema = (schema, options, { level = 0, parentSchema, name, seen = new WeakSet(), schemaPath = [], dynamicScope = [], } = {}) => {
885
+ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, name, seen = new WeakSet(), schemaPath = [], dynamicScope = [], } = {}) => {
860
886
  // A truncation only taints the call it happened in, so every top-level call starts clean.
861
887
  if (level === 0) {
862
888
  truncated = false;
@@ -888,7 +914,7 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
888
914
  // Grow the scope with this schema so nested references can bind to its `$dynamicAnchor`s.
889
915
  const childScope = pushDynamicScope(dynamicScope, _schema);
890
916
  // The same shared node can resolve differently per scope, so skip the result cache under a scope.
891
- const skipCache = dynamicScope.length > 0;
917
+ const skipCache = dynamicScope.length > 0 || !!options?.[EXAMPLE_EVALUATION];
892
918
  // Unpack from all proxies to get the raw schema object for cycle detection
893
919
  const targetValue = getSchemaCacheTarget(_schema);
894
920
  if (seen.has(targetValue)) {
@@ -994,7 +1020,7 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
994
1020
  return result;
995
1021
  }
996
1022
  // Handle array types
997
- if (('type' in _schema && _schema.type === 'array') || 'items' in _schema) {
1023
+ if (('type' in _schema && _schema.type === 'array') || 'items' in _schema || 'prefixItems' in _schema) {
998
1024
  const result = handleArraySchema(_schema, options, level, seen, cacheKey, schemaPath, dynamicScope);
999
1025
  seen.delete(targetValue);
1000
1026
  return result;
@@ -1009,14 +1035,7 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
1009
1035
  const compositionKeyword = _schema.oneOf ? 'oneOf' : _schema.anyOf ? 'anyOf' : undefined;
1010
1036
  const discriminate = compositionKeyword ? _schema[compositionKeyword] : undefined;
1011
1037
  if (compositionKeyword && Array.isArray(discriminate) && discriminate.length > 0) {
1012
- const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, discriminate.length) ??
1013
- getDiscriminatorSelectionIndex(_schema, discriminate, options);
1014
- const candidate = index !== undefined
1015
- ? discriminate[index]
1016
- : discriminate.find((item) => {
1017
- const resolved = resolve.schema(item);
1018
- return resolved && (!('type' in resolved) || resolved.type !== 'null');
1019
- });
1038
+ const candidate = selectExampleComposition(_schema, schemaPath, options);
1020
1039
  if (candidate) {
1021
1040
  const resolved = resolve.schema(candidate);
1022
1041
  if (resolved) {
@@ -1073,3 +1092,33 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
1073
1092
  seen.delete(targetValue);
1074
1093
  return cache(_schema, null, cacheKey, skipCache);
1075
1094
  };
1095
+ /** Generate data, optionally retaining the exact schema decisions for another output format. */
1096
+ export const getExampleFromSchema = (schema, options, context = {}) => {
1097
+ const capture = options?.[EXAMPLE_EVALUATION];
1098
+ if (!capture) {
1099
+ return generateExampleFromSchema(schema, options, context);
1100
+ }
1101
+ const node = {
1102
+ schema,
1103
+ value: undefined,
1104
+ path: context.schemaPath ?? [],
1105
+ name: context.name,
1106
+ dynamicScope: context.dynamicScope ?? [],
1107
+ children: [],
1108
+ };
1109
+ const parent = capture.stack.at(-1);
1110
+ if (parent) {
1111
+ parent.children.push(node);
1112
+ }
1113
+ else {
1114
+ capture.root = node;
1115
+ }
1116
+ capture.stack.push(node);
1117
+ try {
1118
+ node.value = generateExampleFromSchema(schema, options, context);
1119
+ return node.value;
1120
+ }
1121
+ finally {
1122
+ capture.stack.pop();
1123
+ }
1124
+ };
@@ -180,7 +180,7 @@ export type RequestFactory = {
180
180
  * Builds a request object fastory which can be used to build a request object.
181
181
  * @returns A request object factory
182
182
  */
183
- export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, requestBodyCompositionSelection, }: RequestExampleMeta & {
183
+ export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, requestBodyCompositionSelection, }: RequestExampleMeta & {
184
184
  /** The operation object */
185
185
  operation: OperationObject;
186
186
  /** For environment variables in the inputs */
@@ -198,6 +198,8 @@ export declare const requestFactory: ({ exampleName, globalCookies, method, oper
198
198
  /** The selected security schemes for the current operation */
199
199
  selectedSecuritySchemes: SecuritySchemeObjectSecret[];
200
200
  /** Selected anyOf/oneOf request-body variants keyed by schema path */
201
+ /** Originating OpenAPI version, used for XML mapping rules. */
202
+ openapiVersion?: string;
201
203
  requestBodyCompositionSelection?: Record<string, number>;
202
204
  }) => {
203
205
  request: RequestFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAE5F,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,2DAA2D,CAAA;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,2BAA2B,CAAA;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,MAAM,cAA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AAA;IAC9B,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,8DAA8D;IAC9D,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,sEAAsE;IACtE,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,KAAG;IACF,OAAO,EAAE,cAAc,CAAA;CA4ExB,CAAA"}
1
+ {"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAE5F,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,2DAA2D,CAAA;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,2BAA2B,CAAA;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,IAAI,EAAE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YAAY,GAAG,IAAI,CAAA;IAC3B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,8DAA8D;IAC9D,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,sEAAsE;IACtE,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,KAAG;IACF,OAAO,EAAE,cAAc,CAAA;CA4ExB,CAAA"}
@@ -12,7 +12,7 @@ import { buildRequestParameters } from './header/build-request-parameters.js';
12
12
  * Builds a request object fastory which can be used to build a request object.
13
13
  * @returns A request object factory
14
14
  */
15
- export const requestFactory = ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, requestBodyCompositionSelection, }) => {
15
+ export const requestFactory = ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, requestBodyCompositionSelection, }) => {
16
16
  const requestBody = getResolvedRef(operation.requestBody);
17
17
  /** Build out the request parameters */
18
18
  const params = buildRequestParameters(operation.parameters ?? [], exampleName);
@@ -27,7 +27,7 @@ export const requestFactory = ({ exampleName, globalCookies, method, operation,
27
27
  });
28
28
  // If the method can have a body, build the request body, otherwise set it to null
29
29
  const body = canMethodHaveBody(method)
30
- ? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection)
30
+ ? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection, openapiVersion)
31
31
  : null;
32
32
  // Delete the Content-Type header so the browser will set it automatically based on the request body
33
33
  if (body?.mode === 'formdata' || body?.mode === 'urlencoded') {
@@ -8,4 +8,8 @@ export { type BuildRequestExampleContext, combineParams, filterDisabledDefaultHe
8
8
  export { CONTEXT_FUNCTION_NAMES, type ContextFunctionEntry, type ContextFunctionName, POPULAR_CONTEXT_FUNCTION_KEYS, contextFunctions, getContextFunctionComment, isContextFunctionName, } from './functions.js';
9
9
  export { createVariablesStoreForRequest } from './variable-store/index.js';
10
10
  export type { VariableEntry, VariablesStore } from './variable-store/types.js';
11
+ export { getXmlBodyExample } from './xml/get-xml-body-example.js';
12
+ export { type XmlExampleOptions, getXmlExampleFromSchema, serializeXmlExample } from './xml/get-xml-example.js';
13
+ export { serializeXmlPart } from './xml/serialize-xml-part.js';
14
+ export type { XmlDiagnostic, XmlExampleResult } from './xml/xml-node.js';
11
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,6BAA6B,EAC7B,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,2BAA2B,EAC3B,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,iCAAiC,EACjC,kBAAkB,EAClB,4BAA4B,EAC5B,uBAAuB,EACvB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EACL,KAAK,0BAA0B,EAC/B,aAAa,EACb,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,aAAa,EACb,qCAAqC,EACrC,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,6BAA6B,EAC7B,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,8BAA8B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,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA"}
@@ -5,3 +5,6 @@ export { serializeMultipartBody } from './builder/body/encode-multipart-body.js'
5
5
  export { combineParams, filterDisabledDefaultHeaders, getActiveEnvironment, getActiveProxyUrl, getDefaultHeaders, getRequestExampleContext, getSecurityRequirements, getSecuritySchemes, getSelectedSecurity, getSelectedServer, getServers, isAuthOptional, mergeSecurity, restoreConventionalDefaultHeaderNames, restoreConventionalHeaderName, } from './context/index.js';
6
6
  export { CONTEXT_FUNCTION_NAMES, POPULAR_CONTEXT_FUNCTION_KEYS, contextFunctions, getContextFunctionComment, isContextFunctionName, } from './functions.js';
7
7
  export { createVariablesStoreForRequest } from './variable-store/index.js';
8
+ export { getXmlBodyExample } from './xml/get-xml-body-example.js';
9
+ export { getXmlExampleFromSchema, serializeXmlExample } from './xml/get-xml-example.js';
10
+ export { serializeXmlPart } from './xml/serialize-xml-part.js';
@@ -0,0 +1,8 @@
1
+ import { type RefNode } from '../../helpers/get-resolved-ref.js';
2
+ import type { ExampleObject } from '../../schemas/v3.2/strict/example.js';
3
+ import { type SchemaObject } from '../../schemas/v3.2/strict/openapi-document.js';
4
+ import { type XmlExampleOptions } from './get-xml-example.js';
5
+ import type { XmlExampleResult } from './xml-node.js';
6
+ /** Resolve media-level XML examples without treating schema string values as serialized payloads. */
7
+ export declare const getXmlBodyExample: (schema: SchemaObject | undefined, inputExample: ExampleObject | RefNode<ExampleObject> | undefined, options?: XmlExampleOptions) => XmlExampleResult;
8
+ //# sourceMappingURL=get-xml-body-example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-xml-body-example.d.ts","sourceRoot":"","sources":["../../../src/request-example/xml/get-xml-body-example.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,4BAA4B,CAAA;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,wCAAwC,CAAA;AAE9F,OAAO,EAAE,KAAK,iBAAiB,EAAgD,MAAM,mBAAmB,CAAA;AACxG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,qGAAqG;AACrG,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,GAAG,SAAS,EAChC,cAAc,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS,EAChE,UAAS,iBAAsB,KAC9B,gBAeF,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
2
+ import { coerceValue } from '../../schemas/typebox-coerce.js';
3
+ import { SchemaObjectSchema } from '../../schemas/v3.2/strict/openapi-document.js';
4
+ import { getXmlExampleFromSchema, serializeXmlExample } from './get-xml-example.js';
5
+ /** Resolve media-level XML examples without treating schema string values as serialized payloads. */
6
+ export const getXmlBodyExample = (schema, inputExample, options = {}) => {
7
+ const example = getResolvedRef(inputExample);
8
+ if (example?.serializedValue !== undefined) {
9
+ return { xml: example.serializedValue, diagnostics: [] };
10
+ }
11
+ if (example?.dataValue !== undefined) {
12
+ return serializeXmlExample(example.dataValue, schema ?? coerceValue(SchemaObjectSchema, {}), options);
13
+ }
14
+ if (typeof example?.value === 'string') {
15
+ return { xml: example.value, diagnostics: [] };
16
+ }
17
+ if (example?.value !== undefined) {
18
+ return serializeXmlExample(example.value, schema ?? coerceValue(SchemaObjectSchema, {}), options);
19
+ }
20
+ return schema ? getXmlExampleFromSchema(schema, options) : { xml: undefined, diagnostics: [] };
21
+ };
@@ -0,0 +1,21 @@
1
+ import type { SchemaObject } from '../../schemas/v3.2/strict/openapi-document.js';
2
+ import { EXAMPLE_EVALUATION } from '../builder/helpers/example-evaluation.js';
3
+ import { type GetExampleFromSchemaOptions } from '../builder/helpers/get-example-from-schema.js';
4
+ import { type WriteXmlOptions } from './write-xml.js';
5
+ import type { XmlDiagnostic, XmlExampleResult } from './xml-node.js';
6
+ /** XML options share the data generator's value and branch-selection policies. */
7
+ export type XmlExampleOptions = Omit<GetExampleFromSchemaOptions, 'xml' | typeof EXAMPLE_EVALUATION> & WriteXmlOptions & {
8
+ /** Version-specific XML defaults. Existing descriptions default to OpenAPI 3.1 behavior. */
9
+ openapiVersion?: string;
10
+ /** Context retained by callers before resolving a component reference. */
11
+ rootName?: string;
12
+ /** Keep composition-selection keys aligned with the request editor. */
13
+ schemaPath?: string[];
14
+ /** Receives diagnostics; errors otherwise appear in the developer console instead of failing silently. */
15
+ onDiagnostic?: (diagnostic: XmlDiagnostic) => void;
16
+ };
17
+ /** Generate XML using the same value evaluator and selected branches as JSON examples. */
18
+ export declare const getXmlExampleFromSchema: (schema: SchemaObject, options?: XmlExampleOptions) => XmlExampleResult;
19
+ /** Serialize schema-ready example data. Serialized XML strings bypass this function at the media boundary. */
20
+ export declare const serializeXmlExample: (value: unknown, schema: SchemaObject, options?: XmlExampleOptions) => XmlExampleResult;
21
+ //# sourceMappingURL=get-xml-example.d.ts.map