@scalar/workspace-store 0.73.0 → 0.74.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 (81) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +10 -0
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +23 -6
  5. package/dist/entities/auth/schema.d.ts +195 -40
  6. package/dist/entities/auth/schema.d.ts.map +1 -1
  7. package/dist/helpers/async-api-schema-resources/load-inline.d.ts +5 -0
  8. package/dist/helpers/async-api-schema-resources/load-inline.d.ts.map +1 -0
  9. package/dist/helpers/async-api-schema-resources/load-inline.js +71 -0
  10. package/dist/helpers/async-api-schema-resources/protobuf-imports.d.ts +8 -0
  11. package/dist/helpers/async-api-schema-resources/protobuf-imports.d.ts.map +1 -0
  12. package/dist/helpers/async-api-schema-resources/protobuf-imports.js +25 -0
  13. package/dist/helpers/async-api-schema-resources/raml-source.d.ts +12 -0
  14. package/dist/helpers/async-api-schema-resources/raml-source.d.ts.map +1 -0
  15. package/dist/helpers/async-api-schema-resources/raml-source.js +32 -0
  16. package/dist/helpers/async-api-schema-resources/resources.d.ts +10 -0
  17. package/dist/helpers/async-api-schema-resources/resources.d.ts.map +1 -0
  18. package/dist/helpers/async-api-schema-resources/resources.js +124 -0
  19. package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts +3 -0
  20. package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts.map +1 -0
  21. package/dist/helpers/async-api-schema-resources/schema-resource-path.js +9 -0
  22. package/dist/helpers/compact-upgrade-metadata.d.ts +3 -0
  23. package/dist/helpers/compact-upgrade-metadata.d.ts.map +1 -0
  24. package/dist/helpers/compact-upgrade-metadata.js +71 -0
  25. package/dist/helpers/is-file-schema.js +1 -1
  26. package/dist/helpers/querystring-parameter.d.ts +3 -1
  27. package/dist/helpers/querystring-parameter.d.ts.map +1 -1
  28. package/dist/helpers/querystring-parameter.js +2 -2
  29. package/dist/helpers/resolve-async-api-schema.d.ts +2 -0
  30. package/dist/helpers/resolve-async-api-schema.d.ts.map +1 -1
  31. package/dist/helpers/resolve-async-api-schema.js +23 -1
  32. package/dist/mutators/operation/parameters.d.ts.map +1 -1
  33. package/dist/mutators/operation/parameters.js +9 -1
  34. package/dist/mutators/operation/reset-request-body.d.ts.map +1 -1
  35. package/dist/mutators/operation/reset-request-body.js +3 -1
  36. package/dist/plugins/bundler/async-api-schema-resources.d.ts +4 -0
  37. package/dist/plugins/bundler/async-api-schema-resources.d.ts.map +1 -0
  38. package/dist/plugins/bundler/async-api-schema-resources.js +20 -0
  39. package/dist/plugins/bundler/index.d.ts +1 -1
  40. package/dist/plugins/bundler/index.d.ts.map +1 -1
  41. package/dist/plugins/bundler/index.js +7 -4
  42. package/dist/plugins/bundler/openapi-document.d.ts +5 -1
  43. package/dist/plugins/bundler/openapi-document.d.ts.map +1 -1
  44. package/dist/plugins/bundler/openapi-document.js +7 -3
  45. package/dist/plugins/bundler/upgrade-documents.d.ts +4 -0
  46. package/dist/plugins/bundler/upgrade-documents.d.ts.map +1 -0
  47. package/dist/plugins/bundler/upgrade-documents.js +357 -0
  48. package/dist/request-example/builder/body/build-request-body.d.ts +1 -1
  49. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
  50. package/dist/request-example/builder/body/build-request-body.js +2 -2
  51. package/dist/request-example/builder/body/get-request-body-example.d.ts +2 -2
  52. package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
  53. package/dist/request-example/builder/body/get-request-body-example.js +7 -3
  54. package/dist/request-example/builder/helpers/array-contains.d.ts +15 -0
  55. package/dist/request-example/builder/helpers/array-contains.d.ts.map +1 -0
  56. package/dist/request-example/builder/helpers/array-contains.js +199 -0
  57. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +6 -0
  58. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  59. package/dist/request-example/builder/helpers/get-example-from-schema.js +30 -2
  60. package/dist/request-example/builder/request-factory.d.ts +3 -1
  61. package/dist/request-example/builder/request-factory.d.ts.map +1 -1
  62. package/dist/request-example/builder/request-factory.js +5 -3
  63. package/dist/schemas/reference-config/index.d.ts +39 -8
  64. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  65. package/dist/schemas/reference-config/settings.d.ts +39 -8
  66. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  67. package/dist/schemas/v3.1/strict/openapi-document.d.ts +1365 -280
  68. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  69. package/dist/schemas/v3.1/strict/schema.d.ts +62 -10
  70. package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
  71. package/dist/schemas/v3.1/strict/schema.js +10 -2
  72. package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
  73. package/dist/schemas/v3.2/openapi/index.js +5 -2
  74. package/dist/schemas/v3.2/strict/openapi-document.d.ts +1365 -280
  75. package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
  76. package/dist/schemas/v3.2/strict/schema.d.ts +62 -10
  77. package/dist/schemas/v3.2/strict/schema.d.ts.map +1 -1
  78. package/dist/schemas/v3.2/strict/schema.js +10 -2
  79. package/dist/server.d.ts.map +1 -1
  80. package/dist/server.js +33 -3
  81. package/package.json +12 -11
