@scalar/workspace-store 0.73.0 → 0.75.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 (122) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +10 -0
  3. package/dist/client.d.ts +3 -0
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +77 -10
  6. package/dist/entities/auth/schema.d.ts +405 -40
  7. package/dist/entities/auth/schema.d.ts.map +1 -1
  8. package/dist/helpers/async-api-schema-resources/load-inline.d.ts +7 -0
  9. package/dist/helpers/async-api-schema-resources/load-inline.d.ts.map +1 -0
  10. package/dist/helpers/async-api-schema-resources/load-inline.js +31 -0
  11. package/dist/helpers/async-api-schema-resources/protobuf-imports.d.ts +8 -0
  12. package/dist/helpers/async-api-schema-resources/protobuf-imports.d.ts.map +1 -0
  13. package/dist/helpers/async-api-schema-resources/protobuf-imports.js +25 -0
  14. package/dist/helpers/async-api-schema-resources/raml-source.d.ts +12 -0
  15. package/dist/helpers/async-api-schema-resources/raml-source.d.ts.map +1 -0
  16. package/dist/helpers/async-api-schema-resources/raml-source.js +32 -0
  17. package/dist/helpers/async-api-schema-resources/resolver.d.ts +12 -0
  18. package/dist/helpers/async-api-schema-resources/resolver.d.ts.map +1 -0
  19. package/dist/helpers/async-api-schema-resources/resolver.js +31 -0
  20. package/dist/helpers/async-api-schema-resources/resources.d.ts +13 -0
  21. package/dist/helpers/async-api-schema-resources/resources.d.ts.map +1 -0
  22. package/dist/helpers/async-api-schema-resources/resources.js +133 -0
  23. package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts +3 -0
  24. package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts.map +1 -0
  25. package/dist/helpers/async-api-schema-resources/schema-resource-path.js +9 -0
  26. package/dist/helpers/async-api-schema-resources/schema-wrappers.d.ts +9 -0
  27. package/dist/helpers/async-api-schema-resources/schema-wrappers.d.ts.map +1 -0
  28. package/dist/helpers/async-api-schema-resources/schema-wrappers.js +69 -0
  29. package/dist/helpers/async-api-schema-resources/track-edits.d.ts +3 -0
  30. package/dist/helpers/async-api-schema-resources/track-edits.d.ts.map +1 -0
  31. package/dist/helpers/async-api-schema-resources/track-edits.js +46 -0
  32. package/dist/helpers/compact-upgrade-metadata.d.ts +3 -0
  33. package/dist/helpers/compact-upgrade-metadata.d.ts.map +1 -0
  34. package/dist/helpers/compact-upgrade-metadata.js +71 -0
  35. package/dist/helpers/is-file-schema.js +1 -1
  36. package/dist/helpers/querystring-parameter.d.ts +3 -1
  37. package/dist/helpers/querystring-parameter.d.ts.map +1 -1
  38. package/dist/helpers/querystring-parameter.js +2 -2
  39. package/dist/helpers/resolve-async-api-schema.d.ts +2 -0
  40. package/dist/helpers/resolve-async-api-schema.d.ts.map +1 -1
  41. package/dist/helpers/resolve-async-api-schema.js +25 -1
  42. package/dist/helpers/use-async-api-schema-resources.d.ts +12 -0
  43. package/dist/helpers/use-async-api-schema-resources.d.ts.map +1 -0
  44. package/dist/helpers/use-async-api-schema-resources.js +24 -0
  45. package/dist/mutators/operation/parameters.d.ts.map +1 -1
  46. package/dist/mutators/operation/parameters.js +9 -1
  47. package/dist/mutators/operation/reset-request-body.d.ts.map +1 -1
  48. package/dist/mutators/operation/reset-request-body.js +3 -1
  49. package/dist/navigation/helpers/get-x-badges.d.ts +10 -0
  50. package/dist/navigation/helpers/get-x-badges.d.ts.map +1 -0
  51. package/dist/navigation/helpers/get-x-badges.js +26 -0
  52. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  53. package/dist/navigation/helpers/traverse-paths.js +3 -0
  54. package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
  55. package/dist/navigation/helpers/traverse-schemas.js +3 -0
  56. package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
  57. package/dist/navigation/helpers/traverse-tags.js +3 -0
  58. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  59. package/dist/navigation/helpers/traverse-webhooks.js +3 -0
  60. package/dist/plugins/bundler/async-api-schema-resources.d.ts +4 -0
  61. package/dist/plugins/bundler/async-api-schema-resources.d.ts.map +1 -0
  62. package/dist/plugins/bundler/async-api-schema-resources.js +20 -0
  63. package/dist/plugins/bundler/index.d.ts +1 -1
  64. package/dist/plugins/bundler/index.d.ts.map +1 -1
  65. package/dist/plugins/bundler/index.js +7 -4
  66. package/dist/plugins/bundler/openapi-document.d.ts +5 -1
  67. package/dist/plugins/bundler/openapi-document.d.ts.map +1 -1
  68. package/dist/plugins/bundler/openapi-document.js +7 -3
  69. package/dist/plugins/bundler/upgrade-documents.d.ts +4 -0
  70. package/dist/plugins/bundler/upgrade-documents.d.ts.map +1 -0
  71. package/dist/plugins/bundler/upgrade-documents.js +357 -0
  72. package/dist/request-example/builder/body/build-request-body.d.ts +1 -1
  73. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
  74. package/dist/request-example/builder/body/build-request-body.js +2 -2
  75. package/dist/request-example/builder/body/get-request-body-example.d.ts +2 -2
  76. package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
  77. package/dist/request-example/builder/body/get-request-body-example.js +7 -3
  78. package/dist/request-example/builder/build-request.d.ts.map +1 -1
  79. package/dist/request-example/builder/build-request.js +3 -2
  80. package/dist/request-example/builder/helpers/array-contains.d.ts +15 -0
  81. package/dist/request-example/builder/helpers/array-contains.d.ts.map +1 -0
  82. package/dist/request-example/builder/helpers/array-contains.js +199 -0
  83. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +9 -0
  84. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  85. package/dist/request-example/builder/helpers/get-example-from-schema.js +162 -31
  86. package/dist/request-example/builder/request-factory.d.ts +5 -1
  87. package/dist/request-example/builder/request-factory.d.ts.map +1 -1
  88. package/dist/request-example/builder/request-factory.js +5 -3
  89. package/dist/request-example/builder/security/build-request-security.d.ts +6 -4
  90. package/dist/request-example/builder/security/build-request-security.d.ts.map +1 -1
  91. package/dist/request-example/builder/security/build-request-security.js +1 -0
  92. package/dist/schemas/extensions/security/x-scalar-token-prefix.d.ts +11 -0
  93. package/dist/schemas/extensions/security/x-scalar-token-prefix.d.ts.map +1 -0
  94. package/dist/schemas/extensions/security/x-scalar-token-prefix.js +8 -0
  95. package/dist/schemas/navigation.d.ts +49 -0
  96. package/dist/schemas/navigation.d.ts.map +1 -1
  97. package/dist/schemas/navigation.js +5 -0
  98. package/dist/schemas/reference-config/index.d.ts +81 -8
  99. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  100. package/dist/schemas/reference-config/settings.d.ts +81 -8
  101. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  102. package/dist/schemas/v3.1/strict/openapi-document.d.ts +2835 -280
  103. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  104. package/dist/schemas/v3.1/strict/schema.d.ts +62 -10
  105. package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
  106. package/dist/schemas/v3.1/strict/schema.js +10 -2
  107. package/dist/schemas/v3.1/strict/security-scheme.d.ts +4 -1
  108. package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
  109. package/dist/schemas/v3.1/strict/security-scheme.js +2 -1
  110. package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
  111. package/dist/schemas/v3.2/openapi/index.js +7 -2
  112. package/dist/schemas/v3.2/strict/openapi-document.d.ts +2835 -280
  113. package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
  114. package/dist/schemas/v3.2/strict/schema.d.ts +62 -10
  115. package/dist/schemas/v3.2/strict/schema.d.ts.map +1 -1
  116. package/dist/schemas/v3.2/strict/schema.js +10 -2
  117. package/dist/schemas/v3.2/strict/security-scheme.d.ts +4 -1
  118. package/dist/schemas/v3.2/strict/security-scheme.d.ts.map +1 -1
  119. package/dist/schemas/v3.2/strict/security-scheme.js +2 -1
  120. package/dist/server.d.ts.map +1 -1
  121. package/dist/server.js +33 -3
  122. package/package.json +16 -15
