@scalar/workspace-store 0.54.2 → 0.54.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +25 -0
  4. package/dist/entities/auth/schema.d.ts +105 -15
  5. package/dist/entities/auth/schema.d.ts.map +1 -1
  6. package/dist/helpers/dynamic-ref.d.ts +24 -0
  7. package/dist/helpers/dynamic-ref.d.ts.map +1 -0
  8. package/dist/helpers/dynamic-ref.js +74 -0
  9. package/dist/helpers/for-each-path-item-operation.d.ts +33 -0
  10. package/dist/helpers/for-each-path-item-operation.d.ts.map +1 -0
  11. package/dist/helpers/for-each-path-item-operation.js +75 -0
  12. package/dist/mutators/auth.d.ts.map +1 -1
  13. package/dist/mutators/auth.js +7 -13
  14. package/dist/mutators/operation/body.d.ts.map +1 -1
  15. package/dist/mutators/operation/body.js +3 -2
  16. package/dist/mutators/operation/extensions.d.ts.map +1 -1
  17. package/dist/mutators/operation/extensions.js +2 -1
  18. package/dist/mutators/operation/history.d.ts.map +1 -1
  19. package/dist/mutators/operation/history.js +3 -2
  20. package/dist/mutators/operation/operation.d.ts.map +1 -1
  21. package/dist/mutators/operation/operation.js +16 -16
  22. package/dist/mutators/operation/parameters.d.ts.map +1 -1
  23. package/dist/mutators/operation/parameters.js +30 -9
  24. package/dist/mutators/server.d.ts.map +1 -1
  25. package/dist/mutators/server.js +2 -1
  26. package/dist/mutators/tag.d.ts.map +1 -1
  27. package/dist/mutators/tag.js +9 -15
  28. package/dist/navigation/helpers/get-openapi-object.d.ts.map +1 -1
  29. package/dist/navigation/helpers/get-openapi-object.js +2 -1
  30. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  31. package/dist/navigation/helpers/traverse-paths.js +5 -8
  32. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  33. package/dist/navigation/helpers/traverse-webhooks.js +4 -7
  34. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
  35. package/dist/request-example/builder/body/build-request-body.js +81 -7
  36. package/dist/request-example/builder/header/de-serialize-parameter.js +37 -4
  37. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +4 -1
  38. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  39. package/dist/request-example/builder/helpers/get-example-from-schema.js +97 -38
  40. package/dist/request-example/builder/security/build-request-security.d.ts.map +1 -1
  41. package/dist/request-example/builder/security/build-request-security.js +9 -4
  42. package/dist/request-example/context/get-request-example-context.d.ts.map +1 -1
  43. package/dist/request-example/context/get-request-example-context.js +3 -2
  44. package/dist/schemas/reference-config/index.d.ts +21 -3
  45. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  46. package/dist/schemas/reference-config/settings.d.ts +21 -3
  47. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  48. package/dist/schemas/v3.1/strict/components.d.ts +11 -2
  49. package/dist/schemas/v3.1/strict/components.d.ts.map +1 -1
  50. package/dist/schemas/v3.1/strict/components.js +1 -1
  51. package/dist/schemas/v3.1/strict/openapi-document.d.ts +735 -105
  52. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  53. package/dist/schemas/v3.1/strict/openapi-document.js +2 -2
  54. package/dist/schemas/v3.1/strict/paths.d.ts +12 -2
  55. package/dist/schemas/v3.1/strict/paths.d.ts.map +1 -1
  56. package/dist/schemas/v3.1/strict/paths.js +2 -1
  57. package/dist/server.d.ts.map +1 -1
  58. package/dist/server.js +12 -9
  59. package/package.json +5 -5
@@ -1,7 +1,7 @@
1
1
  // import { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables'
2
2
  import { isObject } from '@scalar/helpers/object/is-object';
3
3
  import { setValueAtPath } from '@scalar/helpers/object/set-value-at-path';
