@scalar/workspace-store 0.68.1 → 0.68.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/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 +6 -2
- 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 +89 -32
- 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 +2 -1
- package/dist/channel-example/get-channel-parameters.d.ts.map +1 -1
- package/dist/channel-example/get-channel-parameters.js +2 -1
- 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 +2 -1
- package/dist/channel-example/resolve-operation-channel.d.ts.map +1 -1
- package/dist/channel-example/resolve-operation-channel.js +4 -2
- 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 +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -4
- package/dist/entities/auth/schema.d.ts +5 -0
- package/dist/entities/auth/schema.d.ts.map +1 -1
- 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/chunk-index.d.ts +2 -0
- package/dist/helpers/chunk-index.d.ts.map +1 -1
- package/dist/helpers/chunk-index.js +8 -1
- package/dist/helpers/encode-path-parameter.d.ts +20 -0
- package/dist/helpers/encode-path-parameter.d.ts.map +1 -0
- package/dist/helpers/encode-path-parameter.js +50 -0
- package/dist/helpers/external-examples.d.ts.map +1 -1
- package/dist/helpers/external-examples.js +6 -3
- 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-ref-deep.d.ts.map +1 -1
- package/dist/helpers/get-tag-kind.d.ts +6 -0
- package/dist/helpers/get-tag-kind.d.ts.map +1 -0
- package/dist/helpers/get-tag-kind.js +7 -0
- 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-form-schema.d.ts +9 -0
- package/dist/helpers/resolve-form-schema.d.ts.map +1 -0
- package/dist/helpers/resolve-form-schema.js +143 -0
- package/dist/helpers/resolve-schema-with-annotations.d.ts +11 -0
- package/dist/helpers/resolve-schema-with-annotations.d.ts.map +1 -0
- package/dist/helpers/resolve-schema-with-annotations.js +57 -0
- package/dist/helpers/resolve-security-requirements.d.ts +15 -0
- package/dist/helpers/resolve-security-requirements.d.ts.map +1 -0
- package/dist/helpers/resolve-security-requirements.js +241 -0
- 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 +68 -0
- package/dist/helpers/serialize-stream-example.js +1 -1
- 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.map +1 -1
- package/dist/mutators/auth.js +2 -1
- 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.js +6 -5
- package/dist/navigation/helpers/get-navigation-tag-names.d.ts +5 -0
- package/dist/navigation/helpers/get-navigation-tag-names.d.ts.map +1 -0
- package/dist/navigation/helpers/get-navigation-tag-names.js +3 -0
- package/dist/navigation/helpers/traverse-asyncapi-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-asyncapi-document.js +27 -20
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +5 -3
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-schemas.js +6 -3
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-tags.js +8 -4
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js +4 -2
- 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/build-request-body.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-request-body.js +3 -5
- 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.map +1 -1
- package/dist/request-example/builder/body/get-request-body-example.js +2 -1
- package/dist/request-example/builder/body/schema-value-coercion.d.ts.map +1 -1
- package/dist/request-example/builder/body/schema-value-coercion.js +9 -8
- package/dist/request-example/builder/build-request.d.ts.map +1 -1
- package/dist/request-example/builder/build-request.js +3 -0
- package/dist/request-example/builder/header/build-request-parameters.d.ts +7 -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 +34 -3
- 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 +20 -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/request-factory.d.ts +6 -1
- package/dist/request-example/builder/request-factory.d.ts.map +1 -1
- package/dist/request-example/builder/request-factory.js +3 -1
- package/dist/request-example/builder/resolve-request-factory-url.d.ts.map +1 -1
- package/dist/request-example/builder/resolve-request-factory-url.js +23 -7
- 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 +63 -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 +2 -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/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 +6 -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 +1 -1
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.d.ts +1 -0
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +1 -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 +36 -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 +36 -6
- package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +37 -8
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode-multipart-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/encode-multipart-body.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AA0BtD,sFAAsF;AACtF,eAAO,MAAM,sBAAsB,GACjC,OAAO,aAAa,EAAE,EACtB,oBAAmC,EACnC,UAAS,CAAC,KAAK,EAAE,MAAM,KAAK,MAAyB,EACrD,gBAAW,KACV;IAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"encode-multipart-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/encode-multipart-body.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AA0BtD,sFAAsF;AACtF,eAAO,MAAM,sBAAsB,GACjC,OAAO,aAAa,EAAE,EACtB,oBAAmC,EACnC,UAAS,CAAC,KAAK,EAAE,MAAM,KAAK,MAAyB,EACrD,gBAAW,KACV;IAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CA8C3C,CAAA;AAED,+FAA+F;AAC/F,eAAO,MAAM,mBAAmB,GAC9B,OAAO,aAAa,EAAE,EACtB,oBAAmC,EACnC,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,KAClC,IAGF,CAAA"}
|
|
@@ -33,7 +33,8 @@ export const serializeMultipartBody = (parts, contentType = 'multipart/form-data
|
|
|
33
33
|
const encoded = part.type === 'multipart'
|
|
34
34
|
? serializeMultipartBody(part.value, part.contentType, replace, nesting + 1)
|
|
35
35
|
: { chunks: [part.type === 'text' ? replace(part.value) : part.value], contentType: part.contentType };
|
|
36
|
-
const
|
|
36
|
+
const blobFilename = part.type === 'blob' ? 'blob' : undefined;
|
|
37
|
+
const filename = part.type === 'file' ? part.value.name : blobFilename;
|
|
37
38
|
const partContentType = encoded.contentType ??
|
|
38
39
|
(part.type === 'file' || part.type === 'blob' ? part.value.type || 'application/octet-stream' : undefined);
|
|
39
40
|
if (partContentType && /[\r\n\0]/.test(partContentType)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/get-request-body-example.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AASrE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxD,iBAAiB,MAAM,KACtB,OAgCF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxD,iBAAiB,MAAM,KACtB,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/get-request-body-example.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AASrE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxD,iBAAiB,MAAM,KACtB,OAgCF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxD,iBAAiB,MAAM,KACtB,aAAa,GAAG,IA4ClB,CAAA"}
|
|
@@ -58,8 +58,9 @@ export const getExampleFromBody = (requestBody, contentType, exampleName, reques
|
|
|
58
58
|
compositionSelection: requestBodyCompositionSelection,
|
|
59
59
|
schemaPath: ['requestBody'],
|
|
60
60
|
});
|
|
61
|
-
if (result.xml === undefined)
|
|
61
|
+
if (result.xml === undefined) {
|
|
62
62
|
return null;
|
|
63
|
+
}
|
|
63
64
|
// Consumers select dataValue before value, so retain the serialized result for editor and wire output.
|
|
64
65
|
return example?.dataValue !== undefined
|
|
65
66
|
? { ...example, value: result.xml, serializedValue: result.xml }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-value-coercion.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/schema-value-coercion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;
|
|
1
|
+
{"version":3,"file":"schema-value-coercion.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/schema-value-coercion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAYhG;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,YAAY,GAAG,SAAS,EAAE,UAAU,MAAM,EAAE,KAAG,YAAY,GAAG,SASvG,CAAA;AA2BD;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,OAAO,EAAE,QAAQ,YAAY,GAAG,SAAS,KAAG,OAe9F,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,OAUnD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,GAAI,QAAQ,OAAO,aAG1C,MAAM,UAAU,OAAO,YAgBzC,CAAA"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveSchemaWithAnnotations } from '@scalar/workspace-store/helpers/resolve-schema-with-annotations';
|
|
2
2
|
import { isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards';
|
|
3
3
|
/** Normalize a schema's `type` (string | string[] | absent) into a plain string array. */
|
|
4
4
|
const normalizeSchemaTypes = (schema) => {
|
|
5
5
|
const type = 'type' in schema ? schema.type : undefined;
|
|
6
|
-
|
|
6
|
+
if (Array.isArray(type)) {
|
|
7
|
+
return [...type];
|
|
8
|
+
}
|
|
9
|
+
return type == null ? [] : [type];
|
|
7
10
|
};
|
|
8
11
|
/**
|
|
9
12
|
* Walk an object schema along a dotted-row path and return the resolved leaf schema,
|
|
10
13
|
* or undefined when any segment is not a declared object property.
|
|
11
14
|
*/
|
|
12
15
|
export const resolveLeafSchema = (schema, segments) => {
|
|
13
|
-
let current = schema;
|
|
16
|
+
let current = resolveSchemaWithAnnotations(schema);
|
|
14
17
|
for (const segment of segments) {
|
|
15
18
|
if (!current || !isObjectSchema(current) || !current.properties) {
|
|
16
19
|
return undefined;
|
|
17
20
|
}
|
|
18
|
-
current =
|
|
21
|
+
current = resolveSchemaWithAnnotations(current.properties[segment]);
|
|
19
22
|
}
|
|
20
23
|
return current;
|
|
21
24
|
};
|
|
@@ -97,15 +100,13 @@ export const coerceUntypedValue = (value) => {
|
|
|
97
100
|
* back into nested objects.
|
|
98
101
|
*/
|
|
99
102
|
export const buildDottedNestedRowPredicate = (schema) => {
|
|
100
|
-
const resolved = schema ?
|
|
103
|
+
const resolved = schema ? resolveSchemaWithAnnotations(schema) : undefined;
|
|
101
104
|
if (!resolved || !isObjectSchema(resolved) || !resolved.properties) {
|
|
102
105
|
return (_name, _value) => false;
|
|
103
106
|
}
|
|
104
107
|
const nestedTopKeys = new Set();
|
|
105
108
|
for (const [key, child] of Object.entries(resolved.properties)) {
|
|
106
|
-
const childResolved = child
|
|
107
|
-
? getResolvedRef(child, mergeSiblingReferences)
|
|
108
|
-
: undefined;
|
|
109
|
+
const childResolved = child ? resolveSchemaWithAnnotations(child) : undefined;
|
|
109
110
|
if (childResolved && isObjectSchema(childResolved) && childResolved.properties) {
|
|
110
111
|
nestedTopKeys.add(key);
|
|
111
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAQnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,uDAAuD,CAAA;AAK9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAwClD;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,cAAc,EACvB,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,iBAAiB;IAAE,6BAA6B,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3D,MAyBF,CAAA;AAED;;;;;KAKK;AACL,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kGAAkG;IAClG,cAAc,EAAE,cAAc,CAAA;IAC9B,2BAA2B;IAC3B,UAAU,EAAE,eAAe,CAAA;IAC3B,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAA;AAEnE,MAAM,MAAM,uBAAuB,GAAG,6BAA6B,GAAG,OAAO,oBAAoB,CAAA;AAEjG,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAA;AAElF,eAAO,MAAM,YAAY,GACvB,SAAS,cAAc,EACvB,SAAS;IACP,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC,KACA,
|
|
1
|
+
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAQnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,uDAAuD,CAAA;AAK9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAwClD;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,cAAc,EACvB,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,iBAAiB;IAAE,6BAA6B,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3D,MAyBF,CAAA;AAED;;;;;KAKK;AACL,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kGAAkG;IAClG,cAAc,EAAE,cAAc,CAAA;IAC9B,2BAA2B;IAC3B,UAAU,EAAE,eAAe,CAAA;IAC3B,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAA;AAEnE,MAAM,MAAM,uBAAuB,GAAG,6BAA6B,GAAG,OAAO,oBAAoB,CAAA;AAEjG,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAA;AAElF,eAAO,MAAM,YAAY,GACvB,SAAS,cAAc,EACvB,SAAS;IACP,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC,KACA,kBASF,CAAA"}
|
|
@@ -68,6 +68,9 @@ export const resolveExecutableRequestUrl = (request, envVariables, resolveOption
|
|
|
68
68
|
/** Catch-all code when an unexpected synchronous error escapes a helper during request construction. */
|
|
69
69
|
export const BUILD_REQUEST_FAILED = 'BUILD_REQUEST_FAILED';
|
|
70
70
|
export const buildRequest = (request, options) => {
|
|
71
|
+
if (request.cookieErrors?.length) {
|
|
72
|
+
return err(BUILD_REQUEST_FAILED, request.cookieErrors[0]);
|
|
73
|
+
}
|
|
71
74
|
const guarded = safeRun(() => buildRequestInner(request, options));
|
|
72
75
|
if (!guarded.ok) {
|
|
73
76
|
return err(BUILD_REQUEST_FAILED, guarded.error);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
2
2
|
import type { ParameterObject, ReferenceType } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
3
|
+
import type { ReservedPathParameter } from '../../../helpers/encode-path-parameter.js';
|
|
3
4
|
/**
|
|
4
5
|
* Converts the parameters into a set of headers, cookies and url params while
|
|
5
6
|
* replacing environment variables and extracting example values. Also builds up a record of the path
|
|
@@ -14,10 +15,15 @@ export declare const buildRequestParameters: (
|
|
|
14
15
|
/** All parameters */
|
|
15
16
|
parameters?: ReferenceType<ParameterObject>[],
|
|
16
17
|
/** The key of the current example */
|
|
17
|
-
exampleName?: string
|
|
18
|
+
exampleName?: string,
|
|
19
|
+
/** Reserved path expansion was introduced in OpenAPI 3.2. */
|
|
20
|
+
openapiVersion?: string) => {
|
|
18
21
|
cookies: XScalarCookie[];
|
|
22
|
+
/** Invalid active cookie parameters that prevent sending this request. */
|
|
23
|
+
cookieErrors?: string[];
|
|
19
24
|
headers: Record<string, string>;
|
|
20
25
|
pathVariables: Record<string, string>;
|
|
26
|
+
reservedPathParameters?: Record<string, ReservedPathParameter>;
|
|
21
27
|
allowReservedQueryParameters: Set<string>;
|
|
22
28
|
urlParams: URLSearchParams;
|
|
23
29
|
serializedQuery?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-parameters.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/build-request-parameters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-request-parameters.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/build-request-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,qEAAqE,CAAA;AAE5E,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAA;AAElH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAqB5E;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;AACjC,qBAAqB;AACrB,aAAY,aAAa,CAAC,eAAe,CAAC,EAAO;AACjD,qCAAqC;AACrC,cAAa,MAAkB;AAC/B,6DAA6D;AAC7D,iBAAiB,MAAM,KACtB;IACD,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;IAC9D,4BAA4B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACzC,SAAS,EAAE,eAAe,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1B,wBAAwB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAyKvC,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { isDefined } from '@scalar/helpers/array/is-defined';
|
|
2
|
+
import { getCookieSerializationError } from '@scalar/helpers/http/get-cookie-serialization-error';
|
|
2
3
|
import { isObject } from '@scalar/helpers/object/is-object';
|
|
3
4
|
import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref';
|
|
4
5
|
import { xScalarCookieSchema, } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
5
6
|
import { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce';
|
|
6
7
|
import { getParameterExample } from '../../../helpers/get-parameter-example.js';
|
|
7
8
|
import { deSerializeParameter } from '../../../request-example/builder/header/de-serialize-parameter.js';
|
|
9
|
+
import { filterDisabledProperties } from './filter-disabled-properties.js';
|
|
8
10
|
import { isParamDisabled } from './is-param-disabled.js';
|
|
9
11
|
import { serializeContentValue, serializeCookieStyle, serializeDeepObjectStyle, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './serialize-parameter.js';
|
|
10
12
|
/** Helper to get explode value with default */
|
|
@@ -23,7 +25,9 @@ export const buildRequestParameters = (
|
|
|
23
25
|
/** All parameters */
|
|
24
26
|
parameters = [],
|
|
25
27
|
/** The key of the current example */
|
|
26
|
-
exampleName = 'default'
|
|
28
|
+
exampleName = 'default',
|
|
29
|
+
/** Reserved path expansion was introduced in OpenAPI 3.2. */
|
|
30
|
+
openapiVersion) => {
|
|
27
31
|
const result = {
|
|
28
32
|
cookies: [],
|
|
29
33
|
headers: {},
|
|
@@ -44,7 +48,10 @@ exampleName = 'default') => {
|
|
|
44
48
|
const selected = getParameterExample(param, exampleName);
|
|
45
49
|
const { example, value } = selected;
|
|
46
50
|
// Skip disabled examples
|
|
47
|
-
|
|
51
|
+
const propertyStates = param.in === 'query' && !selected.serialized && !selected.mediaSerialized
|
|
52
|
+
? example?.['x-scalar-disabled-properties']
|
|
53
|
+
: undefined;
|
|
54
|
+
if (!example || (!propertyStates && isParamDisabled(param, example))) {
|
|
48
55
|
continue;
|
|
49
56
|
}
|
|
50
57
|
/** Parameter-level wire text already contains its name, delimiters, and encoding. */
|
|
@@ -91,7 +98,13 @@ exampleName = 'default') => {
|
|
|
91
98
|
continue;
|
|
92
99
|
}
|
|
93
100
|
/** De-serialize the example value if it is a string and matches the schema type */
|
|
94
|
-
const
|
|
101
|
+
const fullValue = deSerializeParameter(value, param);
|
|
102
|
+
const deSerializedValue = propertyStates
|
|
103
|
+
? filterDisabledProperties(fullValue, propertyStates, isParamDisabled(param, example))
|
|
104
|
+
: fullValue;
|
|
105
|
+
if (propertyStates && deSerializedValue === undefined) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
95
108
|
const paramName = param.name;
|
|
96
109
|
// Handle by parameter location
|
|
97
110
|
switch (param.in) {
|
|
@@ -123,6 +136,15 @@ exampleName = 'default') => {
|
|
|
123
136
|
// Path parameters use simple style by default
|
|
124
137
|
const serialized = serializeSimpleStyle(deSerializedValue, getExplode(param, false));
|
|
125
138
|
result.pathVariables[paramName] = String(serialized);
|
|
139
|
+
if (openapiVersion?.startsWith('3.2.') && 'schema' in param && param.allowReserved === true) {
|
|
140
|
+
;
|
|
141
|
+
(result.reservedPathParameters ??= {})[paramName] = {
|
|
142
|
+
value: deSerializedValue,
|
|
143
|
+
originalValue: String(serialized),
|
|
144
|
+
style: param.style ?? 'simple',
|
|
145
|
+
explode: getExplode(param, false),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
126
148
|
break;
|
|
127
149
|
}
|
|
128
150
|
case 'query': {
|
|
@@ -130,6 +152,15 @@ exampleName = 'default') => {
|
|
|
130
152
|
break;
|
|
131
153
|
}
|
|
132
154
|
case 'cookie': {
|
|
155
|
+
const [major, minor] = (openapiVersion ?? '').split('.');
|
|
156
|
+
const error = major === '3' && minor === '2' && !('content' in param)
|
|
157
|
+
? getCookieSerializationError(param, deSerializedValue)
|
|
158
|
+
: undefined;
|
|
159
|
+
if (error) {
|
|
160
|
+
;
|
|
161
|
+
(result.cookieErrors ??= []).push(error);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
133
164
|
if ('style' in param && param.style === 'cookie') {
|
|
134
165
|
result.cookies.push(...serializeCookieStyle(paramName, deSerializedValue, getExplode(param, true)).map((cookie) => coerceValue(xScalarCookieSchema, { ...cookie, path: '/' })));
|
|
135
166
|
break;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Build the enabled portion of a query object without discarding stored disabled values. */
|
|
2
|
+
export declare const filterDisabledProperties: (value: unknown, states: Record<string, boolean>, inheritedDisabled: boolean, path?: string[]) => unknown;
|
|
3
|
+
//# sourceMappingURL=filter-disabled-properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-disabled-properties.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/filter-disabled-properties.ts"],"names":[],"mappings":"AAEA,6FAA6F;AAC7F,eAAO,MAAM,wBAAwB,GACnC,OAAO,OAAO,EACd,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,mBAAmB,OAAO,EAC1B,OAAM,MAAM,EAAO,KAClB,OAgBF,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isObject } from '@scalar/helpers/object/is-object';
|
|
2
|
+
/** Build the enabled portion of a query object without discarding stored disabled values. */
|
|
3
|
+
export const filterDisabledProperties = (value, states, inheritedDisabled, path = []) => {
|
|
4
|
+
const disabled = states[JSON.stringify(path)] ?? inheritedDisabled;
|
|
5
|
+
if (!isObject(value) || Array.isArray(value)) {
|
|
6
|
+
return disabled ? undefined : value;
|
|
7
|
+
}
|
|
8
|
+
const entries = Object.entries(value);
|
|
9
|
+
const enabled = entries.flatMap(([key, child]) => {
|
|
10
|
+
const filtered = filterDisabledProperties(child, states, disabled, [...path, key]);
|
|
11
|
+
return filtered === undefined ? [] : [[key, filtered]];
|
|
12
|
+
});
|
|
13
|
+
// Do not serialize parents whose children were all excluded.
|
|
14
|
+
if (enabled.length === 0 && (disabled || entries.length > 0)) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return Object.fromEntries(enabled);
|
|
18
|
+
};
|
|
@@ -3,7 +3,7 @@ import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/g
|
|
|
3
3
|
* Filter a global cookie to determine if it should be included with a request to the given URL.
|
|
4
4
|
* - Returns false if the cookie is disabled, in the disabledGlobalCookies map, or missing a name.
|
|
5
5
|
* - Returns false if the domain does not match.
|
|
6
|
-
* - Returns false if the path is specified and does not match
|
|
6
|
+
* - Returns false if the path is specified and the request pathname does not path-match it.
|
|
7
7
|
* - Returns true otherwise.
|
|
8
8
|
*/
|
|
9
9
|
export declare const filterGlobalCookie: ({ cookie, url, disabledGlobalCookies, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-global-cookies.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/filter-global-cookies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;
|
|
1
|
+
{"version":3,"file":"filter-global-cookies.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/filter-global-cookies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AAiBxG;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,yCAIhC;IACD,MAAM,EAAE,aAAa,CAAA;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/C,KAAG,OAsBH,CAAA"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { matchesDomain } from './matches-domain.js';
|
|
2
|
+
/**
|
|
3
|
+
* RFC 6265 path-match: cookie-path C matches request-path R when they are the same,
|
|
4
|
+
* or C is a prefix of R and the next character is a slash. A trailing slash on C
|
|
5
|
+
* already supplies that boundary, so `/api` matches `/api/users` but not `/apiv2`.
|
|
6
|
+
*/
|
|
7
|
+
const pathMatches = (requestPath, cookiePath) => {
|
|
8
|
+
if (requestPath === cookiePath || cookiePath.endsWith('/')) {
|
|
9
|
+
return requestPath.startsWith(cookiePath);
|
|
10
|
+
}
|
|
11
|
+
return requestPath.startsWith(`${cookiePath}/`);
|
|
12
|
+
};
|
|
2
13
|
/**
|
|
3
14
|
* Filter a global cookie to determine if it should be included with a request to the given URL.
|
|
4
15
|
* - Returns false if the cookie is disabled, in the disabledGlobalCookies map, or missing a name.
|
|
5
16
|
* - Returns false if the domain does not match.
|
|
6
|
-
* - Returns false if the path is specified and does not match
|
|
17
|
+
* - Returns false if the path is specified and the request pathname does not path-match it.
|
|
7
18
|
* - Returns true otherwise.
|
|
8
19
|
*/
|
|
9
20
|
export const filterGlobalCookie = ({ cookie, url, disabledGlobalCookies, }) => {
|
|
@@ -17,8 +28,9 @@ export const filterGlobalCookie = ({ cookie, url, disabledGlobalCookies, }) => {
|
|
|
17
28
|
if (cookie.domain && !matchesDomain(url, cookie.domain)) {
|
|
18
29
|
return false;
|
|
19
30
|
}
|
|
20
|
-
//
|
|
21
|
-
|
|
31
|
+
// An empty path means no path restriction. Otherwise require an RFC 6265 path-match,
|
|
32
|
+
// so a cookie for `/api` is not sent to `/apiv2`.
|
|
33
|
+
if (cookie.path && !pathMatches(urlObject.pathname, cookie.path)) {
|
|
22
34
|
return false;
|
|
23
35
|
}
|
|
24
36
|
// Cookie passed all checks; include it in the request.
|
|
@@ -3,7 +3,7 @@ import type { ExampleObject, ParameterObject } from '@scalar/workspace-store/sch
|
|
|
3
3
|
* Determines if a parameter is disabled
|
|
4
4
|
*
|
|
5
5
|
* First we explicitly check if its been disabled via the `x-disabled` extension.
|
|
6
|
-
*
|
|
6
|
+
* Authored populated examples are enabled unless explicitly disabled. Empty optional parameters stay disabled.
|
|
7
7
|
*
|
|
8
8
|
* @param param - The parameter to check.
|
|
9
9
|
* @param example - The example to check.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-param-disabled.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/is-param-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;
|
|
1
|
+
{"version":3,"file":"is-param-disabled.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/is-param-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAKlH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,eAAe,EACtB,SAAS,aAAa,GAAG,SAAS,EAClC,kBAAiB,OAAc,KAC9B,OAiBF,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { getExampleValue } from '../../../helpers/get-example-value.js';
|
|
2
|
+
import { isGeneratedExample } from '../../../request-example/builder/helpers/get-example.js';
|
|
2
3
|
/**
|
|
3
4
|
* Determines if a parameter is disabled
|
|
4
5
|
*
|
|
5
6
|
* First we explicitly check if its been disabled via the `x-disabled` extension.
|
|
6
|
-
*
|
|
7
|
+
* Authored populated examples are enabled unless explicitly disabled. Empty optional parameters stay disabled.
|
|
7
8
|
*
|
|
8
9
|
* @param param - The parameter to check.
|
|
9
10
|
* @param example - The example to check.
|
|
@@ -18,7 +19,7 @@ export const isParamDisabled = (param, example, defaultDisabled = true) => {
|
|
|
18
19
|
}
|
|
19
20
|
// Keep the editor, generated snippets, and outgoing requests aligned for pre-populated values.
|
|
20
21
|
const value = getExampleValue(example)?.value;
|
|
21
|
-
const hasValue = value !== undefined && value !== '' && value !== null;
|
|
22
|
+
const hasValue = value !== undefined && value !== '' && value !== null && !isGeneratedExample(example);
|
|
22
23
|
if (!defaultDisabled || hasValue) {
|
|
23
24
|
return false;
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAwZ9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,GACnC,QAAQ,YAAY,EACpB,YAAY,MAAM,EAAE,EACpB,UAAU,2BAA2B,EACrC,mBAAiB,EACjB,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAwZ9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,GACnC,QAAQ,YAAY,EACpB,YAAY,MAAM,EAAE,EACpB,UAAU,2BAA2B,EACrC,mBAAiB,EACjB,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,YAAY,GAAG,SAoBjB,CAAA;AA0ZD,sEAAsE;AACtE,MAAM,MAAM,2BAA2B,GAAG;IACxC,2EAA2E;IAC3E,CAAC,kBAAkB,CAAC,CAAC,EAAE,sBAAsB,CAAA;IAC7C,mFAAmF;IACnF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kFAAkF;IAClF,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,qDAAqD;IACrD,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9C,CAAA;AAyPD;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,yBAAyB,GAC7B,QAAQ,YAAY,EACpB,UAAU,2BAA2B,EACrC,iEAOG,OAAO,CAAC;IACT,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACrB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,qGAAqG;IACrG,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAM,KACN,OAgPF,CAAA;AAoBD,gGAAgG;AAChG,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,YAAY,EACpB,UAAU,2BAA2B,EACrC,UAAS,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAM,KAC5D,OA2BF,CAAA"}
|
|
@@ -324,7 +324,8 @@ const consumeCompositionSelection = (options, schemaPath, composition) => {
|
|
|
324
324
|
};
|
|
325
325
|
/** Select a composition branch once for both generated values and supplied example metadata. */
|
|
326
326
|
export const selectExampleComposition = (schema, schemaPath, options, arrayItem = false, value) => {
|
|
327
|
-
const
|
|
327
|
+
const anyOfKeyword = schema.anyOf ? 'anyOf' : undefined;
|
|
328
|
+
const keyword = schema.oneOf ? 'oneOf' : anyOfKeyword;
|
|
328
329
|
const members = keyword ? schema[keyword] : undefined;
|
|
329
330
|
if (!keyword || !members?.length) {
|
|
330
331
|
return undefined;
|
|
@@ -472,16 +473,14 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
|
|
|
472
473
|
// Use propertyNames enum values as example keys when no custom name is set
|
|
473
474
|
const propertyNamesEnum = hasCustomName ? undefined : getPropertyNamesEnumValues(schema);
|
|
474
475
|
const additionalName = hasCustomName ? customName.trim() : DEFAULT_ADDITIONAL_PROPERTIES_NAME;
|
|
475
|
-
const additionalValue = isAnyType
|
|
476
|
-
?
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
})
|
|
484
|
-
: 'anything';
|
|
476
|
+
const additionalValue = !isAnyType && typeof additional === 'object'
|
|
477
|
+
? getExampleFromSchema(additional, options, {
|
|
478
|
+
level: level + 1,
|
|
479
|
+
schemaPath: [...schemaPath, additionalName],
|
|
480
|
+
seen,
|
|
481
|
+
dynamicScope: childScope,
|
|
482
|
+
})
|
|
483
|
+
: 'anything';
|
|
485
484
|
if (propertyNamesEnum && propertyNamesEnum.length > 0) {
|
|
486
485
|
// Use the first enum value as a realistic example key
|
|
487
486
|
response[String(propertyNamesEnum[0])] = additionalValue;
|
|
@@ -490,7 +489,8 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
|
|
|
490
489
|
response[additionalName] = additionalValue;
|
|
491
490
|
}
|
|
492
491
|
}
|
|
493
|
-
const
|
|
492
|
+
const anyOfKeyword = schema.anyOf ? 'anyOf' : undefined;
|
|
493
|
+
const compositionKeyword = schema.oneOf ? 'oneOf' : anyOfKeyword;
|
|
494
494
|
const oneOfAnyOf = compositionKeyword ? schema[compositionKeyword] : undefined;
|
|
495
495
|
if (compositionKeyword && oneOfAnyOf?.length) {
|
|
496
496
|
const chosen = selectExampleComposition(schema, schemaPath, options, false, response);
|
|
@@ -593,7 +593,8 @@ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath, d
|
|
|
593
593
|
.filter(isDefined);
|
|
594
594
|
return cache(schema, wrapItems ? examples.map((e) => ({ [itemsXmlTagName]: e })) : examples, cacheKey, skipCache);
|
|
595
595
|
}
|
|
596
|
-
const
|
|
596
|
+
const anyOfKeyword = items.anyOf ? 'anyOf' : undefined;
|
|
597
|
+
const compositionKeyword = items.oneOf ? 'oneOf' : anyOfKeyword;
|
|
597
598
|
const union = compositionKeyword ? items[compositionKeyword] : undefined;
|
|
598
599
|
if (compositionKeyword && union && union.length > 0) {
|
|
599
600
|
const selectedIndex = getCompositionSelectionIndex(itemsSchemaPath, compositionKeyword, options, union.length) ??
|
|
@@ -730,7 +731,8 @@ const getEmptyContainer = (schema) => {
|
|
|
730
731
|
};
|
|
731
732
|
/** Pick the `oneOf`/`anyOf` variant the walk itself would have rendered, honoring an explicit selection. */
|
|
732
733
|
const getSelectedVariant = (schema, options, schemaPath) => {
|
|
733
|
-
const
|
|
734
|
+
const anyOfKeyword = schema.anyOf ? 'anyOf' : undefined;
|
|
735
|
+
const compositionKeyword = schema.oneOf ? 'oneOf' : anyOfKeyword;
|
|
734
736
|
const variants = compositionKeyword ? schema[compositionKeyword] : undefined;
|
|
735
737
|
if (!compositionKeyword || !Array.isArray(variants) || variants.length === 0) {
|
|
736
738
|
return undefined;
|
|
@@ -990,7 +992,8 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
|
|
|
990
992
|
}
|
|
991
993
|
// Resolve non-object unions before type dispatch so shared root keywords do not
|
|
992
994
|
// hide the selected member. Use the same selection and discriminator rules as other unions.
|
|
993
|
-
const
|
|
995
|
+
const selectedAnyOf = _schema.anyOf ? 'anyOf' : undefined;
|
|
996
|
+
const selectedComposition = _schema.oneOf ? 'oneOf' : selectedAnyOf;
|
|
994
997
|
const selectedVariant = getSelectedVariant(_schema, options, schemaPath);
|
|
995
998
|
if (selectedComposition && selectedVariant) {
|
|
996
999
|
const rootType = 'type' in _schema ? _schema.type : undefined;
|
|
@@ -1037,7 +1040,8 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
|
|
|
1037
1040
|
return cache(_schema, primitive, cacheKey, skipCache);
|
|
1038
1041
|
}
|
|
1039
1042
|
// Handle composition schemas (oneOf, anyOf)
|
|
1040
|
-
const
|
|
1043
|
+
const anyOfKeyword = _schema.anyOf ? 'anyOf' : undefined;
|
|
1044
|
+
const compositionKeyword = _schema.oneOf ? 'oneOf' : anyOfKeyword;
|
|
1041
1045
|
const discriminate = compositionKeyword ? _schema[compositionKeyword] : undefined;
|
|
1042
1046
|
if (compositionKeyword && Array.isArray(discriminate) && discriminate.length > 0) {
|
|
1043
1047
|
const candidate = selectExampleComposition(_schema, schemaPath, options);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ExampleObject, MediaTypeObject, ParameterObject, RequestBodyObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
2
|
+
/** Whether an example contains only enum suggestions rather than authored values. */
|
|
3
|
+
export declare const isGeneratedExample: (example: ExampleObject | undefined) => boolean;
|
|
2
4
|
/**
|
|
3
5
|
* Resolve an example value for a parameter or requestBody from either `examples` or `content.*.examples`.
|
|
4
6
|
* Or the [deprecated] `example` field.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,iBAAiB,EAGlB,MAAM,8DAA8D,CAAA;
|
|
1
|
+
{"version":3,"file":"get-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,iBAAiB,EAGlB,MAAM,8DAA8D,CAAA;AAQrE,qFAAqF;AACrF,eAAO,MAAM,kBAAkB,GAAI,SAAS,aAAa,GAAG,SAAS,KAAG,OACf,CAAA;AAuHzD;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,eAAe,GAAG,iBAAiB,GAAG,eAAe,EAC5D,aAAa,MAAM,GAAG,SAAS,EAC/B,aAAa,MAAM,GAAG,SAAS,KAC9B,aAAa,GAAG,SAyBlB,CAAA"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { getResolvedRef } from '../../../helpers/get-resolved-ref.js';
|
|
2
2
|
import { resolve } from '../../../resolve.js';
|
|
3
|
+
// Keep suggestion provenance out of API descriptions and persisted user examples.
|
|
4
|
+
const generatedExamples = new WeakSet();
|
|
5
|
+
/** Whether an example contains only enum suggestions rather than authored values. */
|
|
6
|
+
export const isGeneratedExample = (example) => example !== undefined && generatedExamples.has(example);
|
|
3
7
|
/** Helper to get example from examples object with fallback to example field */
|
|
4
8
|
const getExampleFromExamples = (examples, exampleField, exampleName) => {
|
|
5
9
|
if (!examples && exampleField === undefined) {
|
|
@@ -34,15 +38,17 @@ const getSchemaExample = (input, walk = { ancestors: new Set(), withoutValues: n
|
|
|
34
38
|
if ('default' in schema && schema.default !== undefined) {
|
|
35
39
|
return { value: schema.default };
|
|
36
40
|
}
|
|
37
|
-
if ('enum' in schema && schema.enum?.[0] !== undefined) {
|
|
38
|
-
return { value: schema.enum[0] };
|
|
39
|
-
}
|
|
40
41
|
if ('examples' in schema && schema.examples?.[0] !== undefined) {
|
|
41
42
|
return { value: schema.examples[0] };
|
|
42
43
|
}
|
|
43
44
|
if ('example' in schema && schema.example !== undefined) {
|
|
44
45
|
return { value: schema.example };
|
|
45
46
|
}
|
|
47
|
+
if ('enum' in schema && schema.enum?.[0] !== undefined) {
|
|
48
|
+
const example = { value: schema.enum[0] };
|
|
49
|
+
generatedExamples.add(example);
|
|
50
|
+
return example;
|
|
51
|
+
}
|
|
46
52
|
// Reference siblings create a fresh merged object, so track the underlying schema for cycles.
|
|
47
53
|
const target = getResolvedRef(input) ?? input;
|
|
48
54
|
if (!('properties' in schema) || !schema.properties) {
|
|
@@ -62,7 +68,7 @@ const getSchemaExample = (input, walk = { ancestors: new Set(), withoutValues: n
|
|
|
62
68
|
walk.ancestors.add(target);
|
|
63
69
|
const properties = Object.entries(schema.properties).flatMap(([name, property]) => {
|
|
64
70
|
const example = getSchemaExample(property, walk);
|
|
65
|
-
return example === undefined ? [] : [
|
|
71
|
+
return example === undefined ? [] : [{ name, example }];
|
|
66
72
|
});
|
|
67
73
|
walk.ancestors.delete(target);
|
|
68
74
|
// Stops at schemas inside this walk have left the path, so the rest point above it.
|
|
@@ -70,7 +76,11 @@ const getSchemaExample = (input, walk = { ancestors: new Set(), withoutValues: n
|
|
|
70
76
|
walk.stops = outerStops;
|
|
71
77
|
stops.forEach((stop) => outerStops.add(stop));
|
|
72
78
|
if (properties.length > 0) {
|
|
73
|
-
|
|
79
|
+
const example = { value: Object.fromEntries(properties.map(({ name, example }) => [name, example.value])) };
|
|
80
|
+
if (properties.every(({ example }) => isGeneratedExample(example))) {
|
|
81
|
+
generatedExamples.add(example);
|
|
82
|
+
}
|
|
83
|
+
return example;
|
|
74
84
|
}
|
|
75
85
|
walk.withoutValues.set(target, { properties: schema.properties, stops });
|
|
76
86
|
return undefined;
|
|
@@ -5,6 +5,7 @@ export { type SerializedFormProperty, serializeFormPropertyWithEncoding } from '
|
|
|
5
5
|
export { serializeMultipartArray } from './body/serialize-multipart-array.js';
|
|
6
6
|
export { BUILD_REQUEST_FAILED, type BuildRequestData, type BuildRequestFailureCode, type BuildRequestResult, type RequestPayload, buildRequest, resolveExecutableRequestUrl, } from './build-request.js';
|
|
7
7
|
export { deSerializeParameter, deSerializeSchemaValue } from './header/de-serialize-parameter.js';
|
|
8
|
+
export { filterDisabledProperties } from './header/filter-disabled-properties.js';
|
|
8
9
|
export { filterGlobalCookie } from './header/filter-global-cookies.js';
|
|
9
10
|
export { isParamDisabled } from './header/is-param-disabled.js';
|
|
10
11
|
export { serializeContentValue, serializeCookieStyle, serializeDeepObjectStyle, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './header/serialize-parameter.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,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,oBAAoB,EACpB,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,kCAAkC,EAClC,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,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,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,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,yBAAyB,CAAA"}
|
|
@@ -5,6 +5,7 @@ export { serializeFormPropertyWithEncoding } from './body/serialize-form-propert
|
|
|
5
5
|
export { serializeMultipartArray } from './body/serialize-multipart-array.js';
|
|
6
6
|
export { BUILD_REQUEST_FAILED, buildRequest, resolveExecutableRequestUrl, } from './build-request.js';
|
|
7
7
|
export { deSerializeParameter, deSerializeSchemaValue } from './header/de-serialize-parameter.js';
|
|
8
|
+
export { filterDisabledProperties } from './header/filter-disabled-properties.js';
|
|
8
9
|
export { filterGlobalCookie } from './header/filter-global-cookies.js';
|
|
9
10
|
export { isParamDisabled } from './header/is-param-disabled.js';
|
|
10
11
|
export { serializeContentValue, serializeCookieStyle, serializeDeepObjectStyle, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './header/serialize-parameter.js';
|
|
@@ -2,6 +2,7 @@ import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensi
|
|
|
2
2
|
import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
3
3
|
import type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
4
4
|
import type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/operation';
|
|
5
|
+
import type { ReservedPathParameter } from '../../helpers/encode-path-parameter.js';
|
|
5
6
|
import { type QuerystringParameter } from '../../helpers/querystring-parameter.js';
|
|
6
7
|
import { type BuildRequestSecurityResult } from '../../request-example/builder/security/build-request-security.js';
|
|
7
8
|
import type { SecuritySchemeObjectSecret } from '../../request-example/builder/security/secret-types.js';
|
|
@@ -74,6 +75,8 @@ import { type RequestBody } from './body/build-request-body.js';
|
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
77
|
export type RequestFactory = {
|
|
78
|
+
/** Invalid active cookie declarations, retained for previews and reported before sending. */
|
|
79
|
+
cookieErrors?: string[];
|
|
77
80
|
/**
|
|
78
81
|
* The base API server URL prior to environment or server variable substitution.
|
|
79
82
|
* May still contain placeholders such as `{version}` or `{region}`.
|
|
@@ -94,6 +97,8 @@ export type RequestFactory = {
|
|
|
94
97
|
variables: Record<string, string>;
|
|
95
98
|
/** Names whose example is already URI-encoded. */
|
|
96
99
|
serializedParameters?: Set<string>;
|
|
100
|
+
/** Schema-based values using OpenAPI 3.2 reserved expansion. */
|
|
101
|
+
reservedParameters?: Record<string, ReservedPathParameter>;
|
|
97
102
|
/**
|
|
98
103
|
* The raw request path string, as entered by the user or read from the OpenAPI schema.
|
|
99
104
|
* Placeholders are not yet substituted.
|
|
@@ -198,7 +203,7 @@ export declare const requestFactory: ({ exampleName, globalCookies, method, oper
|
|
|
198
203
|
/** The selected security schemes for the current operation */
|
|
199
204
|
selectedSecuritySchemes: SecuritySchemeObjectSecret[];
|
|
200
205
|
/** Selected anyOf/oneOf request-body variants keyed by schema path */
|
|
201
|
-
/** Originating OpenAPI version, used for
|
|
206
|
+
/** Originating OpenAPI version, used for version-specific serialization. */
|
|
202
207
|
openapiVersion?: string;
|
|
203
208
|
requestBodyCompositionSelection?: Record<string, number>;
|
|
204
209
|
}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAE5F,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,2DAA2D,CAAA;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,2BAA2B,CAAA;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,IAAI,EAAE;QACJ;;;;;WAKG;QACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,kDAAkD;QAClD,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAClC;;;;;WAKG;QACH,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IAED;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;OAGG;IACH,KAAK,EAAE,eAAe,CAAA;IAEtB,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAE1B,oFAAoF;IACpF,WAAW,CAAC,EAAE,oBAAoB,CAAA;IAElC;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAA;IAEhB;;;;OAIG;IACH,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;IAExB;;;;OAIG;IACH,OAAO,EAAE,aAAa,EAAE,CAAA;IAExB;;;OAGG;IACH,KAAK,EAAE,YAAY,CAAA;IAEnB;;;;OAIG;IACH,QAAQ,EAAE,0BAA0B,EAAE,CAAA;IAEtC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAE5C;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;QACf;;;WAGG;QACH,UAAU,EAAE,OAAO,CAAA;QACnB;;;WAGG;QACH,eAAe,EAAE,OAAO,CAAA;KACzB,CAAC,CAAA;CACH,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,kLAa5B,kBAAkB,GAAG;IACtB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,8DAA8D;IAC9D,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,sEAAsE;IACtE
|
|
1
|
+
{"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAE5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,2DAA2D,CAAA;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,2BAA2B,CAAA;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,6FAA6F;IAC7F,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,IAAI,EAAE;QACJ;;;;;WAKG;QACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,kDAAkD;QAClD,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAClC,gEAAgE;QAChE,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;QAC1D;;;;;WAKG;QACH,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IAED;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;OAGG;IACH,KAAK,EAAE,eAAe,CAAA;IAEtB,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAE1B,oFAAoF;IACpF,WAAW,CAAC,EAAE,oBAAoB,CAAA;IAElC;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAA;IAEhB;;;;OAIG;IACH,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;IAExB;;;;OAIG;IACH,OAAO,EAAE,aAAa,EAAE,CAAA;IAExB;;;OAGG;IACH,KAAK,EAAE,YAAY,CAAA;IAEnB;;;;OAIG;IACH,QAAQ,EAAE,0BAA0B,EAAE,CAAA;IAEtC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAE5C;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;QACf;;;WAGG;QACH,UAAU,EAAE,OAAO,CAAA;QACnB;;;WAGG;QACH,eAAe,EAAE,OAAO,CAAA;KACzB,CAAC,CAAA;CACH,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,kLAa5B,kBAAkB,GAAG;IACtB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,8DAA8D;IAC9D,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,sEAAsE;IACtE,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,KAAG;IACF,OAAO,EAAE,cAAc,CAAA;CA8ExB,CAAA"}
|
|
@@ -15,7 +15,7 @@ import { buildRequestParameters } from './header/build-request-parameters.js';
|
|
|
15
15
|
export const requestFactory = ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, requestBodyCompositionSelection, }) => {
|
|
16
16
|
const requestBody = getResolvedRef(operation.requestBody);
|
|
17
17
|
/** Build out the request parameters */
|
|
18
|
-
const params = buildRequestParameters(operation.parameters ?? [], exampleName);
|
|
18
|
+
const params = buildRequestParameters(operation.parameters ?? [], exampleName, openapiVersion);
|
|
19
19
|
const querystringParameter = operation.parameters
|
|
20
20
|
?.map((parameter) => getResolvedRef(parameter))
|
|
21
21
|
.find((parameter) => parameter?.in === 'querystring');
|
|
@@ -52,11 +52,13 @@ export const requestFactory = ({ exampleName, globalCookies, method, operation,
|
|
|
52
52
|
headers.set('Pragma', 'no-cache');
|
|
53
53
|
}
|
|
54
54
|
const request = {
|
|
55
|
+
...(params.cookieErrors ? { cookieErrors: params.cookieErrors } : {}),
|
|
55
56
|
baseUrl,
|
|
56
57
|
proxyUrl,
|
|
57
58
|
path: {
|
|
58
59
|
variables: params.pathVariables,
|
|
59
60
|
...(params.serializedPathParameters ? { serializedParameters: params.serializedPathParameters } : {}),
|
|
61
|
+
...(params.reservedPathParameters ? { reservedParameters: params.reservedPathParameters } : {}),
|
|
60
62
|
raw: path,
|
|
61
63
|
},
|
|
62
64
|
query: params.urlParams,
|