@@ -0,0 +1,199 @@
1
+ import { isObject } from '@scalar/helpers/object/is-object';
2
+ /** Unknown dialects and pre-3.1 OpenAPI must not acquire modern contains semantics. */
3
+ export const getArrayDialect = (dialect, openapiVersion) => {
4
+ if (openapiVersion && !/^3\.[1-9](?:\.|$)/.test(openapiVersion)) {
5
+ return 'unsupported';
6
+ }
7
+ if (!dialect || /^https:\/\/spec\.openapis\.org\/oas\/3\.[12]\/dialect\/base#?$/.test(dialect)) {
8
+ return 'modern';
9
+ }
10
+ const uri = dialect.replace(/#$/, '');
11
+ if (uri === 'https://json-schema.org/draft/2020-12/schema') {
12
+ return 'modern';
13
+ }
14
+ return uri === 'http://json-schema.org/draft-07/schema' ? 'draft7' : 'unsupported';
15
+ };
16
+ const MAX_ITEMS = 999;
17
+ const MAX_CANDIDATES = 128;
18
+ const isPrimitive = (value) => value === null ||
19
+ typeof value === 'string' ||
20
+ typeof value === 'boolean' ||
21
+ (typeof value === 'number' && Number.isFinite(value));
22
+ const keywords = new Set([
23
+ '__scalar_',
24
+ '$status',
25
+ '$global',
26
+ 'type',
27
+ 'const',
28
+ 'enum',
29
+ 'minimum',
30
+ 'maximum',
31
+ 'exclusiveMinimum',
32
+ 'exclusiveMaximum',
33
+ 'minLength',
34
+ 'maxLength',
35
+ 'title',
36
+ 'description',
37
+ 'default',
38
+ 'example',
39
+ 'examples',
40
+ 'deprecated',
41
+ 'readOnly',
42
+ 'writeOnly',
43
+ 'xml',
44
+ 'externalDocs',
45
+ ]);
46
+ /** Complex assertions are left to the existing best-effort generator, never treated as nonmatches. */
47
+ const isSimple = (schema) => {
48
+ if (typeof schema === 'boolean') {
49
+ return true;
50
+ }
51
+ if (!isObject(schema) || Object.keys(schema).some((key) => !keywords.has(key) && !key.startsWith('x-'))) {
52
+ return false;
53
+ }
54
+ if (schema.type !== undefined &&
55
+ (typeof schema.type !== 'string' || !['string', 'number', 'integer', 'boolean', 'null'].includes(schema.type))) {
56
+ return false;
57
+ }
58
+ if ('const' in schema && !isPrimitive(schema.const)) {
59
+ return false;
60
+ }
61
+ return (!('enum' in schema) ||
62
+ (Array.isArray(schema.enum) && schema.enum.length <= MAX_CANDIDATES && schema.enum.every(isPrimitive)));
63
+ };
64
+ const bound = (value, fallback) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : fallback;
65
+ const matches = (schema, value) => {
66
+ if (typeof schema === 'boolean') {
67
+ return schema;
68
+ }
69
+ if ('const' in schema && value !== schema.const) {
70
+ return false;
71
+ }
72
+ if (Array.isArray(schema.enum) && !schema.enum.includes(value)) {
73
+ return false;
74
+ }
75
+ if (schema.type !== undefined) {
76
+ const type = value === null ? 'null' : typeof value;
77
+ if (schema.type === 'integer' ? typeof value !== 'number' || !Number.isInteger(value) : schema.type !== type) {
78
+ return false;
79
+ }
80
+ }
81
+ if (typeof value === 'number') {
82
+ if (typeof schema.minimum === 'number' && value < schema.minimum) {
83
+ return false;
84
+ }
85
+ if (typeof schema.maximum === 'number' && value > schema.maximum) {
86
+ return false;
87
+ }
88
+ if (typeof schema.exclusiveMinimum === 'number' && value <= schema.exclusiveMinimum) {
89
+ return false;
90
+ }
91
+ if (typeof schema.exclusiveMaximum === 'number' && value >= schema.exclusiveMaximum) {
92
+ return false;
93
+ }
94
+ }
95
+ if (typeof value === 'string') {
96
+ const length = Array.from(value).length;
97
+ if (length < bound(schema.minLength, 0) || length > bound(schema.maxLength, Number.POSITIVE_INFINITY)) {
98
+ return false;
99
+ }
100
+ }
101
+ return true;
102
+ };
103
+ /**
104
+ * Fill direct primitive arrays with a single contains rule. Tuple values count toward the same
105
+ * limits as tail values. Candidates are bounded and selected linearly; no composition traversal,
106
+ * nested value synthesis, or XML branch selection is attempted. Unsupported schemas return undefined
107
+ * for the existing generator. Contradictions or exhausted candidates return a partial example.
108
+ * TODO: Handle independent contains rules across references and compositions in a follow-up.
109
+ */
110
+ export const generateContainsArray = (schema, prefixes, generate, dialect) => {
111
+ if (dialect === 'unsupported' || !('contains' in schema) || !isSimple(schema.contains)) {
112
+ return undefined;
113
+ }
114
+ if (schema.allOf || schema.anyOf || schema.oneOf || schema.$ref) {
115
+ return undefined;
116
+ }
117
+ const contains = schema.contains;
118
+ const items = schema.items ?? true;
119
+ const tuple = dialect === 'modern' && Array.isArray(schema.prefixItems) ? schema.prefixItems : [];
120
+ if (!isSimple(items) || !tuple.every(isSimple) || (dialect === 'draft7' && schema.prefixItems)) {
121
+ return undefined;
122
+ }
123
+ const minimum = dialect === 'modern' ? bound(schema.minContains, 1) : 1;
124
+ const maximum = dialect === 'modern' ? bound(schema.maxContains, Number.POSITIVE_INFINITY) : Number.POSITIVE_INFINITY;
125
+ const maxItems = Math.min(bound(schema.maxItems, MAX_ITEMS), MAX_ITEMS);
126
+ const length = Math.min(maxItems, Math.max(bound(schema.minItems, 0), minimum, prefixes.length));
127
+ const values = [];
128
+ const candidates = [];
129
+ const add = (value) => {
130
+ if (isPrimitive(value) && candidates.length < MAX_CANDIDATES && !candidates.includes(value)) {
131
+ candidates.push(value);
132
+ }
133
+ };
134
+ // Authored item examples remain fixed even when they cannot satisfy the array constraints.
135
+ const unrestricted = items === true ||
136
+ (isObject(items) && !['type', 'const', 'enum', 'example', 'examples', 'default'].some((key) => key in items));
137
+ const sampleSchema = unrestricted ? contains : items;
138
+ const generatedSample = typeof sampleSchema === 'boolean' ? null : generate(sampleSchema);
139
+ const sample = unrestricted ? (generatedSample ?? null) : generatedSample;
140
+ const authored = isObject(items) && (items.example !== undefined || (Array.isArray(items.examples) && items.examples.length > 0));
141
+ add(sample);
142
+ if (!authored) {
143
+ for (const source of [contains, items]) {
144
+ if (!isObject(source)) {
145
+ continue;
146
+ }
147
+ if ('const' in source) {
148
+ add(source.const);
149
+ }
150
+ if (Array.isArray(source.enum)) {
151
+ source.enum.forEach(add);
152
+ }
153
+ add(generate(source));
154
+ for (const key of ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum']) {
155
+ const limit = source[key];
156
+ if (typeof limit === 'number') {
157
+ for (const offset of [0, 1, -1]) {
158
+ add(limit + offset);
159
+ }
160
+ }
161
+ }
162
+ }
163
+ for (const value of [null, 1, 2, 3, 0, -1, true, false, '', 'string', 'a']) {
164
+ add(value);
165
+ }
166
+ for (let index = 4; index < 32; index++) {
167
+ add(index);
168
+ add(`string${index}`);
169
+ }
170
+ }
171
+ const available = authored ? candidates : candidates.filter((value) => matches(items, value));
172
+ let count = 0;
173
+ const append = (value) => {
174
+ const match = matches(contains, value);
175
+ if ((!authored && match && count >= maximum) || (schema.uniqueItems === true && values.includes(value))) {
176
+ return false;
177
+ }
178
+ values.push(value);
179
+ count += Number(match);
180
+ return true;
181
+ };
182
+ for (const [index, value] of prefixes.slice(0, maxItems).entries()) {
183
+ if (!isPrimitive(value) || !matches(tuple[index] ?? true, value) || !append(value)) {
184
+ return values;
185
+ }
186
+ }
187
+ if (items === false || (sample === undefined && typeof items !== 'boolean')) {
188
+ return values;
189
+ }
190
+ while (values.length < maxItems && (values.length < length || (!authored && count < minimum))) {
191
+ const candidate = available.find((value) => (authored || count >= minimum || matches(contains, value)) &&
192
+ (authored || !matches(contains, value) || count < maximum) &&
193
+ (schema.uniqueItems !== true || !values.includes(value)));
194
+ if (candidate === undefined || !append(candidate)) {
195
+ break;
196
+ }
197
+ }
198
+ return values;
199
+ };
@@ -5,6 +5,12 @@ import { EXAMPLE_EVALUATION, type ExampleEvaluationState } from './example-evalu
5
5
  export declare const selectExampleComposition: (schema: SchemaObject, schemaPath: string[], options?: GetExampleFromSchemaOptions, arrayItem?: boolean, value?: Record<string, unknown>) => SchemaObject | undefined;
6
6
  /** Options shared by data generation and schema-aware serializers. */
7
7
  export type GetExampleFromSchemaOptions = {
8
+ /** Declared document version; absent means a standalone modern schema. */
9
+ openapiVersion?: string;
10
+ /** Original version when a loader upgraded the document. */
11
+ originalOpenapiVersion?: string;
12
+ /** Default dialect, overridden by a schema resource's $schema. */
13
+ jsonSchemaDialect?: string;
8
14
  /** Internal provenance capture, excluded from persistent result caches. */
9
15
  [EXAMPLE_EVALUATION]?: ExampleEvaluationState;
10
16
  /** Preserve binary filename examples as File objects for multipart serializers. */
@@ -54,6 +60,9 @@ declare const generateExampleFromSchema: (schema: SchemaObject, options?: GetExa
54
60
  /**
55
61
  * Generate data, optionally retaining the exact schema decisions for another output format.
56
62
  * Treat returned values as read-only: cached results and padded items can share object references.
63
+ *
64
+ * An example too large to render at full depth is rendered at the deepest depth that fits instead, so
65
+ * every branch is cut at the same level rather than the first ones using up the budget.
57
66
  */
58
67
  export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, context?: Parameters<typeof generateExampleFromSchema>[2]) => unknown;
59
68
  export {};
@@ -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":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAM5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAob9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,WAC3B,YAAY,cACR,MAAM,EAAE,YACV,2BAA2B,+BAE7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,YAAY,GAAG,SAoBjB,CAAA;AA6tBD,sEAAsE;AACtE,MAAM,MAAM,2BAA2B,GAAG;IACxC,2EAA2E;IAC3E,CAAC,kBAAkB,CAAC,CAAC,EAAE,sBAAsB,CAAA;IAC7C,mFAAmF;IACnF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kFAAkF;IAClF,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;AA6fD;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,yBAAyB,WACrB,YAAY,YACV,2BAA2B,sGAUlC,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;IAC1B,4FAA4F;IAC5F,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAClC,+GAA+G;IAC/G,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAC,KACD,OAgTF,CAAA;AAkBD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WACvB,YAAY,YACV,2BAA2B,YAC5B,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,KACvD,OA2BF,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":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAM5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAG1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAod9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,WAC3B,YAAY,cACR,MAAM,EAAE,YACV,2BAA2B,+BAE7B,MAAM,CAAC,M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5B,CAAC,KACD,OAgUF,CAAA;AA+ED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,WACvB,YAAY,YACV,2BAA2B,YAC5B,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,KACvD,OA+BF,CAAA"}
@@ -9,9 +9,24 @@ import { isFileSchema } from '../../../helpers/is-file-schema.js';
9
9
  import { resolveFormSchema } from '../../../helpers/resolve-form-schema.js';
10
10
  import { unpackProxyObject } from '../../../helpers/unpack-proxy.js';
11
11
  import { resolve } from '../../../resolve.js';
12
+ import { generateContainsArray, getArrayDialect } from './array-contains.js';
12
13
  import { EXAMPLE_EVALUATION } from './example-evaluation.js';
13
14
  /** Maximum recursion depth to prevent infinite loops in circular references */
14
15
  const MAX_LEVELS_DEEP = 10;
16
+ /**
17
+ * How many schemas one example may visit at full depth. An example that fits is rendered exactly as the
18
+ * depth cap alone would render it.
19
+ *
20
+ * The depth cap bounds how deep the walk goes, not how wide. References to schemas that reference each
21
+ * other branch at every level, so a handful of them per schema is enough for the walk to never finish.
22
+ * The largest examples in big real-world documents (Stripe, GitHub, Kubernetes) stay just below this.
23
+ */
24
+ const MAX_EXAMPLE_VISITS = 10_000;
25
+ /**
26
+ * How many schemas each shallower attempt may visit once an example does not fit at full depth. An example
27
+ * this large is already long to read, and up to nine of these attempts can run for a single example.
28
+ */
29
+ const MAX_REDUCED_EXAMPLE_VISITS = 2_000;
15
30
  /** Default name used for additional properties when no custom name is provided */
16
31
  const DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'additionalProperty';
17
32
  /**
@@ -116,17 +131,28 @@ const guessFromFormat = (schema, makeUpRandomData = false, fallback = '') => {
116
131
  */
117
132
  const resultCache = new WeakMap();
118
133
  /**
119
- * Set once the depth cap has truncated something in the current top-level call.
134
+ * Set once the depth cap has truncated something in the current attempt, or the attempt ran out of visits.
120
135
  *
121
136
  * A truncated value only holds at the level it was produced at, but `resultCache` keys carry no level,
122
137
  * so a value assembled around one must not be stored. Composition reaches that case: an `allOf` member
123
138
  * climbs a level without growing `schemaPath`, so a schema rendered just above the cap in one chain
124
139
  * shares its key with the same schema used at the top of a document, and the shallow use is served the
125
140
  * truncated result. Widening the key would cost the cache its hits everywhere, so storing simply stops
126
- * for the rest of the call instead. The walk is synchronous, so resetting at level 0 scopes this to one
127
- * top-level call.
141
+ * for the rest of the attempt instead. The walk is synchronous, so resetting at level 0 scopes this to one
142
+ * attempt.
128
143
  */
129
144
  let truncated = false;
145
+ /** The depth cap of the attempt in progress. */
146
+ let levelsDeep = MAX_LEVELS_DEEP;
147
+ /** Schemas the attempt in progress may still visit. Below zero, the attempt has been abandoned. */
148
+ let visitsLeft = MAX_EXAMPLE_VISITS;
149
+ /** Whether an attempt is in progress, so that the calls it makes join it instead of starting another. */
150
+ let isGenerating = false;
151
+ /**
152
+ * What the attempt in progress has cached. An abandoned attempt removes its entries: they would make the
153
+ * next call for the same schema cheaper, and so give it a different example than this one.
154
+ */
155
+ let attemptCacheEntries = [];
130
156
  /** Prevent cached containers from retaining generated dates and times across calls. */
131
157
  let generatedCurrentTime = false;
132
158
  /** Cache required property names per parent schema for O(1) membership checks */
@@ -172,6 +198,7 @@ const cache = (schema, result, cacheKey, skip = false) => {
172
198
  const cacheMap = resultCache.get(rawSchema) ?? new Map();
173
199
  if (cacheMap) {
174
200
  cacheMap.set(cacheKey, result);
201
+ attemptCacheEntries.push([cacheMap, cacheKey]);
175
202
  }
176
203
  resultCache.set(rawSchema, cacheMap);
177
204
  return result;
@@ -539,7 +566,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
539
566
  : undefined);
540
567
  // Past the cap only the properties the object requires are rendered: optional ones are what the cap
541
568
  // exists to stop descending into. Composition members share the names of the object they belong to.
542
- const required = level > MAX_LEVELS_DEEP
569
+ const required = level > levelsDeep
543
570
  ? (memberRequiredScope ?? getCompositionRequiredNames(schema, options, schemaPath, level, seen, dynamicScope))
544
571
  : undefined;
545
572
  if ('properties' in schema && schema.properties) {
@@ -695,9 +722,21 @@ const readArrayLengthBound = (value, fallback) => typeof value === 'number' && N
695
722
  /** Recognize an array described by its item keywords when no type was declared. */
696
723
  const inferArrayType = (schema) => !('properties' in schema) && ('items' in schema || 'prefixItems' in schema) ? 'array' : undefined;
697
724
  /** Apply the same explicit-type and inference precedence at either union selection site. */
698
- const getSelectedType = (variant, holder) => (variant && 'type' in variant ? variant.type : undefined) ??
699
- ('type' in holder ? holder.type : undefined) ??
700
- (hasUnencodedJsonContent(holder) ? 'string' : ((variant && inferArrayType(variant)) ?? inferArrayType(holder)));
725
+ const getSelectedType = (variant, holder) => {
726
+ const explicitSchema = variant && 'type' in variant && variant.type !== undefined ? variant : holder;
727
+ const type = 'type' in explicitSchema ? explicitSchema.type : undefined;
728
+ if (Array.isArray(type)) {
729
+ const named = type.filter((name) => name !== 'null');
730
+ // Only normalize containers whose own keywords can generate a value; unconstrained lists keep their fallback.
731
+ if (named.length === 1 &&
732
+ ((named[0] === 'object' && 'properties' in explicitSchema) ||
733
+ (named[0] === 'array' && ('items' in explicitSchema || 'prefixItems' in explicitSchema)))) {
734
+ return named[0];
735
+ }
736
+ }
737
+ return (type ??
738
+ (hasUnencodedJsonContent(holder) ? 'string' : ((variant && inferArrayType(variant)) ?? inferArrayType(holder))));
739
+ };
701
740
  /** These keywords describe values without restricting which values the schema accepts. */
702
741
  const ITEM_ANNOTATIONS = new Set([
703
742
  '$ref',
@@ -759,6 +798,20 @@ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath, d
759
798
  seen,
760
799
  dynamicScope: childScope,
761
800
  })) ?? [];
801
+ const counted = generateContainsArray(schema, values, (item) => getExampleFromSchema(item, options, {
802
+ level: level + 1,
803
+ schemaPath: [...schemaPath, 'items'],
804
+ seen,
805
+ dynamicScope: childScope,
806
+ }), getArrayDialect(options?.jsonSchemaDialect, options?.originalOpenapiVersion ?? options?.openapiVersion));
807
+ if (counted) {
808
+ const items = 'items' in schema ? resolve.schema(schema.items) : undefined;
809
+ const tag = items && 'xml' in items ? items.xml?.name : undefined;
810
+ const result = options?.xml && 'xml' in schema && schema.xml?.wrapped && tag
811
+ ? counted.map((item, index) => (index < (prefixes?.length ?? 0) ? item : { [tag]: item }))
812
+ : counted;
813
+ return cache(schema, result, cacheKey, skipCache);
814
+ }
762
815
  if (prefixes && values.length >= minItems) {
763
816
  return cache(schema, values, cacheKey, skipCache);
764
817
  }
@@ -887,11 +940,15 @@ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath, d
887
940
  const unrestricted = itemSchema === undefined ||
888
941
  target === true ||
889
942
  (target !== undefined && items && Object.keys(items).every((key) => ITEM_ANNOTATIONS.has(key)));
890
- // The strict model does not yet expose contains, but runtime 3.1+ descriptions can provide it.
943
+ // Preserve best-effort sampling for complex contains schemas in recognized dialects.
944
+ // This fallback does not grade matches or enforce minContains/maxContains.
891
945
  const contains = 'contains' in schema && schema.contains && typeof schema.contains === 'object' && !Array.isArray(schema.contains)
892
946
  ? resolve.schema(schema.contains)
893
947
  : undefined;
894
- if (unrestricted && contains) {
948
+ if (unrestricted &&
949
+ contains &&
950
+ getArrayDialect(options?.jsonSchemaDialect, options?.originalOpenapiVersion ?? options?.openapiVersion) !==
951
+ 'unsupported') {
895
952
  const sample = getExampleFromSchema(contains, options, {
896
953
  level: level + 1,
897
954
  schemaPath: [...schemaPath, 'contains'],
@@ -950,6 +1007,9 @@ const getUnionPrimitiveValue = (schema, makeUpRandomData, emptyString) => {
950
1007
  };
951
1008
  /** Create stable cache key from the options object */
952
1009
  const createOptionsCacheKey = (options) => JSON.stringify({
1010
+ openapiVersion: options?.openapiVersion,
1011
+ originalOpenapiVersion: options?.originalOpenapiVersion,
1012
+ jsonSchemaDialect: options?.jsonSchemaDialect,
953
1013
  binaryAsFile: options?.binaryAsFile,
954
1014
  emptyString: options?.emptyString,
955
1015
  xml: options?.xml,
@@ -985,24 +1045,29 @@ const MAX_DEPTH_EXCEEDED = '[Max Depth Exceeded]';
985
1045
  /** How long a chain of composition wrappers may be unwrapped before the stack becomes the concern. */
986
1046
  const MAX_COMPOSITION_DEPTH = MAX_LEVELS_DEEP * 5;
987
1047
  /**
988
- * How deep the walk keeps going past `MAX_LEVELS_DEEP` to fill the properties a truncated object requires.
1048
+ * How deep the walk goes to fill what a truncated object requires, as a multiple of the depth cap.
989
1049
  *
990
1050
  * Past the cap the walk still renders objects, but only their required properties, so a strict decoder
991
- * reading the example finds every key it insists on. This level bounds that, well below the XML
992
- * serializer's depth limit of 50 (which discards the whole body when crossed), and past it objects
1051
+ * reading the example finds every key it insists on. At full depth this stops at level 20, well below the
1052
+ * XML serializer's depth limit of 50 (which discards the whole body when crossed), and past it objects
993
1053
  * stand in empty again.
994
1054
  */
995
- const MAX_REQUIRED_LEVELS_DEEP = MAX_LEVELS_DEEP * 2;
1055
+ const REQUIRED_LEVELS_FACTOR = 2;
996
1056
  /**
997
- * How many schemas the walk may enter past `MAX_LEVELS_DEEP` in one top-level call.
1057
+ * How many schemas the walk may enter past the depth cap in one attempt.
998
1058
  *
999
1059
  * Cycle guards stop a schema that requires itself, but not a chain of distinct schemas that each point
1000
1060
  * at the next one twice, through two required properties or an `allOf` that lists the same member
1001
1061
  * twice: the work doubles with every link. Once the budget is spent, objects stand in empty.
1002
1062
  */
1003
1063
  const MAX_REQUIRED_STEPS = 10_000;
1004
- /** Schemas the walk may still enter past `MAX_LEVELS_DEEP` in the current top-level call. */
1064
+ /** Schemas the walk may still enter past the depth cap in the current attempt. */
1005
1065
  let requiredSteps = MAX_REQUIRED_STEPS;
1066
+ /**
1067
+ * How many steps of the search for required properties cost an attempt one visit. Ordinary compositions
1068
+ * take a few steps and cost nothing; one that keeps exhausting the search soon uses up the attempt.
1069
+ */
1070
+ const REQUIRED_STEPS_PER_VISIT = 25;
1006
1071
  /** Cache requirements within one walk; generated discriminator values may select a new branch next time. */
1007
1072
  let compositionRequiredNamesCache = new WeakMap();
1008
1073
  /** Values are reused only within one call; generated dates and traversal contexts must not leak across calls. */
@@ -1109,7 +1174,7 @@ const getCompositionRequiredNames = (schema, options, schemaPath, level, seen, d
1109
1174
  const keyword = current.schema.oneOf ? 'oneOf' : current.schema.anyOf ? 'anyOf' : undefined;
1110
1175
  if (keyword) {
1111
1176
  const discriminator = current.schema.discriminator;
1112
- const requiredOnly = level + current.depth > MAX_LEVELS_DEEP;
1177
+ const requiredOnly = level + current.depth > levelsDeep;
1113
1178
  const omittedDiscriminator = requiredOnly &&
1114
1179
  discriminator?.defaultMapping !== undefined &&
1115
1180
  // The negative level gathers shared requirements without evaluating discriminator values.
@@ -1160,6 +1225,8 @@ const getCompositionRequiredNames = (schema, options, schemaPath, level, seen, d
1160
1225
  }
1161
1226
  }
1162
1227
  }
1228
+ // A long search does the work of many visits, so the attempt pays for it.
1229
+ visitsLeft -= Math.floor(Math.min(MAX_REQUIRED_STEPS, MAX_REQUIRED_STEPS - steps) / REQUIRED_STEPS_PER_VISIT);
1163
1230
  if (dynamicScope.length === 0) {
1164
1231
  const contexts = compositionRequiredNamesCache.get(root) ?? new Map();
1165
1232
  contexts.set(cacheKey, names);
@@ -1168,7 +1235,7 @@ const getCompositionRequiredNames = (schema, options, schemaPath, level, seen, d
1168
1235
  return names;
1169
1236
  };
1170
1237
  /**
1171
- * Whether the walk keeps rendering a schema past `MAX_LEVELS_DEEP` to fill its required properties.
1238
+ * Whether the walk keeps rendering a schema past the depth cap to fill its required properties.
1172
1239
  *
1173
1240
  * Only an object or composition with a property marked `required` qualifies, either somewhere in its
1174
1241
  * own compositions or, for a composition member, in the object it belongs to (`requiredScope`):
@@ -1367,7 +1434,7 @@ const hasUnencodedJsonContent = (schema) => {
1367
1434
  * @returns An example value for the given schema.
1368
1435
  */
1369
1436
  const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, name, seen = new WeakSet(), schemaPath = [], dynamicScope = [], requiredScope, isRequiredProperty = false, } = {}) => {
1370
- // Cache restrictions only apply to the current traversal, so every top-level call starts clean.
1437
+ // Cache restrictions only apply to the current traversal, so every attempt starts clean.
1371
1438
  if (level === 0) {
1372
1439
  truncated = false;
1373
1440
  generatedCurrentTime = false;
@@ -1375,11 +1442,20 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1375
1442
  compositionRequiredNamesCache = new WeakMap();
1376
1443
  discriminatorExamples = new WeakMap();
1377
1444
  }
1445
+ // The attempt is over budget and will be discarded. Anything finished from here on is missing children,
1446
+ // so it must not reach the cache either.
1447
+ if (--visitsLeft < 0) {
1448
+ truncated = true;
1449
+ return undefined;
1450
+ }
1378
1451
  // Resolve any $ref references to get the actual schema
1379
1452
  const _schema = resolve.schema(schema);
1380
1453
  if (!isDefined(_schema)) {
1381
1454
  return undefined;
1382
1455
  }
1456
+ if (typeof _schema.$schema === 'string') {
1457
+ options = { ...options, jsonSchemaDialect: _schema.$schema };
1458
+ }
1383
1459
  // Resolve a `$dynamicRef` against the active dynamic scope, then continue with the bound schema.
1384
1460
  // When nothing matches, fall through and render the reference as before (no regression).
1385
1461
  if (isDynamicRef(_schema)) {
@@ -1412,7 +1488,9 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1412
1488
  }
1413
1489
  seen.add(targetValue);
1414
1490
  /** Make the cache key unique per options and schema path */
1415
- const cacheKey = getOptionsCacheKey(options, level) + (schemaPath.length > 0 ? `:path:${schemaPath.join('.')}` : '');
1491
+ const cacheKey = getOptionsCacheKey(options, level) +
1492
+ (levelsDeep === MAX_LEVELS_DEEP ? '' : `:depth:${levelsDeep}`) +
1493
+ (schemaPath.length > 0 ? `:path:${schemaPath.join('.')}` : '');
1416
1494
  // Check cache first for performance - avoid recomputing the same schema (skipped under a dynamic scope)
1417
1495
  if (!skipCache) {
1418
1496
  const cached = resultCache.get(targetValue)?.get(cacheKey);
@@ -1473,15 +1551,16 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1473
1551
  // every rule that applies at a shallower level (read/write omission, composition selection, variables,
1474
1552
  // binary files) applies to them too. Required primitive compositions use the same walk so their
1475
1553
  // members retain those rules as well; arrays and anything past the bounds still stand in.
1476
- if (level > MAX_LEVELS_DEEP) {
1477
- if ((!(isRequiredProperty && getEmptyContainer(_schema) === undefined) &&
1478
- !fillsRequiredProperties(_schema, requiredScope, options, schemaPath, level, seen, dynamicScope)) ||
1479
- level > MAX_REQUIRED_LEVELS_DEEP ||
1480
- requiredSteps <= 0) {
1554
+ if (level > levelsDeep) {
1555
+ if (level > levelsDeep * REQUIRED_LEVELS_FACTOR ||
1556
+ requiredSteps <= 0 ||
1557
+ (!(isRequiredProperty && getEmptyContainer(_schema) === undefined) &&
1558
+ !fillsRequiredProperties(_schema, requiredScope, options, schemaPath, level, seen, dynamicScope))) {
1481
1559
  seen.delete(targetValue);
1482
1560
  // Deliberately not cached: the value holds only at this level, and the cache key carries none.
1483
1561
  // Constraint-only composition members must not replace a sibling's required fields with the depth marker.
1484
- const fallback = isRequiredProperty || requiredScope?.size ? null : MAX_DEPTH_EXCEEDED;
1562
+ // Neither must a shallower attempt show it where a full walk would have rendered the schema.
1563
+ const fallback = isRequiredProperty || requiredScope?.size || level <= MAX_LEVELS_DEEP ? null : MAX_DEPTH_EXCEEDED;
1485
1564
  return getMaxDepthValue(_schema, options, schemaPath, undefined, fallback);
1486
1565
  }
1487
1566
  requiredSteps--;
@@ -1501,7 +1580,8 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1501
1580
  const selectedVariant = getSelectedVariant(_schema, options, schemaPath);
1502
1581
  if (selectedComposition && selectedVariant) {
1503
1582
  const selectedType = getSelectedType(selectedVariant, _schema);
1504
- if (selectedType !== undefined && selectedType !== 'object') {
1583
+ // A declared null must be selected directly: merging it into shared object properties loses it.
1584
+ if (selectedType !== undefined && (selectedType !== 'object' || getDeclaredValue(selectedVariant) === null)) {
1505
1585
  if (seen.has(getSchemaCacheTarget(selectedVariant))) {
1506
1586
  seen.delete(targetValue);
1507
1587
  return undefined;
@@ -1638,11 +1718,11 @@ const asBinaryFile = (schema, value, options, schemaPath = []) => {
1638
1718
  }
1639
1719
  return value;
1640
1720
  };
1641
- /**
1642
- * Generate data, optionally retaining the exact schema decisions for another output format.
1643
- * Treat returned values as read-only: cached results and padded items can share object references.
1644
- */
1645
- export const getExampleFromSchema = (schema, options, context = {}) => {
1721
+ /** Generate data for one schema within the attempt in progress. */
1722
+ const generateWithCapture = (schema, options, context = {}) => {
1723
+ if (schema && typeof schema === 'object' && '$schema' in schema && typeof schema.$schema === 'string') {
1724
+ options = { ...options, jsonSchemaDialect: schema.$schema };
1725
+ }
1646
1726
  const capture = options?.[EXAMPLE_EVALUATION];
1647
1727
  if (!capture) {
1648
1728
  const value = generateExampleFromSchema(schema, options, context);
@@ -1672,3 +1752,54 @@ export const getExampleFromSchema = (schema, options, context = {}) => {
1672
1752
  capture.stack.pop();
1673
1753
  }
1674
1754
  };
1755
+ /** Walks at one depth cap, returning nothing when the walk does not fit in the given number of visits. */
1756
+ const attemptExample = (schema, options, context, depth, visits) => {
1757
+ levelsDeep = depth;
1758
+ visitsLeft = visits;
1759
+ attemptCacheEntries = [];
1760
+ const value = generateWithCapture(schema, options, context);
1761
+ if (visitsLeft < 0) {
1762
+ for (const [entries, key] of attemptCacheEntries) {
1763
+ entries.delete(key);
1764
+ }
1765
+ return undefined;
1766
+ }
1767
+ return { value, evaluation: options?.[EXAMPLE_EVALUATION]?.root };
1768
+ };
1769
+ /**
1770
+ * Generate data, optionally retaining the exact schema decisions for another output format.
1771
+ * Treat returned values as read-only: cached results and padded items can share object references.
1772
+ *
1773
+ * An example too large to render at full depth is rendered at the deepest depth that fits instead, so
1774
+ * every branch is cut at the same level rather than the first ones using up the budget.
1775
+ */
1776
+ export const getExampleFromSchema = (schema, options, context = {}) => {
1777
+ if (isGenerating) {
1778
+ return generateWithCapture(schema, options, context);
1779
+ }
1780
+ isGenerating = true;
1781
+ try {
1782
+ const full = attemptExample(schema, options, context, MAX_LEVELS_DEEP, MAX_EXAMPLE_VISITS);
1783
+ if (full) {
1784
+ return full.value;
1785
+ }
1786
+ // At depth zero every child stands in, so this walk is only as long as the root is wide.
1787
+ let kept = attemptExample(schema, options, context, 0, Number.POSITIVE_INFINITY);
1788
+ for (let depth = 1; depth < MAX_LEVELS_DEEP; depth++) {
1789
+ const attempt = attemptExample(schema, options, context, depth, MAX_REDUCED_EXAMPLE_VISITS);
1790
+ if (!attempt) {
1791
+ break;
1792
+ }
1793
+ kept = attempt;
1794
+ }
1795
+ const capture = options?.[EXAMPLE_EVALUATION];
1796
+ if (capture) {
1797
+ // The last walk may be one that was abandoned.
1798
+ capture.root = kept.evaluation;
1799
+ }
1800
+ return kept.value;
1801
+ }
1802
+ finally {
1803
+ isGenerating = false;
1804
+ }
1805
+ };
@@ -157,6 +157,8 @@ export type RequestFactory = {
157
157
  * List of all security requirements for this request (e.g., API key, OAuth2, etc.)
158
158
  * Each entry reflects a selected Security Scheme.
159
159
  * Values (e.g., tokens, secrets) may still be unsubstituted at this point.
160
+ * Header API-key prefixes are carried separately in `tokenPrefix`. Consumers using
161
+ * `disableSecurity` must resolve variables and apply authentication formatting themselves.
160
162
  */
161
163
  security: BuildRequestSecurityResult[];
162
164
  /**
@@ -185,7 +187,7 @@ export type RequestFactory = {
185
187
  * Builds a request object fastory which can be used to build a request object.
186
188
  * @returns A request object factory
187
189
  */
188
- export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, requestBodyCompositionSelection, }: RequestExampleMeta & {
190
+ export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, }: RequestExampleMeta & {
189
191
  /** The operation object */
190
192
  operation: OperationObject;
191
193
  /** For environment variables in the inputs */
@@ -205,6 +207,8 @@ export declare const requestFactory: ({ exampleName, globalCookies, method, oper
205
207
  /** Selected anyOf/oneOf request-body variants keyed by schema path */
206
208
  /** Originating OpenAPI version, used for version-specific serialization. */
207
209
  openapiVersion?: string;
210
+ /** Document default for schema resources without $schema. */
211
+ jsonSchemaDialect?: string;
208
212
  requestBodyCompositionSelection?: Record<string, number>;
209
213
  }) => {
210
214
  request: RequestFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAE5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,2DAA2D,CAAA;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,2BAA2B,CAAA;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,6FAA6F;IAC7F,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,IAAI,EAAE;QACJ;;;;;WAKG;QACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,kDAAkD;QAClD,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAClC,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M,EAAE,MAAM,CAAC,CAAA;IACtC,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,8DAA8D;IAC9D,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,sEAAsE;IACtE,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,KAAG;IACF,OAAO,EAAE,cAAc,CAAA;CA8ExB,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,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,2DAA2D,CAAA;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,2BAA2B,CAAA;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,6FAA6F;IAC7F,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH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