4
- import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref';
4
+ import { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref';
5
5
  import { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy';
6
6
  import { isObjectSchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards';
7
7
  import { getExampleFromBody } from './get-request-body-example.js';
@@ -16,13 +16,15 @@ const getMultipartEncodingContentType = (requestBody, bodyContentType, fieldName
16
16
  * by `get-form-body-rows.ts` are folded back via `foldDottedRowsToObject`.
17
17
  */
18
18
  const buildDottedNestedRowPredicate = (schema) => {
19
- const resolved = schema ? getResolvedRef(schema) : undefined;
19
+ const resolved = schema ? getResolvedRef(schema, mergeSiblingReferences) : undefined;
20
20
  if (!resolved || !isObjectSchema(resolved) || !resolved.properties) {
21
21
  return (_name, _value) => false;
22
22
  }
23
23
  const nestedTopKeys = new Set();
24
24
  for (const [key, child] of Object.entries(resolved.properties)) {
25
- const childResolved = child ? getResolvedRef(child) : undefined;
25
+ const childResolved = child
26
+ ? getResolvedRef(child, mergeSiblingReferences)
27
+ : undefined;
26
28
  if (childResolved && isObjectSchema(childResolved) && childResolved.properties) {
27
29
  nestedTopKeys.add(key);
28
30
  }
@@ -35,6 +37,75 @@ const buildDottedNestedRowPredicate = (schema) => {
35
37
  return !!head && nestedTopKeys.has(head);
36
38
  };
37
39
  };
40
+ /** Normalize a schema's `type` (string | string[] | absent) into a plain string array. */
41
+ const normalizeSchemaTypes = (schema) => {
42
+ const type = 'type' in schema ? schema.type : undefined;
43
+ return Array.isArray(type) ? [...type] : type == null ? [] : [type];
44
+ };
45
+ /**
46
+ * Walk an object schema along a dotted-row path and return the resolved leaf schema,
47
+ * or undefined when any segment is not a declared object property.
48
+ */
49
+ const resolveLeafSchema = (schema, segments) => {
50
+ let current = schema;
51
+ for (const segment of segments) {
52
+ if (!current || !isObjectSchema(current) || !current.properties) {
53
+ return undefined;
54
+ }
55
+ current = getResolvedRef(current.properties[segment], mergeSiblingReferences);
56
+ }
57
+ return current;
58
+ };
59
+ /** True when a JSON-parsed value's runtime type is allowed by the schema's declared types. */
60
+ const parsedValueMatchesSchemaType = (value, types) => {
61
+ if (value === null) {
62
+ return types.includes('null');
63
+ }
64
+ if (Array.isArray(value)) {
65
+ return types.includes('array');
66
+ }
67
+ if (typeof value === 'object') {
68
+ return types.includes('object');
69
+ }
70
+ if (typeof value === 'boolean') {
71
+ return types.includes('boolean');
72
+ }
73
+ if (typeof value === 'number') {
74
+ // A fractional value only satisfies `number`; `integer` requires a whole number so a
75
+ // string like "3.14" against an integer-only leaf stays untouched instead of being coerced.
76
+ return types.includes('number') || (types.includes('integer') && Number.isInteger(value));
77
+ }
78
+ if (typeof value === 'string') {
79
+ return types.includes('string');
80
+ }
81
+ return false;
82
+ };
83
+ /**
84
+ * The form table stringifies every value for display, so an edited nested field comes back
85
+ * as a string (`false` -> "false", `[]` -> "[]"). When the leaf schema declares a non-string
86
+ * type, parse the string back to that type so the regrouped JSON part keeps its original
87
+ * shape instead of becoming string-typed (issue #9416).
88
+ *
89
+ * Coercion is deliberately conservative: schemas that allow `string` keep the raw text, and a
90
+ * value that does not parse as its declared type is left untouched so user input is never lost.
91
+ */
92
+ const coerceLeafValueToSchemaType = (value, schema) => {
93
+ if (typeof value !== 'string' || !schema) {
94
+ return value;
95
+ }
96
+ const types = normalizeSchemaTypes(schema);
97
+ // No declared type, or a string is allowed: keep the user's text as-is.
98
+ if (types.length === 0 || types.includes('string')) {
99
+ return value;
100
+ }
101
+ try {
102
+ const parsed = JSON.parse(value);
103
+ return parsedValueMatchesSchemaType(parsed, types) ? parsed : value;
104
+ }
105
+ catch {
106
+ return value;
107
+ }
108
+ };
38
109
  /**
39
110
  * Create the fetch request body
40
111
  */
@@ -81,9 +152,10 @@ requestBodyCompositionSelection) => {
81
152
  // lazily allocate the regrouped object for its top-level key and push it into
82
153
  // `entries` at the position of the *first* matching row, then keep folding leaves
83
154
  // into the same live object reference so interleaved flat rows keep their order.
84
- const isDottedNestedRow = result.mode === 'formdata'
85
- ? buildDottedNestedRowPredicate(requestBody.content[bodyContentType]?.schema)
86
- : () => false;
155
+ const multipartSchema = result.mode === 'formdata'
156
+ ? getResolvedRef(requestBody.content[bodyContentType]?.schema, mergeSiblingReferences)
157
+ : undefined;
158
+ const isDottedNestedRow = result.mode === 'formdata' ? buildDottedNestedRowPredicate(multipartSchema) : () => false;
87
159
  const entries = [];
88
160
  const regroupedByTopKey = new Map();
89
161
  for (const row of exampleValue) {
@@ -102,7 +174,9 @@ requestBodyCompositionSelection) => {
102
174
  regroupedByTopKey.set(topKey, target);
103
175
  entries.push({ name: topKey, value: target });
104
176
  }
105
- setValueAtPath(target, segments.slice(1), row.value);
177
+ // The form table stringifies leaf values; restore the schema-declared type so the
178
+ // regrouped JSON part keeps booleans/numbers/arrays instead of string-typing them.
179
+ setValueAtPath(target, segments.slice(1), coerceLeafValueToSchemaType(row.value, resolveLeafSchema(multipartSchema, segments)));
106
180
  }
107
181
  // Loop over all entries and add them to the form
108
182
  entries.forEach(({ name, value }) => {
@@ -29,6 +29,40 @@ const deSerializeContentExample = (example, contentType) => {
29
29
  };
30
30
  /** Schema types that must become arrays/objects — serializers branch on `Array.isArray` / objects. */
31
31
  const structuredSchemaTypes = new Set(['array', 'object']);
32
+ /**
33
+ * Find the structured (`array` or `object`) type a schema represents, looking through
34
+ * `anyOf`/`oneOf`/`allOf` composition.
35
+ *
36
+ * Optional array/object parameters are commonly described as `anyOf: [{ type: 'array' }, { type: 'null' }]`
37
+ * (e.g. FastAPI/Pydantic `Optional[List[str]]`). Without unwrapping these we would treat the value as a
38
+ * plain string and send a single `id=a,b` query parameter instead of repeating `id=a&id=b`.
39
+ */
40
+ const getStructuredType = (schema) => {
41
+ const resolved = getResolvedRef(schema);
42
+ if (!resolved || typeof resolved !== 'object') {
43
+ return undefined;
44
+ }
45
+ if ('type' in resolved && resolved.type) {
46
+ const type = Array.isArray(resolved.type)
47
+ ? resolved.type.find((t) => structuredSchemaTypes.has(t))
48
+ : resolved.type;
49
+ if (type === 'array' || type === 'object') {
50
+ return type;
51
+ }
52
+ }
53
+ for (const key of ['anyOf', 'oneOf', 'allOf']) {
54
+ const subSchemas = resolved[key];
55
+ if (Array.isArray(subSchemas)) {
56
+ for (const subSchema of subSchemas) {
57
+ const type = getStructuredType(subSchema);
58
+ if (type) {
59
+ return type;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ return undefined;
65
+ };
32
66
  /**
33
67
  * Schema-based parameters from the request editor.
34
68
  *
@@ -36,10 +70,9 @@ const structuredSchemaTypes = new Set(['array', 'object']);
36
70
  * Only `array` and `object` values are parsed so OpenAPI style serialization can expand them.
37
71
  */
38
72
  const deSerializeSchemaExample = (example, schema) => {
39
- const resolvedSchema = getResolvedRef(schema);
40
- if (typeof example === 'string' && resolvedSchema && 'type' in resolvedSchema) {
41
- const type = Array.isArray(resolvedSchema.type) ? resolvedSchema.type[0] : resolvedSchema.type;
42
- if (type && structuredSchemaTypes.has(type)) {
73
+ if (typeof example === 'string') {
74
+ const type = getStructuredType(schema);
75
+ if (type) {
43
76
  try {
44
77
  return JSON.parse(example);
45
78
  }
@@ -1,3 +1,4 @@
1
+ import { type DynamicScope } from '../../../helpers/dynamic-ref.js';
1
2
  import type { SchemaObject } from '../../../schemas/v3.1/strict/openapi-document.js';
2
3
  type GetExampleFromSchemaOptions = {
3
4
  /** Fallback string for empty string values. */
@@ -28,13 +29,15 @@ type GetExampleFromSchemaOptions = {
28
29
  * @param name - The name of the property being processed.
29
30
  * @returns An example value for the given schema.
30
31
  */
31
- export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, { level, parentSchema, name, seen, schemaPath, }?: Partial<{
32
+ export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, { level, parentSchema, name, seen, schemaPath, dynamicScope, }?: Partial<{
32
33
  level: number;
33
34
  parentSchema: SchemaObject;
34
35
  name: string;
35
36
  seen: WeakSet<object>;
36
37
  /** Internal traversal path used to resolve nested composition selections. */
37
38
  schemaPath: string[];
39
+ /** Chain of schema resources entered so far, used to resolve `$dynamicRef` (JSON Schema 2020-12). */
40
+ dynamicScope: DynamicScope;
38
41
  }>) => unknown;
39
42
  export {};
40
43
  //# 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":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAypB1E,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,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9C,CAAA;AAeD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,YAAY,EACpB,UAAU,2BAA2B,EACrC,mDAMG,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;CACrB,CAAM,KACN,OAqKF,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":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAisB1E,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,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9C,CAAA;AAeD;;;;;;;;;;;;;;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,OAmMF,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { isDefined } from '@scalar/helpers/array/is-defined';
2
+ import { isDynamicRef, pushDynamicScope, resolveDynamicRef } from '../../../helpers/dynamic-ref.js';
2
3
  import { unpackProxyObject } from '../../../helpers/unpack-proxy.js';
3
4
  import { resolve } from '../../../resolve.js';
4
5
  /** Maximum recursion depth to prevent infinite loops in circular references */
@@ -108,9 +109,13 @@ const getRequiredNames = (parentSchema) => {
108
109
  * Cache the result for a schema if it is an object type.
109
110
  * Primitive values are not cached to avoid unnecessary WeakMap operations.
110
111
  * Stores a map of cacheKey strings which is made up of the options object.
112
+ *
113
+ * Skips the cache while a dynamic scope is active: the same shared schema node can resolve to
114
+ * different examples depending on the dynamic scope it was reached through, so caching it by object
115
+ * identity would leak one scope's result into another.
111
116
  */
112
- const cache = (schema, result, cacheKey) => {
113
- if (typeof result !== 'object' || result === null) {
117
+ const cache = (schema, result, cacheKey, skip = false) => {
118
+ if (skip || typeof result !== 'object' || result === null) {
114
119
  return result;
115
120
  }
116
121
  const rawSchema = getSchemaCacheTarget(schema);
@@ -313,8 +318,11 @@ const sortPropertyNamesByXOrder = (properties) => Object.keys(properties).sort((
313
318
  * Build an example for an object schema, including properties, patternProperties,
314
319
  * additionalProperties, and composition (allOf/oneOf/anyOf) merging.
315
320
  */
316
- const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath) => {
321
+ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath, dynamicScope) => {
317
322
  const response = {};
323
+ // Children are evaluated with this schema added to the dynamic scope so nested `$dynamicRef`s bind here.
324
+ const childScope = pushDynamicScope(dynamicScope, schema);
325
+ const skipCache = dynamicScope.length > 0;
318
326
  if ('properties' in schema && schema.properties) {
319
327
  const properties = schema.properties;
320
328
  const propertyNames = sortPropertyNamesByXOrder(properties);
@@ -332,6 +340,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath)
332
340
  name: propertyName,
333
341
  schemaPath: [...schemaPath, propertyName],
334
342
  seen,
343
+ dynamicScope: childScope,
335
344
  });
336
345
  if (typeof value !== 'undefined') {
337
346
  response[propertyXmlName ?? propertyName] = value;
@@ -350,6 +359,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath)
350
359
  name: pattern,
351
360
  schemaPath: [...schemaPath, pattern],
352
361
  seen,
362
+ dynamicScope: childScope,
353
363
  });
354
364
  }
355
365
  }
@@ -376,6 +386,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath)
376
386
  level: level + 1,
377
387
  schemaPath: [...schemaPath, additionalName],
378
388
  seen,
389
+ dynamicScope: childScope,
379
390
  })
380
391
  : 'anything';
381
392
  if (propertyNamesEnum && propertyNamesEnum.length > 0) {
@@ -396,6 +407,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath)
396
407
  level: level + 1,
397
408
  schemaPath,
398
409
  seen,
410
+ dynamicScope: childScope,
399
411
  }));
400
412
  }
401
413
  }
@@ -407,6 +419,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath)
407
419
  level: level + 1,
408
420
  parentSchema: schema,
409
421
  seen,
422
+ dynamicScope: childScope,
410
423
  });
411
424
  merged = mergeExamples(merged, ex);
412
425
  }
@@ -417,18 +430,33 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath)
417
430
  if (options?.xml && 'xml' in schema && schema.xml?.name && level === 0) {
418
431
  const wrapped = {};
419
432
  wrapped[schema.xml.name] = response;
420
- return cache(schema, wrapped, cacheKey);
433
+ return cache(schema, wrapped, cacheKey, skipCache);
421
434
  }
422
- return cache(schema, response, cacheKey);
435
+ return cache(schema, response, cacheKey, skipCache);
423
436
  };
424
437
  /** Build an example for an array schema, including items, allOf, oneOf/anyOf, and XML wrapping */
425
- const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath) => {
426
- const items = 'items' in schema ? resolve.schema(schema.items) : undefined;
438
+ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath, dynamicScope) => {
439
+ const childScope = pushDynamicScope(dynamicScope, schema);
440
+ const skipCache = dynamicScope.length > 0;
441
+ let items = 'items' in schema ? resolve.schema(schema.items) : undefined;
442
+ // Bind a dynamic item type (e.g. the generic `PaginatedResponse<T>` pattern) before inspecting it.
443
+ // Crossing a `$dynamicRef` leaves the static schema graph, so the cycle guard built up by the outer
444
+ // walk no longer applies to the bound type. Restart `seen` for the item recursion so recursive trees
445
+ // (e.g. a category whose children reference the same anchor) render their nested levels instead of
446
+ // tripping the shared guard. Depth stays bounded by `MAX_LEVELS_DEEP`.
447
+ let itemsSeen = seen;
448
+ if (items && isDynamicRef(items)) {
449
+ const resolvedDynamic = resolveDynamicRef(items.$dynamicRef, childScope);
450
+ if (resolvedDynamic) {
451
+ items = resolvedDynamic;
452
+ itemsSeen = new WeakSet();
453
+ }
454
+ }
427
455
  const itemsSchemaPath = [...schemaPath, 'items'];
428
456
  const itemsXmlTagName = items && typeof items === 'object' && 'xml' in items ? items.xml?.name : undefined;
429
457
  const wrapItems = !!(options?.xml && 'xml' in schema && schema.xml?.wrapped && itemsXmlTagName);
430
458
  if (schema.example !== undefined) {
431
- return cache(schema, wrapItems ? { [itemsXmlTagName]: schema.example } : schema.example, cacheKey);
459
+ return cache(schema, wrapItems ? { [itemsXmlTagName]: schema.example } : schema.example, cacheKey, skipCache);
432
460
  }
433
461
  if (items && typeof items === 'object') {
434
462
  if (Array.isArray(items.allOf) && items.allOf.length > 0) {
@@ -440,19 +468,21 @@ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath) =
440
468
  level: level + 1,
441
469
  parentSchema: schema,
442
470
  schemaPath: itemsSchemaPath,
443
- seen,
471
+ seen: itemsSeen,
472
+ dynamicScope: childScope,
444
473
  });
445
- return cache(schema, wrapItems ? [{ [itemsXmlTagName]: merged }] : [merged], cacheKey);
474
+ return cache(schema, wrapItems ? [{ [itemsXmlTagName]: merged }] : [merged], cacheKey, skipCache);
446
475
  }
447
476
  const examples = allOf
448
477
  .map((s) => getExampleFromSchema(resolve.schema(s), options, {
449
478
  level: level + 1,
450
479
  parentSchema: schema,
451
480
  schemaPath: itemsSchemaPath,
452
- seen,
481
+ seen: itemsSeen,
482
+ dynamicScope: childScope,
453
483
  }))
454
484
  .filter(isDefined);
455
- return cache(schema, wrapItems ? examples.map((e) => ({ [itemsXmlTagName]: e })) : examples, cacheKey);
485
+ return cache(schema, wrapItems ? examples.map((e) => ({ [itemsXmlTagName]: e })) : examples, cacheKey, skipCache);
456
486
  }
