@scalar/workspace-store 0.60.0 → 0.62.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 +68 -0
- package/README.md +6 -0
- package/dist/channel-example/build-connection-url.d.ts.map +1 -1
- package/dist/channel-example/build-connection-url.js +3 -3
- package/dist/channel-example/dedupe-requirements.d.ts +1 -1
- package/dist/channel-example/get-async-api-protocols.js +2 -2
- package/dist/channel-example/get-asyncapi-security-requirements.d.ts +1 -1
- package/dist/channel-example/get-channel-connection-security.d.ts +1 -1
- package/dist/channel-example/get-channel-operations.d.ts.map +1 -1
- package/dist/channel-example/get-channel-operations.js +4 -1
- package/dist/channel-example/get-channel-parameters.d.ts.map +1 -1
- package/dist/channel-example/get-channel-parameters.js +3 -1
- package/dist/channel-example/resolve-channel.d.ts.map +1 -1
- package/dist/channel-example/resolve-channel.js +2 -0
- package/dist/channel-example/resolve-operation-channel.d.ts.map +1 -1
- package/dist/channel-example/resolve-operation-channel.js +4 -0
- package/dist/channel-example/resolve-operation-with-traits.js +2 -2
- package/dist/channel-example/servers.d.ts.map +1 -1
- package/dist/channel-example/servers.js +3 -1
- package/dist/channel-example/types.d.ts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +10 -4
- package/dist/entities/auth/schema.d.ts +640 -200
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/entities/auth/schema.js +2 -2
- package/dist/events/definitions/auth.d.ts +2 -2
- package/dist/events/definitions/document.d.ts +1 -1
- package/dist/events/definitions/operation.d.ts +3 -2
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/events/definitions/server.d.ts +1 -1
- package/dist/events/old-definitions.d.ts +1 -1
- package/dist/helpers/create-chunk-writer.d.ts +6 -0
- package/dist/helpers/create-chunk-writer.d.ts.map +1 -0
- package/dist/helpers/create-chunk-writer.js +44 -0
- package/dist/helpers/dynamic-ref.d.ts +13 -2
- package/dist/helpers/dynamic-ref.d.ts.map +1 -1
- package/dist/helpers/dynamic-ref.js +20 -7
- package/dist/helpers/encode-chunk-name.d.ts +3 -0
- package/dist/helpers/encode-chunk-name.d.ts.map +1 -0
- package/dist/helpers/encode-chunk-name.js +9 -0
- package/dist/helpers/for-each-path-item-operation.d.ts +2 -2
- package/dist/helpers/get-first-server.d.ts +1 -1
- package/dist/helpers/get-resolved-ref-deep.d.ts +1 -1
- package/dist/helpers/get-resolved-ref-deep.d.ts.map +1 -1
- package/dist/helpers/get-resolved-ref.d.ts +6 -1
- package/dist/helpers/get-resolved-ref.d.ts.map +1 -1
- package/dist/helpers/get-resolved-ref.js +3 -10
- package/dist/helpers/is-non-optional-security-requirement.d.ts +1 -1
- package/dist/helpers/merge-object.d.ts +2 -2
- package/dist/helpers/merge-object.d.ts.map +1 -1
- package/dist/helpers/merge-object.js +2 -5
- package/dist/mutators/auth.d.ts +1 -1
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +9 -4
- package/dist/mutators/index.d.ts +10 -10
- package/dist/mutators/operation/body.js +2 -2
- package/dist/mutators/operation/helpers/fetch-request-to-har.d.ts.map +1 -1
- package/dist/mutators/operation/helpers/fetch-request-to-har.js +12 -2
- package/dist/mutators/operation/helpers/har-to-operation.d.ts +1 -1
- package/dist/mutators/operation/helpers/har-to-operation.d.ts.map +1 -1
- package/dist/mutators/operation/helpers/har-to-operation.js +9 -5
- package/dist/mutators/operation/helpers/sync-path-parameters.d.ts +2 -2
- package/dist/mutators/operation/history.js +2 -2
- package/dist/mutators/operation/operation.d.ts.map +1 -1
- package/dist/mutators/operation/operation.js +4 -0
- package/dist/mutators/operation/parameters.js +1 -1
- package/dist/mutators/server.d.ts +3 -3
- package/dist/mutators/server.js +1 -1
- package/dist/mutators/tag.d.ts.map +1 -1
- package/dist/mutators/tag.js +4 -0
- package/dist/navigation/helpers/get-openapi-object.d.ts +1 -1
- package/dist/navigation/helpers/traverse-asyncapi-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-asyncapi-document.js +2 -2
- package/dist/navigation/helpers/traverse-description.d.ts +1 -1
- package/dist/navigation/helpers/traverse-document.d.ts +1 -1
- package/dist/navigation/helpers/traverse-examples.d.ts +12 -1
- package/dist/navigation/helpers/traverse-examples.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-examples.js +22 -1
- package/dist/navigation/helpers/traverse-paths.d.ts +1 -1
- package/dist/navigation/helpers/traverse-schemas.d.ts +1 -1
- package/dist/navigation/helpers/traverse-tags.d.ts +1 -1
- package/dist/navigation/helpers/traverse-webhooks.d.ts +1 -1
- package/dist/navigation/helpers/update-order-ids.d.ts +2 -2
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/types.d.ts +1 -1
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +10 -10
- package/dist/persistence/indexdb.d.ts.map +1 -1
- package/dist/persistence/indexdb.js +7 -5
- package/dist/persistence/migrations/v2-team-to-local.d.ts.map +1 -1
- package/dist/persistence/migrations/v2-team-to-local.js +3 -4
- package/dist/plugins/bundler/index.d.ts +5 -2
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +24 -26
- package/dist/request-example/builder/body/build-request-body.d.ts +2 -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 +41 -5
- package/dist/request-example/builder/body/encode-multipart-body.d.ts +9 -0
- package/dist/request-example/builder/body/encode-multipart-body.d.ts.map +1 -0
- package/dist/request-example/builder/body/encode-multipart-body.js +29 -0
- package/dist/request-example/builder/body/get-request-body-example.d.ts +1 -1
- package/dist/request-example/builder/body/get-selected-body-content-type.d.ts +1 -1
- package/dist/request-example/builder/body/schema-value-coercion.d.ts +1 -1
- package/dist/request-example/builder/body/schema-value-coercion.js +1 -1
- package/dist/request-example/builder/body/serialize-form-property.d.ts +1 -1
- package/dist/request-example/builder/body/serialize-multipart-array.d.ts +16 -0
- package/dist/request-example/builder/body/serialize-multipart-array.d.ts.map +1 -0
- package/dist/request-example/builder/body/serialize-multipart-array.js +37 -0
- package/dist/request-example/builder/build-request.d.ts.map +1 -1
- package/dist/request-example/builder/build-request.js +14 -8
- package/dist/request-example/builder/header/build-request-parameters.d.ts +1 -1
- package/dist/request-example/builder/header/build-request-parameters.d.ts.map +1 -1
- package/dist/request-example/builder/header/build-request-parameters.js +7 -1
- package/dist/request-example/builder/header/de-serialize-parameter.d.ts +1 -1
- package/dist/request-example/builder/header/de-serialize-parameter.d.ts.map +1 -1
- package/dist/request-example/builder/header/de-serialize-parameter.js +2 -1
- package/dist/request-example/builder/header/is-param-disabled.d.ts +1 -1
- package/dist/request-example/builder/header/serialize-parameter.d.ts.map +1 -1
- package/dist/request-example/builder/header/serialize-parameter.js +13 -14
- package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +9 -1
- 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 +255 -20
- package/dist/request-example/builder/helpers/get-example.d.ts +1 -1
- package/dist/request-example/builder/helpers/get-example.js +2 -2
- package/dist/request-example/builder/helpers/get-resolved-url.d.ts +1 -1
- package/dist/request-example/builder/helpers/get-server-variables.d.ts +1 -1
- package/dist/request-example/builder/index.d.ts +1 -0
- package/dist/request-example/builder/index.d.ts.map +1 -1
- package/dist/request-example/builder/index.js +1 -0
- package/dist/request-example/builder/request-factory.d.ts +2 -2
- package/dist/request-example/builder/security/broker-scheme-types.d.ts.map +1 -1
- package/dist/request-example/builder/security/broker-scheme-types.js +2 -2
- package/dist/request-example/builder/security/build-request-security.d.ts.map +1 -1
- package/dist/request-example/builder/security/build-request-security.js +3 -4
- package/dist/request-example/builder/security/secret-types.d.ts +13 -4
- package/dist/request-example/builder/security/secret-types.d.ts.map +1 -1
- package/dist/request-example/context/get-request-example-context.d.ts +3 -3
- package/dist/request-example/context/get-request-example-context.js +1 -1
- package/dist/request-example/context/headers.d.ts +1 -1
- package/dist/request-example/context/headers.js +1 -1
- package/dist/request-example/context/helpers/combine-params.d.ts +1 -1
- package/dist/request-example/context/security/extract-security-scheme-secrets.d.ts +16 -3
- package/dist/request-example/context/security/extract-security-scheme-secrets.d.ts.map +1 -1
- package/dist/request-example/context/security/extract-security-scheme-secrets.js +21 -19
- package/dist/request-example/context/security/get-security-requirements.d.ts +2 -2
- package/dist/request-example/context/security/get-security-schemes.d.ts +1 -1
- package/dist/request-example/context/security/get-selected-security.d.ts +1 -1
- package/dist/request-example/context/security/is-auth-optional.d.ts +1 -1
- package/dist/request-example/context/security/merge-security.d.ts +3 -3
- package/dist/request-example/context/security/merge-security.d.ts.map +1 -1
- package/dist/request-example/context/security/merge-security.js +40 -11
- package/dist/request-example/context/servers.d.ts +2 -2
- package/dist/request-example/functions.d.ts.map +1 -1
- package/dist/request-example/index.d.ts +1 -1
- package/dist/request-example/index.d.ts.map +1 -1
- package/dist/request-example/index.js +1 -1
- package/dist/resolve.d.ts +1 -1
- package/dist/resolve.js +1 -1
- package/dist/schemas/navigation.d.ts +4 -4
- package/dist/schemas/navigation.js +1 -1
- package/dist/schemas/reference-config/index.d.ts +128 -40
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +129 -41
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.js +1 -1
- package/dist/schemas/type-guards.d.ts +1 -1
- package/dist/schemas/v3.1/openapi/index.d.ts.map +1 -1
- package/dist/schemas/v3.1/openapi/index.js +11 -1
- package/dist/schemas/v3.1/strict/callback.d.ts +1 -1
- package/dist/schemas/v3.1/strict/components.d.ts +11 -11
- package/dist/schemas/v3.1/strict/encoding.d.ts +1 -1
- package/dist/schemas/v3.1/strict/header.d.ts +2 -2
- package/dist/schemas/v3.1/strict/media-type.d.ts +2 -2
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +1470 -1260
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.d.ts +3 -3
- package/dist/schemas/v3.1/strict/parameter.d.ts +2 -2
- package/dist/schemas/v3.1/strict/path-item.d.ts +10 -10
- package/dist/schemas/v3.1/strict/paths.d.ts +1 -1
- package/dist/schemas/v3.1/strict/reference.d.ts +14 -2
- package/dist/schemas/v3.1/strict/reference.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/reference.js +13 -1
- package/dist/schemas/v3.1/strict/response.d.ts +2 -2
- package/dist/schemas/v3.1/strict/responses.d.ts +1 -1
- package/dist/schemas/v3.1/strict/security-scheme.d.ts +13 -1
- package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/security-scheme.js +11 -1
- package/dist/schemas/v3.2/openapi/index.d.ts +2 -0
- package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
- package/dist/schemas/v3.2/openapi/index.js +16 -1
- package/dist/schemas/v3.2/strict/callback.d.ts +1 -1
- package/dist/schemas/v3.2/strict/components.d.ts +12 -12
- package/dist/schemas/v3.2/strict/encoding.d.ts +1 -1
- package/dist/schemas/v3.2/strict/header.d.ts +2 -2
- package/dist/schemas/v3.2/strict/media-type.d.ts +3 -3
- package/dist/schemas/v3.2/strict/oauth-flow.d.ts +23 -1
- package/dist/schemas/v3.2/strict/oauth-flow.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/oauth-flow.js +6 -1
- package/dist/schemas/v3.2/strict/oauthflows.d.ts +20 -0
- package/dist/schemas/v3.2/strict/oauthflows.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/openapi-document.d.ts +2839 -1541
- package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/openapi-document.js +2 -1
- package/dist/schemas/v3.2/strict/operation.d.ts +3 -3
- package/dist/schemas/v3.2/strict/parameter.d.ts +2 -2
- package/dist/schemas/v3.2/strict/path-item.d.ts +12 -12
- package/dist/schemas/v3.2/strict/paths.d.ts +1 -1
- package/dist/schemas/v3.2/strict/reference.d.ts +14 -2
- package/dist/schemas/v3.2/strict/reference.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/reference.js +13 -1
- package/dist/schemas/v3.2/strict/response.d.ts +2 -2
- package/dist/schemas/v3.2/strict/responses.d.ts +1 -1
- package/dist/schemas/v3.2/strict/security-scheme.d.ts +31 -8
- package/dist/schemas/v3.2/strict/security-scheme.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/security-scheme.js +17 -4
- package/dist/schemas/workspace-specification/index.d.ts +1 -1
- package/dist/schemas/workspace.d.ts +1 -1
- package/dist/server.d.ts +28 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +41 -27
- package/package.json +10 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isDefined } from '@scalar/helpers/array/is-defined';
|
|
2
|
+
import { escapeJsonPointer } from '@scalar/helpers/json/escape-json-pointer';
|
|
2
3
|
import { isDynamicRef, pushDynamicScope, resolveDynamicRef } from '../../../helpers/dynamic-ref.js';
|
|
3
4
|
import { unpackProxyObject } from '../../../helpers/unpack-proxy.js';
|
|
4
5
|
import { resolve } from '../../../resolve.js';
|
|
@@ -70,7 +71,10 @@ const guessFromFormat = (schema, makeUpRandomData = false, fallback = '') => {
|
|
|
70
71
|
}
|
|
71
72
|
// Return format-specific example if we have one and are making up data
|
|
72
73
|
if (makeUpRandomData && 'format' in schema && schema.format) {
|
|
73
|
-
|
|
74
|
+
// Some generators emit version-specific UUID formats (for example FastAPI/Pydantic
|
|
75
|
+
// uses uuid1, uuid3, uuid4 and uuid5). Treat them all like a regular uuid.
|
|
76
|
+
const format = /^uuid[1-8]$/.test(schema.format) ? 'uuid' : schema.format;
|
|
77
|
+
return genericExampleValues[format] ?? fallback;
|
|
74
78
|
}
|
|
75
79
|
return fallback;
|
|
76
80
|
};
|
|
@@ -79,6 +83,18 @@ const guessFromFormat = (schema, makeUpRandomData = false, fallback = '') => {
|
|
|
79
83
|
* Uses the resolved schema object as the key for efficient lookups.
|
|
80
84
|
*/
|
|
81
85
|
const resultCache = new WeakMap();
|
|
86
|
+
/**
|
|
87
|
+
* Set once the depth cap has truncated something in the current top-level call.
|
|
88
|
+
*
|
|
89
|
+
* A truncated value only holds at the level it was produced at, but `resultCache` keys carry no level,
|
|
90
|
+
* so a value assembled around one must not be stored. Composition reaches that case: an `allOf` member
|
|
91
|
+
* climbs a level without growing `schemaPath`, so a schema rendered just above the cap in one chain
|
|
92
|
+
* shares its key with the same schema used at the top of a document, and the shallow use is served the
|
|
93
|
+
* truncated result. Widening the key would cost the cache its hits everywhere, so storing simply stops
|
|
94
|
+
* for the rest of the call instead. The walk is synchronous, so resetting at level 0 scopes this to one
|
|
95
|
+
* top-level call.
|
|
96
|
+
*/
|
|
97
|
+
let truncated = false;
|
|
82
98
|
/** Cache required property names per parent schema for O(1) membership checks */
|
|
83
99
|
const requiredNamesCache = new WeakMap();
|
|
84
100
|
/** Normalize schema identity for cache and cycle tracking */
|
|
@@ -115,7 +131,7 @@ const getRequiredNames = (parentSchema) => {
|
|
|
115
131
|
* identity would leak one scope's result into another.
|
|
116
132
|
*/
|
|
117
133
|
const cache = (schema, result, cacheKey, skip = false) => {
|
|
118
|
-
if (skip || typeof result !== 'object' || result === null) {
|
|
134
|
+
if (skip || truncated || typeof result !== 'object' || result === null) {
|
|
119
135
|
return result;
|
|
120
136
|
}
|
|
121
137
|
const rawSchema = getSchemaCacheTarget(schema);
|
|
@@ -136,8 +152,8 @@ const isComposed = (schema) => !!(schema.allOf || schema.oneOf || schema.anyOf);
|
|
|
136
152
|
* Properties are omitted if they are not required and the option is enabled.
|
|
137
153
|
*/
|
|
138
154
|
const shouldOmitProperty = (schema, parentSchema, propertyName, options) => {
|
|
139
|
-
// Early exits for schemas that should not be included (deprecated, readOnly, writeOnly)
|
|
140
|
-
if (schema.deprecated ||
|
|
155
|
+
// Early exits for schemas that should not be included (deprecated unless opted in, readOnly, writeOnly)
|
|
156
|
+
if ((schema.deprecated && options?.includeDeprecated !== true) ||
|
|
141
157
|
(options?.mode === 'write' && schema.readOnly) ||
|
|
142
158
|
(options?.mode === 'read' && schema.writeOnly)) {
|
|
143
159
|
return true;
|
|
@@ -292,6 +308,44 @@ const getCompositionSelectionIndex = (schemaPath, composition, options, length)
|
|
|
292
308
|
}
|
|
293
309
|
return Math.max(0, Math.min(rawIndex, length - 1));
|
|
294
310
|
};
|
|
311
|
+
/**
|
|
312
|
+
* Use the discriminator as a generation hint. Only referenced variants have
|
|
313
|
+
* implicit names; inline titles are display labels, not discriminator mappings.
|
|
314
|
+
*/
|
|
315
|
+
const getDiscriminatorSelectionIndex = (schema, variants, options, value) => {
|
|
316
|
+
const discriminator = schema.discriminator;
|
|
317
|
+
if (discriminator?.defaultMapping === undefined) {
|
|
318
|
+
return undefined;
|
|
319
|
+
}
|
|
320
|
+
const property = 'properties' in schema ? schema.properties?.[discriminator.propertyName] : undefined;
|
|
321
|
+
const resolvedProperty = property ? resolve.schema(property) : undefined;
|
|
322
|
+
const propertyName = options?.xml && resolvedProperty && 'xml' in resolvedProperty
|
|
323
|
+
? (resolvedProperty.xml?.name ?? discriminator.propertyName)
|
|
324
|
+
: discriminator.propertyName;
|
|
325
|
+
const variableValue = resolvedProperty?.['x-variable']
|
|
326
|
+
? options?.variables?.[resolvedProperty['x-variable']]
|
|
327
|
+
: undefined;
|
|
328
|
+
const declaredValue = resolvedProperty ? getDeclaredValue(resolvedProperty) : undefined;
|
|
329
|
+
const schemaValue = variableValue !== undefined ? variableValue : declaredValue;
|
|
330
|
+
const tag = value ? value[propertyName] : schemaValue;
|
|
331
|
+
const findReference = (reference) => variants.findIndex((variant) => '$ref' in variant && variant.$ref === reference);
|
|
332
|
+
const findComponent = (name) => findReference(`#/components/schemas/${escapeJsonPointer(name)}`);
|
|
333
|
+
const findTarget = (target) => {
|
|
334
|
+
// Prefer a component name when the same string could also be a relative URI.
|
|
335
|
+
const componentIndex = findComponent(target);
|
|
336
|
+
return componentIndex >= 0 ? componentIndex : findReference(target);
|
|
337
|
+
};
|
|
338
|
+
if (typeof tag === 'string') {
|
|
339
|
+
const explicit = discriminator.mapping && Object.hasOwn(discriminator.mapping, tag) ? discriminator.mapping[tag] : undefined;
|
|
340
|
+
const mappedIndex = explicit === undefined ? findComponent(tag) : findTarget(explicit);
|
|
341
|
+
// A broken explicit mapping must not silently select the fallback.
|
|
342
|
+
if (explicit !== undefined || mappedIndex >= 0) {
|
|
343
|
+
return mappedIndex >= 0 ? mappedIndex : undefined;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const fallbackIndex = findTarget(discriminator.defaultMapping);
|
|
347
|
+
return fallbackIndex >= 0 ? fallbackIndex : undefined;
|
|
348
|
+
};
|
|
295
349
|
/**
|
|
296
350
|
* Read the numeric `x-order` extension value from a raw property entry, if present.
|
|
297
351
|
* The entry may be a schema or a `$ref` object, so we check membership before reading.
|
|
@@ -378,15 +432,13 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
|
|
|
378
432
|
const isAnyType = schema.additionalProperties === true ||
|
|
379
433
|
(typeof schema.additionalProperties === 'object' && Object.keys(schema.additionalProperties).length === 0);
|
|
380
434
|
// Check for explicit x-additionalPropertiesName first
|
|
381
|
-
const
|
|
382
|
-
'x-additionalPropertiesName'
|
|
383
|
-
|
|
384
|
-
|
|
435
|
+
const customName = typeof additional === 'object' && 'x-additionalPropertiesName' in additional
|
|
436
|
+
? additional['x-additionalPropertiesName']
|
|
437
|
+
: undefined;
|
|
438
|
+
const hasCustomName = typeof customName === 'string' && customName.trim().length > 0;
|
|
385
439
|
// Use propertyNames enum values as example keys when no custom name is set
|
|
386
440
|
const propertyNamesEnum = hasCustomName ? undefined : getPropertyNamesEnumValues(schema);
|
|
387
|
-
const additionalName = hasCustomName
|
|
388
|
-
? additional['x-additionalPropertiesName'].trim()
|
|
389
|
-
: DEFAULT_ADDITIONAL_PROPERTIES_NAME;
|
|
441
|
+
const additionalName = hasCustomName ? customName.trim() : DEFAULT_ADDITIONAL_PROPERTIES_NAME;
|
|
390
442
|
const additionalValue = isAnyType
|
|
391
443
|
? 'anything'
|
|
392
444
|
: typeof additional === 'object'
|
|
@@ -408,7 +460,9 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
|
|
|
408
460
|
const compositionKeyword = schema.oneOf ? 'oneOf' : schema.anyOf ? 'anyOf' : undefined;
|
|
409
461
|
const oneOfAnyOf = compositionKeyword ? schema[compositionKeyword] : undefined;
|
|
410
462
|
if (compositionKeyword && oneOfAnyOf?.length) {
|
|
411
|
-
const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, oneOfAnyOf.length) ??
|
|
463
|
+
const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, oneOfAnyOf.length) ??
|
|
464
|
+
getDiscriminatorSelectionIndex(schema, oneOfAnyOf, options, response) ??
|
|
465
|
+
0;
|
|
412
466
|
const chosen = resolve.schema(oneOfAnyOf[index]);
|
|
413
467
|
if (chosen) {
|
|
414
468
|
Object.assign(response, getExampleFromSchema(chosen, options, {
|
|
@@ -503,7 +557,9 @@ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath, d
|
|
|
503
557
|
const compositionKeyword = items.oneOf ? 'oneOf' : items.anyOf ? 'anyOf' : undefined;
|
|
504
558
|
const union = compositionKeyword ? items[compositionKeyword] : undefined;
|
|
505
559
|
if (compositionKeyword && union && union.length > 0) {
|
|
506
|
-
const selectedIndex = getCompositionSelectionIndex(itemsSchemaPath, compositionKeyword, options, union.length) ??
|
|
560
|
+
const selectedIndex = getCompositionSelectionIndex(itemsSchemaPath, compositionKeyword, options, union.length) ??
|
|
561
|
+
getDiscriminatorSelectionIndex(items, union, options) ??
|
|
562
|
+
0;
|
|
507
563
|
const selected = union[selectedIndex];
|
|
508
564
|
const ex = getExampleFromSchema(resolve.schema(selected), options, {
|
|
509
565
|
level: level + 1,
|
|
@@ -581,10 +637,181 @@ const createOptionsCacheKey = (options) => JSON.stringify({
|
|
|
581
637
|
mode: options?.mode,
|
|
582
638
|
variables: options?.variables,
|
|
583
639
|
omitEmptyAndOptionalProperties: options?.omitEmptyAndOptionalProperties,
|
|
640
|
+
// Load-bearing: `resultCache` is a module global keyed by schema identity plus this string, and
|
|
641
|
+
// the lookup happens before `shouldOmitProperty` runs. Without this entry an include-caller's
|
|
642
|
+
// populated object could be handed back to a default caller, and vice versa. `JSON.stringify`
|
|
643
|
+
// drops `undefined`, so existing callers' keys stay byte-identical.
|
|
644
|
+
includeDeprecated: options?.includeDeprecated,
|
|
584
645
|
compositionSelection: options?.compositionSelection
|
|
585
646
|
? Object.entries(options.compositionSelection).sort(([a], [b]) => a.localeCompare(b))
|
|
586
647
|
: undefined,
|
|
587
648
|
});
|
|
649
|
+
/** Stand-in for a truncated schema whose shape cannot be read off the document. */
|
|
650
|
+
const MAX_DEPTH_EXCEEDED = '[Max Depth Exceeded]';
|
|
651
|
+
/** How long a chain of composition wrappers may be unwrapped before the stack becomes the concern. */
|
|
652
|
+
const MAX_COMPOSITION_DEPTH = MAX_LEVELS_DEEP * 5;
|
|
653
|
+
/** Read a schema's declared types as a list, so `type: 'object'` and `type: ['object']` behave alike. */
|
|
654
|
+
const getDeclaredTypes = (schema) => {
|
|
655
|
+
if (!('type' in schema) || !schema.type) {
|
|
656
|
+
return [];
|
|
657
|
+
}
|
|
658
|
+
return Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
659
|
+
};
|
|
660
|
+
/** Return the empty container a schema declares, or `undefined` when it declares neither. */
|
|
661
|
+
const getEmptyContainer = (schema) => {
|
|
662
|
+
const types = getDeclaredTypes(schema);
|
|
663
|
+
if ('properties' in schema || types.includes('object')) {
|
|
664
|
+
return {};
|
|
665
|
+
}
|
|
666
|
+
if ('items' in schema || types.includes('array')) {
|
|
667
|
+
return [];
|
|
668
|
+
}
|
|
669
|
+
return undefined;
|
|
670
|
+
};
|
|
671
|
+
/** Pick the `oneOf`/`anyOf` variant the walk itself would have rendered, honoring an explicit selection. */
|
|
672
|
+
const getSelectedVariant = (schema, options, schemaPath) => {
|
|
673
|
+
const compositionKeyword = schema.oneOf ? 'oneOf' : schema.anyOf ? 'anyOf' : undefined;
|
|
674
|
+
const variants = compositionKeyword ? schema[compositionKeyword] : undefined;
|
|
675
|
+
if (!compositionKeyword || !Array.isArray(variants) || variants.length === 0) {
|
|
676
|
+
return undefined;
|
|
677
|
+
}
|
|
678
|
+
const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, variants.length) ??
|
|
679
|
+
getDiscriminatorSelectionIndex(schema, variants, options);
|
|
680
|
+
const candidate = index !== undefined
|
|
681
|
+
? variants[index]
|
|
682
|
+
: variants.find((variant) => {
|
|
683
|
+
const resolved = resolve.schema(variant);
|
|
684
|
+
return resolved && (!('type' in resolved) || resolved.type !== 'null');
|
|
685
|
+
});
|
|
686
|
+
return candidate ? resolve.schema(candidate) : undefined;
|
|
687
|
+
};
|
|
688
|
+
/**
|
|
689
|
+
* Return the value a schema states outright, in the order the walk prefers them.
|
|
690
|
+
*
|
|
691
|
+
* The walk applies this before the cap, so a truncated schema has already had its turn — but a
|
|
692
|
+
* composition member reached from below the cap has not, and answering an `allOf`-wrapped enum with an
|
|
693
|
+
* empty string hands back a value that very schema forbids.
|
|
694
|
+
*/
|
|
695
|
+
const getDeclaredValue = (schema) => {
|
|
696
|
+
if (Array.isArray(schema.examples) && schema.examples.length > 0) {
|
|
697
|
+
return schema.examples[0];
|
|
698
|
+
}
|
|
699
|
+
if (schema.example !== undefined) {
|
|
700
|
+
return schema.example;
|
|
701
|
+
}
|
|
702
|
+
if (schema.default !== undefined) {
|
|
703
|
+
const normalizedDefault = normalizeSchemaDefault(schema);
|
|
704
|
+
if (normalizedDefault !== INVALID_DEFAULT) {
|
|
705
|
+
return normalizedDefault;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
if (schema.const !== undefined) {
|
|
709
|
+
return schema.const;
|
|
710
|
+
}
|
|
711
|
+
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
712
|
+
return schema.enum[0];
|
|
713
|
+
}
|
|
714
|
+
return undefined;
|
|
715
|
+
};
|
|
716
|
+
/**
|
|
717
|
+
* Describe a composed schema by the member the walk itself would have rendered.
|
|
718
|
+
* Returns `undefined` when no member describes a shape.
|
|
719
|
+
*/
|
|
720
|
+
const describeComposition = (schema, options, schemaPath, seen) => {
|
|
721
|
+
const variant = getSelectedVariant(schema, options, schemaPath);
|
|
722
|
+
if (variant) {
|
|
723
|
+
return getMaxDepthValue(variant, options, schemaPath, seen);
|
|
724
|
+
}
|
|
725
|
+
if (!Array.isArray(schema.allOf) || schema.allOf.length === 0) {
|
|
726
|
+
return undefined;
|
|
727
|
+
}
|
|
728
|
+
// `allOf` merges every member, so merge their truncated values the same way. Members that describe
|
|
729
|
+
// nothing contribute nothing rather than clobbering the ones that do.
|
|
730
|
+
let merged = undefined;
|
|
731
|
+
let choiceIndex = 0;
|
|
732
|
+
for (const member of schema.allOf) {
|
|
733
|
+
const resolved = resolve.schema(member);
|
|
734
|
+
// Each direct choice member gets its own ordinal in the path, the same way the walk keys them, so
|
|
735
|
+
// an explicit selection on an `allOf`-wrapped `oneOf` still resolves here.
|
|
736
|
+
const isChoiceMember = !!resolved && (Array.isArray(resolved.oneOf) || Array.isArray(resolved.anyOf));
|
|
737
|
+
const memberSchemaPath = isChoiceMember ? [...schemaPath, String(choiceIndex++)] : schemaPath;
|
|
738
|
+
const value = resolved ? getMaxDepthValue(resolved, options, memberSchemaPath, seen) : undefined;
|
|
739
|
+
if (value !== undefined && value !== MAX_DEPTH_EXCEEDED) {
|
|
740
|
+
merged = mergeExamples(merged, value);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return merged;
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* Build the value that stands in for a schema the recursion depth cap cut off.
|
|
747
|
+
*
|
|
748
|
+
* The stand-in is still read as an example of the schema it replaced, so a plain string makes the
|
|
749
|
+
* example contradict its own type: a mock server answering a `type: object` field with
|
|
750
|
+
* `[Max Depth Exceeded]` hands a strict SDK decoder a body it cannot parse. Describe the declared
|
|
751
|
+
* type instead, dispatching in the order the walk does, so a truncated value differs from a full render
|
|
752
|
+
* in having no children. A schema that describes no shape at all keeps the sentinel, which is then the
|
|
753
|
+
* only signal that truncation happened.
|
|
754
|
+
*
|
|
755
|
+
* Two deliberate departures from the walk, both answering with the declared container where the walk
|
|
756
|
+
* answers `null`: a container spelled as a list (`type: ['object']`, or `['object', 'null']`) is read
|
|
757
|
+
* here as the container it names, where the walk's strict comparison misses it.
|
|
758
|
+
*
|
|
759
|
+
* The value is empty rather than complete: satisfying `required` or `minItems` means descending
|
|
760
|
+
* again, which is exactly what the cap exists to prevent.
|
|
761
|
+
*/
|
|
762
|
+
const getMaxDepthValue = (schema, options, schemaPath, seen = new Set()) => {
|
|
763
|
+
// A stated value beats any stand-in, and matches what a full render would have produced.
|
|
764
|
+
const declared = getDeclaredValue(schema);
|
|
765
|
+
if (declared !== undefined) {
|
|
766
|
+
return declared;
|
|
767
|
+
}
|
|
768
|
+
const container = getEmptyContainer(schema);
|
|
769
|
+
if (container !== undefined) {
|
|
770
|
+
// Children were dropped here, so anything assembled around this value is level-bound too.
|
|
771
|
+
truncated = true;
|
|
772
|
+
return container;
|
|
773
|
+
}
|
|
774
|
+
// A schema with no children renders the same at every level, so nothing is lost and the cache stays
|
|
775
|
+
// usable for the rest of the call.
|
|
776
|
+
const makeUpRandomData = !!options?.emptyString;
|
|
777
|
+
const primitive = getPrimitiveValue(schema, makeUpRandomData, options?.emptyString);
|
|
778
|
+
if (primitive !== undefined) {
|
|
779
|
+
return primitive;
|
|
780
|
+
}
|
|
781
|
+
// A wrapper such as `allOf: [$ref]` declares no type of its own, so describe its members instead.
|
|
782
|
+
// Unwrapping runs outside the walk's own cycle guard, so it carries one: refusing to re-enter a
|
|
783
|
+
// wrapper already on the path terminates a self-reference without capping how long a legitimate
|
|
784
|
+
// inheritance chain may be. `seen` holds exactly the path, so its size bounds the stack against a
|
|
785
|
+
// pathological chain, the way `schemaAllowsValue` bounds its own recursion.
|
|
786
|
+
const target = getSchemaCacheTarget(schema);
|
|
787
|
+
if (!seen.has(target) && seen.size < MAX_COMPOSITION_DEPTH) {
|
|
788
|
+
seen.add(target);
|
|
789
|
+
const composed = describeComposition(schema, options, schemaPath, seen);
|
|
790
|
+
seen.delete(target);
|
|
791
|
+
if (composed !== undefined) {
|
|
792
|
+
return composed;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
// A description declined is never the value a full render would have produced.
|
|
797
|
+
truncated = true;
|
|
798
|
+
}
|
|
799
|
+
const unionPrimitive = getUnionPrimitiveValue(schema, makeUpRandomData, options?.emptyString);
|
|
800
|
+
if (unionPrimitive !== undefined) {
|
|
801
|
+
return unionPrimitive;
|
|
802
|
+
}
|
|
803
|
+
// A schema that declares `null` has exactly one valid value, which is what the walk falls back to.
|
|
804
|
+
if (getDeclaredTypes(schema).includes('null')) {
|
|
805
|
+
return null;
|
|
806
|
+
}
|
|
807
|
+
// A composition or a negative constraint none of the above could describe still says something about
|
|
808
|
+
// the value, and the walk answers both with `null` rather than a value of no particular type.
|
|
809
|
+
if (isComposed(schema) || 'not' in schema) {
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
truncated = true;
|
|
813
|
+
return MAX_DEPTH_EXCEEDED;
|
|
814
|
+
};
|
|
588
815
|
/**
|
|
589
816
|
* Generate an example value from a given OpenAPI SchemaObject.
|
|
590
817
|
*
|
|
@@ -601,6 +828,10 @@ const createOptionsCacheKey = (options) => JSON.stringify({
|
|
|
601
828
|
* @returns An example value for the given schema.
|
|
602
829
|
*/
|
|
603
830
|
export const getExampleFromSchema = (schema, options, { level = 0, parentSchema, name, seen = new WeakSet(), schemaPath = [], dynamicScope = [], } = {}) => {
|
|
831
|
+
// A truncation only taints the call it happened in, so every top-level call starts clean.
|
|
832
|
+
if (level === 0) {
|
|
833
|
+
truncated = false;
|
|
834
|
+
}
|
|
604
835
|
// Resolve any $ref references to get the actual schema
|
|
605
836
|
const _schema = resolve.schema(schema);
|
|
606
837
|
if (!isDefined(_schema)) {
|
|
@@ -645,14 +876,9 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
|
|
|
645
876
|
return cached;
|
|
646
877
|
}
|
|
647
878
|
}
|
|
648
|
-
// Prevent infinite recursion in circular references
|
|
649
|
-
if (level > MAX_LEVELS_DEEP) {
|
|
650
|
-
seen.delete(targetValue);
|
|
651
|
-
return '[Max Depth Exceeded]';
|
|
652
|
-
}
|
|
653
879
|
// Determine if we should generate realistic example data
|
|
654
880
|
const makeUpRandomData = !!options?.emptyString;
|
|
655
|
-
// Early exits for schemas that should not be included (deprecated, readOnly, writeOnly, omitEmptyAndOptionalProperties)
|
|
881
|
+
// Early exits for schemas that should not be included (deprecated unless opted in, readOnly, writeOnly, omitEmptyAndOptionalProperties)
|
|
656
882
|
if (shouldOmitProperty(_schema, parentSchema, name, options)) {
|
|
657
883
|
seen.delete(targetValue);
|
|
658
884
|
return undefined;
|
|
@@ -694,6 +920,14 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
|
|
|
694
920
|
seen.delete(targetValue);
|
|
695
921
|
return cache(_schema, _schema.enum[0], cacheKey, skipCache);
|
|
696
922
|
}
|
|
923
|
+
// Stop descending once the walk is too deep to keep going, which also breaks circular references.
|
|
924
|
+
// Everything above still applied, so an explicit example, `const` or `enum` wins here as it would at
|
|
925
|
+
// any other level; only the children are given up on.
|
|
926
|
+
if (level > MAX_LEVELS_DEEP) {
|
|
927
|
+
seen.delete(targetValue);
|
|
928
|
+
// Deliberately not cached: the value holds only at this level, and the cache key carries none.
|
|
929
|
+
return getMaxDepthValue(_schema, options, schemaPath);
|
|
930
|
+
}
|
|
697
931
|
// Handle object types - check for properties to identify objects
|
|
698
932
|
if ('properties' in _schema || ('type' in _schema && _schema.type === 'object')) {
|
|
699
933
|
const result = handleObjectSchema(_schema, options, level, seen, cacheKey, schemaPath, dynamicScope);
|
|
@@ -716,7 +950,8 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
|
|
|
716
950
|
const compositionKeyword = _schema.oneOf ? 'oneOf' : _schema.anyOf ? 'anyOf' : undefined;
|
|
717
951
|
const discriminate = compositionKeyword ? _schema[compositionKeyword] : undefined;
|
|
718
952
|
if (compositionKeyword && Array.isArray(discriminate) && discriminate.length > 0) {
|
|
719
|
-
const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, discriminate.length)
|
|
953
|
+
const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, discriminate.length) ??
|
|
954
|
+
getDiscriminatorSelectionIndex(_schema, discriminate, options);
|
|
720
955
|
const candidate = index !== undefined
|
|
721
956
|
? discriminate[index]
|
|
722
957
|
: discriminate.find((item) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExampleObject, MediaTypeObject, ParameterObject, RequestBodyObject } from '@scalar/workspace-store/schemas/v3.
|
|
1
|
+
import type { ExampleObject, MediaTypeObject, ParameterObject, RequestBodyObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
2
2
|
/**
|
|
3
3
|
* Resolve an example value for a parameter or requestBody from either `examples` or `content.*.examples`.
|
|
4
4
|
* Or the [deprecated] `example` field.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getResolvedRef } from '../../../helpers/get-resolved-ref.js';
|
|
2
2
|
/** Helper to get example from examples object with fallback to example field */
|
|
3
3
|
const getExampleFromExamples = (examples, exampleField, exampleName) => {
|
|
4
|
-
if (!examples &&
|
|
4
|
+
if (!examples && exampleField === undefined) {
|
|
5
5
|
return undefined;
|
|
6
6
|
}
|
|
7
7
|
const hasExamples = !!examples && Object.keys(examples).length > 0;
|
|
@@ -43,7 +43,7 @@ export const getExample = (param, exampleName, contentType) => {
|
|
|
43
43
|
}
|
|
44
44
|
// Derive value from the schema
|
|
45
45
|
const resolvedParam = getResolvedRef(param);
|
|
46
|
-
if ('schema' in resolvedParam && resolvedParam.schema) {
|
|
46
|
+
if (resolvedParam && 'schema' in resolvedParam && resolvedParam.schema) {
|
|
47
47
|
const schema = resolvedParam.schema;
|
|
48
48
|
// Default value
|
|
49
49
|
if ('default' in schema && schema.default !== undefined) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ServerObject } from '../../../schemas/v3.
|
|
1
|
+
import type { ServerObject } from '../../../schemas/v3.2/strict/server.js';
|
|
2
2
|
/**
|
|
3
3
|
* Extracts the default values of variables defined in a ServerObject into a simple key-value map.
|
|
4
4
|
* Ignores variables with no default value.
|
|
@@ -2,6 +2,7 @@ export { getExampleFromBody, getSchemaExampleFromBody } from './body/get-request
|
|
|
2
2
|
export { getSelectedBodyContentType } from './body/get-selected-body-content-type.js';
|
|
3
3
|
export { buildDottedNestedRowPredicate, coerceLeafValueToSchemaType, coerceUntypedValue, resolveLeafSchema, } from './body/schema-value-coercion.js';
|
|
4
4
|
export { type SerializedFormProperty, serializeFormPropertyWithEncoding } from './body/serialize-form-property.js';
|
|
5
|
+
export { serializeMultipartArray } from './body/serialize-multipart-array.js';
|
|
5
6
|
export { BUILD_REQUEST_FAILED, type BuildRequestData, type BuildRequestFailureCode, type BuildRequestResult, type RequestPayload, buildRequest, resolveExecutableRequestUrl, } from './build-request.js';
|
|
6
7
|
export { deSerializeParameter, deSerializeSchemaValue } from './header/de-serialize-parameter.js';
|
|
7
8
|
export { filterGlobalCookie } from './header/filter-global-cookies.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAClF,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,KAAK,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAA;AAC/G,OAAO,EACL,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,YAAY,EACZ,2BAA2B,GAC5B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,wBAAwB,GACzB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,yBAAyB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAClF,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,KAAK,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAA;AAC/G,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC1E,OAAO,EACL,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,YAAY,EACZ,2BAA2B,GAC5B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,wBAAwB,GACzB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,yBAAyB,CAAA"}
|
|
@@ -2,6 +2,7 @@ export { getExampleFromBody, getSchemaExampleFromBody } from './body/get-request
|
|
|
2
2
|
export { getSelectedBodyContentType } from './body/get-selected-body-content-type.js';
|
|
3
3
|
export { buildDottedNestedRowPredicate, coerceLeafValueToSchemaType, coerceUntypedValue, resolveLeafSchema, } from './body/schema-value-coercion.js';
|
|
4
4
|
export { serializeFormPropertyWithEncoding } from './body/serialize-form-property.js';
|
|
5
|
+
export { serializeMultipartArray } from './body/serialize-multipart-array.js';
|
|
5
6
|
export { BUILD_REQUEST_FAILED, buildRequest, resolveExecutableRequestUrl, } from './build-request.js';
|
|
6
7
|
export { deSerializeParameter, deSerializeSchemaValue } from './header/de-serialize-parameter.js';
|
|
7
8
|
export { filterGlobalCookie } from './header/filter-global-cookies.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
2
2
|
import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
3
|
-
import type { ServerObject } from '@scalar/workspace-store/schemas/v3.
|
|
4
|
-
import type { OperationObject } from '@scalar/workspace-store/schemas/v3.
|
|
3
|
+
import type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
4
|
+
import type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/operation';
|
|
5
5
|
import { type BuildRequestSecurityResult } from '../../request-example/builder/security/build-request-security.js';
|
|
6
6
|
import type { SecuritySchemeObjectSecret } from '../../request-example/builder/security/secret-types.js';
|
|
7
7
|
import type { RequestExampleMeta } from '../../request-example/types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker-scheme-types.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/broker-scheme-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2FAA2F;AAC3F,QAAA,MAAM,iBAAiB,kEAAmE,CAAA;AAE1F,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/D,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"broker-scheme-types.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/broker-scheme-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2FAA2F;AAC3F,QAAA,MAAM,iBAAiB,kEAAmE,CAAA;AAE1F,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/D,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,IAAI,IAAI,cACP,CAAA;AAE7D,qDAAqD;AACrD,QAAA,MAAM,uBAAuB,0DAA2D,CAAA;AAExF,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3E,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,IAAI,IAAI,oBACP,CAAA"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/** SASL-style broker schemes: all of them authenticate with a username + password pair. */
|
|
8
8
|
const SASL_SCHEME_TYPES = ['userPassword', 'plain', 'scramSha256', 'scramSha512'];
|
|
9
|
-
export const isSaslSchemeType = (type) =>
|
|
9
|
+
export const isSaslSchemeType = (type) => SASL_SCHEME_TYPES.some((schemeType) => schemeType === type);
|
|
10
10
|
/** Encryption broker schemes: a single key value. */
|
|
11
11
|
const ENCRYPTION_SCHEME_TYPES = ['symmetricEncryption', 'asymmetricEncryption'];
|
|
12
|
-
export const isEncryptionSchemeType = (type) =>
|
|
12
|
+
export const isEncryptionSchemeType = (type) => ENCRYPTION_SCHEME_TYPES.some((schemeType) => schemeType === type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;AAC5D,yBAAyB,0BAA0B,EAAE;AACrD,qEAAqE;AACrE,8BAA0B,KACzB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;AAC5D,yBAAyB,0BAA0B,EAAE;AACrD,qEAAqE;AACrE,8BAA0B,KACzB,0BAA0B,EA4F5B,CAAA"}
|
|
@@ -12,26 +12,25 @@ emptyTokenPlaceholder = '') => {
|
|
|
12
12
|
selectedSecuritySchemes.forEach((scheme) => {
|
|
13
13
|
// Api key
|
|
14
14
|
if (scheme.type === 'apiKey') {
|
|
15
|
-
const name = scheme.name;
|
|
16
15
|
const value = scheme['x-scalar-secret-token'] || emptyTokenPlaceholder;
|
|
17
16
|
if (scheme.in === 'header') {
|
|
18
17
|
return result.push({
|
|
19
18
|
in: scheme.in,
|
|
20
|
-
name,
|
|
19
|
+
name: scheme.name,
|
|
21
20
|
value,
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
23
|
if (scheme.in === 'query') {
|
|
25
24
|
return result.push({
|
|
26
25
|
in: 'query',
|
|
27
|
-
name,
|
|
26
|
+
name: scheme.name,
|
|
28
27
|
value,
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
if (scheme.in === 'cookie') {
|
|
32
31
|
return result.push({
|
|
33
32
|
in: 'cookie',
|
|
34
|
-
name,
|
|
33
|
+
name: scheme.name,
|
|
35
34
|
value,
|
|
36
35
|
});
|
|
37
36
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EncryptionSchemeType, SaslSchemeType } from '../../../request-example/builder/security/broker-scheme-types.js';
|
|
2
2
|
import type { XScalarAuthUrl, XScalarCredentialsLocation, XScalarSecretClientCertificate, XScalarSecretClientId, XScalarSecretClientSecret, XScalarSecretHTTP, XScalarSecretPrivateKey, XScalarSecretRedirectUri, XScalarSecretRefreshToken, XScalarSecretServiceName, XScalarSecretToken, XScalarTokenUrl } from '../../../schemas/extensions/security/index.js';
|
|
3
|
-
import type { OAuthFlowAuthorizationCode, OAuthFlowClientCredentials, OAuthFlowImplicit, OAuthFlowPassword } from '../../../schemas/v3.
|
|
4
|
-
import type { ApiKeyObject, HttpObject, OAuth2Object, OpenIdConnectObject } from '../../../schemas/v3.
|
|
3
|
+
import type { OAuthFlowAuthorizationCode, OAuthFlowClientCredentials, OAuthFlowImplicit, OAuthFlowPassword } from '../../../schemas/v3.2/strict/oauth-flow.js';
|
|
4
|
+
import type { ApiKeyObject, HttpObject, MutualTlsObject, OAuth2Object, OpenIdConnectObject } from '../../../schemas/v3.2/strict/security-scheme.js';
|
|
5
5
|
type OAuthFlowCommonSecret = XScalarSecretClientId & XScalarSecretToken & XScalarSecretRefreshToken & XScalarAuthUrl & XScalarTokenUrl;
|
|
6
6
|
export type OAuthFlowImplicitSecret = OAuthFlowImplicit & OAuthFlowCommonSecret & XScalarSecretRedirectUri;
|
|
7
7
|
export type OAuthFlowPasswordSecret = OAuthFlowPassword & OAuthFlowCommonSecret & XScalarSecretHTTP & XScalarSecretClientSecret & XScalarCredentialsLocation;
|
|
@@ -13,8 +13,17 @@ export type OAuthFlowsObjectSecret = {
|
|
|
13
13
|
clientCredentials?: OAuthFlowClientCredentialsSecret;
|
|
14
14
|
authorizationCode?: OAuthFlowAuthorizationCodeSecret;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
/** AsyncAPI API keys occupy broker credentials instead of an HTTP parameter. */
|
|
17
|
+
export type BrokerApiKeyObject = {
|
|
18
|
+
type: 'apiKey';
|
|
19
|
+
in: 'user' | 'password';
|
|
20
|
+
name?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
};
|
|
23
|
+
export type ApiKeyObjectSecret = (ApiKeyObject | BrokerApiKeyObject) & XScalarSecretToken;
|
|
17
24
|
export type HttpObjectSecret = HttpObject & XScalarSecretHTTP & XScalarSecretToken;
|
|
25
|
+
/** Mutual TLS: the client certificate is presented at the TLS layer, so there is no secret to enter. */
|
|
26
|
+
export type MutualTlsObjectSecret = MutualTlsObject;
|
|
18
27
|
export type OAuth2ObjectSecret = Omit<OAuth2Object, 'flows'> & {
|
|
19
28
|
flows: OAuthFlowsObjectSecret;
|
|
20
29
|
};
|
|
@@ -37,6 +46,6 @@ export type X509ObjectSecret = AsyncApiBrokerScheme<'X509'> & XScalarSecretClien
|
|
|
37
46
|
export type EncryptionObjectSecret = AsyncApiBrokerScheme<EncryptionSchemeType> & XScalarSecretToken;
|
|
38
47
|
/** AsyncAPI GSSAPI (Kerberos) scheme: the service name the client authenticates against. */
|
|
39
48
|
export type GssapiObjectSecret = AsyncApiBrokerScheme<'gssapi'> & XScalarSecretServiceName;
|
|
40
|
-
export type SecuritySchemeObjectSecret = ApiKeyObjectSecret | HttpObjectSecret | OpenIdConnectObjectSecret | OAuth2ObjectSecret | SaslObjectSecret | X509ObjectSecret | EncryptionObjectSecret | GssapiObjectSecret;
|
|
49
|
+
export type SecuritySchemeObjectSecret = ApiKeyObjectSecret | HttpObjectSecret | MutualTlsObjectSecret | OpenIdConnectObjectSecret | OAuth2ObjectSecret | SaslObjectSecret | X509ObjectSecret | EncryptionObjectSecret | GssapiObjectSecret;
|
|
41
50
|
export {};
|
|
42
51
|
//# sourceMappingURL=secret-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret-types.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/secret-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAA;AAClH,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,EAChB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"secret-types.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/secret-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAA;AAClH,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,EAChB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,eAAe,EACf,YAAY,EACZ,mBAAmB,EACpB,MAAM,uCAAuC,CAAA;AAE9C,KAAK,qBAAqB,GAAG,qBAAqB,GAChD,kBAAkB,GAClB,yBAAyB,GACzB,cAAc,GACd,eAAe,CAAA;AAEjB,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,wBAAwB,CAAA;AAE1G,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GACrD,qBAAqB,GACrB,iBAAiB,GACjB,yBAAyB,GACzB,0BAA0B,CAAA;AAE5B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,GACzB,0BAA0B,CAAA;AAE5B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,GACzB,wBAAwB,GACxB,0BAA0B,CAAA;AAE5B,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;IACpD,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;CACrD,CAAA;AAED,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,QAAQ,CAAA;IACd,EAAE,EAAE,MAAM,GAAG,UAAU,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,YAAY,GAAG,kBAAkB,CAAC,GAAG,kBAAkB,CAAA;AACzF,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAClF,wGAAwG;AACxG,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAA;AACnD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAChG,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,GAAG;IAAE,KAAK,CAAC,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAEhG;;;GAGG;AACH,KAAK,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI;IAC5C,IAAI,EAAE,CAAC,CAAA;IACP,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,wFAAwF;AACxF,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,cAAc,CAAC,GAAG,iBAAiB,CAAA;AAEvF,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,CAAC,GAAG,8BAA8B,GAAG,uBAAuB,CAAA;AAEtH,wFAAwF;AACxF,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,CAAC,oBAAoB,CAAC,GAAG,kBAAkB,CAAA;AAEpG,4FAA4F;AAC5F,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,GAAG,wBAAwB,CAAA;AAE1F,MAAM,MAAM,0BAA0B,GAClC,kBAAkB,GAClB,gBAAgB,GAChB,qBAAqB,GACrB,yBAAyB,GACzB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,sBAAsB,GACtB,kBAAkB,CAAA"}
|
|
@@ -8,9 +8,9 @@ import { type MergedSecuritySchemes } from '../../request-example/context/securi
|
|
|
8
8
|
import type { RequestExampleMeta, Result } from '../../request-example/types.js';
|
|
9
9
|
import type { XScalarEnvironment } from '../../schemas/extensions/document/x-scalar-environments.js';
|
|
10
10
|
import type { XScalarCookie } from '../../schemas/extensions/general/x-scalar-cookies.js';
|
|
11
|
-
import type { OperationObject } from '../../schemas/v3.
|
|
12
|
-
import type { SecurityRequirementObject } from '../../schemas/v3.
|
|
13
|
-
import type { ServerObject } from '../../schemas/v3.
|
|
11
|
+
import type { OperationObject } from '../../schemas/v3.2/strict/operation.js';
|
|
12
|
+
import type { SecurityRequirementObject } from '../../schemas/v3.2/strict/security-requirement.js';
|
|
13
|
+
import type { ServerObject } from '../../schemas/v3.2/strict/server.js';
|
|
14
14
|
import type { WorkspaceDocument } from '../../schemas/workspace.js';
|
|
15
15
|
export type BuildRequestExampleContext = {
|
|
16
16
|
operation: OperationObject;
|
|
@@ -79,7 +79,7 @@ export const getRequestExampleContext = (workspaceStore, documentName, requestEx
|
|
|
79
79
|
const selectedSecurity = getSelectedSecurity(documentSelectedSecurity, operationSelectedSecurity, securityRequirements, securitySchemes, options.authentication?.preferredSecurityScheme);
|
|
80
80
|
/** The above selected requirements in scheme form */
|
|
81
81
|
const selectedSecuritySchemes = getSecuritySchemes(securitySchemes, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {});
|
|
82
|
-
const serverMeta = !isWebhook && operation.servers != null
|
|
82
|
+
const serverMeta = !isWebhook && options.servers == null && operation.servers != null
|
|
83
83
|
? { type: 'operation', path: path ?? '', method: method ?? 'get' }
|
|
84
84
|
: { type: 'document' };
|
|
85
85
|
const authMeta = operationSelectedSecurity !== undefined
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
-
import type { OperationObject } from '@scalar/workspace-store/schemas/v3.
|
|
2
|
+
import type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
3
3
|
/**
|
|
4
4
|
* Restores conventional casing for well-known default headers.
|
|
5
5
|
*
|
|
@@ -28,7 +28,7 @@ const getEnabledOperationHeaderParameterNames = (operation, exampleName) => {
|
|
|
28
28
|
const names = new Set();
|
|
29
29
|
for (const ref of operation.parameters ?? []) {
|
|
30
30
|
const param = getResolvedRef(ref);
|
|
31
|
-
if (param.in !== 'header') {
|
|
31
|
+
if (!param || param.in !== 'header') {
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
34
|
const rawExample = 'examples' in param && param.examples?.[exampleName] ? param.examples[exampleName] : undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OperationObject, PathItemObject } from '@scalar/workspace-store/schemas/v3.
|
|
1
|
+
import type { OperationObject, PathItemObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
2
2
|
/** Combine pathItem and operation parameters into a single, dereferenced parameter array */
|
|
3
3
|
export declare const combineParams: (pathParams?: PathItemObject["parameters"], operationParams?: OperationObject["parameters"]) => OperationObject["parameters"];
|
|
4
4
|
//# sourceMappingURL=combine-params.d.ts.map
|