@@ -0,0 +1,4 @@
1
+ import type { LifecyclePlugin } from '@scalar/json-magic/bundle';
2
+ /** Load native dependencies only at real AsyncAPI schema wrappers, never inside examples or extensions. */
3
+ export declare const asyncApiSchemaResources: () => LifecyclePlugin;
4
+ //# sourceMappingURL=async-api-schema-resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-api-schema-resources.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/async-api-schema-resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAIhE,2GAA2G;AAC3G,eAAO,MAAM,uBAAuB,QAAO,eAe1C,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { createSchemaResourceLoader } from '../../helpers/async-api-schema-resources/resources.js';
2
+ /** Load native dependencies only at real AsyncAPI schema wrappers, never inside examples or extensions. */
3
+ export const asyncApiSchemaResources = () => {
4
+ const load = createSchemaResourceLoader();
5
+ return {
6
+ type: 'lifecycle',
7
+ onBeforeNodeProcess: async (node, context) => {
8
+ if (context.referenceContext !== 'asyncapi-schema' || typeof node.schemaFormat !== 'string' || '$ref' in node)
9
+ return;
10
+ // Serialized workspace/SSR graphs carry their origin through relocation. Authored copies are inert
11
+ // data: readers validate and bound them, no credentials or loader capabilities are restored here.
12
+ // Editable-document cleanup removes these graphs before an authored change is ingested again.
13
+ if (node['x-scalar-schema-resources'] !== undefined)
14
+ return;
15
+ const resources = await load(node.schemaFormat, node.schema, context.origin, context.loaders);
16
+ if (resources)
17
+ node['x-scalar-schema-resources'] = resources;
18
+ },
19
+ };
20
+ };
@@ -90,7 +90,7 @@ export declare const normalizeAuthSchemes: () => LifecyclePlugin;
90
90
  /**
91
91
  * Lifecycle plugin to normalize $ref nodes:
92
92
  * Ensures that for any OpenAPI Reference Object containing a $ref, only $ref,
93
- * summary, description, and $status properties are preserved.
93
+ * summary, description, $status, and $global properties are preserved.
94
94
  * This keeps $ref references clean and predictable for downstream consumers.
95
95
  *
96
96
  * Schema Objects are deliberately skipped: in JSON Schema 2020-12 a $ref may
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAStF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,aAAc;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,eA6CpE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eA6BtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAAO,eAyBhC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAO,eAmFrC,CAAA;AAKD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAO,eAaxC,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAStF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,aAAc;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,eA6CpE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eA6BtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAAO,eAyBhC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAO,eAmFrC,CAAA;AAKD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAO,eAexC,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -221,7 +221,7 @@ export const normalizeAuthSchemes = () => {
221
221
  /**
222
222
  * Lifecycle plugin to normalize $ref nodes:
223
223
  * Ensures that for any OpenAPI Reference Object containing a $ref, only $ref,
224
- * summary, description, and $status properties are preserved.
224
+ * summary, description, $status, and $global properties are preserved.
225
225
  * This keeps $ref references clean and predictable for downstream consumers.
226
226
  *
227
227
  * Schema Objects are deliberately skipped: in JSON Schema 2020-12 a $ref may
@@ -240,8 +240,8 @@ export const normalizeRefs = () => {
240
240
  // and in raw external schema documents. Stripping those siblings would discard the binding and leave
241
241
  // `$dynamicRef` resolving to the template's empty fallback. See https://github.com/scalar/scalar/issues/9414.
242
242
  if (typeof node['$ref'] === 'string' && !isSchema) {
243
- // Remove any other properties from the node and only keep the '$ref', 'summary', 'description' and '$status'
244
- const keepProperties = new Set(['$ref', 'summary', 'description', '$status']);
243
+ // Keep the server chunk marker so reloads retain the owning document's dialect and media types.
244
+ const keepProperties = new Set(['$ref', 'summary', 'description', '$status', '$global']);
245
245
  Object.keys(node).forEach((key) => {
246
246
  if (!keepProperties.has(key)) {
247
247
  delete node[key];
@@ -331,8 +331,11 @@ const NESTED_INTERNAL_KEYS = ['__scalar_', '$status'];
331
331
  export const removeExtraScalarKeys = () => {
332
332
  return {
333
333
  type: 'lifecycle',
334
- onBeforeNodeProcess: (node) => {
334
+ onBeforeNodeProcess: (node, context) => {
335
335
  if (isObject(node)) {
336
+ // Authored edits must reload native dependencies; workspace snapshots retain their prepared graphs.
337
+ if (context.referenceContext === 'asyncapi-schema')
338
+ delete node['x-scalar-schema-resources'];
336
339
  for (const key of NESTED_INTERNAL_KEYS) {
337
340
  if (key in node) {
338
341
  delete node[key];
@@ -2,5 +2,9 @@ import { type DocumentResolver, type LifecyclePlugin } from '@scalar/json-magic/
2
2
  /** Resolves an OpenAPI document's declared identity against its retrieval location. */