457
487
  const compositionKeyword = items.oneOf ? 'oneOf' : items.anyOf ? 'anyOf' : undefined;
458
488
  const union = compositionKeyword ? items[compositionKeyword] : undefined;
@@ -463,9 +493,10 @@ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath) =
463
493
  level: level + 1,
464
494
  parentSchema: schema,
465
495
  schemaPath: itemsSchemaPath,
466
- seen,
496
+ seen: itemsSeen,
497
+ dynamicScope: childScope,
467
498
  });
468
- return cache(schema, wrapItems ? [{ [itemsXmlTagName]: ex }] : [ex], cacheKey);
499
+ return cache(schema, wrapItems ? [{ [itemsXmlTagName]: ex }] : [ex], cacheKey, skipCache);
469
500
  }
470
501
  }
471
502
  const isObject = items && typeof items === 'object' && (('type' in items && items.type === 'object') || 'properties' in items);
@@ -474,11 +505,12 @@ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath) =
474
505
  const ex = getExampleFromSchema(items, options, {
475
506
  level: level + 1,
476
507
  schemaPath: itemsSchemaPath,
477
- seen,
508
+ seen: itemsSeen,
509
+ dynamicScope: childScope,
478
510
  });
479
- return cache(schema, wrapItems ? [{ [itemsXmlTagName]: ex }] : [ex], cacheKey);
511
+ return cache(schema, wrapItems ? [{ [itemsXmlTagName]: ex }] : [ex], cacheKey, skipCache);
480
512
  }
