@scalar/workspace-store 0.68.2 → 0.68.4
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 +39 -0
- package/README.md +20 -0
- package/dist/channel-example/build-connection-url.d.ts.map +1 -1
- package/dist/channel-example/build-connection-url.js +6 -5
- package/dist/channel-example/get-all-channel-messages.js +2 -2
- package/dist/channel-example/get-async-api-protocols.d.ts +3 -1
- package/dist/channel-example/get-async-api-protocols.d.ts.map +1 -1
- package/dist/channel-example/get-async-api-protocols.js +9 -5
- package/dist/channel-example/get-asyncapi-security-requirements.d.ts +14 -2
- package/dist/channel-example/get-asyncapi-security-requirements.d.ts.map +1 -1
- package/dist/channel-example/get-asyncapi-security-requirements.js +93 -36
- package/dist/channel-example/get-channel-connection-context.d.ts.map +1 -1
- package/dist/channel-example/get-channel-connection-context.js +3 -4
- package/dist/channel-example/get-channel-connection-security.d.ts +3 -2
- package/dist/channel-example/get-channel-connection-security.d.ts.map +1 -1
- package/dist/channel-example/get-channel-connection-security.js +4 -6
- package/dist/channel-example/get-channel-operations.d.ts.map +1 -1
- package/dist/channel-example/get-channel-operations.js +4 -3
- package/dist/channel-example/get-channel-parameters.d.ts.map +1 -1
- package/dist/channel-example/get-channel-parameters.js +4 -3
- package/dist/channel-example/index.d.ts +2 -2
- package/dist/channel-example/index.d.ts.map +1 -1
- package/dist/channel-example/index.js +2 -2
- package/dist/channel-example/resolve-channel.d.ts.map +1 -1
- package/dist/channel-example/resolve-channel.js +4 -3
- package/dist/channel-example/resolve-operation-channel.d.ts.map +1 -1
- package/dist/channel-example/resolve-operation-channel.js +8 -6
- package/dist/channel-example/resolve-operation-with-traits.d.ts +1 -3
- package/dist/channel-example/resolve-operation-with-traits.d.ts.map +1 -1
- package/dist/channel-example/resolve-operation-with-traits.js +3 -41
- package/dist/channel-example/servers.d.ts.map +1 -1
- package/dist/channel-example/servers.js +4 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -4
- package/dist/entities/auth/schema.d.ts +25 -0
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/entities/auth/schema.js +2 -0
- package/dist/events/definitions/operation.d.ts +7 -0
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/helpers/asyncapi-chunk-groups.d.ts.map +1 -1
- package/dist/helpers/asyncapi-chunk-groups.js +8 -4
- package/dist/helpers/asyncapi-model-chunk-reference.d.ts.map +1 -1
- package/dist/helpers/asyncapi-model-chunk-reference.js +2 -1
- package/dist/helpers/auth-secret-fields.d.ts +11 -0
- package/dist/helpers/auth-secret-fields.d.ts.map +1 -1
- package/dist/helpers/auth-secret-fields.js +22 -0
- package/dist/helpers/encode-path-parameter.d.ts.map +1 -1
- package/dist/helpers/encode-path-parameter.js +11 -12
- package/dist/helpers/external-examples.d.ts.map +1 -1
- package/dist/helpers/external-examples.js +6 -3
- package/dist/helpers/get-async-api-schema-view.d.ts +8 -0
- package/dist/helpers/get-async-api-schema-view.d.ts.map +1 -0
- package/dist/helpers/get-async-api-schema-view.js +82 -0
- package/dist/helpers/get-boolean-schema.d.ts +7 -0
- package/dist/helpers/get-boolean-schema.d.ts.map +1 -0
- package/dist/helpers/get-boolean-schema.js +5 -0
- package/dist/helpers/get-resolved-async-api-ref.d.ts +10 -0
- package/dist/helpers/get-resolved-async-api-ref.d.ts.map +1 -0
- package/dist/helpers/get-resolved-async-api-ref.js +18 -0
- package/dist/helpers/get-resolved-ref-deep.d.ts.map +1 -1
- package/dist/helpers/normalize-boolean-schemas.d.ts.map +1 -1
- package/dist/helpers/normalize-boolean-schemas.js +6 -1
- package/dist/helpers/operation-examples.d.ts.map +1 -1
- package/dist/helpers/operation-examples.js +2 -1
- package/dist/helpers/querystring-parameter.d.ts.map +1 -1
- package/dist/helpers/querystring-parameter.js +6 -6
- package/dist/helpers/resolve-security-requirements.d.ts.map +1 -1
- package/dist/helpers/resolve-security-requirements.js +38 -19
- package/dist/helpers/resolve-traits.d.ts +3 -0
- package/dist/helpers/resolve-traits.d.ts.map +1 -0
- package/dist/helpers/resolve-traits.js +76 -0
- package/dist/helpers/serialize-stream-example.js +1 -1
- package/dist/helpers/snapshot-schema.d.ts +9 -0
- package/dist/helpers/snapshot-schema.d.ts.map +1 -0
- package/dist/helpers/snapshot-schema.js +38 -0
- package/dist/helpers/use-external-examples.d.ts.map +1 -1
- package/dist/helpers/use-external-examples.js +10 -5
- package/dist/mutators/auth.d.ts +2 -1
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +32 -2
- package/dist/mutators/index.d.ts +2 -2
- package/dist/mutators/operation/helpers/har-to-operation.d.ts.map +1 -1
- package/dist/mutators/operation/helpers/har-to-operation.js +4 -2
- package/dist/mutators/operation/operation.d.ts.map +1 -1
- package/dist/mutators/operation/operation.js +4 -2
- package/dist/mutators/operation/parameters.d.ts.map +1 -1
- package/dist/mutators/operation/parameters.js +23 -1
- package/dist/mutators/tag.d.ts.map +1 -1
- package/dist/mutators/tag.js +4 -2
- package/dist/navigation/get-navigation-options.d.ts.map +1 -1
- package/dist/navigation/get-navigation-options.js +9 -5
- package/dist/navigation/helpers/get-tag-external-docs.d.ts +4 -0
- package/dist/navigation/helpers/get-tag-external-docs.d.ts.map +1 -0
- package/dist/navigation/helpers/get-tag-external-docs.js +6 -0
- package/dist/navigation/helpers/traverse-asyncapi-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-asyncapi-document.js +75 -36
- package/dist/navigation/helpers/traverse-paths.js +1 -1
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-schemas.js +2 -1
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-tags.js +3 -0
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +2 -1
- package/dist/plugins/bundler/openapi-document.d.ts.map +1 -1
- package/dist/plugins/bundler/openapi-document.js +2 -1
- package/dist/request-example/builder/body/build-multipart.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-multipart.js +18 -16
- package/dist/request-example/builder/body/encode-multipart-body.d.ts.map +1 -1
- package/dist/request-example/builder/body/encode-multipart-body.js +2 -1
- package/dist/request-example/builder/body/get-request-body-example.d.ts +2 -2
- package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
- package/dist/request-example/builder/body/get-request-body-example.js +8 -7
- package/dist/request-example/builder/body/schema-value-coercion.d.ts.map +1 -1
- package/dist/request-example/builder/body/schema-value-coercion.js +4 -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 +12 -2
- package/dist/request-example/builder/header/filter-disabled-properties.d.ts +3 -0
- package/dist/request-example/builder/header/filter-disabled-properties.d.ts.map +1 -0
- package/dist/request-example/builder/header/filter-disabled-properties.js +18 -0
- package/dist/request-example/builder/header/filter-global-cookies.d.ts +1 -1
- package/dist/request-example/builder/header/filter-global-cookies.d.ts.map +1 -1
- package/dist/request-example/builder/header/filter-global-cookies.js +15 -3
- package/dist/request-example/builder/header/is-param-disabled.d.ts +1 -1
- package/dist/request-example/builder/header/is-param-disabled.d.ts.map +1 -1
- package/dist/request-example/builder/header/is-param-disabled.js +3 -2
- 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 +27 -16
- package/dist/request-example/builder/helpers/get-example.d.ts +2 -0
- package/dist/request-example/builder/helpers/get-example.d.ts.map +1 -1
- package/dist/request-example/builder/helpers/get-example.js +15 -5
- 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/resolve-request-factory-url.d.ts.map +1 -1
- package/dist/request-example/builder/resolve-request-factory-url.js +9 -8
- package/dist/request-example/builder/security/secret-types.d.ts +13 -3
- package/dist/request-example/builder/security/secret-types.d.ts.map +1 -1
- package/dist/request-example/context/headers.js +1 -1
- 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 +65 -25
- package/dist/request-example/context/security/get-selected-security.js +1 -1
- package/dist/request-example/context/security/merge-security.d.ts.map +1 -1
- package/dist/request-example/context/security/merge-security.js +12 -2
- package/dist/request-example/context/security/uses-api-key-name-override.d.ts +9 -0
- package/dist/request-example/context/security/uses-api-key-name-override.d.ts.map +1 -0
- package/dist/request-example/context/security/uses-api-key-name-override.js +9 -0
- 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/request-example/xml/get-xml-example.js +2 -1
- package/dist/request-example/xml/write-xml.d.ts.map +1 -1
- package/dist/request-example/xml/write-xml.js +7 -5
- package/dist/resolve.d.ts +1 -1
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +16 -1
- package/dist/schemas/extensions/example/x-disabled.d.ts +4 -0
- package/dist/schemas/extensions/example/x-disabled.d.ts.map +1 -1
- package/dist/schemas/extensions/example/x-disabled.js +3 -1
- package/dist/schemas/navigation.d.ts +5 -1
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/navigation.js +2 -1
- package/dist/schemas/reference-config/index.d.ts +3 -0
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +3 -0
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/example.d.ts +3 -0
- package/dist/schemas/v3.1/strict/example.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +106 -6
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/example.d.ts +3 -0
- package/dist/schemas/v3.2/strict/example.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/openapi-document.d.ts +106 -6
- package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +16 -7
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode-path-parameter.d.ts","sourceRoot":"","sources":["../../src/helpers/encode-path-parameter.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,EAAE,uBAAqB,KAAG,MAS1E,CAAA;AAED,gFAAgF;AAChF,MAAM,MAAM,qBAAqB,GAAG;IAClC,oFAAoF;IACpF,KAAK,EAAE,OAAO,CAAA;IACd,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,wFAAwF;AACxF,eAAO,MAAM,8BAA8B,GACzC,MAAM,MAAM,EACZ,WAAW,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC,EACrE,UAAS,CAAC,KAAK,EAAE,MAAM,KAAK,MAAyB,KACpD,
|
|
1
|
+
{"version":3,"file":"encode-path-parameter.d.ts","sourceRoot":"","sources":["../../src/helpers/encode-path-parameter.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,EAAE,uBAAqB,KAAG,MAS1E,CAAA;AAED,gFAAgF;AAChF,MAAM,MAAM,qBAAqB,GAAG;IAClC,oFAAoF;IACpF,KAAK,EAAE,OAAO,CAAA;IACd,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,wFAAwF;AACxF,eAAO,MAAM,8BAA8B,GACzC,MAAM,MAAM,EACZ,WAAW,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC,EACrE,UAAS,CAAC,KAAK,EAAE,MAAM,KAAK,MAAyB,KACpD,MA4BF,CAAA;AAED,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,IAKnD,CAAA"}
|
|
@@ -25,21 +25,20 @@ export const serializeReservedPathParameter = (name, parameter, replace = (value
|
|
|
25
25
|
if (array && explode) {
|
|
26
26
|
return array.map((item) => `;${encode(name)}=${encode(item)}`).join('');
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
: array
|
|
31
|
-
? array.map(encode).join(',')
|
|
32
|
-
: encode(value);
|
|
28
|
+
const parts = entries ? entries.flatMap(([key, item]) => [key, item]) : (array ?? [value]);
|
|
29
|
+
const data = parts.map(encode).join(',');
|
|
33
30
|
return `;${encode(name)}=${data}`;
|
|
34
31
|
}
|
|
35
32
|
const delimiter = style === 'label' && explode ? '.' : ',';
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
let data;
|
|
34
|
+
if (entries) {
|
|
35
|
+
data = entries
|
|
36
|
+
.map(([key, item]) => (explode ? `${encode(key)}=${encode(item)}` : `${encode(key)}${delimiter}${encode(item)}`))
|
|
37
|
+
.join(delimiter);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
data = array ? array.map(encode).join(delimiter) : encode(value);
|
|
41
|
+
}
|
|
43
42
|
return style === 'label' ? `.${data}` : data;
|
|
44
43
|
};
|
|
45
44
|
/** Rejects dot segments that browser URL parsing would silently remove. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-examples.d.ts","sourceRoot":"","sources":["../../src/helpers/external-examples.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,2BAA2B,CAAA;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAA;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAw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,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,YAAY,CAAA;CAAO,KAC7F,uBA8CF,CAAA"}
|
|
@@ -11,16 +11,19 @@ export const createExternalExampleResolver = (options = {}) => {
|
|
|
11
11
|
}
|
|
12
12
|
const url = resolveReferencePath(options.origin ?? '', example.externalValue) ?? example.externalValue;
|
|
13
13
|
const cached = cache.get(url);
|
|
14
|
-
if (cached)
|
|
14
|
+
if (cached) {
|
|
15
15
|
return cached;
|
|
16
|
+
}
|
|
16
17
|
let pending;
|
|
17
18
|
const state = shallowReactive({
|
|
18
19
|
status: 'idle',
|
|
19
20
|
load: () => {
|
|
20
|
-
if (pending)
|
|
21
|
+
if (pending) {
|
|
21
22
|
return pending;
|
|
22
|
-
|
|
23
|
+
}
|
|
24
|
+
if (state.status === 'loaded') {
|
|
23
25
|
return Promise.resolve();
|
|
26
|
+
}
|
|
24
27
|
state.status = 'loading';
|
|
25
28
|
pending = (async () => {
|
|
26
29
|
try {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Give shared schema renderers and example generation an AsyncAPI view without authored
|
|
3
|
+
* reference siblings. Keep reference wrappers for model links and traverse only schema
|
|
4
|
+
* positions: examples, defaults, extensions, and property names can contain literal `$ref`s.
|
|
5
|
+
* The snapshot is local to a read so subsequent reactive edits are not hidden by a cache.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getAsyncApiSchemaView: (source: unknown, schemaFormat?: string) => unknown;
|
|
8
|
+
//# sourceMappingURL=get-async-api-schema-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-async-api-schema-view.d.ts","sourceRoot":"","sources":["../../src/helpers/get-async-api-schema-view.ts"],"names":[],"mappings":"AAoBA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,OAAO,EAAE,eAAe,MAAM,KAAG,OAiE9E,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isObject } from '@scalar/helpers/object/is-object';
|
|
2
|
+
import { getResolvedAsyncApiRef } from './get-resolved-async-api-ref.js';
|
|
3
|
+
const schemaMaps = new Set(['properties', 'patternProperties', 'definitions', '$defs', 'dependentSchemas']);
|
|
4
|
+
const schemaArrays = new Set(['allOf', 'anyOf', 'oneOf', 'prefixItems']);
|
|
5
|
+
const schemaFields = new Set([
|
|
6
|
+
'items',
|
|
7
|
+
'additionalItems',
|
|
8
|
+
'additionalProperties',
|
|
9
|
+
'contains',
|
|
10
|
+
'propertyNames',
|
|
11
|
+
'not',
|
|
12
|
+
'if',
|
|
13
|
+
'then',
|
|
14
|
+
'else',
|
|
15
|
+
'unevaluatedItems',
|
|
16
|
+
'unevaluatedProperties',
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* Give shared schema renderers and example generation an AsyncAPI view without authored
|
|
20
|
+
* reference siblings. Keep reference wrappers for model links and traverse only schema
|
|
21
|
+
* positions: examples, defaults, extensions, and property names can contain literal `$ref`s.
|
|
22
|
+
* The snapshot is local to a read so subsequent reactive edits are not hidden by a cache.
|
|
23
|
+
*/
|
|
24
|
+
export const getAsyncApiSchemaView = (source, schemaFormat) => {
|
|
25
|
+
// Foreign schema formats own their reference semantics. AsyncAPI's native schemas and
|
|
26
|
+
// its required JSON Schema draft-07 format both ignore reference siblings.
|
|
27
|
+
if (schemaFormat &&
|
|
28
|
+
!/^application\/(?:vnd\.aai\.asyncapi(?:\+json|\+yaml)?(?:;|$)|schema\+(?:json|yaml)(?:;version=draft-07)?$)/i.test(schemaFormat)) {
|
|
29
|
+
return source;
|
|
30
|
+
}
|
|
31
|
+
const seen = new WeakMap();
|
|
32
|
+
const visit = (value) => {
|
|
33
|
+
if (!isObject(value)) {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
const existing = seen.get(value);
|
|
37
|
+
if (existing) {
|
|
38
|
+
return existing;
|
|
39
|
+
}
|
|
40
|
+
const result = {};
|
|
41
|
+
seen.set(value, result);
|
|
42
|
+
if (typeof value.$ref === 'string') {
|
|
43
|
+
result.$ref = value.$ref;
|
|
44
|
+
// Bookkeeping belongs to the store, not the authored Reference Object.
|
|
45
|
+
for (const key of ['$global', '$status']) {
|
|
46
|
+
if (Object.hasOwn(value, key)) {
|
|
47
|
+
result[key] = value[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
Object.defineProperty(result, '$ref-value', {
|
|
51
|
+
value: visit(getResolvedAsyncApiRef(value)),
|
|
52
|
+
enumerable: true,
|
|
53
|
+
});
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
for (const [key, child] of Object.entries(value)) {
|
|
57
|
+
Object.defineProperty(result, key, {
|
|
58
|
+
value: visitChild(key, child),
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
};
|
|
66
|
+
const visitChild = (key, child) => {
|
|
67
|
+
if (schemaMaps.has(key) && isObject(child)) {
|
|
68
|
+
return Object.fromEntries(Object.entries(child).map(([name, schema]) => [name, visit(schema)]));
|
|
69
|
+
}
|
|
70
|
+
if (key === 'dependencies' && isObject(child)) {
|
|
71
|
+
return Object.fromEntries(Object.entries(child).map(([name, dependency]) => [
|
|
72
|
+
name,
|
|
73
|
+
Array.isArray(dependency) ? dependency : visit(dependency),
|
|
74
|
+
]));
|
|
75
|
+
}
|
|
76
|
+
if ((schemaArrays.has(key) || key === 'items') && Array.isArray(child)) {
|
|
77
|
+
return child.map(visit);
|
|
78
|
+
}
|
|
79
|
+
return schemaFields.has(key) ? visit(child) : child;
|
|
80
|
+
};
|
|
81
|
+
return visit(source);
|
|
82
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SchemaObject } from '../schemas/v3.2/strict/openapi-document.js';
|
|
2
|
+
/**
|
|
3
|
+
* Explain boolean schemas to object-based renderers without changing the source document.
|
|
4
|
+
* The strict schema union requires a type, but these equivalent JSON Schemas intentionally have none.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getBooleanSchema: (value: boolean) => SchemaObject;
|
|
7
|
+
//# sourceMappingURL=get-boolean-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-boolean-schema.d.ts","sourceRoot":"","sources":["../../src/helpers/get-boolean-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,KAAG,YAC+D,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explain boolean schemas to object-based renderers without changing the source document.
|
|
3
|
+
* The strict schema union requires a type, but these equivalent JSON Schemas intentionally have none.
|
|
4
|
+
*/
|
|
5
|
+
export const getBooleanSchema = (value) => (value ? { description: 'Accepts any value.' } : { not: {}, description: 'Accepts no value.' });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AsyncAPI Reference Objects have no authored siblings. Follow every hop, including
|
|
3
|
+
* references with ignored siblings, and leave missing or circular aliases unresolved.
|
|
4
|
+
* Keep the shared OpenAPI resolver unchanged: its schema resources have different rules.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getResolvedAsyncApiRef: <Node>(node: Node | {
|
|
7
|
+
$ref: string;
|
|
8
|
+
"$ref-value"?: Node;
|
|
9
|
+
}) => Node | undefined;
|
|
10
|
+
//# sourceMappingURL=get-resolved-async-api-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-resolved-async-api-ref.d.ts","sourceRoot":"","sources":["../../src/helpers/get-resolved-async-api-ref.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,IAAI,EAAE,MAAM,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,IAAI,CAAA;CAAE,KAAG,IAAI,GAAG,SAWxG,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isObject } from '@scalar/helpers/object/is-object';
|
|
2
|
+
/**
|
|
3
|
+
* AsyncAPI Reference Objects have no authored siblings. Follow every hop, including
|
|
4
|
+
* references with ignored siblings, and leave missing or circular aliases unresolved.
|
|
5
|
+
* Keep the shared OpenAPI resolver unchanged: its schema resources have different rules.
|
|
6
|
+
*/
|
|
7
|
+
export const getResolvedAsyncApiRef = (node) => {
|
|
8
|
+
const seen = new Set();
|
|
9
|
+
let current = node;
|
|
10
|
+
while (isObject(current) && typeof current.$ref === 'string') {
|
|
11
|
+
if (seen.has(current)) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
seen.add(current);
|
|
15
|
+
current = current['$ref-value'];
|
|
16
|
+
}
|
|
17
|
+
return current;
|
|
18
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-resolved-ref-deep.d.ts","sourceRoot":"","sources":["../../src/helpers/get-resolved-ref-deep.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,kDAAkD,CAAA;AAMnG,KAAK,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAA;AAC1F,KAAK,SAAS,CAAC,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAE3C;;;;GAIG;AACH,KAAK,eAAe,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"get-resolved-ref-deep.d.ts","sourceRoot":"","sources":["../../src/helpers/get-resolved-ref-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AAS,CAAC,IAAI,CAAC,CAyE/F,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-boolean-schemas.d.ts","sourceRoot":"","sources":["../../src/helpers/normalize-boolean-schemas.ts"],"names":[],"mappings":"AAgDA;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"normalize-boolean-schemas.d.ts","sourceRoot":"","sources":["../../src/helpers/normalize-boolean-schemas.ts"],"names":[],"mappings":"AAgDA;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,KAAG,CAuJxF,CAAA"}
|
|
@@ -152,11 +152,16 @@ export const normalizeBooleanSchemas = (document) => {
|
|
|
152
152
|
// Vendor extensions are opaque. x-ext additionally contains bundled documents
|
|
153
153
|
// and schema targets whose context can be supplied by a local reference.
|
|
154
154
|
if (child !== null && typeof child === 'object') {
|
|
155
|
+
let mapDepth = task.mapDepth - 1;
|
|
156
|
+
if (!isMapEntry) {
|
|
157
|
+
const mapLevels = openApiMaps.has(key) ? 1 : 0;
|
|
158
|
+
mapDepth = key === 'callbacks' ? 2 : mapLevels;
|
|
159
|
+
}
|
|
155
160
|
tasks.push({
|
|
156
161
|
node: link(node, key, child),
|
|
157
162
|
kind: 'document',
|
|
158
163
|
path: childPath,
|
|
159
|
-
mapDepth
|
|
164
|
+
mapDepth,
|
|
160
165
|
});
|
|
161
166
|
}
|
|
162
167
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-examples.d.ts","sourceRoot":"","sources":["../../src/helpers/operation-examples.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAmB,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE7G,+FAA+F;AAC/F,eAAO,MAAM,oBAAoB,GAC/B,WAAW,eAAe,EAC1B,KAAK,MAAM,EACX,cAAc,MAAM,KACnB,CAAC,aAAa,GAAG,SAAS,CAAC,EAS7B,CAAA;AAED,8FAA8F;AAC9F,eAAO,MAAM,wBAAwB,GACnC,WAAW,eAAe,EAC1B,KAAK,MAAM,EACX,aAAa,MAAM,GAAG,SAAS,EAC/B,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,KAAK,aAAa,GAAG,SAAS,KACzE,
|
|
1
|
+
{"version":3,"file":"operation-examples.d.ts","sourceRoot":"","sources":["../../src/helpers/operation-examples.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAmB,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE7G,+FAA+F;AAC/F,eAAO,MAAM,oBAAoB,GAC/B,WAAW,eAAe,EAC1B,KAAK,MAAM,EACX,cAAc,MAAM,KACnB,CAAC,aAAa,GAAG,SAAS,CAAC,EAS7B,CAAA;AAED,8FAA8F;AAC9F,eAAO,MAAM,wBAAwB,GACnC,WAAW,eAAe,EAC1B,KAAK,MAAM,EACX,aAAa,MAAM,GAAG,SAAS,EAC/B,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,KAAK,aAAa,GAAG,SAAS,KACzE,eAkCF,CAAA"}
|
|
@@ -32,8 +32,9 @@ export const resolveOperationExamples = (operation, key, contentType, resolve) =
|
|
|
32
32
|
: {}),
|
|
33
33
|
parameters: operation.parameters?.map((parameter) => {
|
|
34
34
|
const resolved = getResolvedRef(parameter);
|
|
35
|
-
if (!resolved)
|
|
35
|
+
if (!resolved) {
|
|
36
36
|
return parameter;
|
|
37
|
+
}
|
|
37
38
|
const content = 'content' in resolved ? resolved.content : undefined;
|
|
38
39
|
const mediaType = Object.keys(content ?? {})[0];
|
|
39
40
|
if (mediaType && content?.[mediaType]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"querystring-parameter.d.ts","sourceRoot":"","sources":["../../src/helpers/querystring-parameter.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAiB,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE5G,yFAAyF;AACzF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACzC,sGAAsG;IACtG,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,MAAM,CAAA;CAC1C,CAAA;AAmBD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,WAAW,eAAe,EAC1B,cAAc,MAAM,EACpB,wCAGG;IACD,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,8DAA8D;IAC9D,eAAe,CAAC,EAAE,OAAO,CAAA;CACrB,KACL,oBAAoB,GAAG,
|
|
1
|
+
{"version":3,"file":"querystring-parameter.d.ts","sourceRoot":"","sources":["../../src/helpers/querystring-parameter.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAiB,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE5G,yFAAyF;AACzF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACzC,sGAAsG;IACtG,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,MAAM,CAAA;CAC1C,CAAA;AAmBD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,WAAW,eAAe,EAC1B,cAAc,MAAM,EACpB,wCAGG;IACD,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,8DAA8D;IAC9D,eAAe,CAAC,EAAE,OAAO,CAAA;CACrB,KACL,oBAAoB,GAAG,SA4BzB,CAAA;AAED,wFAAwF;AACxF,eAAO,MAAM,6BAA6B,GACxC,WAAW,oBAAoB,EAC/B,YAAW,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAM,KAC1E,MAyDF,CAAA"}
|
|
@@ -44,8 +44,12 @@ export const getQuerystringParameter = (parameter, exampleName, { defaultDisable
|
|
|
44
44
|
}
|
|
45
45
|
const value = example?.serializedValue ?? (example?.dataValue !== undefined ? example.dataValue : example?.value);
|
|
46
46
|
const schema = getResolvedRef(mediaType?.schema);
|
|
47
|
+
let resolvedValue = value;
|
|
48
|
+
if (resolvedValue === undefined) {
|
|
49
|
+
resolvedValue = schema ? getExampleFromSchema(schema) : '';
|
|
50
|
+
}
|
|
47
51
|
return {
|
|
48
|
-
value:
|
|
52
|
+
value: resolvedValue,
|
|
49
53
|
contentType,
|
|
50
54
|
encoding: mediaType?.encoding,
|
|
51
55
|
kind: getQuerystringValueKind(example, parameterExample === undefined ? 'media' : 'parameter'),
|
|
@@ -99,10 +103,6 @@ export const serializeQuerystringParameter = (parameter, variables = {}) => {
|
|
|
99
103
|
}
|
|
100
104
|
return applyAllowReservedToUrl(`?${params}`, reservedKeys).slice(1);
|
|
101
105
|
}
|
|
102
|
-
const serialized = parameter.kind
|
|
103
|
-
? String(value)
|
|
104
|
-
: isJsonMediaType(contentType)
|
|
105
|
-
? JSON.stringify(value)
|
|
106
|
-
: String(value);
|
|
106
|
+
const serialized = parameter.kind !== 'serialized' && isJsonMediaType(contentType) ? JSON.stringify(value) : String(value);
|
|
107
107
|
return encodeURIComponent(serialized).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
108
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-security-requirements.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-security-requirements.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAgC,MAAM,2BAA2B,CAAA;AAa3F,KAAK,kBAAkB,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,YAAY,EAAE,CAAA;CACxB,CAAA;AAUD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GACtC,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,qBAA2B,kBAAkB,KAC5C,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"resolve-security-requirements.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-security-requirements.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAgC,MAAM,2BAA2B,CAAA;AAa3F,KAAK,kBAAkB,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,YAAY,EAAE,CAAA;CACxB,CAAA;AAUD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GACtC,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,qBAA2B,kBAAkB,KAC5C,OAAO,CAAC,IAAI,CAoKd,CAAA;AAED,iGAAiG;AACjG,eAAO,MAAM,2BAA2B,GAAI,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAkE/E,CAAA"}
|
|
@@ -25,8 +25,9 @@ const absoluteReference = (reference, base) => {
|
|
|
25
25
|
* Relative keys in referenced documents become absolute to keep distinct document bases apart.
|
|
26
26
|
*/
|
|
27
27
|
export const resolveSecurityRequirements = async (document, { origin = '/', loaders }) => {
|
|
28
|
-
if (typeof document.openapi !== 'string' || !/^3\.2\.\d+$/.test(document.openapi))
|
|
28
|
+
if (typeof document.openapi !== 'string' || !/^3\.2\.\d+$/.test(document.openapi)) {
|
|
29
29
|
return;
|
|
30
|
+
}
|
|
30
31
|
const originalKeys = isObject(document[ORIGINAL_KEYS]) ? document[ORIGINAL_KEYS] : {};
|
|
31
32
|
const components = isObject(document.components) ? document.components : {};
|
|
32
33
|
const schemes = isObject(components.securitySchemes) ? components.securitySchemes : {};
|
|
@@ -44,8 +45,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
44
45
|
const processedDocuments = new Set();
|
|
45
46
|
const cache = new Map();
|
|
46
47
|
const visit = async (node, path, base, external) => {
|
|
47
|
-
if (node === null || typeof node !== 'object' || visited.has(node) || isSchemaPath(path))
|
|
48
|
+
if (node === null || typeof node !== 'object' || visited.has(node) || isSchemaPath(path)) {
|
|
48
49
|
return;
|
|
50
|
+
}
|
|
49
51
|
visited.add(node);
|
|
50
52
|
// Security is a fixed field on document and operation objects, not arbitrary example payloads.
|
|
51
53
|
const operationKey = path.at(-1) ?? '';
|
|
@@ -53,11 +55,13 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
53
55
|
const isDocument = path.length === 0 || (path[0] === 'x-ext' && path.length === 2);
|
|
54
56
|
if (isObject(node) && (isDocument || isOperation) && Array.isArray(node.security)) {
|
|
55
57
|
for (const [index, requirement] of node.security.entries()) {
|
|
56
|
-
if (!isObject(requirement))
|
|
58
|
+
if (!isObject(requirement)) {
|
|
57
59
|
continue;
|
|
60
|
+
}
|
|
58
61
|
for (const [name, scopes] of Object.entries(requirement)) {
|
|
59
|
-
if (namedSchemes.has(name) || !Array.isArray(scopes))
|
|
62
|
+
if (namedSchemes.has(name) || !Array.isArray(scopes)) {
|
|
60
63
|
continue;
|
|
64
|
+
}
|
|
61
65
|
const uri = (() => {
|
|
62
66
|
try {
|
|
63
67
|
return Object.hasOwn(aliases, name) && typeof aliases[name] === 'string'
|
|
@@ -68,8 +72,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
68
72
|
return undefined;
|
|
69
73
|
}
|
|
70
74
|
})();
|
|
71
|
-
if (uri === undefined)
|
|
75
|
+
if (uri === undefined) {
|
|
72
76
|
continue;
|
|
77
|
+
}
|
|
73
78
|
const key = await generateUniqueValue({
|
|
74
79
|
defaultValue: external ? uri : name,
|
|
75
80
|
validation: (candidate) => !namedSchemes.has(candidate) &&
|
|
@@ -77,8 +82,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
77
82
|
(!external || candidate === name || !Object.hasOwn(requirement, candidate)),
|
|
78
83
|
maxRetries: Object.keys(schemes).length + 1,
|
|
79
84
|
});
|
|
80
|
-
if (key === undefined)
|
|
85
|
+
if (key === undefined) {
|
|
81
86
|
continue;
|
|
87
|
+
}
|
|
82
88
|
if (!Object.hasOwn(aliases, key)) {
|
|
83
89
|
const reference = { $ref: uri };
|
|
84
90
|
await bundle({ components: { securitySchemes: { target: reference } } }, {
|
|
@@ -106,8 +112,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
106
112
|
])),
|
|
107
113
|
}
|
|
108
114
|
: target;
|
|
109
|
-
if (!Value.Check(SecuritySchemeObjectSchema, validationTarget))
|
|
115
|
+
if (!Value.Check(SecuritySchemeObjectSchema, validationTarget)) {
|
|
110
116
|
continue;
|
|
117
|
+
}
|
|
111
118
|
Object.defineProperty(schemes, key, {
|
|
112
119
|
value: reference,
|
|
113
120
|
enumerable: true,
|
|
@@ -125,8 +132,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
125
132
|
Object.defineProperty(mapping, name, { value: key, enumerable: true, writable: true, configurable: true });
|
|
126
133
|
originalKeys[location] = mapping;
|
|
127
134
|
document[ORIGINAL_KEYS] = originalKeys;
|
|
128
|
-
if (key === name)
|
|
135
|
+
if (key === name) {
|
|
129
136
|
continue;
|
|
137
|
+
}
|
|
130
138
|
const previous = Object.hasOwn(requirement, key) ? requirement[key] : [];
|
|
131
139
|
Object.defineProperty(requirement, key, {
|
|
132
140
|
value: [...new Set([...(Array.isArray(previous) ? previous : []), ...scopes])],
|
|
@@ -140,8 +148,9 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
140
148
|
}
|
|
141
149
|
}
|
|
142
150
|
for (const [key, child] of Object.entries(node)) {
|
|
143
|
-
if (key.startsWith('x-') || key === 'example' || key === 'examples' || key === 'security')
|
|
151
|
+
if (key.startsWith('x-') || key === 'example' || key === 'examples' || key === 'security') {
|
|
144
152
|
continue;
|
|
153
|
+
}
|
|
145
154
|
await visit(child, [...path, key], base, external);
|
|
146
155
|
}
|
|
147
156
|
};
|
|
@@ -150,14 +159,17 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
150
159
|
// URI-only dependencies can load further documents, so process newly embedded documents too.
|
|
151
160
|
while (isObject(document['x-ext'])) {
|
|
152
161
|
const next = Object.entries(document['x-ext']).find(([key]) => !processedDocuments.has(key));
|
|
153
|
-
if (!next)
|
|
162
|
+
if (!next) {
|
|
154
163
|
break;
|
|
164
|
+
}
|
|
155
165
|
const [key, external] = next;
|
|
156
166
|
processedDocuments.add(key);
|
|
157
|
-
if (!isObject(external))
|
|
167
|
+
if (!isObject(external)) {
|
|
158
168
|
continue;
|
|
159
|
-
|
|
169
|
+
}
|
|
170
|
+
if (typeof external.openapi === 'string' && !/^3\.2\.\d+$/.test(external.openapi)) {
|
|
160
171
|
continue;
|
|
172
|
+
}
|
|
161
173
|
const mappings = document['x-ext-urls'];
|
|
162
174
|
const retrieval = isObject(mappings) && typeof mappings[key] === 'string' ? mappings[key] : key;
|
|
163
175
|
const retrievalUri = resolveReferencePath(entryBase, retrieval);
|
|
@@ -179,20 +191,24 @@ export const restoreSecurityRequirements = (document) => {
|
|
|
179
191
|
})();
|
|
180
192
|
if (!Array.isArray(path) ||
|
|
181
193
|
!path.every((segment) => typeof segment === 'string' && !isPollutionKey(segment)) ||
|
|
182
|
-
!isObject(mapping))
|
|
194
|
+
!isObject(mapping)) {
|
|
183
195
|
continue;
|
|
196
|
+
}
|
|
184
197
|
const requirement = path.reduce((parent, segment) => {
|
|
185
|
-
if (parent === null || typeof parent !== 'object' || !Object.hasOwn(parent, segment))
|
|
198
|
+
if (parent === null || typeof parent !== 'object' || !Object.hasOwn(parent, segment)) {
|
|
186
199
|
return undefined;
|
|
200
|
+
}
|
|
187
201
|
return Reflect.get(parent, segment);
|
|
188
202
|
}, document);
|
|
189
|
-
if (!isObject(requirement))
|
|
203
|
+
if (!isObject(requirement)) {
|
|
190
204
|
continue;
|
|
205
|
+
}
|
|
191
206
|
const entries = Object.entries(mapping).flatMap(([original, rewritten]) => typeof rewritten === 'string' && Object.hasOwn(requirement, rewritten)
|
|
192
207
|
? [{ original, rewritten, scopes: requirement[rewritten] }]
|
|
193
208
|
: []);
|
|
194
|
-
for (const { rewritten } of entries)
|
|
209
|
+
for (const { rewritten } of entries) {
|
|
195
210
|
delete requirement[rewritten];
|
|
211
|
+
}
|
|
196
212
|
for (const { original, scopes } of entries) {
|
|
197
213
|
Object.defineProperty(requirement, original, {
|
|
198
214
|
value: scopes,
|
|
@@ -210,12 +226,15 @@ export const restoreSecurityRequirements = (document) => {
|
|
|
210
226
|
isObject(components) &&
|
|
211
227
|
Object.hasOwn(components, 'securitySchemes') &&
|
|
212
228
|
isObject(components.securitySchemes)) {
|
|
213
|
-
for (const key of Object.keys(metadata.schemes))
|
|
229
|
+
for (const key of Object.keys(metadata.schemes)) {
|
|
214
230
|
delete components.securitySchemes[key];
|
|
215
|
-
|
|
231
|
+
}
|
|
232
|
+
if (!metadata.hadSecuritySchemes && Object.keys(components.securitySchemes).length === 0) {
|
|
216
233
|
delete components.securitySchemes;
|
|
217
|
-
|
|
234
|
+
}
|
|
235
|
+
if (!metadata.hadComponents && Object.keys(components).length === 0) {
|
|
218
236
|
delete document.components;
|
|
237
|
+
}
|
|
219
238
|
}
|
|
220
239
|
delete document[ALIASES];
|
|
221
240
|
delete document[ORIGINAL_KEYS];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-traits.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-traits.ts"],"names":[],"mappings":"AA4EA,uFAAuF;AACvF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,SAAS,MAAM,EAAE,KAAG,CAetF,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isObject } from '@scalar/helpers/object/is-object';
|
|
2
|
+
import { getResolvedAsyncApiRef } from './get-resolved-async-api-ref.js';
|
|
3
|
+
const schemaMaps = new Set(['properties', 'patternProperties', '$defs', 'definitions', 'dependentSchemas']);
|
|
4
|
+
const dataFields = new Set(['example', 'examples', 'default', 'enum', 'const', 'value', 'dataValue']);
|
|
5
|
+
/** Select how the next trait field treats schema references and literal data. */
|
|
6
|
+
const getChildContext = (context, key) => {
|
|
7
|
+
if (context === 'data') {
|
|
8
|
+
return 'data';
|
|
9
|
+
}
|
|
10
|
+
if (context === 'map') {
|
|
11
|
+
return 'object';
|
|
12
|
+
}
|
|
13
|
+
if (key === 'channel') {
|
|
14
|
+
return 'reference';
|
|
15
|
+
}
|
|
16
|
+
if (dataFields.has(key) || key.startsWith('x-')) {
|
|
17
|
+
return 'data';
|
|
18
|
+
}
|
|
19
|
+
return schemaMaps.has(key) ? 'map' : 'object';
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Apply JSON Merge Patch to resolved trait fields. Unlike mergeObjects, null removes a key.
|
|
23
|
+
* Resolve schema references before merging so a message can extend referenced trait headers.
|
|
24
|
+
*/
|
|
25
|
+
const mergeTraitFields = (target, patch, context = 'object', ancestors = new WeakMap()) => {
|
|
26
|
+
// Reply channels identify a location in the document, so retain their reference wrappers.
|
|
27
|
+
if (context === 'reference') {
|
|
28
|
+
return patch;
|
|
29
|
+
}
|
|
30
|
+
const resolvedPatch = context === 'object' && isObject(patch) && typeof patch.$ref === 'string' ? getResolvedAsyncApiRef(patch) : patch;
|
|
31
|
+
if (!isObject(resolvedPatch)) {
|
|
32
|
+
return resolvedPatch;
|
|
33
|
+
}
|
|
34
|
+
// Resolved schemas can be recursive. Keep their cycles without changing the source document.
|
|
35
|
+
if (ancestors.has(resolvedPatch)) {
|
|
36
|
+
return ancestors.get(resolvedPatch);
|
|
37
|
+
}
|
|
38
|
+
const resolvedTarget = context === 'object' && isObject(target) && typeof target.$ref === 'string'
|
|
39
|
+
? getResolvedAsyncApiRef(target)
|
|
40
|
+
: target;
|
|
41
|
+
const result = isObject(resolvedTarget) ? { ...resolvedTarget } : {};
|
|
42
|
+
ancestors.set(resolvedPatch, result);
|
|
43
|
+
for (const [key, value] of Object.entries(resolvedPatch)) {
|
|
44
|
+
if (value === null) {
|
|
45
|
+
delete result[key];
|
|
46
|
+
}
|
|
47
|
+
else if (value !== undefined) {
|
|
48
|
+
// Schema names and example data can contain literal $ref keys without being references.
|
|
49
|
+
const childContext = getChildContext(context, key);
|
|
50
|
+
// Define an own property even for schema properties named __proto__.
|
|
51
|
+
Object.defineProperty(result, key, {
|
|
52
|
+
value: mergeTraitFields(Object.hasOwn(result, key) ? result[key] : undefined, value, childContext, ancestors),
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
ancestors.delete(resolvedPatch);
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
/** Merge traits in order, then apply the target's own fields with highest priority. */
|
|
63
|
+
export const resolveTraits = (target, traits) => {
|
|
64
|
+
if (traits.length === 0) {
|
|
65
|
+
return target;
|
|
66
|
+
}
|
|
67
|
+
const inherited = traits.reduce((fields, trait) => {
|
|
68
|
+
const resolved = getResolvedAsyncApiRef(trait);
|
|
69
|
+
return resolved ? mergeTraitFields(fields, resolved) : fields;
|
|
70
|
+
}, {});
|
|
71
|
+
// Only overlay fields supplied by traits. Unrelated fields keep their references and identity.
|
|
72
|
+
const overrides = Object.fromEntries(Object.entries(target).filter(([key]) => Object.hasOwn(inherited, key)));
|
|
73
|
+
const merged = mergeTraitFields(inherited, overrides);
|
|
74
|
+
const ownFields = Object.fromEntries(Object.entries(target).filter(([key]) => !Object.hasOwn(inherited, key)));
|
|
75
|
+
return { ...ownFields, ...merged };
|
|
76
|
+
};
|
|
@@ -11,7 +11,7 @@ export const serializeStreamExample = (value, contentType, singleItem) => {
|
|
|
11
11
|
return undefined;
|
|
12
12
|
}
|
|
13
13
|
const format = getStreamFormat(contentType);
|
|
14
|
-
const items = singleItem
|
|
14
|
+
const items = !singleItem && Array.isArray(value) ? value : [value];
|
|
15
15
|
if (format === 'json-lines') {
|
|
16
16
|
return items.map((item) => `${JSON.stringify(item)}\n`).join('');
|
|
17
17
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot each schema object once, retaining shared and recursive references.
|
|
3
|
+
* Unpacking is shallow: use the raw object only for identity and ownership, then
|
|
4
|
+
* read through the proxy so reactive edits remain tracked and references resolve.
|
|
5
|
+
* Synthetic reference targets stay accessible to the generator but are omitted
|
|
6
|
+
* when literal example data is serialized.
|
|
7
|
+
*/
|
|
8
|
+
export declare const snapshotSchema: <T>(source: T, seen?: WeakMap<object, object>) => T;
|
|
9
|
+
//# sourceMappingURL=snapshot-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-schema.d.ts","sourceRoot":"","sources":["../../src/helpers/snapshot-schema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,QAAQ,CAAC,EAAE,8BAAoC,KAAG,CA+BnF,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { unpackProxyShallow } from '../helpers/unpack-proxy.js';
|
|
2
|
+
/**
|
|
3
|
+
* Snapshot each schema object once, retaining shared and recursive references.
|
|
4
|
+
* Unpacking is shallow: use the raw object only for identity and ownership, then
|
|
5
|
+
* read through the proxy so reactive edits remain tracked and references resolve.
|
|
6
|
+
* Synthetic reference targets stay accessible to the generator but are omitted
|
|
7
|
+
* when literal example data is serialized.
|
|
8
|
+
*/
|
|
9
|
+
export const snapshotSchema = (source, seen = new WeakMap()) => {
|
|
10
|
+
if (typeof source !== 'object' || source === null) {
|
|
11
|
+
return source;
|
|
12
|
+
}
|
|
13
|
+
const raw = unpackProxyShallow(source);
|
|
14
|
+
const existing = seen.get(raw);
|
|
15
|
+
if (existing) {
|
|
16
|
+
return existing;
|
|
17
|
+
}
|
|
18
|
+
const snapshot = Array.isArray(source) ? [] : {};
|
|
19
|
+
seen.set(raw, snapshot);
|
|
20
|
+
for (const key of Object.keys(source)) {
|
|
21
|
+
// Data descriptors also preserve literal __proto__ and inherited accessor names.
|
|
22
|
+
Object.defineProperty(snapshot, key, {
|
|
23
|
+
value: snapshotSchema(Reflect.get(source, key), seen),
|
|
24
|
+
enumerable: key !== '$ref-value' || Object.hasOwn(raw, key),
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Static document loaders can keep reference targets non-enumerable.
|
|
30
|
+
if ('$ref' in source && '$ref-value' in source && !Object.hasOwn(snapshot, '$ref-value')) {
|
|
31
|
+
Object.defineProperty(snapshot, '$ref-value', {
|
|
32
|
+
value: snapshotSchema(Reflect.get(source, '$ref-value'), seen),
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return snapshot;
|
|
38
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-external-examples.d.ts","sourceRoot":"","sources":["../../src/helpers/use-external-examples.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,GAAG,EAOT,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,KAAK,uBAAuB,EAAiC,MAAM,6BAA6B,CAAA;AACzG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAE3E,4FAA4F;AAC5F,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,MAAM,uBAAuB,CAA+B,C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