@scalar/workspace-store 0.65.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 (121) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/client.js +1 -1
  3. package/dist/entities/auth/schema.d.ts +115 -20
  4. package/dist/entities/auth/schema.d.ts.map +1 -1
  5. package/dist/events/definitions/auth.d.ts +1 -2
  6. package/dist/events/definitions/auth.d.ts.map +1 -1
  7. package/dist/events/definitions/operation.d.ts +5 -4
  8. package/dist/events/definitions/operation.d.ts.map +1 -1
  9. package/dist/events/definitions/server.d.ts +1 -2
  10. package/dist/events/definitions/server.d.ts.map +1 -1
  11. package/dist/events/definitions/ui.d.ts +3 -4
  12. package/dist/events/definitions/ui.d.ts.map +1 -1
  13. package/dist/events/old-definitions.d.ts +1 -2
  14. package/dist/events/old-definitions.d.ts.map +1 -1
  15. package/dist/helpers/encode-chunk-name.d.ts.map +1 -1
  16. package/dist/helpers/encode-chunk-name.js +6 -1
  17. package/dist/helpers/for-each-path-item-operation.d.ts +6 -5
  18. package/dist/helpers/for-each-path-item-operation.d.ts.map +1 -1
  19. package/dist/helpers/for-each-path-item-operation.js +36 -10
  20. package/dist/helpers/get-parameter-example.d.ts +14 -0
  21. package/dist/helpers/get-parameter-example.d.ts.map +1 -0
  22. package/dist/helpers/get-parameter-example.js +19 -0
  23. package/dist/helpers/merge-object.d.ts.map +1 -1
  24. package/dist/helpers/merge-object.js +9 -3
  25. package/dist/helpers/querystring-parameter.d.ts +21 -0
  26. package/dist/helpers/querystring-parameter.d.ts.map +1 -0
  27. package/dist/helpers/querystring-parameter.js +108 -0
  28. package/dist/mutators/operation/operation.d.ts.map +1 -1
  29. package/dist/mutators/operation/operation.js +4 -7
  30. package/dist/mutators/operation/parameters.d.ts.map +1 -1
  31. package/dist/mutators/operation/parameters.js +43 -3
  32. package/dist/navigation/get-navigation-options.d.ts.map +1 -1
  33. package/dist/navigation/get-navigation-options.js +19 -4
  34. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  35. package/dist/navigation/helpers/traverse-paths.js +2 -2
  36. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  37. package/dist/navigation/helpers/traverse-webhooks.js +2 -2
  38. package/dist/navigation/helpers/update-order-ids.d.ts +1 -2
  39. package/dist/navigation/helpers/update-order-ids.d.ts.map +1 -1
  40. package/dist/plugins/bundler/index.d.ts.map +1 -1
  41. package/dist/plugins/bundler/index.js +3 -2
  42. package/dist/request-example/builder/body/build-request-body.d.ts +1 -1
  43. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
  44. package/dist/request-example/builder/body/build-request-body.js +2 -2
  45. package/dist/request-example/builder/body/get-request-body-example.d.ts +4 -4
  46. package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
  47. package/dist/request-example/builder/body/get-request-body-example.js +29 -5
  48. package/dist/request-example/builder/build-request.d.ts.map +1 -1
  49. package/dist/request-example/builder/build-request.js +2 -1
  50. package/dist/request-example/builder/header/build-request-parameters.d.ts +2 -0
  51. package/dist/request-example/builder/header/build-request-parameters.d.ts.map +1 -1
  52. package/dist/request-example/builder/header/build-request-parameters.js +49 -10
  53. package/dist/request-example/builder/header/is-param-disabled.d.ts.map +1 -1
  54. package/dist/request-example/builder/header/is-param-disabled.js +3 -1
  55. package/dist/request-example/builder/helpers/example-evaluation.d.ts +19 -0
  56. package/dist/request-example/builder/helpers/example-evaluation.d.ts.map +1 -0
  57. package/dist/request-example/builder/helpers/example-evaluation.js +2 -0
  58. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +11 -3
  59. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  60. package/dist/request-example/builder/helpers/get-example-from-schema.js +66 -17
  61. package/dist/request-example/builder/request-factory.d.ts +10 -1
  62. package/dist/request-example/builder/request-factory.d.ts.map +1 -1
  63. package/dist/request-example/builder/request-factory.js +12 -3
  64. package/dist/request-example/builder/resolve-request-factory-url.d.ts.map +1 -1
  65. package/dist/request-example/builder/resolve-request-factory-url.js +18 -2
  66. package/dist/request-example/context/headers.d.ts +1 -2
  67. package/dist/request-example/context/headers.d.ts.map +1 -1
  68. package/dist/request-example/index.d.ts +4 -0
  69. package/dist/request-example/index.d.ts.map +1 -1
  70. package/dist/request-example/index.js +3 -0
  71. package/dist/request-example/types.d.ts +1 -2
  72. package/dist/request-example/types.d.ts.map +1 -1
  73. package/dist/request-example/xml/get-xml-body-example.d.ts +8 -0
  74. package/dist/request-example/xml/get-xml-body-example.d.ts.map +1 -0
  75. package/dist/request-example/xml/get-xml-body-example.js +21 -0
  76. package/dist/request-example/xml/get-xml-example.d.ts +21 -0
  77. package/dist/request-example/xml/get-xml-example.d.ts.map +1 -0
  78. package/dist/request-example/xml/get-xml-example.js +352 -0
  79. package/dist/request-example/xml/match-xml-property-pattern.d.ts +10 -0
  80. package/dist/request-example/xml/match-xml-property-pattern.d.ts.map +1 -0
  81. package/dist/request-example/xml/match-xml-property-pattern.js +48 -0
  82. package/dist/request-example/xml/serialize-xml-part.d.ts +4 -5
  83. package/dist/request-example/xml/serialize-xml-part.d.ts.map +1 -1
  84. package/dist/request-example/xml/serialize-xml-part.js +14 -8
  85. package/dist/request-example/xml/write-xml.d.ts +9 -0
  86. package/dist/request-example/xml/write-xml.d.ts.map +1 -0
  87. package/dist/request-example/xml/write-xml.js +119 -0
  88. package/dist/request-example/xml/xml-node.d.ts +32 -0
  89. package/dist/request-example/xml/xml-node.d.ts.map +1 -0
  90. package/dist/request-example/xml/xml-node.js +1 -0
  91. package/dist/schemas/extensions/operation/x-code-samples.d.ts +22 -0
  92. package/dist/schemas/extensions/operation/x-code-samples.d.ts.map +1 -1
  93. package/dist/schemas/extensions/operation/x-code-samples.js +4 -0
  94. package/dist/schemas/navigation.d.ts +40 -34
  95. package/dist/schemas/navigation.d.ts.map +1 -1
  96. package/dist/schemas/navigation.js +2 -3
  97. package/dist/schemas/reference-config/index.d.ts +23 -4
  98. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  99. package/dist/schemas/reference-config/settings.d.ts +23 -4
  100. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  101. package/dist/schemas/v3.1/strict/openapi-document.d.ts +770 -140
  102. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  103. package/dist/schemas/v3.1/strict/operation.d.ts +8 -0
  104. package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
  105. package/dist/schemas/v3.1/strict/path-item.d.ts +19 -0
  106. package/dist/schemas/v3.1/strict/path-item.d.ts.map +1 -1
  107. package/dist/schemas/v3.1/strict/path-item.js +5 -0
  108. package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
  109. package/dist/schemas/v3.2/openapi/index.js +2 -0
  110. package/dist/schemas/v3.2/openapi/reference.d.ts.map +1 -1
  111. package/dist/schemas/v3.2/openapi/reference.js +11 -3
  112. package/dist/schemas/v3.2/strict/openapi-document.d.ts +805 -140
  113. package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
  114. package/dist/schemas/v3.2/strict/operation.d.ts +8 -0
  115. package/dist/schemas/v3.2/strict/operation.d.ts.map +1 -1
  116. package/dist/schemas/v3.2/strict/parameter.d.ts +14 -0
  117. package/dist/schemas/v3.2/strict/parameter.d.ts.map +1 -1
  118. package/dist/schemas/v3.2/strict/parameter.js +2 -0
  119. package/dist/server.d.ts.map +1 -1
  120. package/dist/server.js +34 -13
  121. package/package.json +9 -9