481
- return cache(schema, [], cacheKey);
513
+ return cache(schema, [], cacheKey, skipCache);
482
514
  };
483
515
  /** Return primitive example value for single-type schemas, or undefined if not primitive */
484
516
  const getPrimitiveValue = (schema, makeUpRandomData, emptyString) => {
@@ -552,12 +584,35 @@ const createOptionsCacheKey = (options) => JSON.stringify({
552
584
  * @param name - The name of the property being processed.
553
585
  * @returns An example value for the given schema.
554
586
  */
555
- export const getExampleFromSchema = (schema, options, { level = 0, parentSchema, name, seen = new WeakSet(), schemaPath = [], } = {}) => {
587
+ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema, name, seen = new WeakSet(), schemaPath = [], dynamicScope = [], } = {}) => {
556
588
  // Resolve any $ref references to get the actual schema
557
589
  const _schema = resolve.schema(schema);
558
590
  if (!isDefined(_schema)) {
559
591
  return undefined;
560
592
  }
593
+ // Resolve a `$dynamicRef` against the active dynamic scope, then continue with the bound schema.
594
+ // When nothing matches, fall through and render the reference as before (no regression).
595
+ if (isDynamicRef(_schema)) {
596
+ const resolvedDynamic = resolveDynamicRef(_schema.$dynamicRef, dynamicScope);
597
+ if (resolvedDynamic) {
598
+ // The `seen` set guards against cycles in the static schema graph, but a `$dynamicRef` is resolved
599
+ // per evaluation path and intentionally points outside that graph. Re-entering the bound type with a
600
+ // fresh `seen` lets recursive examples (e.g. a category tree) render their nested levels instead of
601
+ // bailing out on the shared cycle guard. Depth stays bounded by `MAX_LEVELS_DEEP`.
602
+ return getExampleFromSchema(resolvedDynamic, options, {
603
+ level: level + 1,
604
+ parentSchema,
605
+ name,
606
+ seen: new WeakSet(),
607
+ schemaPath,
608
+ dynamicScope,
609
+ });
610
+ }
611
+ }
612
+ // Grow the scope with this schema so nested references can bind to its `$dynamicAnchor`s.
613
+ const childScope = pushDynamicScope(dynamicScope, _schema);
614
+ // The same shared node can resolve differently per scope, so skip the result cache under a scope.
615
+ const skipCache = dynamicScope.length > 0;
561
616
  // Unpack from all proxies to get the raw schema object for cycle detection
562
617
  const targetValue = getSchemaCacheTarget(_schema);
563
618
  if (seen.has(targetValue)) {
@@ -566,11 +621,13 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
566
621
  seen.add(targetValue);
567
622
  /** Make the cache key unique per options and schema path */
568
623
  const cacheKey = createOptionsCacheKey(options) + (schemaPath.length > 0 ? `:path:${schemaPath.join('.')}` : '');
569
- // Check cache first for performance - avoid recomputing the same schema
570
- const cached = resultCache.get(targetValue)?.get(cacheKey);
571
- if (typeof cached !== 'undefined') {
572
- seen.delete(targetValue);
573
- return cached;
624
+ // Check cache first for performance - avoid recomputing the same schema (skipped under a dynamic scope)
625
+ if (!skipCache) {
626
+ const cached = resultCache.get(targetValue)?.get(cacheKey);
627
+ if (typeof cached !== 'undefined') {
628
+ seen.delete(targetValue);
629
+ return cached;
630
+ }
574
631
  }
575
632
  // Prevent infinite recursion in circular references
576
633
  if (level > MAX_LEVELS_DEEP) {
@@ -591,45 +648,45 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
591
648
  // Type coercion for numeric types
592
649
  if ('type' in _schema && (_schema.type === 'number' || _schema.type === 'integer')) {
593
650
  seen.delete(targetValue);
594
- return cache(_schema, Number(value), cacheKey);
651
+ return cache(_schema, Number(value), cacheKey, skipCache);
595
652
  }
596
653
  seen.delete(targetValue);
597
- return cache(_schema, value, cacheKey);
654
+ return cache(_schema, value, cacheKey, skipCache);
598
655
  }
599
656
  }
600
657
  // Priority order: examples > example > default > const > enum
601
658
  if (Array.isArray(_schema.examples) && _schema.examples.length > 0) {
602
659
  seen.delete(targetValue);
603
- return cache(_schema, _schema.examples[0], cacheKey);
660
+ return cache(_schema, _schema.examples[0], cacheKey, skipCache);
604
661
  }
605
662
  if (_schema.example !== undefined) {
606
663
  seen.delete(targetValue);
607
- return cache(_schema, _schema.example, cacheKey);
664
+ return cache(_schema, _schema.example, cacheKey, skipCache);
608
665
  }
609
666
  if (_schema.default !== undefined) {
610
667
  const normalizedDefault = normalizeSchemaDefault(_schema);
611
668
  if (normalizedDefault !== INVALID_DEFAULT) {
612
669
  seen.delete(targetValue);
613
- return cache(_schema, normalizedDefault, cacheKey);
670
+ return cache(_schema, normalizedDefault, cacheKey, skipCache);
614
671
  }
615
672
  }
616
673
  if (_schema.const !== undefined) {
617
674
  seen.delete(targetValue);
618
- return cache(_schema, _schema.const, cacheKey);
675
+ return cache(_schema, _schema.const, cacheKey, skipCache);
619
676
  }
620
677
  if (Array.isArray(_schema.enum) && _schema.enum.length > 0) {
621
678
  seen.delete(targetValue);
622
- return cache(_schema, _schema.enum[0], cacheKey);
679
+ return cache(_schema, _schema.enum[0], cacheKey, skipCache);
623
680
  }
624
681
  // Handle object types - check for properties to identify objects
625
682
  if ('properties' in _schema || ('type' in _schema && _schema.type === 'object')) {
626
- const result = handleObjectSchema(_schema, options, level, seen, cacheKey, schemaPath);
683
+ const result = handleObjectSchema(_schema, options, level, seen, cacheKey, schemaPath, dynamicScope);
627
684
  seen.delete(targetValue);
628
685
  return result;
629
686
  }
630
687
  // Handle array types
631
688
  if (('type' in _schema && _schema.type === 'array') || 'items' in _schema) {
632
- const result = handleArraySchema(_schema, options, level, seen, cacheKey, schemaPath);
689
+ const result = handleArraySchema(_schema, options, level, seen, cacheKey, schemaPath, dynamicScope);
633
690
  seen.delete(targetValue);
634
691
  return result;
635
692
  }
@@ -637,7 +694,7 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
637
694
  const primitive = getPrimitiveValue(_schema, makeUpRandomData, options?.emptyString);
638
695
  if (primitive !== undefined) {
639
696
  seen.delete(targetValue);
640
- return cache(_schema, primitive, cacheKey);
697
+ return cache(_schema, primitive, cacheKey, skipCache);
641
698
  }
642
699
  // Handle composition schemas (oneOf, anyOf)
643
700
  const compositionKeyword = _schema.oneOf ? 'oneOf' : _schema.anyOf ? 'anyOf' : undefined;
@@ -658,11 +715,12 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
658
715
  level: level + 1,
659
716
  schemaPath,
660
717
  seen,
661
- }), cacheKey);
718
+ dynamicScope: childScope,
719
+ }), cacheKey, skipCache);
662
720
  }