3
3
  export declare const resolveOpenApiDocument: DocumentResolver;
4
4
  /** Honors `$self` for complete OpenAPI documents, including external and cached documents. */
5
- export declare const openApiDocument: () => LifecyclePlugin;
5
+ export declare const openApiDocument: (options?: {
6
+ preserveOriginalRefs?: boolean;
7
+ /** The caller already supplies the node location within the complete bundle. */
8
+ useContextPath?: boolean;
9
+ }) => LifecyclePlugin;
6
10
  //# sourceMappingURL=openapi-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openapi-document.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/openapi-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAI7G,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,gBASpC,CAAA;AAED,8FAA8F;AAC9F,eAAO,MAAM,eAAe,QAAO,eAwClC,CAAA"}
1
+ {"version":3,"file":"openapi-document.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/openapi-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAI7G,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,gBASpC,CAAA;AAED,8FAA8F;AAC9F,eAAO,MAAM,eAAe,aAAc;IACxC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,gFAAgF;IAChF,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,KAAG,eA4CH,CAAA"}
@@ -13,7 +13,7 @@ export const resolveOpenApiDocument = (document, retrievalUri) => {
13
13
  return { baseUri, metadata: { openapi: document.openapi, $self: self } };
14
14
  };
15
15
  /** Honors `$self` for complete OpenAPI documents, including external and cached documents. */
