@scalar/workspace-store 0.74.0 → 0.76.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 +34 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +55 -5
- package/dist/entities/auth/schema.d.ts +210 -0
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/helpers/async-api-schema-resources/load-inline.d.ts +3 -1
- package/dist/helpers/async-api-schema-resources/load-inline.d.ts.map +1 -1
- package/dist/helpers/async-api-schema-resources/load-inline.js +20 -60
- 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 +3 -0
- package/dist/helpers/async-api-schema-resources/resources.d.ts.map +1 -1
- package/dist/helpers/async-api-schema-resources/resources.js +17 -8
- 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/get-resolved-security-scheme.d.ts +12 -0
- package/dist/helpers/get-resolved-security-scheme.d.ts.map +1 -0
- package/dist/helpers/get-resolved-security-scheme.js +24 -0
- package/dist/helpers/resolve-async-api-schema.d.ts.map +1 -1
- package/dist/helpers/resolve-async-api-schema.js +3 -1
- package/dist/helpers/resolve-security-requirements.js +2 -2
- 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/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 +1 -1
- package/dist/plugins/bundler/async-api-schema-resources.d.ts.map +1 -1
- package/dist/plugins/bundler/async-api-schema-resources.js +9 -9
- package/dist/request-example/builder/body/aspnet-form-fields.d.ts +26 -0
- package/dist/request-example/builder/body/aspnet-form-fields.d.ts.map +1 -0
- package/dist/request-example/builder/body/aspnet-form-fields.js +179 -0
- package/dist/request-example/builder/body/build-multipart.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-multipart.js +9 -5
- package/dist/request-example/builder/body/build-request-body.d.ts +5 -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 +38 -8
- 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/get-example-from-schema.d.ts +3 -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 +132 -29
- 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 +4 -2
- 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/request-example/index.d.ts +1 -0
- package/dist/request-example/index.d.ts.map +1 -1
- package/dist/request-example/index.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 +42 -0
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +42 -0
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +1470 -0
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- 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 +2 -0
- package/dist/schemas/v3.2/strict/openapi-document.d.ts +1470 -0
- package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
- 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/package.json +12 -11
|
@@ -13,6 +13,20 @@ import { generateContainsArray, getArrayDialect } from './array-contains.js';
|
|
|
13
13
|
import { EXAMPLE_EVALUATION } from './example-evaluation.js';
|
|
14
14
|
/** Maximum recursion depth to prevent infinite loops in circular references */
|
|
15
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;
|
|
16
30
|
/** Default name used for additional properties when no custom name is provided */
|
|
17
31
|
const DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'additionalProperty';
|
|
18
32
|
/**
|
|
@@ -117,17 +131,28 @@ const guessFromFormat = (schema, makeUpRandomData = false, fallback = '') => {
|
|
|
117
131
|
*/
|
|
118
132
|
const resultCache = new WeakMap();
|
|
119
133
|
/**
|
|
120
|
-
* Set once the depth cap has truncated something in the current
|
|
134
|
+
* Set once the depth cap has truncated something in the current attempt, or the attempt ran out of visits.
|
|
121
135
|
*
|
|
122
136
|
* A truncated value only holds at the level it was produced at, but `resultCache` keys carry no level,
|
|
123
137
|
* so a value assembled around one must not be stored. Composition reaches that case: an `allOf` member
|
|
124
138
|
* climbs a level without growing `schemaPath`, so a schema rendered just above the cap in one chain
|
|
125
139
|
* shares its key with the same schema used at the top of a document, and the shallow use is served the
|
|
126
140
|
* truncated result. Widening the key would cost the cache its hits everywhere, so storing simply stops
|
|
127
|
-
* for the rest of the
|
|
128
|
-
*
|
|
141
|
+
* for the rest of the attempt instead. The walk is synchronous, so resetting at level 0 scopes this to one
|
|
142
|
+
* attempt.
|
|
129
143
|
*/
|
|
130
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 = [];
|
|
131
156
|
/** Prevent cached containers from retaining generated dates and times across calls. */
|
|
132
157
|
let generatedCurrentTime = false;
|
|
133
158
|
/** Cache required property names per parent schema for O(1) membership checks */
|
|
@@ -173,6 +198,7 @@ const cache = (schema, result, cacheKey, skip = false) => {
|
|
|
173
198
|
const cacheMap = resultCache.get(rawSchema) ?? new Map();
|
|
174
199
|
if (cacheMap) {
|
|
175
200
|
cacheMap.set(cacheKey, result);
|
|
201
|
+
attemptCacheEntries.push([cacheMap, cacheKey]);
|
|
176
202
|
}
|
|
177
203
|
resultCache.set(rawSchema, cacheMap);
|
|
178
204
|
return result;
|
|
@@ -540,7 +566,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
|
|
|
540
566
|
: undefined);
|
|
541
567
|
// Past the cap only the properties the object requires are rendered: optional ones are what the cap
|
|
542
568
|
// exists to stop descending into. Composition members share the names of the object they belong to.
|
|
543
|
-
const required = level >
|
|
569
|
+
const required = level > levelsDeep
|
|
544
570
|
? (memberRequiredScope ?? getCompositionRequiredNames(schema, options, schemaPath, level, seen, dynamicScope))
|
|
545
571
|
: undefined;
|
|
546
572
|
if ('properties' in schema && schema.properties) {
|
|
@@ -696,9 +722,21 @@ const readArrayLengthBound = (value, fallback) => typeof value === 'number' && N
|
|
|
696
722
|
/** Recognize an array described by its item keywords when no type was declared. */
|
|
697
723
|
const inferArrayType = (schema) => !('properties' in schema) && ('items' in schema || 'prefixItems' in schema) ? 'array' : undefined;
|
|
698
724
|
/** Apply the same explicit-type and inference precedence at either union selection site. */
|
|
699
|
-
const getSelectedType = (variant, holder) =>
|
|
700
|
-
|
|
701
|
-
|
|
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
|
+
};
|
|
702
740
|
/** These keywords describe values without restricting which values the schema accepts. */
|
|
703
741
|
const ITEM_ANNOTATIONS = new Set([
|
|
704
742
|
'$ref',
|
|
@@ -1007,24 +1045,29 @@ const MAX_DEPTH_EXCEEDED = '[Max Depth Exceeded]';
|
|
|
1007
1045
|
/** How long a chain of composition wrappers may be unwrapped before the stack becomes the concern. */
|
|
1008
1046
|
const MAX_COMPOSITION_DEPTH = MAX_LEVELS_DEEP * 5;
|
|
1009
1047
|
/**
|
|
1010
|
-
* How deep the walk
|
|
1048
|
+
* How deep the walk goes to fill what a truncated object requires, as a multiple of the depth cap.
|
|
1011
1049
|
*
|
|
1012
1050
|
* Past the cap the walk still renders objects, but only their required properties, so a strict decoder
|
|
1013
|
-
* reading the example finds every key it insists on.
|
|
1014
|
-
* 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
|
|
1015
1053
|
* stand in empty again.
|
|
1016
1054
|
*/
|
|
1017
|
-
const
|
|
1055
|
+
const REQUIRED_LEVELS_FACTOR = 2;
|
|
1018
1056
|
/**
|
|
1019
|
-
* How many schemas the walk may enter past
|
|
1057
|
+
* How many schemas the walk may enter past the depth cap in one attempt.
|
|
1020
1058
|
*
|
|
1021
1059
|
* Cycle guards stop a schema that requires itself, but not a chain of distinct schemas that each point
|
|
1022
1060
|
* at the next one twice, through two required properties or an `allOf` that lists the same member
|
|
1023
1061
|
* twice: the work doubles with every link. Once the budget is spent, objects stand in empty.
|
|
1024
1062
|
*/
|
|
1025
1063
|
const MAX_REQUIRED_STEPS = 10_000;
|
|
1026
|
-
/** Schemas the walk may still enter past
|
|
1064
|
+
/** Schemas the walk may still enter past the depth cap in the current attempt. */
|
|
1027
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;
|
|
1028
1071
|
/** Cache requirements within one walk; generated discriminator values may select a new branch next time. */
|
|
1029
1072
|
let compositionRequiredNamesCache = new WeakMap();
|
|
1030
1073
|
/** Values are reused only within one call; generated dates and traversal contexts must not leak across calls. */
|
|
@@ -1131,7 +1174,7 @@ const getCompositionRequiredNames = (schema, options, schemaPath, level, seen, d
|
|
|
1131
1174
|
const keyword = current.schema.oneOf ? 'oneOf' : current.schema.anyOf ? 'anyOf' : undefined;
|
|
1132
1175
|
if (keyword) {
|
|
1133
1176
|
const discriminator = current.schema.discriminator;
|
|
1134
|
-
const requiredOnly = level + current.depth >
|
|
1177
|
+
const requiredOnly = level + current.depth > levelsDeep;
|
|
1135
1178
|
const omittedDiscriminator = requiredOnly &&
|
|
1136
1179
|
discriminator?.defaultMapping !== undefined &&
|
|
1137
1180
|
// The negative level gathers shared requirements without evaluating discriminator values.
|
|
@@ -1182,6 +1225,8 @@ const getCompositionRequiredNames = (schema, options, schemaPath, level, seen, d
|
|
|
1182
1225
|
}
|
|
1183
1226
|
}
|
|
1184
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);
|
|
1185
1230
|
if (dynamicScope.length === 0) {
|
|
1186
1231
|
const contexts = compositionRequiredNamesCache.get(root) ?? new Map();
|
|
1187
1232
|
contexts.set(cacheKey, names);
|
|
@@ -1190,7 +1235,7 @@ const getCompositionRequiredNames = (schema, options, schemaPath, level, seen, d
|
|
|
1190
1235
|
return names;
|
|
1191
1236
|
};
|
|
1192
1237
|
/**
|
|
1193
|
-
* Whether the walk keeps rendering a schema past
|
|
1238
|
+
* Whether the walk keeps rendering a schema past the depth cap to fill its required properties.
|
|
1194
1239
|
*
|
|
1195
1240
|
* Only an object or composition with a property marked `required` qualifies, either somewhere in its
|
|
1196
1241
|
* own compositions or, for a composition member, in the object it belongs to (`requiredScope`):
|
|
@@ -1389,7 +1434,7 @@ const hasUnencodedJsonContent = (schema) => {
|
|
|
1389
1434
|
* @returns An example value for the given schema.
|
|
1390
1435
|
*/
|
|
1391
1436
|
const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, name, seen = new WeakSet(), schemaPath = [], dynamicScope = [], requiredScope, isRequiredProperty = false, } = {}) => {
|
|
1392
|
-
// Cache restrictions only apply to the current traversal, so every
|
|
1437
|
+
// Cache restrictions only apply to the current traversal, so every attempt starts clean.
|
|
1393
1438
|
if (level === 0) {
|
|
1394
1439
|
truncated = false;
|
|
1395
1440
|
generatedCurrentTime = false;
|
|
@@ -1397,6 +1442,12 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
|
|
|
1397
1442
|
compositionRequiredNamesCache = new WeakMap();
|
|
1398
1443
|
discriminatorExamples = new WeakMap();
|
|
1399
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
|
+
}
|
|
1400
1451
|
// Resolve any $ref references to get the actual schema
|
|
1401
1452
|
const _schema = resolve.schema(schema);
|
|
1402
1453
|
if (!isDefined(_schema)) {
|
|
@@ -1437,7 +1488,9 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
|
|
|
1437
1488
|
}
|
|
1438
1489
|
seen.add(targetValue);
|
|
1439
1490
|
/** Make the cache key unique per options and schema path */
|
|
1440
|
-
const cacheKey = getOptionsCacheKey(options, level) +
|
|
1491
|
+
const cacheKey = getOptionsCacheKey(options, level) +
|
|
1492
|
+
(levelsDeep === MAX_LEVELS_DEEP ? '' : `:depth:${levelsDeep}`) +
|
|
1493
|
+
(schemaPath.length > 0 ? `:path:${schemaPath.join('.')}` : '');
|
|
1441
1494
|
// Check cache first for performance - avoid recomputing the same schema (skipped under a dynamic scope)
|
|
1442
1495
|
if (!skipCache) {
|
|
1443
1496
|
const cached = resultCache.get(targetValue)?.get(cacheKey);
|
|
@@ -1498,15 +1551,16 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
|
|
|
1498
1551
|
// every rule that applies at a shallower level (read/write omission, composition selection, variables,
|
|
1499
1552
|
// binary files) applies to them too. Required primitive compositions use the same walk so their
|
|
1500
1553
|
// members retain those rules as well; arrays and anything past the bounds still stand in.
|
|
1501
|
-
if (level >
|
|
1502
|
-
if (
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
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))) {
|
|
1506
1559
|
seen.delete(targetValue);
|
|
1507
1560
|
// Deliberately not cached: the value holds only at this level, and the cache key carries none.
|
|
1508
1561
|
// Constraint-only composition members must not replace a sibling's required fields with the depth marker.
|
|
1509
|
-
|
|
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;
|
|
1510
1564
|
return getMaxDepthValue(_schema, options, schemaPath, undefined, fallback);
|
|
1511
1565
|
}
|
|
1512
1566
|
requiredSteps--;
|
|
@@ -1526,7 +1580,8 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
|
|
|
1526
1580
|
const selectedVariant = getSelectedVariant(_schema, options, schemaPath);
|
|
1527
1581
|
if (selectedComposition && selectedVariant) {
|
|
1528
1582
|
const selectedType = getSelectedType(selectedVariant, _schema);
|
|
1529
|
-
|
|
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)) {
|
|
1530
1585
|
if (seen.has(getSchemaCacheTarget(selectedVariant))) {
|
|
1531
1586
|
seen.delete(targetValue);
|
|
1532
1587
|
return undefined;
|
|
@@ -1663,11 +1718,8 @@ const asBinaryFile = (schema, value, options, schemaPath = []) => {
|
|
|
1663
1718
|
}
|
|
1664
1719
|
return value;
|
|
1665
1720
|
};
|
|
1666
|
-
/**
|
|
1667
|
-
|
|
1668
|
-
* Treat returned values as read-only: cached results and padded items can share object references.
|
|
1669
|
-
*/
|
|
1670
|
-
export const getExampleFromSchema = (schema, options, context = {}) => {
|
|
1721
|
+
/** Generate data for one schema within the attempt in progress. */
|
|
1722
|
+
const generateWithCapture = (schema, options, context = {}) => {
|
|
1671
1723
|
if (schema && typeof schema === 'object' && '$schema' in schema && typeof schema.$schema === 'string') {
|
|
1672
1724
|
options = { ...options, jsonSchemaDialect: schema.$schema };
|
|
1673
1725
|
}
|
|
@@ -1700,3 +1752,54 @@ export const getExampleFromSchema = (schema, options, context = {}) => {
|
|
|
1700
1752
|
capture.stack.pop();
|
|
1701
1753
|
}
|
|
1702
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
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MultipartNaming } from '@scalar/types/api-reference';
|
|
1
2
|
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
2
3
|
import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
3
4
|
import type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
@@ -157,6 +158,8 @@ export type RequestFactory = {
|
|
|
157
158
|
* List of all security requirements for this request (e.g., API key, OAuth2, etc.)
|
|
158
159
|
* Each entry reflects a selected Security Scheme.
|
|
159
160
|
* Values (e.g., tokens, secrets) may still be unsubstituted at this point.
|
|
161
|
+
* Header API-key prefixes are carried separately in `tokenPrefix`. Consumers using
|
|
162
|
+
* `disableSecurity` must resolve variables and apply authentication formatting themselves.
|
|
160
163
|
*/
|
|
161
164
|
security: BuildRequestSecurityResult[];
|
|
162
165
|
/**
|
|
@@ -185,7 +188,7 @@ export type RequestFactory = {
|
|
|
185
188
|
* Builds a request object fastory which can be used to build a request object.
|
|
186
189
|
* @returns A request object factory
|
|
187
190
|
*/
|
|
188
|
-
export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, }: RequestExampleMeta & {
|
|
191
|
+
export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, multipartNaming, }: RequestExampleMeta & {
|
|
189
192
|
/** The operation object */
|
|
190
193
|
operation: OperationObject;
|
|
191
194
|
/** For environment variables in the inputs */
|
|
@@ -208,6 +211,7 @@ export declare const requestFactory: ({ exampleName, globalCookies, method, oper
|
|
|
208
211
|
/** Document default for schema resources without $schema. */
|
|
209
212
|
jsonSchemaDialect?: string;
|
|
210
213
|
requestBodyCompositionSelection?: Record<string, number>;
|
|
214
|
+
multipartNaming?: MultipartNaming;
|
|
211
215
|
}) => {
|
|
212
216
|
request: RequestFactory;
|
|
213
217
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"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"}
|
|
@@ -12,7 +12,7 @@ import { buildRequestParameters } from './header/build-request-parameters.js';
|
|
|
12
12
|
* Builds a request object fastory which can be used to build a request object.
|
|
13
13
|
* @returns A request object factory
|
|
14
14
|
*/
|
|
15
|
-
export const requestFactory = ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, }) => {
|
|
15
|
+
export const requestFactory = ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, multipartNaming, }) => {
|
|
16
16
|
const requestBody = getResolvedRef(operation.requestBody);
|
|
17
17
|
/** Build out the request parameters */
|
|
18
18
|
const params = buildRequestParameters(operation.parameters ?? [], exampleName, openapiVersion);
|
|
@@ -29,7 +29,9 @@ export const requestFactory = ({ exampleName, globalCookies, method, operation,
|
|
|
29
29
|
});
|
|
30
30
|
// If the method can have a body, build the request body, otherwise set it to null
|
|
31
31
|
const body = canMethodHaveBody(method)
|
|
32
|
-
? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect
|
|
32
|
+
? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect, {
|
|
33
|
+
multipartNaming,
|
|
34
|
+
})
|
|
33
35
|
: null;
|
|
34
36
|
// Delete the Content-Type header so the browser will set it automatically based on the request body
|
|
35
37
|
if (body?.mode === 'formdata' || body?.mode === 'urlencoded') {
|
|
@@ -24,9 +24,9 @@ import type { SecuritySchemeObjectSecret } from './secret-types.js';
|
|
|
24
24
|
* - `'bearer'`: HTTP Bearer token.
|
|
25
25
|
* - Not present for schemes without a special format (e.g., generic API keys).
|
|
26
26
|
*
|
|
27
|
-
* - `value`: The
|
|
28
|
-
* -
|
|
29
|
-
*
|
|
27
|
+
* - `value`: The raw credential, before environment substitution or authentication formatting.
|
|
28
|
+
* - HTTP Basic credentials use `username:password`; HTTP Bearer and API keys carry the token.
|
|
29
|
+
* - Apply `format` or `tokenPrefix` after resolving credential variables.
|
|
30
30
|
*
|
|
31
31
|
* NOTE: This type does not capture UI display info, secret labels, or environment binding.
|
|
32
32
|
* It is intended purely for producing the final request input object. Multiple
|
|
@@ -40,8 +40,10 @@ export type BuildRequestSecurityResult = {
|
|
|
40
40
|
name: string;
|
|
41
41
|
/** Format code for HTTP schemes (e.g., 'basic' | 'bearer'), if relevant */
|
|
42
42
|
format?: 'basic' | 'bearer';
|
|
43
|
+
/** Explicit header API-key prefix, applied after resolving credential variables. */
|
|
44
|
+
tokenPrefix?: string;
|
|
43
45
|
/**
|
|
44
|
-
* The
|
|
46
|
+
* The raw credential. Resolve environment variables, then apply `format` or `tokenPrefix` before sending.
|
|
45
47
|
*/
|
|
46
48
|
value: string;
|
|
47
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;yBACnC,0BAA0B,EAAE;AACrD,qEAAqE;mCAEpE,0BAA0B,
|
|
1
|
+
{"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B,oFAAoF;IACpF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;yBACnC,0BAA0B,EAAE;AACrD,qEAAqE;mCAEpE,0BAA0B,EA6F5B,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { ApiKeyObjectSecret, BuildRequestData, BuildRequestFailureCode, BuildRequestResult, EncryptionObjectSecret, GssapiObjectSecret, HttpObjectSecret, OAuth2ObjectSecret, OAuthFlowAuthorizationCodeSecret, OAuthFlowClientCredentialsSecret, OAuthFlowDeviceAuthorizationSecret, OAuthFlowImplicitSecret, OAuthFlowPasswordSecret, OAuthFlowsObjectSecret, OpenIdConnectObjectSecret, RequestPayload, ResolveRequestFactoryUrlError, ResolveRequestFactoryUrlResult, SaslObjectSecret, SecuritySchemeObjectSecret, X509ObjectSecret, } from './builder/index.js';
|
|
2
2
|
export { BUILD_REQUEST_FAILED, INVALID_REQUEST_FACTORY_URL, MISSING_REQUEST_SERVER_BASE, type RequestFactory, type SerializedFormProperty, buildDottedNestedRowPredicate, buildRequest, buildRequestSecurity, coerceLeafValueToSchemaType, coerceUntypedValue, deSerializeParameter, deSerializeSchemaValue, filterDisabledProperties, filterGlobalCookie, getEnvironmentVariables, getExample, getExampleFromBody, getExampleFromSchema, getResolvedUrl, getSchemaExampleFromBody, getSelectedBodyContentType, getServerVariables, isEncryptionSchemeType, isParamDisabled, isSaslSchemeType, requestFactory, resolveExecutableRequestUrl, resolveLeafSchema, resolveRequestFactoryUrl, serializeContentValue, serializeCookieStyle, serializeDeepObjectStyle, serializeFormPropertyWithEncoding, serializeFormStyle, serializeFormStyleForCookies, serializeMultipartArray, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './builder/index.js';
|
|
3
|
+
export { getAspNetFormFields, usesAspNetFormNaming, } from './builder/body/aspnet-form-fields.js';
|
|
3
4
|
export { getMultipartItemSchema, needsMultipartEncoding } from './builder/body/build-multipart.js';
|
|
4
5
|
export { buildRequestBody } from './builder/body/build-request-body.js';
|
|
5
6
|
export { serializeMultipartBody } from './builder/body/encode-multipart-body.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,6BAA6B,EAC7B,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,2BAA2B,EAC3B,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,iCAAiC,EACjC,kBAAkB,EAClB,4BAA4B,EAC5B,uBAAuB,EACvB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AACvE,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EACL,KAAK,0BAA0B,EAC/B,aAAa,EACb,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,aAAa,EACb,qCAAqC,EACrC,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAA;AAClG,OAAO,EACL,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,6BAA6B,EAC7B,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,6BAA6B,EAC7B,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,2BAA2B,EAC3B,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,iCAAiC,EACjC,kBAAkB,EAClB,4BAA4B,EAC5B,uBAAuB,EACvB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AACvE,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EACL,KAAK,0BAA0B,EAC/B,aAAa,EACb,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,aAAa,EACb,qCAAqC,EACrC,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAA;AAClG,OAAO,EACL,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,6BAA6B,EAC7B,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BUILD_REQUEST_FAILED, INVALID_REQUEST_FACTORY_URL, MISSING_REQUEST_SERVER_BASE, buildDottedNestedRowPredicate, buildRequest, buildRequestSecurity, coerceLeafValueToSchemaType, coerceUntypedValue, deSerializeParameter, deSerializeSchemaValue, filterDisabledProperties, filterGlobalCookie, getEnvironmentVariables, getExample, getExampleFromBody, getExampleFromSchema, getResolvedUrl, getSchemaExampleFromBody, getSelectedBodyContentType, getServerVariables, isEncryptionSchemeType, isParamDisabled, isSaslSchemeType, requestFactory, resolveExecutableRequestUrl, resolveLeafSchema, resolveRequestFactoryUrl, serializeContentValue, serializeCookieStyle, serializeDeepObjectStyle, serializeFormPropertyWithEncoding, serializeFormStyle, serializeFormStyleForCookies, serializeMultipartArray, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './builder/index.js';
|
|
2
|
+
export { getAspNetFormFields, usesAspNetFormNaming, } from './builder/body/aspnet-form-fields.js';
|
|
2
3
|
export { getMultipartItemSchema, needsMultipartEncoding } from './builder/body/build-multipart.js';
|
|
3
4
|
export { buildRequestBody } from './builder/body/build-request-body.js';
|
|
4
5
|
export { serializeMultipartBody } from './builder/body/encode-multipart-body.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A prefix added to header API keys only, separated from the credential by one space. */
|
|
2
|
+
export type XScalarTokenPrefix = {
|
|
3
|
+
'x-scalar-token-prefix'?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const XScalarTokenPrefixSchema: import("@scalar/typebox").TObject<{
|
|
6
|
+
'x-scalar-token-prefix': import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const XScalarTokenPrefix: import("@scalar/validation").ObjectSchema<{
|
|
9
|
+
'x-scalar-token-prefix': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=x-scalar-token-prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x-scalar-token-prefix.d.ts","sourceRoot":"","sources":["../../../../src/schemas/extensions/security/x-scalar-token-prefix.ts"],"names":[],"mappings":"AAGA,0FAA0F;AAC1F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,wBAAwB;;EAEnC,CAAA;AAEF,eAAO,MAAM,kBAAkB;;EAE7B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Type } from '@scalar/typebox';
|
|
2
|
+
import { object, optional, string } from '@scalar/validation';
|
|
3
|
+
export const XScalarTokenPrefixSchema = Type.Object({
|
|
4
|
+
'x-scalar-token-prefix': Type.Optional(Type.String()),
|
|
5
|
+
});
|
|
6
|
+
export const XScalarTokenPrefix = object({
|
|
7
|
+
'x-scalar-token-prefix': optional(string()),
|
|
8
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
2
|
import type { AsyncApiInfoObject } from '@scalar/types/asyncapi/3.1';
|
|
3
3
|
import type { LiteralUnion } from 'type-fest';
|
|
4
|
+
import { type XBadge } from './extensions/operation/x-badge.js';
|
|
4
5
|
import type { ExternalDocumentationObject } from './v3.2/strict/external-documentation.js';
|
|
5
6
|
import type { InfoObject } from './v3.2/strict/info.js';
|
|
6
7
|
import type { OperationObject } from './v3.2/strict/operation.js';
|
|
@@ -85,6 +86,11 @@ export declare const TraversedOperationSchemaDefinition: import("@scalar/typebox
|
|
|
85
86
|
method: import("@scalar/typebox").TString;
|
|
86
87
|
path: import("@scalar/typebox").TString;
|
|
87
88
|
isDeprecated: import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
|
|
89
|
+
badges: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TObject<{
|
|
90
|
+
name: import("@scalar/typebox").TString;
|
|
91
|
+
position: import("@scalar/typebox").TOptional<import("@scalar/typebox").TUnion<[import("@scalar/typebox").TLiteral<"before">, import("@scalar/typebox").TLiteral<"after">]>>;
|
|
92
|
+
color: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
|
|
93
|
+
}>>>;
|
|
88
94
|
children: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TRef<"TraversedEntryObject">>>;
|
|
89
95
|
}>]>;
|
|
90
96
|
/**
|
|
@@ -96,6 +102,8 @@ export type TraversedOperation = BaseSchema & {
|
|
|
96
102
|
method: OperationMethod;
|
|
97
103
|
path: string;
|
|
98
104
|
isDeprecated?: boolean;
|
|
105
|
+
/** Badges from the `x-badges` extension of the operation */
|
|
106
|
+
badges?: XBadge[];
|
|
99
107
|
children?: TraversedEntry[];
|
|
100
108
|
};
|
|
101
109
|
export declare const TraversedAsyncApiOperationSchemaDefinition: import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
|
|
@@ -170,6 +178,11 @@ export declare const TraversedSchemaSchemaDefinition: import("@scalar/typebox").
|
|
|
170
178
|
type: import("@scalar/typebox").TLiteral<"model">;
|
|
171
179
|
ref: import("@scalar/typebox").TString;
|
|
172
180
|
name: import("@scalar/typebox").TString;
|
|
181
|
+
badges: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TObject<{
|
|
182
|
+
name: import("@scalar/typebox").TString;
|
|
183
|
+
position: import("@scalar/typebox").TOptional<import("@scalar/typebox").TUnion<[import("@scalar/typebox").TLiteral<"before">, import("@scalar/typebox").TLiteral<"after">]>>;
|
|
184
|
+
color: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
|
|
185
|
+
}>>>;
|
|
173
186
|
}>]>;
|
|
174
187
|
/**
|
|
175
188
|
* An entry representing a model in the navigation structure.
|
|
@@ -178,6 +191,8 @@ export type TraversedSchema = BaseSchema & {
|
|
|
178
191
|
type: 'model';
|
|
179
192
|
ref: string;
|
|
180
193
|
name: string;
|
|
194
|
+
/** Badges from the `x-badges` extension of the schema */
|
|
195
|
+
badges?: XBadge[];
|
|
181
196
|
};
|
|
182
197
|
export declare const TraversedWebhookSchemaDefinition: import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
|
|
183
198
|
id: import("@scalar/typebox").TString;
|
|
@@ -188,6 +203,11 @@ export declare const TraversedWebhookSchemaDefinition: import("@scalar/typebox")
|
|
|
188
203
|
method: import("@scalar/typebox").TString;
|
|
189
204
|
name: import("@scalar/typebox").TString;
|
|
190
205
|
isDeprecated: import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
|
|
206
|
+
badges: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TObject<{
|
|
207
|
+
name: import("@scalar/typebox").TString;
|
|
208
|
+
position: import("@scalar/typebox").TOptional<import("@scalar/typebox").TUnion<[import("@scalar/typebox").TLiteral<"before">, import("@scalar/typebox").TLiteral<"after">]>>;
|
|
209
|
+
color: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
|
|
210
|
+
}>>>;
|
|
191
211
|
}>]>;
|
|
192
212
|
/**
|
|
193
213
|
* An entry representing a webhook in the navigation structure.
|
|
@@ -198,6 +218,8 @@ export type TraversedWebhook = BaseSchema & {
|
|
|
198
218
|
method: OperationMethod;
|
|
199
219
|
name: string;
|
|
200
220
|
isDeprecated?: boolean;
|
|
221
|
+
/** Badges from the `x-badges` extension of the webhook operation */
|
|
222
|
+
badges?: XBadge[];
|
|
201
223
|
};
|
|
202
224
|
export declare const TraversedTagSchemaDefinition: import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
|
|
203
225
|
id: import("@scalar/typebox").TString;
|
|
@@ -211,6 +233,11 @@ export declare const TraversedTagSchemaDefinition: import("@scalar/typebox").TIn
|
|
|
211
233
|
isGroup: import("@scalar/typebox").TBoolean;
|
|
212
234
|
isTagGroup: import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
|
|
213
235
|
isWebhooks: import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
|
|
236
|
+
badges: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TObject<{
|
|
237
|
+
name: import("@scalar/typebox").TString;
|
|
238
|
+
position: import("@scalar/typebox").TOptional<import("@scalar/typebox").TUnion<[import("@scalar/typebox").TLiteral<"before">, import("@scalar/typebox").TLiteral<"after">]>>;
|
|
239
|
+
color: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
|
|
240
|
+
}>>>;
|
|
214
241
|
xKeys: import("@scalar/typebox").TOptional<import("@scalar/typebox").TRecord<import("@scalar/typebox").TString, import("@scalar/typebox").TUnknown>>;
|
|
215
242
|
}>]>;
|
|
216
243
|
/**
|
|
@@ -232,6 +259,8 @@ export type TraversedTag = BaseSchema & {
|
|
|
232
259
|
*/
|
|
233
260
|
isTagGroup?: boolean;
|
|
234
261
|
isWebhooks?: boolean;
|
|
262
|
+
/** Badges from the `x-badges` extension of the tag or the `x-tagGroups` entry */
|
|
263
|
+
badges?: XBadge[];
|
|
235
264
|
xKeys?: Record<string, unknown>;
|
|
236
265
|
};
|
|
237
266
|
export declare const TraversedModelsSchemaDefinition: import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
|
|
@@ -288,6 +317,11 @@ export declare const TraversedEntrySchemaDefinition: import("@scalar/typebox").T
|
|
|
288
317
|
method: import("@scalar/typebox").TString;
|
|
289
318
|
path: import("@scalar/typebox").TString;
|
|
290
319
|
isDeprecated: import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
|
|
320
|
+
badges: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TObject<{
|
|
321
|
+
name: import("@scalar/typebox").TString;
|
|
322
|
+
position: import("@scalar/typebox").TOptional<import("@scalar/typebox").TUnion<[import("@scalar/typebox").TLiteral<"before">, import("@scalar/typebox").TLiteral<"after">]>>;
|
|
323
|
+
color: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
|
|
324
|
+
}>>>;
|
|
291
325
|
children: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TRef<"TraversedEntryObject">>>;
|
|
292
326
|
}>]>, import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
|
|
293
327
|
id: import("@scalar/typebox").TString;
|
|
@@ -321,6 +355,11 @@ export declare const TraversedEntrySchemaDefinition: import("@scalar/typebox").T
|
|
|
321
355
|
type: import("@scalar/typebox").TLiteral<"model">;
|
|
322
356
|
ref: import("@scalar/typebox").TString;
|
|
323
357
|
name: import("@scalar/typebox").TString;
|
|
358
|
+
badges: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TObject<{
|
|
359
|
+
name: import("@scalar/typebox").TString;
|
|
360
|
+
position: import("@scalar/typebox").TOptional<import("@scalar/typebox").TUnion<[import("@scalar/typebox").TLiteral<"before">, import("@scalar/typebox").TLiteral<"after">]>>;
|
|
361
|
+
color: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
|
|
362
|
+
}>>>;
|
|
324
363
|
}>]>, import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
|
|
325
364
|
id: import("@scalar/typebox").TString;
|
|
326
365
|
title: import("@scalar/typebox").TString;
|
|
@@ -333,6 +372,11 @@ export declare const TraversedEntrySchemaDefinition: import("@scalar/typebox").T
|
|
|
333
372
|
isGroup: import("@scalar/typebox").TBoolean;
|
|
334
373
|
isTagGroup: import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
|
|
335
374
|
isWebhooks: import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
|
|
375
|
+
badges: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TObject<{
|
|
376
|
+
name: import("@scalar/typebox").TString;
|
|
377
|
+
position: import("@scalar/typebox").TOptional<import("@scalar/typebox").TUnion<[import("@scalar/typebox").TLiteral<"before">, import("@scalar/typebox").TLiteral<"after">]>>;
|
|
378
|
+
color: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
|
|
379
|
+
}>>>;
|
|
336
380
|
xKeys: import("@scalar/typebox").TOptional<import("@scalar/typebox").TRecord<import("@scalar/typebox").TString, import("@scalar/typebox").TUnknown>>;
|
|
337
381
|
}>]>, import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
|
|
338
382
|
id: import("@scalar/typebox").TString;
|
|
@@ -343,6 +387,11 @@ export declare const TraversedEntrySchemaDefinition: import("@scalar/typebox").T
|
|
|
343
387
|
method: import("@scalar/typebox").TString;
|
|
344
388
|
name: import("@scalar/typebox").TString;
|
|
345
389
|
isDeprecated: import("@scalar/typebox").TOptional<import("@scalar/typebox").TBoolean>;
|
|
390
|
+
badges: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TObject<{
|
|
391
|
+
name: import("@scalar/typebox").TString;
|
|
392
|
+
position: import("@scalar/typebox").TOptional<import("@scalar/typebox").TUnion<[import("@scalar/typebox").TLiteral<"before">, import("@scalar/typebox").TLiteral<"after">]>>;
|
|
393
|
+
color: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
|
|
394
|
+
}>>>;
|
|
346
395
|
}>]>, import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
|
|
347
396
|
id: import("@scalar/typebox").TString;
|
|
348
397
|
title: import("@scalar/typebox").TString;
|