663
721
  }
664
722
  seen.delete(targetValue);
665
- return cache(_schema, null, cacheKey);
723
+ return cache(_schema, null, cacheKey, skipCache);
666
724
  }
667
725
  // Handle allOf at root level (non-object/array schemas)
668
726
  if (Array.isArray(_schema.allOf) && _schema.allOf.length > 0) {
@@ -674,6 +732,7 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
674
732
  parentSchema: _schema,
675
733
  schemaPath,
676
734
  seen,
735
+ dynamicScope: childScope,
677
736
  });
678
737
  if (merged === undefined) {
679
738
  merged = ex;
@@ -687,15 +746,15 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
687
746
  }
688
747
  }
689
748
  seen.delete(targetValue);
690
- return cache(_schema, merged ?? null, cacheKey);
749
+ return cache(_schema, merged ?? null, cacheKey, skipCache);
691
750
  }
692
751
  // Handle union types (array of types)
693
752
  const unionPrimitive = getUnionPrimitiveValue(_schema, makeUpRandomData, options?.emptyString);
694
753
  if (unionPrimitive !== undefined) {
695
754
  seen.delete(targetValue);
696
- return cache(_schema, unionPrimitive, cacheKey);
755
+ return cache(_schema, unionPrimitive, cacheKey, skipCache);
697
756
  }
