@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.
- package/CHANGELOG.md +43 -0
- package/README.md +10 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +77 -10
- package/dist/entities/auth/schema.d.ts +405 -40
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/helpers/async-api-schema-resources/load-inline.d.ts +7 -0
- package/dist/helpers/async-api-schema-resources/load-inline.d.ts.map +1 -0
- package/dist/helpers/async-api-schema-resources/load-inline.js +31 -0
- package/dist/helpers/async-api-schema-resources/protobuf-imports.d.ts +8 -0
- package/dist/helpers/async-api-schema-resources/protobuf-imports.d.ts.map +1 -0
- package/dist/helpers/async-api-schema-resources/protobuf-imports.js +25 -0
- package/dist/helpers/async-api-schema-resources/raml-source.d.ts +12 -0
- package/dist/helpers/async-api-schema-resources/raml-source.d.ts.map +1 -0
- package/dist/helpers/async-api-schema-resources/raml-source.js +32 -0
- package/dist/helpers/async-api-schema-resources/resolver.d.ts +12 -0
- package/dist/helpers/async-api-schema-resources/resolver.d.ts.map +1 -0
- package/dist/helpers/async-api-schema-resources/resolver.js +31 -0
- package/dist/helpers/async-api-schema-resources/resources.d.ts +13 -0
- package/dist/helpers/async-api-schema-resources/resources.d.ts.map +1 -0
- package/dist/helpers/async-api-schema-resources/resources.js +133 -0
- package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts +3 -0
- package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts.map +1 -0
- package/dist/helpers/async-api-schema-resources/schema-resource-path.js +9 -0
- package/dist/helpers/async-api-schema-resources/schema-wrappers.d.ts +9 -0
- package/dist/helpers/async-api-schema-resources/schema-wrappers.d.ts.map +1 -0
- package/dist/helpers/async-api-schema-resources/schema-wrappers.js +69 -0
- package/dist/helpers/async-api-schema-resources/track-edits.d.ts +3 -0
- package/dist/helpers/async-api-schema-resources/track-edits.d.ts.map +1 -0
- package/dist/helpers/async-api-schema-resources/track-edits.js +46 -0
- package/dist/helpers/compact-upgrade-metadata.d.ts +3 -0
- package/dist/helpers/compact-upgrade-metadata.d.ts.map +1 -0
- package/dist/helpers/compact-upgrade-metadata.js +71 -0
- package/dist/helpers/is-file-schema.js +1 -1
- package/dist/helpers/querystring-parameter.d.ts +3 -1
- package/dist/helpers/querystring-parameter.d.ts.map +1 -1
- package/dist/helpers/querystring-parameter.js +2 -2
- package/dist/helpers/resolve-async-api-schema.d.ts +2 -0
- package/dist/helpers/resolve-async-api-schema.d.ts.map +1 -1
- package/dist/helpers/resolve-async-api-schema.js +25 -1
- package/dist/helpers/use-async-api-schema-resources.d.ts +12 -0
- package/dist/helpers/use-async-api-schema-resources.d.ts.map +1 -0
- package/dist/helpers/use-async-api-schema-resources.js +24 -0
- package/dist/mutators/operation/parameters.d.ts.map +1 -1
- package/dist/mutators/operation/parameters.js +9 -1
- package/dist/mutators/operation/reset-request-body.d.ts.map +1 -1
- package/dist/mutators/operation/reset-request-body.js +3 -1
- package/dist/navigation/helpers/get-x-badges.d.ts +10 -0
- package/dist/navigation/helpers/get-x-badges.d.ts.map +1 -0
- package/dist/navigation/helpers/get-x-badges.js +26 -0
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +3 -0
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-schemas.js +3 -0
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-tags.js +3 -0
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js +3 -0
- package/dist/plugins/bundler/async-api-schema-resources.d.ts +4 -0
- package/dist/plugins/bundler/async-api-schema-resources.d.ts.map +1 -0
- package/dist/plugins/bundler/async-api-schema-resources.js +20 -0
- package/dist/plugins/bundler/index.d.ts +1 -1
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +7 -4
- package/dist/plugins/bundler/openapi-document.d.ts +5 -1
- package/dist/plugins/bundler/openapi-document.d.ts.map +1 -1
- package/dist/plugins/bundler/openapi-document.js +7 -3
- package/dist/plugins/bundler/upgrade-documents.d.ts +4 -0
- package/dist/plugins/bundler/upgrade-documents.d.ts.map +1 -0
- package/dist/plugins/bundler/upgrade-documents.js +357 -0
- package/dist/request-example/builder/body/build-request-body.d.ts +1 -1
- package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-request-body.js +2 -2
- package/dist/request-example/builder/body/get-request-body-example.d.ts +2 -2
- package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
- package/dist/request-example/builder/body/get-request-body-example.js +7 -3
- package/dist/request-example/builder/build-request.d.ts.map +1 -1
- package/dist/request-example/builder/build-request.js +3 -2
- package/dist/request-example/builder/helpers/array-contains.d.ts +15 -0
- package/dist/request-example/builder/helpers/array-contains.d.ts.map +1 -0
- package/dist/request-example/builder/helpers/array-contains.js +199 -0
- package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +9 -0
- package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
- package/dist/request-example/builder/helpers/get-example-from-schema.js +162 -31
- package/dist/request-example/builder/request-factory.d.ts +5 -1
- package/dist/request-example/builder/request-factory.d.ts.map +1 -1
- package/dist/request-example/builder/request-factory.js +5 -3
- package/dist/request-example/builder/security/build-request-security.d.ts +6 -4
- package/dist/request-example/builder/security/build-request-security.d.ts.map +1 -1
- package/dist/request-example/builder/security/build-request-security.js +1 -0
- package/dist/schemas/extensions/security/x-scalar-token-prefix.d.ts +11 -0
- package/dist/schemas/extensions/security/x-scalar-token-prefix.d.ts.map +1 -0
- package/dist/schemas/extensions/security/x-scalar-token-prefix.js +8 -0
- package/dist/schemas/navigation.d.ts +49 -0
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/navigation.js +5 -0
- package/dist/schemas/reference-config/index.d.ts +81 -8
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +81 -8
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +2835 -280
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.d.ts +62 -10
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +10 -2
- package/dist/schemas/v3.1/strict/security-scheme.d.ts +4 -1
- package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/security-scheme.js +2 -1
- package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
- package/dist/schemas/v3.2/openapi/index.js +7 -2
- package/dist/schemas/v3.2/strict/openapi-document.d.ts +2835 -280
- package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/schema.d.ts +62 -10
- package/dist/schemas/v3.2/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/schema.js +10 -2
- package/dist/schemas/v3.2/strict/security-scheme.d.ts +4 -1
- package/dist/schemas/v3.2/strict/security-scheme.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/security-scheme.js +2 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +33 -3
- package/package.json +16 -15
|
@@ -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,
|
|
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,
|
|
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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAQnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,uDAAuD,CAAA;AAK9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAwClD;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,YAC7B,cAAc,gBACT,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACnB;IAAE,6BAA6B,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3D,MAyBF,CAAA;AAED;;;;;KAKK;AACL,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kGAAkG;IAClG,cAAc,EAAE,cAAc,CAAA;IAC9B,2BAA2B;IAC3B,UAAU,EAAE,eAAe,CAAA;IAC3B,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAA;AAEnE,MAAM,MAAM,uBAAuB,GAAG,6BAA6B,GAAG,OAAO,oBAAoB,CAAA;AAEjG,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAA;AAElF,eAAO,MAAM,YAAY,YACd,cAAc,WACd;IACP,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC,KACA,kBASF,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatTokenPrefix } from '@scalar/helpers/http/format-token-prefix';
|
|
1
2
|
import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
|
|
2
3
|
import { X_SCALAR_DATE, X_SCALAR_DNT, X_SCALAR_REFERER, X_SCALAR_USER_AGENT } from '@scalar/helpers/http/scalar-headers';
|
|
3
4
|
import { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables';
|
|
@@ -25,7 +26,7 @@ const formatSecurityValue = (security, replace) => {
|
|
|
25
26
|
// Normalize pasted tokens after resolving variables, which may also contain surrounding whitespace.
|
|
26
27
|
return `Bearer ${substitutedValue.trim()}`;
|
|
27
28
|
}
|
|
28
|
-
return substitutedValue;
|
|
29
|
+
return formatTokenPrefix(substitutedValue, security.tokenPrefix);
|
|
29
30
|
};
|
|
30
31
|
const createEnvReplaceFn = (envVariables) => {
|
|
31
32
|
return (value) => {
|
|
@@ -135,7 +136,7 @@ const buildRequestInner = (request, options) => {
|
|
|
135
136
|
// Format the security value based on its authentication scheme.
|
|
136
137
|
// - For 'basic': prefix with 'Basic' and base64-encode the value (username:password).
|
|
137
138
|
// - For 'bearer': prefix with 'Bearer'.
|
|
138
|
-
// - Otherwise:
|
|
139
|
+
// - Otherwise: apply any configured API-key prefix to the substituted credential.
|
|
139
140
|
const securityValue = formatSecurityValue(security, replace);
|
|
140
141
|
if (security.in === 'header') {
|
|
141
142
|
// Set the header (use replaced header name so {{ env }} placeholders work)
|
|
@@ -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"}
|