16
- export const openApiDocument = () => {
16
+ export const openApiDocument = (options) => {
17
17
  const authoredRefs = new WeakMap();
18
18
  const paths = new WeakMap();
19
19
  const indexPaths = (value, path) => {
@@ -29,10 +29,14 @@ export const openApiDocument = () => {
29
29
  type: 'lifecycle',
30
30
  resolveDocument: resolveOpenApiDocument,
31
31
  onBeforeNodeProcess: (node, context) => {
32
- if (typeof node.$ref === 'string' && resolveOpenApiDocument(context.rootNode, context.origin)) {
32
+ if (typeof node.$ref === 'string' &&
33
+ (options?.preserveOriginalRefs || resolveOpenApiDocument(context.rootNode, context.origin))) {
33
34
  // Partial bundles report paths relative to the selected subtree. Index the supplied root
34
35
  // so the saved references can also be restored when exporting the entire document.
35
- indexPaths(context.rootNode, []);
36
+ if (options?.useContextPath)
37
+ paths.set(node, context.path);
38
+ else
39
+ indexPaths(context.rootNode, []);
36
40
  authoredRefs.set(node, node.$ref);
37
41
  }
38
42
  },
@@ -0,0 +1,4 @@
1
+ import { type LifecyclePlugin } from '@scalar/json-magic/bundle';
2
+ /** Upgrade loaded resources at their source locations, before bundling hides them under x-ext. */
3
+ export declare const upgradeDocuments: (entryVersion?: unknown) => LifecyclePlugin;
4
+ //# sourceMappingURL=upgrade-documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-documents.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/upgrade-documents.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAsGtF,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,kBAAmB,OAAO,KAAG,eAkSzD,CAAA"}
@@ -0,0 +1,357 @@
1
+ import { parseJsonPointerSegments } from '@scalar/helpers/json/parse-json-pointer-segments';
2
+ import { isObject } from '@scalar/helpers/object/is-object';
3
+ import { isSchemaPath } from '@scalar/helpers/openapi/is-schema-path';
4
+ import { resolveReferencePath } from '@scalar/json-magic/bundle';
5
+ import { getHash, uniqueValueGeneratorFactory } from '@scalar/json-magic/bundle/value-generator';
6
+ import { getValueByPath } from '@scalar/json-magic/helpers/get-value-by-path';
7
+ import { upgradeFragment } from '@scalar/openapi-upgrader';
8
+ import { openApiDocument, resolveOpenApiDocument } from './openapi-document.js';
9
+ const metadataKey = 'x-scalar-upgrade';
10
+ const sourceVersion = (value) => {
11
+ if (value === '2.0') {
12
+ return '2.0';
13
+ }
14
+ if (value === '3.0') {
15
+ return '3.0';
16
+ }
17
+ if (typeof value === 'string' && /^3\.0\.\d+$/.test(value)) {
18
+ return '3.0';
19
+ }
20
+ return undefined;
21
+ };
22
+ const metadataCache = new WeakMap();
23
+ const metadata = (document) => {
24
+ if (!isObject(document) || !isObject(document[metadataKey])) {
25
+ return undefined;
26
+ }
27
+ const entry = document[metadataKey];
28
+ if (metadataCache.has(entry)) {
29
+ return metadataCache.get(entry);
30
+ }
31
+ const from = sourceVersion(entry.from);
32
+ const locations = Array.isArray(entry.locations)
33
+ ? entry.locations.filter((location) => isObject(location) &&
34
+ Array.isArray(location.source) &&
35
+ Array.isArray(location.output) &&
36
+ location.source.every((part) => typeof part === 'string') &&
37
+ location.output.every((part) => typeof part === 'string'))
38
+ : undefined;
39
+ const pointers = new Map();
40
+ for (const location of locations ?? []) {
41
+ const key = JSON.stringify(location.source);
42
+ if (!pointers.has(key)) {
43
+ pointers.set(key, location.output);
44
+ }
45
+ }
46
+ const result = from && locations ? { from, locations, pointers } : undefined;
47
+ metadataCache.set(entry, result);
48
+ return result;
49
+ };
50
+ const pointerSegments = (fragment) => {
51
+ let decoded = fragment;
52
+ try {
53
+ decoded = decodeURIComponent(fragment);
54
+ }
55
+ catch {
56
+ /* Retain legacy literal percent characters. */
57
+ }
58
+ // The shared helper decodes URI escapes too; protect literal percent signs from a second decode.
59
+ return decoded.startsWith('/') ? parseJsonPointerSegments(decoded.replaceAll('%', '%25')) : [];
60
+ };
61
+ const atPath = (value, path) => getValueByPath(value, [...path]).value;
62
+ const stringArray = (value) => Array.isArray(value) && value.every((part) => typeof part === 'string');
63
+ const fragmentKind = (path) => {
64
+ if (isSchemaPath([...path])) {
65
+ return 'schema';
66
+ }
67
+ if (path.at(-2) === 'callbacks') {
68
+ return 'callback';
69
+ }
70
+ if (path.at(-3) === 'callbacks') {
71
+ return 'path-item';
72
+ }
73
+ if (path.at(-2) === 'parameters') {
74
+ return 'parameter';
75
+ }
76
+ if (path.at(-2) === 'headers') {
77
+ return 'header';
78
+ }
79
+ if (path.at(-2) === 'responses') {
80
+ return 'response';
81
+ }
82
+ if (path.at(-1) === 'requestBody' || path.at(-2) === 'requestBodies') {
83
+ return 'request-body';
84
+ }
85
+ if (path.at(-2) === 'paths' || path.at(-2) === 'pathItems' || path.at(-2) === 'webhooks') {
86
+ return 'path-item';
87
+ }
88
+ return undefined;
89
+ };
90
+ /** Upgrade loaded resources at their source locations, before bundling hides them under x-ext. */
91
+ export const upgradeDocuments = (entryVersion) => {
92
+ const sources = new Map();
93
+ let entryUri;
94
+ const resolvers = new Map();
95
+ const converted = new WeakSet();
96
+ const transformedReferences = new WeakSet();
97
+ const originalReferences = openApiDocument({ preserveOriginalRefs: true, useContextPath: true });
98
+ const markConverted = (value) => {
99
+ if (value === null || typeof value !== 'object' || converted.has(value)) {
100
+ return;
101
+ }
102
+ converted.add(value);
103
+ Object.values(value).forEach(markConverted);
104
+ };
105
+ return {
106
+ type: 'lifecycle',
107
+ onAfterNodeProcess: (node, context) => {
108
+ if (transformedReferences.has(node)) {
109
+ return originalReferences.onAfterNodeProcess?.(node, context);
110
+ }
111
+ },
112
+ onDocumentLoaded: async (document, { uri, loadDocument, stored }) => {
113
+ entryUri ??= uri;
114
+ const from = !stored && isObject(document) ? sourceVersion(document.swagger ?? document.openapi) : undefined;
115
+ const version = from ??
116
+ metadata(document)?.from ??
117
+ (isObject(document)
118
+ ? (sourceVersion(document['x-original-oas-version']) ??
119
+ (typeof document.openapi === 'string' || typeof document.swagger === 'string' ? 'modern' : undefined))
120
+ : undefined);
121
+ // Retain source context only when a complete legacy resource will be replaced.
122
+ // Lazy resolves of an already upgraded root must not copy the whole API description.
123
+ sources.set(uri, { document: from && !metadata(document) ? structuredClone(document) : document, version });
124
+ const resolveSource = async (ref, origin = uri, visited = new Set()) => {
125
+ const [prefix, fragment = ''] = ref.split('#', 2);
126
+ const resource = prefix ? resolveReferencePath(origin, prefix) : origin;
127
+ const absolute = `${resource}#${fragment}`;
128
+ if (visited.has(absolute)) {
129
+ throw new Error(`Cyclic parameter reference: ${absolute}`);
130
+ }
131
+ visited.add(absolute);
132
+ const loaded = resource === uri ? { ok: true, data: document } : await loadDocument(resource);
133
+ if (!loaded.ok) {
134
+ throw new Error(`Cannot upgrade referenced parameter: ${absolute}`);
135
+ }
136
+ const target = atPath(loaded.data, pointerSegments(fragment));
137
+ if (isObject(target) && typeof target.$ref === 'string') {
138
+ return resolveSource(target.$ref, resource, visited);
139
+ }
140
+ // The operation may inline a referenced body/form parameter. Rebase its schema refs
141
+ // before moving it out of its resource; example/default payloads remain literal data.
142
+ const rebased = new WeakMap();
143
+ const rebase = (value, kind = 'object') => {
144
+ if (value === null || typeof value !== 'object') {
145
+ return value;
146
+ }
147
+ if (rebased.has(value)) {
148
+ return rebased.get(value);
149
+ }
150
+ if (Array.isArray(value)) {
151
+ const result = [];
152
+ rebased.set(value, result);
153
+ result.push(...value.map((entry) => rebase(entry, kind)));
154
+ return result;
155
+ }
156
+ const result = Object.create(null);
157
+ rebased.set(value, result);
158
+ for (const [key, child] of Object.entries(value)) {
159
+ const [name, entry] = (() => {
160
+ if (key === '$ref' && typeof child === 'string') {
161
+ const [relative, pointer] = child.split('#', 2);
162
+ const targetResource = relative ? resolveReferencePath(resource, relative) : resource;
163
+ const base = targetResource === uri ? '' : targetResource;
164
+ return [key, `${base}${pointer === undefined ? '' : `#${pointer}`}`];
165
+ }
166
+ if (['example', 'examples', 'default', 'enum', 'const'].includes(key) && kind !== 'map') {
167
+ return [key, structuredClone(child)];
168
+ }
169
+ if (key.startsWith('x-') && kind !== 'map') {
170
+ return [key, structuredClone(child)];
171
+ }
172
+ return [
173
+ key,
174
+ rebase(child, key === 'properties' || key === 'definitions'
175
+ ? 'map'
176
+ : key === 'schema' || kind === 'map'
177
+ ? 'schema'
178
+ : kind),
179
+ ];
180
+ })();
181
+ result[name] = entry;
182
+ }
183
+ return result;
184
+ };
185
+ return rebase(target);
186
+ };
187
+ resolvers.set(uri, resolveSource);
188
+ if (!from || metadata(document)) {
189
+ return document;
190
+ }
191
+ const result = await upgradeFragment(document, { from, to: '3.1', kind: 'document', resolveSource });
192
+ if (!isObject(result.value)) {
193
+ return result.value;
194
+ }
195
+ // Keep only prefix substitutions that cannot be inherited from a relocated parent.
196
+ const prefixes = new Map();
197
+ const locations = result.locations.filter(({ source, output }) => {
198
+ const key = JSON.stringify(source);
199
+ if (prefixes.has(key)) {
200
+ return false;
201
+ }
202
+ prefixes.set(key, output);
203
+ for (let length = source.length - 1; length >= 0; length--) {
204
+ const parent = prefixes.get(JSON.stringify(source.slice(0, length)));
205
+ if (parent) {
206
+ return JSON.stringify([...parent, ...source.slice(length)]) !== JSON.stringify(output);
207
+ }
208
+ }
209
+ return JSON.stringify(source) !== JSON.stringify(output);
210
+ });
211
+ const keepMetadata = uri !== entryUri || locations.length > 0 || result.contexts.length > 0;
212
+ const upgraded = {
213
+ ...result.value,
214
+ ...(keepMetadata ? { [metadataKey]: { from, locations, contexts: result.contexts } } : {}),
215
+ ...(uri === entryUri && isObject(document) && !document['x-original-oas-version']
216
+ ? { 'x-original-oas-version': document.swagger ?? document.openapi }
217
+ : {}),
218
+ };
219
+ markConverted(upgraded);
220
+ return upgraded;
221
+ },
222
+ resolveDocument: (document, uri) => {
223
+ const upgrade = metadata(document);
224
+ if (!upgrade) {
225
+ return isObject(document) && !document.openapi && !document.swagger && !document.asyncapi
226
+ ? { baseUri: uri, visitReferencedSubtrees: true }
227
+ : undefined;
228
+ }
229
+ const identity = resolveOpenApiDocument(document, uri);
230
+ return {
231
+ ...identity,
232
+ baseUri: identity?.baseUri ?? uri,
233
+ remapPointer: (pointer) => {
234
+ for (let length = pointer.length; length >= 0; length--) {
235
+ const output = upgrade.pointers.get(JSON.stringify(pointer.slice(0, length)));
236
+ if (output) {
237
+ return [...output, ...pointer.slice(length)];
238
+ }
239
+ }
240
+ return pointer;
241
+ },
242
+ };
243
+ },
244
+ onBeforeTargetProcess: async (target, context) => {
245
+ if (!isObject(target) || context.path[0] === metadataKey) {
246
+ return undefined;
247
+ }
248
+ const source = sources.get(context.uri);
249
+ const document = context.document;
250
+ // Complete versioned resources were converted at load time. Saved resources carry
251
+ // the same information so lazy resolution after serialization cannot upgrade twice.
252
+ const referenceNode = atPath(context.referenceSource.document, context.referenceSource.path);
253
+ if (isObject(document) && (document.openapi || document.swagger || metadata(document))) {
254
+ if (metadata(document) && document !== context.referencedFrom.rootNode && isObject(referenceNode)) {
255
+ originalReferences.onBeforeNodeProcess?.(referenceNode, {
256
+ ...context.referencedFrom,
257
+ path: context.referenceSource.document === context.referencedFrom.rootNode
258
+ ? [...context.referenceSource.path]
259
+ : context.referencedFrom.path,
260
+ });
261
+ transformedReferences.add(referenceNode);
262
+ }
263
+ return undefined;
264
+ }
265
+ if (converted.has(target)) {
266
+ return undefined;
267
+ }
268
+ const referring = sources.get(context.referenceSource.uri);
269
+ const storedPath = context.referenceSource.path;
270
+ const variant = storedPath[0] === metadataKey && storedPath[1] === 'variants'
271
+ ? atPath(context.referenceSource.document, storedPath.slice(0, 3))
272
+ : undefined;
273
+ const inherited = isObject(variant) ? sourceVersion(variant.from) : undefined;
274
+ const from = inherited ?? referring?.version ?? sourceVersion(entryVersion);
275
+ if (!from || from === 'modern' || typeof target.$schema === 'string') {
276
+ return undefined;
277
+ }
278
+ const path = isObject(variant) && stringArray(variant.semanticPath)
279
+ ? [...variant.semanticPath, ...storedPath.slice(4)]
280
+ : storedPath;
281
+ const kind = fragmentKind(path);
282
+ if (!kind || !isObject(document)) {
283
+ return undefined;
284
+ }
285
+ if (isObject(referenceNode)) {
286
+ originalReferences.onBeforeNodeProcess?.(referenceNode, {
287
+ ...context.referencedFrom,
288
+ path: context.referenceSource.document === context.referencedFrom.rootNode
289
+ ? [...context.referenceSource.path]
290
+ : context.referencedFrom.path,
291
+ });
292
+ transformedReferences.add(referenceNode);
293
+ }
294
+ // Saved API descriptions restore external refs and discard bundled resources. Keep
295
+ // the original entry dialect so bare targets are interpreted the same way on reload.
296
+ const entryDialect = entryUri === undefined ? undefined : sources.get(entryUri)?.version;
297
+ if (entryDialect && entryDialect !== 'modern' && !metadata(context.referencedFrom.rootNode)) {
298
+ context.referencedFrom.rootNode[metadataKey] = { from: entryDialect, locations: [] };
299
+ }
300
+ const originalValue = atPath(source?.document ?? document, context.path) ?? target;
301
+ const original = context.path.length === 0 && isObject(originalValue)
302
+ ? Object.fromEntries(Object.entries(originalValue).filter(([key]) => key !== metadataKey))
303
+ : originalValue;
304
+ const owner = referring?.document;
305
+ const operation = path[0] === 'paths' ? atPath(owner, path.slice(0, 3)) : undefined;
306
+ const savedContexts = atPath(owner, [metadataKey, 'contexts']);
307
+ const saved = Array.isArray(savedContexts)
308
+ ? savedContexts
309
+ .filter((item) => isObject(item) &&
310
+ stringArray(item.consumes) &&
311
+ stringArray(item.produces) &&
312
+ stringArray(item.path) &&
313
+ item.path.every((segment, index) => segment === path[index]))
314
+ .sort((a, b) => b.path.length - a.path.length)[0]
315
+ : undefined;
316
+ const consumes = isObject(variant) && stringArray(variant.consumes)
317
+ ? variant.consumes
318
+ : isObject(operation) && stringArray(operation.consumes)
319
+ ? operation.consumes
320
+ : isObject(owner) && stringArray(owner.consumes)
321
+ ? owner.consumes
322
+ : saved?.consumes;
323
+ const produces = isObject(variant) && stringArray(variant.produces)
324
+ ? variant.produces
325
+ : isObject(operation) && stringArray(operation.produces)
326
+ ? operation.produces
327
+ : isObject(owner) && stringArray(owner.produces)
328
+ ? owner.produces
329
+ : saved?.produces;
330
+ const storage = Object.assign(Object.create(null), isObject(document[metadataKey]) ? document[metadataKey] : {});
331
+ const mappings = Object.assign(Object.create(null), Object.fromEntries(Object.entries(isObject(storage.mappings) ? storage.mappings : {}).filter(([key, value]) => !['__proto__', 'prototype', 'constructor'].includes(key) && typeof value === 'string')));
332
+ const { generate } = uniqueValueGeneratorFactory(getHash, mappings);
333
+ const key = await generate(JSON.stringify([context.path, from, kind, consumes, produces]));
334
+ storage.mappings = mappings;
335
+ document[metadataKey] = storage;
336
+ const variantPath = [metadataKey, 'variants', key, 'value'];
337
+ const cached = atPath(document, variantPath);
338
+ if (cached !== undefined) {
339
+ return { value: cached, path: variantPath };
340
+ }
341
+ const result = await upgradeFragment(original, {
342
+ from,
343
+ to: '3.1',
344
+ kind,
345
+ consumes,
346
+ produces,
347
+ resolveSource: resolvers.get(context.uri),
348
+ });
349
+ markConverted(result.value);
350
+ const variants = Object.assign(Object.create(null), isObject(storage.variants) ? storage.variants : {});
351
+ variants[key] = { from, semanticPath: path, consumes, produces, value: result.value };
352
+ storage.variants = variants;
353
+ document[metadataKey] = storage;
354
+ return { value: result.value, path: variantPath };
355
+ },
356
+ };
357
+ };
@@ -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>, openapiVersion?: string) => RequestBody | null;
46
+ requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string, jsonSchemaDialect?: 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":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAMjG,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,gBACd,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;;AAErC,sEAAsE;kCACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,KACtB,WAAW,GAAG,IAiXhB,CAAA"}
1
+ {"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAMjG,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,gBACd,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;;AAErC,sEAAsE;kCACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,sBACH,MAAM,KACzB,WAAW,GAAG,IAkXhB,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, openapiVersion) => {
70
+ requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
71
71
  if (!requestBody) {
72
72
  return null;
73
73
  }
@@ -77,7 +77,7 @@ requestBodyCompositionSelection, openapiVersion) => {
77
77
  return null;
78
78
  }
79
79
  /** An example value */
80
- const example = getExampleFromBody(requestBody, bodyContentType, exampleName, requestBodyCompositionSelection, openapiVersion);
80
+ const example = getExampleFromBody(requestBody, bodyContentType, exampleName, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect);
81
81
  if (!example) {
82
82
  return null;
83
83
  }
@@ -10,9 +10,9 @@ import type { ExampleObject, RequestBodyObject } from '@scalar/workspace-store/s
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>, openapiVersion?: string) => unknown;
13
+ export declare const getSchemaExampleFromBody: (requestBody: RequestBodyObject, contentType: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string, jsonSchemaDialect?: 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>, openapiVersion?: string) => ExampleObject | null;
17
+ export declare const getExampleFromBody: (requestBody: RequestBodyObject, contentType: string, exampleName: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string, jsonSchemaDialect?: 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":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AAUrE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,gBACtB,iBAAiB,eACjB,MAAM,oCACe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,KACtB,OA8BF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,gBAChB,iBAAiB,eACjB,MAAM,eACN,MAAM,oCACe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,KACtB,aAAa,GAAG,IA4ClB,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;AAUrE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,gBACtB,iBAAiB,eACjB,MAAM,oCACe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,sBACH,MAAM,KACzB,OAiCF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,gBAChB,iBAAiB,eACjB,MAAM,eACN,MAAM,oCACe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,sBACH,MAAM,KACzB,aAAa,GAAG,IA8ClB,CAAA"}
@@ -18,7 +18,7 @@ import { getXmlBodyExample } from '../../xml/get-xml-body-example.js';
18
18
  *
19
19
  * Returns `undefined` when there is no schema for the content type.
20
20
  */
21
- export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCompositionSelection, openapiVersion) => {
21
+ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
22
22
  const mediaType = requestBody.content?.[contentType];
23
23
  const schema = mediaType?.schema ??
24
24
  (mediaType?.itemSchema && parseMimeType(contentType).type === 'multipart'
@@ -27,6 +27,7 @@ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCo
27
27
  if (isXmlMediaType(contentType)) {
28
28
  return getXmlBodyExample(mediaType?.schema, undefined, {
29
29
  openapiVersion,
30
+ jsonSchemaDialect,
30
31
  mode: 'write',
31
32
  compositionSelection: requestBodyCompositionSelection,
32
33
  schemaPath: ['requestBody'],
@@ -37,6 +38,8 @@ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCo
37
38
  }
38
39
  const value = getExampleFromSchema(snapshotSchema(schema), {
39
40
  mode: 'write',
41
+ openapiVersion,
42
+ jsonSchemaDialect,
40
43
  compositionSelection: requestBodyCompositionSelection,
41
44
  }, {
42
45
  schemaPath: ['requestBody'],
@@ -46,7 +49,7 @@ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCo
46
49
  /**
47
50
  * Basically getExample + we generate an example from the schema if no example is found
48
51
  */
49
- export const getExampleFromBody = (requestBody, contentType, exampleName, requestBodyCompositionSelection, openapiVersion) => {
52
+ export const getExampleFromBody = (requestBody, contentType, exampleName, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
50
53
  // Return the existing example when it carries a usable value. An example that only has an
51
54
  // `externalValue` (not yet resolved to a `value`) is treated as missing, so we fall back to a
52
55
  // schema-generated example instead of building an empty request body.
@@ -54,6 +57,7 @@ export const getExampleFromBody = (requestBody, contentType, exampleName, reques
54
57
  if (isXmlMediaType(contentType)) {
55
58
  const result = getXmlBodyExample(requestBody.content?.[contentType]?.schema, example, {
56
59
  openapiVersion,
60
+ jsonSchemaDialect,
57
61
  mode: 'write',
58
62
  compositionSelection: requestBodyCompositionSelection,
59
63
  schemaPath: ['requestBody'],
@@ -77,7 +81,7 @@ export const getExampleFromBody = (requestBody, contentType, exampleName, reques
77
81
  return selected.source === 'value' ? example : { ...example, value: selected.value };
78
82
  }
79
83
  // Generate an example from the schema
80
- const schemaExample = getSchemaExampleFromBody(requestBody, contentType, requestBodyCompositionSelection, openapiVersion);
84
+ const schemaExample = getSchemaExampleFromBody(requestBody, contentType, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect);
81
85
  if (schemaExample === undefined || schemaExample === null) {
82
86
  return null;
83
87
  }
@@ -0,0 +1,15 @@
1
+ /** Dialects whose direct array assertions this generator understands. */
2
+ type ArrayDialect = 'modern' | 'draft7' | 'unsupported';
3
+ type Primitive = string | number | boolean | null;
4
+ /** Unknown dialects and pre-3.1 OpenAPI must not acquire modern contains semantics. */
5
+ export declare const getArrayDialect: (dialect?: string, openapiVersion?: string) => ArrayDialect;
6
+ /**
7
+ * Fill direct primitive arrays with a single contains rule. Tuple values count toward the same
8
+ * limits as tail values. Candidates are bounded and selected linearly; no composition traversal,
9
+ * nested value synthesis, or XML branch selection is attempted. Unsupported schemas return undefined
10
+ * for the existing generator. Contradictions or exhausted candidates return a partial example.
11
+ * TODO: Handle independent contains rules across references and compositions in a follow-up.
12
+ */
13
+ export declare const generateContainsArray: (schema: Record<string, unknown>, prefixes: unknown[], generate: (schema: unknown) => unknown, dialect: ArrayDialect) => Primitive[] | undefined;
14
+ export {};
15
+ //# sourceMappingURL=array-contains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-contains.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/array-contains.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,KAAK,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAAa,CAAA;AACvD,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAEjD,uFAAuF;AACvF,eAAO,MAAM,eAAe,aAAc,MAAM,mBAAmB,MAAM,KAAG,YAY3E,CAAA;AAoGD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,WACxB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACrB,OAAO,EAAE,YACT,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,WAC7B,YAAY,KACpB,SAAS,EAAE,GAAG,SA8FhB,CAAA"}