698
757
  // Default fallback
699
758
  seen.delete(targetValue);
700
- return cache(_schema, null, cacheKey);
759
+ return cache(_schema, null, cacheKey, skipCache);
701
760
  };
@@ -1 +1 @@
1
- {"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;AAC5D,yBAAyB,0BAA0B,EAAE;AACrD,qEAAqE;AACrE,8BAA0B,KACzB,0BAA0B,EAuF5B,CAAA"}
1
+ {"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;AAC5D,yBAAyB,0BAA0B,EAAE;AACrD,qEAAqE;AACrE,8BAA0B,KACzB,0BAA0B,EA6F5B,CAAA"}
@@ -39,14 +39,19 @@ emptyTokenPlaceholder = '') => {
39
39
  // HTTP
40
40
  if (scheme.type === 'http') {
41
41
  if (scheme.scheme === 'basic') {
42
- const username = scheme['x-scalar-secret-username'];
43
- const password = scheme['x-scalar-secret-password'];
44
- const value = `${username}:${password}`;
42
+ const username = scheme['x-scalar-secret-username'] || '';
43
+ const password = scheme['x-scalar-secret-password'] || '';
44
+ // When the user has cleared both fields we must not send any credentials.
45
+ // Falling back to placeholder values here would emit `Basic username:password`,
46
+ // which some servers accept as a valid (but bogus) credential instead of returning 401.
47
+ if (username === '' && password === '') {
48
+ return null;
49
+ }
45
50
  return result.push({
46
51
  in: 'header',
47
52
  name: 'Authorization',
48
53
  // We encode the value when we build the request since we want to be able to replace the variables in the value
49
- value: value === ':' ? 'username:password' : value,
54
+ value: `${username}:${password}`,
50
55
  format: 'basic',
51
56
  });
52
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-request-example-context.d.ts","sourceRoot":"","sources":["../../../src/request-example/context/get-request-example-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAE9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAIjG,OAAO,EAAE,KAAK,MAAM,EAAqB,MAAM,iCAAiC,CAAA;AAIhF,OAAO,EAAE,KAAK,qBAAqB,EAAiB,MAAM,mDAAmD,CAAA;AAE7G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAA;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,EAAE,eAAe,CAAA;IAC1B,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;QACnB,WAAW,EAAE,kBAAkB,CAAA;KAChC,CAAA;IACD,OAAO,EAAE;QACP,SAAS,EAAE,aAAa,EAAE,CAAA;QAC1B,QAAQ,EAAE,aAAa,EAAE,CAAA;KAC1B,CAAA;IACD,OAAO,EAAE;QACP,IAAI,EAAE,YAAY,EAAE,CAAA;QACpB,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAA;QAC7B,IAAI,EAAE,UAAU,CAAA;KACjB,CAAA;IACD,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;KACnB,CAAA;IACD,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAChC,CAAA;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,qBAAqB,CAAA;QAC9B,YAAY,EAAE,yBAAyB,EAAE,CAAA;QACzC,QAAQ,EAAE,gBAAgB,CAAA;QAC1B,eAAe,EAAE,0BAA0B,EAAE,CAAA;QAC7C,IAAI,EAAE,QAAQ,CAAA;KACf,CAAA;CACF,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,cAAc,EAC9B,cAAc,MAAM,EACpB,oBAAoB,kBAAkB,EACtC,UAAS,OAAO,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,+CAA+C;IAC/C,cAAc,EAAE,2BAA2B,CAAA;IAC3C;;;;OAIG;IACH,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAC3C,CAAM,KACN,MAAM,CAAC,0BAA0B,CA6InC,CAAA"}
1
+ {"version":3,"file":"get-request-example-context.d.ts","sourceRoot":"","sources":["../../../src/request-example/context/get-request-example-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAE9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAGpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAIjG,OAAO,EAAE,KAAK,MAAM,EAAqB,MAAM,iCAAiC,CAAA;AAIhF,OAAO,EAAE,KAAK,qBAAqB,EAAiB,MAAM,mDAAmD,CAAA;AAE7G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAA;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,EAAE,eAAe,CAAA;IAC1B,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;QACnB,WAAW,EAAE,kBAAkB,CAAA;KAChC,CAAA;IACD,OAAO,EAAE;QACP,SAAS,EAAE,aAAa,EAAE,CAAA;QAC1B,QAAQ,EAAE,aAAa,EAAE,CAAA;KAC1B,CAAA;IACD,OAAO,EAAE;QACP,IAAI,EAAE,YAAY,EAAE,CAAA;QACpB,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAA;QAC7B,IAAI,EAAE,UAAU,CAAA;KACjB,CAAA;IACD,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;KACnB,CAAA;IACD,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAChC,CAAA;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,qBAAqB,CAAA;QAC9B,YAAY,EAAE,yBAAyB,EAAE,CAAA;QACzC,QAAQ,EAAE,gBAAgB,CAAA;QAC1B,eAAe,EAAE,0BAA0B,EAAE,CAAA;QAC7C,IAAI,EAAE,QAAQ,CAAA;KACf,CAAA;CACF,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,cAAc,EAC9B,cAAc,MAAM,EACpB,oBAAoB,kBAAkB,EACtC,UAAS,OAAO,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,+CAA+C;IAC/C,cAAc,EAAE,2BAA2B,CAAA;IAC3C;;;;OAIG;IACH,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAC3C,CAAM,KACN,MAAM,CAAC,0BAA0B,CA6InC,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { getPathItemOperation, getResolvedPathItem } from '../../helpers/for-each-path-item-operation.js';
1
2
  import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
2
3
  import { getActiveEnvironment } from '../../request-example/context/environment.js';
3
4
  import { getDefaultHeaders } from '../../request-example/context/headers.js';
@@ -24,14 +25,14 @@ export const getRequestExampleContext = (workspaceStore, documentName, requestEx
24
25
  error: `Document ${documentName} is not an OpenAPI document`,
25
26
  };
26
27
  }
27
- const pathItem = getResolvedRef(document.paths?.[path]);
28
+ const pathItem = getResolvedPathItem(document.paths?.[path]);
28
29
  if (!pathItem) {
29
30
  return {
30
31
  ok: false,
31
32
  error: `Path ${path} not found`,
32
33
  };
33
34
  }
34
- const resolvedOperation = getResolvedRef(pathItem[method]);
35
+ const resolvedOperation = getResolvedRef(getPathItemOperation(document.paths?.[path], method));
35
36
  if (!resolvedOperation) {
36
37
  return {
37
38
  ok: false,