@@ -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
+ };
@@ -2,6 +2,7 @@ import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensi
2
2
  import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
3
3
  import type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
4
4
  import type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/operation';
5
+ import { type QuerystringParameter } from '../../helpers/querystring-parameter.js';
5
6
  import { type BuildRequestSecurityResult } from '../../request-example/builder/security/build-request-security.js';
6
7
  import type { SecuritySchemeObjectSecret } from '../../request-example/builder/security/secret-types.js';
7
8
  import type { RequestExampleMeta } from '../../request-example/types.js';
@@ -91,6 +92,8 @@ export type RequestFactory = {
91
92
  * @example { "userId": "{env.USER_ID}" }
92
93
  */
93
94
  variables: Record<string, string>;
95
+ /** Names whose example is already URI-encoded. */
96
+ serializedParameters?: Set<string>;
94
97
  /**
95
98
  * The raw request path string, as entered by the user or read from the OpenAPI schema.
96
99
  * Placeholders are not yet substituted.
@@ -119,6 +122,10 @@ export type RequestFactory = {
119
122
  * The actual query string is assembled later, after variable and environment expansion.
120
123
  */
121
124
  query: URLSearchParams;
125
+ /** URI-ready named-parameter examples, appended without re-encoding. */
126
+ serializedQuery?: string[];
127
+ /** OpenAPI 3.2 whole-query parameter, serialized after environment substitution. */
128
+ querystring?: QuerystringParameter;
122
129
  /**
123
130
  * Headers to be sent with this request, combining spec-provided defaults, user overrides,
124
131
  * and (potentially) security-related fields. All header values are unsubstituted at this stage.
@@ -173,7 +180,7 @@ export type RequestFactory = {
173
180
  * Builds a request object fastory which can be used to build a request object.
174
181
  * @returns A request object factory
175
182
  */
176
- 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 & {
177
184
  /** The operation object */
178
185
  operation: OperationObject;
179
186
  /** For environment variables in the inputs */
@@ -191,6 +198,8 @@ export declare const requestFactory: ({ exampleName, globalCookies, method, oper
191
198
  /** The selected security schemes for the current operation */
192
199
  selectedSecuritySchemes: SecuritySchemeObjectSecret[];
193
200
  /** Selected anyOf/oneOf request-body variants keyed by schema path */
201
+ /** Originating OpenAPI version, used for XML mapping rules. */
202
+ openapiVersion?: string;
194
203
  requestBodyCompositionSelection?: Record<string, number>;
195
204
  }) => {
196
205
  request: RequestFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAGA,OAAO,KA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AM,CAAC,CAAA;IAE5C;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;QACf;;;WAGG;QACH,UAAU,EAAE,OAAO,CAAA;QACnB;;;WAGG;QACH,eAAe,EAAE,OAAO,CAAA;KACzB,CAAC,CAAA;CACH,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,kKAY5B,kBAAkB,GAAG;IACtB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;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;CAqExB,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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AAE,OAAO,CAAA;QACnB;;;WAGG;QACH,eAAe,EAAE,OAAO,CAAA;KACzB,CAAC,CAAA;CACH,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,kLAa5B,kBAAkB,GAAG;IACtB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;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,+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"}
@@ -1,6 +1,8 @@
1
1
  import { canMethodHaveBody } from '@scalar/helpers/http/can-method-have-body';
2
+ import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
2
3
  import { replacePathVariables } from '@scalar/helpers/regex/replace-variables';
3
4
  import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref';
5
+ import { getQuerystringParameter } from '../../helpers/querystring-parameter.js';
4
6
  import { getServerVariables } from '../../request-example/builder/helpers/get-server-variables.js';
5
7
  import { buildRequestSecurity, } from '../../request-example/builder/security/build-request-security.js';
6
8
  import { filterDisabledDefaultHeaders } from '../context/headers.js';
@@ -10,10 +12,14 @@ import { buildRequestParameters } from './header/build-request-parameters.js';
10
12
  * Builds a request object fastory which can be used to build a request object.
11
13
  * @returns A request object factory
12
14
  */
13
- 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, }) => {
14
16
  const requestBody = getResolvedRef(operation.requestBody);
15
17
  /** Build out the request parameters */
16
18
  const params = buildRequestParameters(operation.parameters ?? [], exampleName);
19
+ const querystringParameter = operation.parameters
20
+ ?.map((parameter) => getResolvedRef(parameter))
21
+ .find((parameter) => parameter?.in === 'querystring');
22
+ const querystring = querystringParameter ? getQuerystringParameter(querystringParameter, exampleName) : undefined;
17
23
  const security = buildRequestSecurity(selectedSecuritySchemes);
18
24
  const headers = new Headers({
19
25
  ...filterDisabledDefaultHeaders(operation, exampleName, defaultHeaders),
@@ -21,7 +27,7 @@ export const requestFactory = ({ exampleName, globalCookies, method, operation,
21
27
  });
22
28
  // If the method can have a body, build the request body, otherwise set it to null
23
29
  const body = canMethodHaveBody(method)
24
- ? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection)
30
+ ? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection, openapiVersion)
25
31
  : null;
26
32
  // Delete the Content-Type header so the browser will set it automatically based on the request body
27
33
  if (body?.mode === 'formdata' || body?.mode === 'urlencoded') {
@@ -50,10 +56,13 @@ export const requestFactory = ({ exampleName, globalCookies, method, operation,
50
56
  proxyUrl,
51
57
  path: {
52
58
  variables: params.pathVariables,
59
+ ...(params.serializedPathParameters ? { serializedParameters: params.serializedPathParameters } : {}),
53
60
  raw: path,
54
61
  },
55
62
  query: params.urlParams,
56
- method: method.toUpperCase(),
63
+ ...(params.serializedQuery ? { serializedQuery: params.serializedQuery } : {}),
64
+ ...(querystring ? { querystring } : {}),
65
+ method: isHttpMethod(method) && method === method.toLowerCase() ? method.toUpperCase() : method,
57
66
  headers,
58
67
  body,
59
68
  cookies: cookiesList,
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-request-factory-url.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/resolve-request-factory-url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAKnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAG,6BAAsC,CAAA;AAEjF;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAG,6BAAsC,CAAA;AAEjF,MAAM,MAAM,6BAA6B,GAAG,OAAO,2BAA2B,GAAG,OAAO,2BAA2B,CAAA;AAEnH,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAA;AAK1F;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,cAAc,EACvB,SAAS;IACP,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC,CAAA;IACzE,mBAAmB,EAAE,eAAe,CAAA;IACpC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC,KACA,8BAqDF,CAAA"}
1
+ {"version":3,"file":"resolve-request-factory-url.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/resolve-request-factory-url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAMnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAG,6BAAsC,CAAA;AAEjF;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAG,6BAAsC,CAAA;AAEjF,MAAM,MAAM,6BAA6B,GAAG,OAAO,2BAA2B,GAAG,OAAO,2BAA2B,CAAA;AAEnH,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAA;AAK1F;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,cAAc,EACvB,SAAS;IACP,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC,CAAA;IACzE,mBAAmB,EAAE,eAAe,CAAA;IACpC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC,KACA,8BAoEF,CAAA"}
@@ -3,6 +3,7 @@ import { err, ok } from '@scalar/helpers/types/result';
3
3
  import { safeRun } from '@scalar/helpers/types/safe-run';
4
4
  import { isRelativePath } from '@scalar/helpers/url/is-relative-path';
5
5
  import { mergeSearchParams, mergeUrls } from '@scalar/helpers/url/merge-urls';
6
+ import { serializeQuerystringParameter } from '../../helpers/querystring-parameter.js';
6
7
  /**
7
8
  * Discriminated error code when the merged request URL is not a complete absolute target
8
9
  * (for example no OpenAPI server, or unresolved `{{environment}}` segments left in the merged URL).
@@ -22,7 +23,9 @@ export const resolveRequestFactoryUrl = (request, options) => {
22
23
  const variables = options.envVariables;
23
24
  const pathVariablesEncoded = safeRun(() => Object.fromEntries(Object.entries(request.path.variables).map(([key, value]) => [
24
25
  key,
25
- encodeURIComponent(replaceEnvVariables(value, variables)),
26
+ request.path.serializedParameters?.has(key)
27
+ ? replaceEnvVariables(value, variables)
28
+ : encodeURIComponent(replaceEnvVariables(value, variables)),
26
29
  ])));
27
30
  if (!pathVariablesEncoded.ok) {
28
31
  return err(INVALID_REQUEST_FACTORY_URL, 'The request URL contains invalid characters in path parameters.');
@@ -54,6 +57,19 @@ export const resolveRequestFactoryUrl = (request, options) => {
54
57
  for (const [key, value] of options.securityQueryParams.entries()) {
55
58
  securityQueryParams.append(key, value);
56
59
  }
57
- url.search = mergeSearchParams(url.searchParams, operationQueryParams, securityQueryParams).toString();
60
+ if (request.querystring) {
61
+ // A whole-query value replaces the server/path query and must never pass through
62
+ // URLSearchParams, which would add '=' and change existing percent encodings.
63
+ const query = serializeQuerystringParameter(request.querystring, variables);
64
+ const extra = mergeSearchParams(operationQueryParams, securityQueryParams).toString();
65
+ url.search = [query, extra].filter(Boolean).join('&');
66
+ }
67
+ else {
68
+ url.search = mergeSearchParams(url.searchParams, operationQueryParams, securityQueryParams).toString();
69
+ }
70
+ if (request.serializedQuery?.length) {
71
+ const query = request.serializedQuery.map((value) => replaceEnvVariables(value, variables)).join('&');
72
+ url.search = [url.search.slice(1), query].filter(Boolean).join('&');
73
+ }
58
74
  return ok(url.toString());
59
75
  };
@@ -1,4 +1,3 @@
1
- import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
1
  import type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
3
2
  /**
4
3
  * Restores conventional casing for well-known default headers.
@@ -35,7 +34,7 @@ export declare const filterDisabledDefaultHeaders: (operation: OperationObject,
35
34
  * operation parameter with `in: header` (disabled optional header parameters do not shadow defaults).
36
35
  */
37
36
  export declare const getDefaultHeaders: ({ method, operation, exampleName, hideDisabledHeaders, hideOverriddenHeaders, options, }: {
38
- method: HttpMethod;
37
+ method: string;
39
38
  operation: OperationObject;
40
39
  exampleName: string;
41
40
  hideDisabledHeaders?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../src/request-example/context/headers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAcnG;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GAAI,YAAY,MAAM,KAAG,MACQ,CAAA;AAE3E;;GAEG;AACH,eAAO,MAAM,qCAAqC,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CA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EAAE,MAAM,CAAA;IACd,SAAS,EAAE,eAAe,CAAA;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,OAAO,CAAC,EAAE;QACR,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,OAAO,CAAA;KACpB,CAAA;CACF,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAuCxB,CAAA"}
@@ -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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AAM,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,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;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';
@@ -1,4 +1,3 @@
1
- import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
1
  /**
3
2
  * Re-exported from `@scalar/helpers/types/result` so the rest of the
4
3
  * workspace-store codebase keeps importing `Result` from a colocated
@@ -8,7 +7,7 @@ export type { Result } from '@scalar/helpers/types/result';
8
7
  export type RequestExampleMeta = {
9
8
  /** API path, or webhook name when `isWebhook` is true. */
10
9
  path: string;
11
- method: HttpMethod;
10
+ method: string;
12
11
  exampleName: string;
13
12
  /** Resolve the operation from `document.webhooks` instead of `document.paths`. */
14
13
  isWebhook?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/request-example/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE;;;;GAIG;AACH,YAAY,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,UAAU,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/request-example/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA"}
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-xml-example.d.ts","sourceRoot":"","sources":["../../../src/request-example/xml/get-xml-example.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAG1E,OAAO,EACL,kBAAkB,EAGnB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACL,KAAK,2BAA2B,EAGjC,MAAM,4CAA4C,CAAA;AAEnD,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,aAAa,CAAA;AAC5D,OAAO,KAAK,EAAgB,aAAa,EAAE,gBAAgB,EAAoB,MAAM,YAAY,CAAA;AAEjG,kFAAkF;AAClF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,2BAA2B,EAAE,KAAK,GAAG,OAAO,kBAAkB,CAAC,GAClG,eAAe,GAAG;IAChB,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,0GAA0G;IAC1G,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,IAAI,CAAA;CACnD,CAAA;AAmBH,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB,GAAI,QAAQ,YAAY,EAAE,UAAS,iBAAsB,KAAG,gBAQ/F,CAAA;AAED,8GAA8G;AAC9G,eAAO,MAAM,mBAAmB,GAC9B,OAAO,OAAO,EACd,QAAQ,YAAY,EACpB,UAAS,iBAAsB,KAC9B,gBAAqF,CAAA"}