@scalar/workspace-store 0.65.0 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/dist/client.js +1 -1
- package/dist/entities/auth/schema.d.ts +115 -20
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/events/definitions/auth.d.ts +1 -2
- package/dist/events/definitions/auth.d.ts.map +1 -1
- package/dist/events/definitions/operation.d.ts +5 -4
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/events/definitions/server.d.ts +1 -2
- package/dist/events/definitions/server.d.ts.map +1 -1
- package/dist/events/definitions/ui.d.ts +3 -4
- package/dist/events/definitions/ui.d.ts.map +1 -1
- package/dist/events/old-definitions.d.ts +1 -2
- package/dist/events/old-definitions.d.ts.map +1 -1
- package/dist/helpers/encode-chunk-name.d.ts.map +1 -1
- package/dist/helpers/encode-chunk-name.js +6 -1
- package/dist/helpers/for-each-path-item-operation.d.ts +6 -5
- package/dist/helpers/for-each-path-item-operation.d.ts.map +1 -1
- package/dist/helpers/for-each-path-item-operation.js +36 -10
- package/dist/helpers/get-parameter-example.d.ts +14 -0
- package/dist/helpers/get-parameter-example.d.ts.map +1 -0
- package/dist/helpers/get-parameter-example.js +19 -0
- package/dist/helpers/merge-object.d.ts.map +1 -1
- package/dist/helpers/merge-object.js +9 -3
- package/dist/helpers/querystring-parameter.d.ts +21 -0
- package/dist/helpers/querystring-parameter.d.ts.map +1 -0
- package/dist/helpers/querystring-parameter.js +108 -0
- package/dist/mutators/operation/operation.d.ts.map +1 -1
- package/dist/mutators/operation/operation.js +4 -7
- package/dist/mutators/operation/parameters.d.ts.map +1 -1
- package/dist/mutators/operation/parameters.js +43 -3
- package/dist/navigation/get-navigation-options.d.ts.map +1 -1
- package/dist/navigation/get-navigation-options.js +19 -4
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +2 -2
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js +2 -2
- package/dist/navigation/helpers/update-order-ids.d.ts +1 -2
- package/dist/navigation/helpers/update-order-ids.d.ts.map +1 -1
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +3 -2
- package/dist/request-example/builder/body/build-request-body.d.ts +1 -1
- package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-request-body.js +2 -2
- package/dist/request-example/builder/body/get-request-body-example.d.ts +4 -4
- 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 +29 -5
- package/dist/request-example/builder/build-request.d.ts.map +1 -1
- package/dist/request-example/builder/build-request.js +2 -1
- package/dist/request-example/builder/header/build-request-parameters.d.ts +2 -0
- package/dist/request-example/builder/header/build-request-parameters.d.ts.map +1 -1
- package/dist/request-example/builder/header/build-request-parameters.js +49 -10
- 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 -1
- package/dist/request-example/builder/helpers/example-evaluation.d.ts +19 -0
- package/dist/request-example/builder/helpers/example-evaluation.d.ts.map +1 -0
- package/dist/request-example/builder/helpers/example-evaluation.js +2 -0
- package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +11 -3
- 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 +66 -17
- package/dist/request-example/builder/request-factory.d.ts +10 -1
- package/dist/request-example/builder/request-factory.d.ts.map +1 -1
- package/dist/request-example/builder/request-factory.js +12 -3
- package/dist/request-example/builder/resolve-request-factory-url.d.ts.map +1 -1
- package/dist/request-example/builder/resolve-request-factory-url.js +18 -2
- package/dist/request-example/context/headers.d.ts +1 -2
- package/dist/request-example/context/headers.d.ts.map +1 -1
- package/dist/request-example/index.d.ts +4 -0
- package/dist/request-example/index.d.ts.map +1 -1
- package/dist/request-example/index.js +3 -0
- package/dist/request-example/types.d.ts +1 -2
- package/dist/request-example/types.d.ts.map +1 -1
- package/dist/request-example/xml/get-xml-body-example.d.ts +8 -0
- package/dist/request-example/xml/get-xml-body-example.d.ts.map +1 -0
- package/dist/request-example/xml/get-xml-body-example.js +21 -0
- package/dist/request-example/xml/get-xml-example.d.ts +21 -0
- package/dist/request-example/xml/get-xml-example.d.ts.map +1 -0
- package/dist/request-example/xml/get-xml-example.js +352 -0
- package/dist/request-example/xml/match-xml-property-pattern.d.ts +10 -0
- package/dist/request-example/xml/match-xml-property-pattern.d.ts.map +1 -0
- package/dist/request-example/xml/match-xml-property-pattern.js +48 -0
- package/dist/request-example/xml/serialize-xml-part.d.ts +4 -5
- package/dist/request-example/xml/serialize-xml-part.d.ts.map +1 -1
- package/dist/request-example/xml/serialize-xml-part.js +14 -8
- package/dist/request-example/xml/write-xml.d.ts +9 -0
- package/dist/request-example/xml/write-xml.d.ts.map +1 -0
- package/dist/request-example/xml/write-xml.js +119 -0
- package/dist/request-example/xml/xml-node.d.ts +32 -0
- package/dist/request-example/xml/xml-node.d.ts.map +1 -0
- package/dist/request-example/xml/xml-node.js +1 -0
- package/dist/schemas/extensions/operation/x-code-samples.d.ts +22 -0
- package/dist/schemas/extensions/operation/x-code-samples.d.ts.map +1 -1
- package/dist/schemas/extensions/operation/x-code-samples.js +4 -0
- package/dist/schemas/navigation.d.ts +40 -34
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/navigation.js +2 -3
- package/dist/schemas/reference-config/index.d.ts +23 -4
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +23 -4
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +770 -140
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.d.ts +8 -0
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/path-item.d.ts +19 -0
- package/dist/schemas/v3.1/strict/path-item.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/path-item.js +5 -0
- package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
- package/dist/schemas/v3.2/openapi/index.js +2 -0
- package/dist/schemas/v3.2/openapi/reference.d.ts.map +1 -1
- package/dist/schemas/v3.2/openapi/reference.js +11 -3
- package/dist/schemas/v3.2/strict/openapi-document.d.ts +805 -140
- package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/operation.d.ts +8 -0
- package/dist/schemas/v3.2/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/parameter.d.ts +14 -0
- package/dist/schemas/v3.2/strict/parameter.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/parameter.js +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +34 -13
- package/package.json +9 -9
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { getPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
2
|
+
import { getParameterExample } from '../../helpers/get-parameter-example.js';
|
|
2
3
|
import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
|
|
4
|
+
import { getQuerystringParameter, serializeQuerystringParameter } from '../../helpers/querystring-parameter.js';
|
|
3
5
|
import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
|
|
4
6
|
import { isOpenApiDocument } from '../../schemas/type-guards.js';
|
|
5
7
|
import { isContentTypeParameterObject } from '../../schemas/v3.2/strict/type-guards.js';
|
|
@@ -41,8 +43,13 @@ const getPathItemsForParameterMutation = (pathItemRef) => {
|
|
|
41
43
|
export const upsertOperationParameter = (document, { meta, type, payload, originalParameter }) => {
|
|
42
44
|
// We are editing an existing parameter
|
|
43
45
|
if (originalParameter) {
|
|
46
|
+
const querystring = getQuerystringParameter(originalParameter, meta.exampleKey, { includeDisabled: true });
|
|
47
|
+
const preserveQuerystringValue = querystring && payload.value === serializeQuerystringParameter(querystring);
|
|
44
48
|
const param = originalParameter;
|
|
45
|
-
const
|
|
49
|
+
const selected = getParameterExample(param, meta.exampleKey);
|
|
50
|
+
const target = param.in !== 'querystring' && !selected.serialized && isContentTypeParameterObject(param)
|
|
51
|
+
? Object.values(param.content ?? {})[0]
|
|
52
|
+
: param;
|
|
46
53
|
if (!target) {
|
|
47
54
|
return;
|
|
48
55
|
}
|
|
@@ -77,7 +84,39 @@ export const upsertOperationParameter = (document, { meta, type, payload, origin
|
|
|
77
84
|
return;
|
|
78
85
|
}
|
|
79
86
|
// Update the example value and disabled state
|
|
80
|
-
|
|
87
|
+
if (param.in === 'querystring') {
|
|
88
|
+
// The whole-query editor displays the URI-ready value, including percent encoding.
|
|
89
|
+
delete example.value;
|
|
90
|
+
delete example.dataValue;
|
|
91
|
+
// Inline edits replace the external example source as well as its cached representation.
|
|
92
|
+
delete example.externalValue;
|
|
93
|
+
delete example.serializedValue;
|
|
94
|
+
// Toggling an unchanged preview must preserve data and environment placeholders
|
|
95
|
+
// so future environment changes still happen before serialization.
|
|
96
|
+
if (preserveQuerystringValue && querystring.kind !== 'uri-ready') {
|
|
97
|
+
if (querystring.kind === 'serialized') {
|
|
98
|
+
example.value = querystring.value;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
example.dataValue = querystring.value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
example.serializedValue = String(payload.value);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
delete example.dataValue;
|
|
110
|
+
delete example.serializedValue;
|
|
111
|
+
delete example.externalValue;
|
|
112
|
+
if (selected.serialized || selected.mediaSerialized) {
|
|
113
|
+
delete example.value;
|
|
114
|
+
example.serializedValue = String(payload.value);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
example.value = payload.value;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
81
120
|
example['x-disabled'] = payload.isDisabled;
|
|
82
121
|
return;
|
|
83
122
|
}
|
|
@@ -212,5 +251,6 @@ export const deleteAllOperationParameters = (document, { meta, type }) => {
|
|
|
212
251
|
return;
|
|
213
252
|
}
|
|
214
253
|
// Filter out parameters of the specified type
|
|
215
|
-
operation.parameters =
|
|
254
|
+
operation.parameters =
|
|
255
|
+
operation.parameters?.filter((it) => getResolvedRef(it)?.in !== type && !(type === 'query' && getResolvedRef(it)?.in === 'querystring')) ?? [];
|
|
216
256
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-navigation-options.d.ts","sourceRoot":"","sources":["../../src/navigation/get-navigation-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-navigation-options.d.ts","sourceRoot":"","sources":["../../src/navigation/get-navigation-options.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,4BAA4B,EAAgC,MAAM,6BAA6B,CAAA;AAE7G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAe7D,MAAM,MAAM,iBAAiB,GACzB,OAAO,CACL,IAAI,CACF,4BAA4B,EAC1B,qBAAqB,GACrB,iBAAiB,GACjB,uBAAuB,GACvB,qBAAqB,GACrB,mBAAmB,GACnB,kBAAkB,GAClB,YAAY,GACZ,YAAY,GACZ,oBAAoB,GACpB,sBAAsB,CACzB,CACF,GACD,SAAS,CAAA;AAEb;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,cAAc,MAAM,EAAE,UAAU,iBAAiB,KAAG,mBAyJxF,CAAA"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
|
|
1
2
|
import { slugify } from '@scalar/helpers/string/slugify';
|
|
2
3
|
import { DEFAULT_MODELS_SECTION_LABEL } from '@scalar/types/api-reference';
|
|
4
|
+
/**
|
|
5
|
+
* Fixed fields retain their existing links; authored variants need a distinct namespace.
|
|
6
|
+
* Extension methods retain exact case because HTTP method tokens are case-sensitive.
|
|
7
|
+
* Normalizing COPY and copy would collapse distinct operations onto the same anchor.
|
|
8
|
+
*/
|
|
9
|
+
const getMethodId = (method) => isHttpMethod(method)
|
|
10
|
+
? method === method.toLowerCase()
|
|
11
|
+
? method.toUpperCase()
|
|
12
|
+
: `additionalOperations/${method}`
|
|
13
|
+
: method;
|
|
3
14
|
/**
|
|
4
15
|
* Returns options for traversing an OpenAPI document, allowing customization of
|
|
5
16
|
* how IDs and slugs are generated for tags, headings, models, operations, and webhooks.
|
|
@@ -65,11 +76,13 @@ export const getNavigationOptions = (documentName, options) => {
|
|
|
65
76
|
return `${prefixTag}${options.generateOperationSlug({
|
|
66
77
|
path: props.path,
|
|
67
78
|
operationId: props.operation.operationId,
|
|
68
|
-
method: props.method.
|
|
79
|
+
method: isHttpMethod(props.method) && props.method === props.method.toLowerCase()
|
|
80
|
+
? props.method.toUpperCase()
|
|
81
|
+
: props.method,
|
|
69
82
|
summary: props.operation.summary,
|
|
70
83
|
})}`;
|
|
71
84
|
}
|
|
72
|
-
return `${prefixTag}${props.method
|
|
85
|
+
return `${prefixTag}${getMethodId(props.method)}${props.path}`;
|
|
73
86
|
}
|
|
74
87
|
// -------- Default webhook id generation logic --------
|
|
75
88
|
if (props.type === 'webhook') {
|
|
@@ -83,13 +96,15 @@ export const getNavigationOptions = (documentName, options) => {
|
|
|
83
96
|
if (options?.generateWebhookSlug) {
|
|
84
97
|
return `${prefixTag}webhook/${options.generateWebhookSlug({
|
|
85
98
|
name: props.name,
|
|
86
|
-
method: props.method
|
|
99
|
+
method: isHttpMethod(props.method) && props.method === props.method.toLowerCase()
|
|
100
|
+
? props.method.toUpperCase()
|
|
101
|
+
: props.method,
|
|
87
102
|
})}`;
|
|
88
103
|
}
|
|
89
104
|
// Webhook events are commonly named with dots (e.g. "account_holder.created").
|
|
90
105
|
// Keep the dot so the deep link stays close to the event name, instead of
|
|
91
106
|
// dropping it and joining adjacent words ("account-holdercreated").
|
|
92
|
-
return `${prefixTag}webhook/${props.method
|
|
107
|
+
return `${prefixTag}webhook/${getMethodId(props.method)}/${slugify(props.name, { allowedSpecialChars: '.' })}`;
|
|
93
108
|
}
|
|
94
109
|
// -------- Default model id generation logic --------
|
|
95
110
|
if (props.type === 'model') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-paths.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"traverse-paths.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-paths.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5F,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAI9F,eAAO,MAAM,qBAAqB,GAAI,WAAW,eAAe,YAE/D,CAAA;AAsED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,GAAI,sEAM3B;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,0DAA0D;IAC1D,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,oFAAoF;IACpF,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;CAC5C,KAAG;IAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAA;CA0D7C,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointer';
|
|
2
|
-
import { forEachPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
2
|
+
import { forEachPathItemOperation, getPathItemOperationKey } from '../../helpers/for-each-path-item-operation.js';
|
|
3
3
|
import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
|
|
4
4
|
import { isHidden } from '../../helpers/is-hidden.js';
|
|
5
5
|
import { traverseOperationExamples } from '../../navigation/helpers/traverse-examples.js';
|
|
@@ -83,7 +83,7 @@ export const traversePaths = ({ document, tagsMap, generateId, documentId, opera
|
|
|
83
83
|
if (isHidden(operation)) {
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
const ref = `#/paths/${escapeJsonPointer(path)}/${method}`;
|
|
86
|
+
const ref = `#/paths/${escapeJsonPointer(path)}/${getPathItemOperationKey(method)}`;
|
|
87
87
|
// Traverse tags
|
|
88
88
|
if (operation.tags?.length) {
|
|
89
89
|
operation.tags.forEach((tagName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,wCAAwC,CAAA;AA2DzG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAAI,0EAM9B;IACD,uBAAuB;IACvB,QAAQ,EAAE,eAAe,CAAA;IACzB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,wBAAwB,EAAE,MAAM,CAAA;IAChC,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,gBAAgB,EAuDnB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forEachPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
|
|
1
|
+
import { forEachPathItemOperation, getPathItemOperationKey } from '../../helpers/for-each-path-item-operation.js';
|
|
2
2
|
import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
|
|
3
3
|
import { isHidden } from '../../helpers/is-hidden.js';
|
|
4
4
|
import { isDeprecatedOperation } from '../../navigation/helpers/traverse-paths.js';
|
|
@@ -62,7 +62,7 @@ export const traverseWebhooks = ({ document, tagsMap, generateId, untaggedWebhoo
|
|
|
62
62
|
if (isHidden(operation)) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
const ref = `#/webhooks/${name}/${method}`;
|
|
65
|
+
const ref = `#/webhooks/${name}/${getPathItemOperationKey(method)}`;
|
|
66
66
|
if (operation.tags?.length) {
|
|
67
67
|
operation.tags.forEach((tagName) => {
|
|
68
68
|
const { tag, id: tagId } = getTag({ tagsMap, name: tagName, documentId, generateId });
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
1
|
import type { WorkspaceStore } from '../../client.js';
|
|
3
2
|
import type { IdGenerator, TraversedOperation, TraversedTag, TraversedWebhook, WithParent } from '../../schemas/navigation.js';
|
|
4
3
|
import type { TagObject } from '../../schemas/v3.2/strict/openapi-document.js';
|
|
@@ -10,7 +9,7 @@ type UpdateOrderIdParams = {
|
|
|
10
9
|
/** Operation or webhook entries to update the order ID for */
|
|
11
10
|
entries: (WithParent<TraversedOperation> | WithParent<TraversedWebhook>)[];
|
|
12
11
|
operation: OperationObject;
|
|
13
|
-
method:
|
|
12
|
+
method: string;
|
|
14
13
|
path: string;
|
|
15
14
|
} | {
|
|
16
15
|
/** Tag entries to update the order ID for */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-order-ids.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/update-order-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"update-order-ids.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/update-order-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEvH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,cAAc,CAAA;IACrB,UAAU,EAAE,WAAW,CAAA;CACxB,GAAG,CACA;IACE,8DAA8D;IAC9D,OAAO,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAA;IAC1E,SAAS,EAAE,eAAe,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,6CAA6C;IAC7C,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,SAAS,CAAA;CACf,CACJ,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,gCAAgC,mBAAmB,SAiEjF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAStF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,eA2CpE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eA6BtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAAO,eAyBhC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAStF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,eA2CpE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eA6BtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAAO,eAyBhC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAO,eAmFrC,CAAA;AAKD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAO,eAaxC,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -273,8 +273,9 @@ export const syncPathParameters = () => {
|
|
|
273
273
|
}
|
|
274
274
|
const pathString = path[1];
|
|
275
275
|
// Sync parameters for each operation method
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
const additionalOperations = isObject(node.additionalOperations) ? Object.values(node.additionalOperations) : [];
|
|
277
|
+
for (const operationNode of [...HTTP_METHODS.map((method) => node[method]), ...additionalOperations]) {
|
|
278
|
+
const operation = getResolvedRef(operationNode, context);
|
|
278
279
|
if (!isObject(operation)) {
|
|
279
280
|
continue;
|
|
280
281
|
}
|
|
@@ -43,6 +43,6 @@ export declare const buildRequestBody: (requestBody: RequestBodyObject | undefin
|
|
|
43
43
|
/** The key of the current example */
|
|
44
44
|
exampleName?: string,
|
|
45
45
|
/** Selected anyOf/oneOf request-body variants keyed by schema path */
|
|
46
|
-
requestBodyCompositionSelection?: Record<string, number
|
|
46
|
+
requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string) => RequestBody | null;
|
|
47
47
|
export {};
|
|
48
48
|
//# sourceMappingURL=build-request-body.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAKjG,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,mBAAmB,CAAA;AAO1B,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,CACH;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CACJ,EAAE,CAAA;CACJ,CAAA;AAwBD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ,CAAA;AAED,KAAK,GAAG,GAAG;IACT,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,UAAU,GACV,GAAG,GACH;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,CAAA;AA2CtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;AACrC,oBAAuB;AACvB,sEAAsE;AACtE,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAKjG,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,mBAAmB,CAAA;AAO1B,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,CACH;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CACJ,EAAE,CAAA;CACJ,CAAA;AAwBD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ,CAAA;AAED,KAAK,GAAG,GAAG;IACT,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,UAAU,GACV,GAAG,GACH;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,CAAA;AA2CtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;AACrC,oBAAuB;AACvB,sEAAsE;AACtE,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxD,iBAAiB,MAAM,KACtB,WAAW,GAAG,IAoXhB,CAAA"}
|
|
@@ -67,7 +67,7 @@ export const buildRequestBody = (requestBody,
|
|
|
67
67
|
/** The key of the current example */
|
|
68
68
|
exampleName = 'default',
|
|
69
69
|
/** Selected anyOf/oneOf request-body variants keyed by schema path */
|
|
70
|
-
requestBodyCompositionSelection) => {
|
|
70
|
+
requestBodyCompositionSelection, openapiVersion) => {
|
|
71
71
|
if (!requestBody) {
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
@@ -77,7 +77,7 @@ requestBodyCompositionSelection) => {
|
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
/** An example value */
|
|
80
|
-
const example = getExampleFromBody(requestBody, bodyContentType, exampleName, requestBodyCompositionSelection);
|
|
80
|
+
const example = getExampleFromBody(requestBody, bodyContentType, exampleName, requestBodyCompositionSelection, openapiVersion);
|
|
81
81
|
if (!example) {
|
|
82
82
|
return null;
|
|
83
83
|
}
|
|
@@ -5,14 +5,14 @@ import type { ExampleObject, RequestBodyObject } from '@scalar/workspace-store/s
|
|
|
5
5
|
* This is the schema-generation half of {@link getExampleFromBody}. It is exposed on its own so
|
|
6
6
|
* callers that need to regenerate a body for a freshly selected composition branch (rather than the
|
|
7
7
|
* edited example that would otherwise shadow it) produce the exact same value the initial example
|
|
8
|
-
* does.
|
|
9
|
-
*
|
|
8
|
+
* does. Data generation deep-resolves nested `$ref` members. XML retains reference sites so node
|
|
9
|
+
* naming and version-specific wrappers survive serialization.
|
|
10
10
|
*
|
|
11
11
|
* Returns `undefined` when there is no schema for the content type.
|
|
12
12
|
*/
|
|
13
|
-
export declare const getSchemaExampleFromBody: (requestBody: RequestBodyObject, contentType: string, requestBodyCompositionSelection?: Record<string, number
|
|
13
|
+
export declare const getSchemaExampleFromBody: (requestBody: RequestBodyObject, contentType: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string) => unknown;
|
|
14
14
|
/**
|
|
15
15
|
* Basically getExample + we generate an example from the schema if no example is found
|
|
16
16
|
*/
|
|
17
|
-
export declare const getExampleFromBody: (requestBody: RequestBodyObject, contentType: string, exampleName: string, requestBodyCompositionSelection?: Record<string, number
|
|
17
|
+
export declare const getExampleFromBody: (requestBody: RequestBodyObject, contentType: string, exampleName: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string) => ExampleObject | null;
|
|
18
18
|
//# sourceMappingURL=get-request-body-example.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/get-request-body-example.ts"],"names":[],"mappings":"
|
|
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,IA0ClB,CAAA"}
|
|
@@ -1,26 +1,36 @@
|
|
|
1
|
+
import { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type';
|
|
1
2
|
import { parseMimeType } from '@scalar/helpers/http/mime-type';
|
|
2
3
|
import { getExampleValue } from '../../../helpers/get-example-value.js';
|
|
3
4
|
import { getResolvedRefDeep } from '../../../helpers/get-resolved-ref-deep.js';
|
|
4
5
|
import { serializeStreamExample } from '../../../helpers/serialize-stream-example.js';
|
|
5
6
|
import { getExample } from '../../../request-example/builder/helpers/get-example.js';
|
|
6
7
|
import { getExampleFromSchema } from '../../../request-example/builder/helpers/get-example-from-schema.js';
|
|
8
|
+
import { getXmlBodyExample } from '../../../request-example/xml/get-xml-body-example.js';
|
|
7
9
|
/**
|
|
8
10
|
* Generate a write-mode example directly from a request body's schema, ignoring any stored example.
|
|
9
11
|
*
|
|
10
12
|
* This is the schema-generation half of {@link getExampleFromBody}. It is exposed on its own so
|
|
11
13
|
* callers that need to regenerate a body for a freshly selected composition branch (rather than the
|
|
12
14
|
* edited example that would otherwise shadow it) produce the exact same value the initial example
|
|
13
|
-
* does.
|
|
14
|
-
*
|
|
15
|
+
* does. Data generation deep-resolves nested `$ref` members. XML retains reference sites so node
|
|
16
|
+
* naming and version-specific wrappers survive serialization.
|
|
15
17
|
*
|
|
16
18
|
* Returns `undefined` when there is no schema for the content type.
|
|
17
19
|
*/
|
|
18
|
-
export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCompositionSelection) => {
|
|
20
|
+
export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCompositionSelection, openapiVersion) => {
|
|
19
21
|
const mediaType = requestBody.content?.[contentType];
|
|
20
22
|
const schema = mediaType?.schema ??
|
|
21
23
|
(mediaType?.itemSchema && parseMimeType(contentType).type === 'multipart'
|
|
22
24
|
? { type: 'array', items: mediaType.itemSchema }
|
|
23
25
|
: mediaType?.itemSchema);
|
|
26
|
+
if (isXmlMediaType(contentType)) {
|
|
27
|
+
return getXmlBodyExample(mediaType?.schema, undefined, {
|
|
28
|
+
openapiVersion,
|
|
29
|
+
mode: 'write',
|
|
30
|
+
compositionSelection: requestBodyCompositionSelection,
|
|
31
|
+
schemaPath: ['requestBody'],
|
|
32
|
+
}).xml;
|
|
33
|
+
}
|
|
24
34
|
if (!schema) {
|
|
25
35
|
return undefined;
|
|
26
36
|
}
|
|
@@ -36,11 +46,25 @@ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCo
|
|
|
36
46
|
/**
|
|
37
47
|
* Basically getExample + we generate an example from the schema if no example is found
|
|
38
48
|
*/
|
|
39
|
-
export const getExampleFromBody = (requestBody, contentType, exampleName, requestBodyCompositionSelection) => {
|
|
49
|
+
export const getExampleFromBody = (requestBody, contentType, exampleName, requestBodyCompositionSelection, openapiVersion) => {
|
|
40
50
|
// Return the existing example when it carries a usable value. An example that only has an
|
|
41
51
|
// `externalValue` (not yet resolved to a `value`) is treated as missing, so we fall back to a
|
|
42
52
|
// schema-generated example instead of building an empty request body.
|
|
43
53
|
const example = getExample(requestBody, exampleName, contentType);
|
|
54
|
+
if (isXmlMediaType(contentType)) {
|
|
55
|
+
const result = getXmlBodyExample(requestBody.content?.[contentType]?.schema, example, {
|
|
56
|
+
openapiVersion,
|
|
57
|
+
mode: 'write',
|
|
58
|
+
compositionSelection: requestBodyCompositionSelection,
|
|
59
|
+
schemaPath: ['requestBody'],
|
|
60
|
+
});
|
|
61
|
+
if (result.xml === undefined)
|
|
62
|
+
return null;
|
|
63
|
+
// Consumers select dataValue before value, so retain the serialized result for editor and wire output.
|
|
64
|
+
return example?.dataValue !== undefined
|
|
65
|
+
? { ...example, value: result.xml, serializedValue: result.xml }
|
|
66
|
+
: { ...example, value: result.xml };
|
|
67
|
+
}
|
|
44
68
|
const selected = getExampleValue(example);
|
|
45
69
|
if (example && selected) {
|
|
46
70
|
const stream = typeof selected.value === 'string' ? undefined : serializeStreamExample(selected.value, contentType, false);
|
|
@@ -52,7 +76,7 @@ export const getExampleFromBody = (requestBody, contentType, exampleName, reques
|
|
|
52
76
|
return selected.source === 'value' ? example : { ...example, value: selected.value };
|
|
53
77
|
}
|
|
54
78
|
// Generate an example from the schema
|
|
55
|
-
const schemaExample = getSchemaExampleFromBody(requestBody, contentType, requestBodyCompositionSelection);
|
|
79
|
+
const schemaExample = getSchemaExampleFromBody(requestBody, contentType, requestBodyCompositionSelection, openapiVersion);
|
|
56
80
|
if (schemaExample === undefined || schemaExample === null) {
|
|
57
81
|
return null;
|
|
58
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"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,kBAMF,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
|
|
1
2
|
import { X_SCALAR_DATE, X_SCALAR_DNT, X_SCALAR_REFERER, X_SCALAR_USER_AGENT } from '@scalar/helpers/http/scalar-headers';
|
|
2
3
|
import { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables';
|
|
3
4
|
import { err, ok } from '@scalar/helpers/types/result';
|
|
@@ -206,7 +207,7 @@ const buildRequestInner = (request, options) => {
|
|
|
206
207
|
*
|
|
207
208
|
* @see https://github.com/whatwg/fetch/issues/50
|
|
208
209
|
*/
|
|
209
|
-
method: request.method.toUpperCase(),
|
|
210
|
+
method: isHttpMethod(request.method) ? request.method.toUpperCase() : request.method,
|
|
210
211
|
headers,
|
|
211
212
|
body,
|
|
212
213
|
cache: request.cache,
|
|
@@ -20,5 +20,7 @@ exampleName?: string) => {
|
|
|
20
20
|
pathVariables: Record<string, string>;
|
|
21
21
|
allowReservedQueryParameters: Set<string>;
|
|
22
22
|
urlParams: URLSearchParams;
|
|
23
|
+
serializedQuery?: string[];
|
|
24
|
+
serializedPathParameters?: Set<string>;
|
|
23
25
|
};
|
|
24
26
|
//# sourceMappingURL=build-request-parameters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-parameters.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/build-request-parameters.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,qEAAqE,CAAA;AAE5E,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAA;AAqBlH;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;AACjC,qBAAqB;AACrB,aAAY,aAAa,CAAC,eAAe,CAAC,EAAO;AACjD,qCAAqC;AACrC,cAAa,MAAkB,KAC9B;IACD,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,4BAA4B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACzC,SAAS,EAAE,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"build-request-parameters.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/build-request-parameters.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,qEAAqE,CAAA;AAE5E,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAA;AAqBlH;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;AACjC,qBAAqB;AACrB,aAAY,aAAa,CAAC,eAAe,CAAC,EAAO;AACjD,qCAAqC;AACrC,cAAa,MAAkB,KAC9B;IACD,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,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;CA8IvC,CAAA"}
|
|
@@ -3,8 +3,8 @@ import { isObject } from '@scalar/helpers/object/is-object';
|
|
|
3
3
|
import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref';
|
|
4
4
|
import { xScalarCookieSchema, } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
5
5
|
import { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce';
|
|
6
|
+
import { getParameterExample } from '../../../helpers/get-parameter-example.js';
|
|
6
7
|
import { deSerializeParameter } from '../../../request-example/builder/header/de-serialize-parameter.js';
|
|
7
|
-
import { getExample } from '../helpers/get-example.js';
|
|
8
8
|
import { isParamDisabled } from './is-param-disabled.js';
|
|
9
9
|
import { serializeContentValue, serializeCookieStyle, serializeDeepObjectStyle, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './serialize-parameter.js';
|
|
10
10
|
/** Helper to get explode value with default */
|
|
@@ -38,15 +38,58 @@ exampleName = 'default') => {
|
|
|
38
38
|
// Second pass: process all parameters
|
|
39
39
|
for (const referencedParam of parameters) {
|
|
40
40
|
const param = getResolvedRef(referencedParam);
|
|
41
|
-
if (!param)
|
|
41
|
+
if (!param) {
|
|
42
42
|
continue;
|
|
43
|
-
|
|
43
|
+
}
|
|
44
|
+
const selected = getParameterExample(param, exampleName);
|
|
45
|
+
const { example, value } = selected;
|
|
44
46
|
// Skip disabled examples
|
|
45
47
|
if (!example || isParamDisabled(param, example)) {
|
|
46
48
|
continue;
|
|
47
49
|
}
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
+
/** Parameter-level wire text already contains its name, delimiters, and encoding. */
|
|
51
|
+
if (selected.serialized) {
|
|
52
|
+
const wireValue = String(value);
|
|
53
|
+
switch (param.in) {
|
|
54
|
+
case 'query':
|
|
55
|
+
;
|
|
56
|
+
(result.serializedQuery ??= []).push(wireValue);
|
|
57
|
+
break;
|
|
58
|
+
case 'path':
|
|
59
|
+
result.pathVariables[param.name] = wireValue;
|
|
60
|
+
(result.serializedPathParameters ??= new Set()).add(param.name);
|
|
61
|
+
break;
|
|
62
|
+
case 'header':
|
|
63
|
+
result.headers[param.name] = wireValue;
|
|
64
|
+
break;
|
|
65
|
+
case 'cookie':
|
|
66
|
+
result.headers.Cookie = [result.headers.Cookie, wireValue].filter(Boolean).join('; ');
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (selected.mediaSerialized) {
|
|
72
|
+
const text = String(value);
|
|
73
|
+
switch (param.in) {
|
|
74
|
+
case 'query':
|
|
75
|
+
result.urlParams.set(param.name, text);
|
|
76
|
+
break;
|
|
77
|
+
case 'header':
|
|
78
|
+
result.headers[param.name] = text;
|
|
79
|
+
break;
|
|
80
|
+
case 'path':
|
|
81
|
+
result.pathVariables[param.name] = text;
|
|
82
|
+
break;
|
|
83
|
+
case 'cookie':
|
|
84
|
+
result.cookies.push(coerceValue(xScalarCookieSchema, {
|
|
85
|
+
name: encodeURIComponent(param.name),
|
|
86
|
+
value: encodeURIComponent(text),
|
|
87
|
+
path: '/',
|
|
88
|
+
}));
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
50
93
|
/** De-serialize the example value if it is a string and matches the schema type */
|
|
51
94
|
const deSerializedValue = deSerializeParameter(value, param);
|
|
52
95
|
const paramName = param.name;
|
|
@@ -82,11 +125,7 @@ exampleName = 'default') => {
|
|
|
82
125
|
result.pathVariables[paramName] = String(serialized);
|
|
83
126
|
break;
|
|
84
127
|
}
|
|
85
|
-
|
|
86
|
-
// regular query parameter so schema-based values still expand into the query string
|
|
87
|
-
// instead of being silently dropped.
|
|
88
|
-
case 'query':
|
|
89
|
-
case 'querystring': {
|
|
128
|
+
case 'query': {
|
|
90
129
|
processQueryParameter(param, paramName, deSerializedValue, result.urlParams, result.allowReservedQueryParameters);
|
|
91
130
|
break;
|
|
92
131
|
}
|
|
@@ -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;AAIlH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,eAAe,EACtB,SAAS,aAAa,GAAG,SAAS,EAClC,kBAAiB,OAAc,KAC9B,OAiBF,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getExampleValue } from '../../../helpers/get-example-value.js';
|
|
1
2
|
/**
|
|
2
3
|
* Determines if a parameter is disabled
|
|
3
4
|
*
|
|
@@ -16,7 +17,8 @@ export const isParamDisabled = (param, example, defaultDisabled = true) => {
|
|
|
16
17
|
return xDisabled;
|
|
17
18
|
}
|
|
18
19
|
// Keep the editor, generated snippets, and outgoing requests aligned for pre-populated values.
|
|
19
|
-
const
|
|
20
|
+
const value = getExampleValue(example)?.value;
|
|
21
|
+
const hasValue = value !== undefined && value !== '' && value !== null;
|
|
20
22
|
if (!defaultDisabled || hasValue) {
|
|
21
23
|
return false;
|
|
22
24
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DynamicScope } from '../../../helpers/dynamic-ref.js';
|
|
2
|
+
import type { SchemaObject } from '../../../schemas/v3.1/strict/openapi-document.js';
|
|
3
|
+
/** Schema provenance collected only when a format needs more than the generated data. */
|
|
4
|
+
export type ExampleEvaluation = {
|
|
5
|
+
schema: SchemaObject;
|
|
6
|
+
value: unknown;
|
|
7
|
+
path: string[];
|
|
8
|
+
name?: string;
|
|
9
|
+
dynamicScope: DynamicScope;
|
|
10
|
+
children: ExampleEvaluation[];
|
|
11
|
+
};
|
|
12
|
+
/** Per-call capture state; never shared with the JSON result cache. */
|
|
13
|
+
export type ExampleEvaluationState = {
|
|
14
|
+
stack: ExampleEvaluation[];
|
|
15
|
+
root?: ExampleEvaluation;
|
|
16
|
+
};
|
|
17
|
+
/** Internal option: keep the default JSON generation path free of provenance allocations. */
|
|
18
|
+
export declare const EXAMPLE_EVALUATION: unique symbol;
|
|
19
|
+
//# sourceMappingURL=example-evaluation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-evaluation.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/example-evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,yFAAyF;AACzF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,YAAY,CAAA;IACpB,KAAK,EAAE,OAAO,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;IAC1B,QAAQ,EAAE,iBAAiB,EAAE,CAAA;CAC9B,CAAA;AAED,uEAAuE;AACvE,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,iBAAiB,EAAE,CAAA;IAC1B,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB,CAAA;AAED,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,eAA+B,CAAA"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { type DynamicScope } from '../../../helpers/dynamic-ref.js';
|
|
2
2
|
import type { SchemaObject } from '../../../schemas/v3.2/strict/openapi-document.js';
|
|
3
|
-
type
|
|
3
|
+
import { EXAMPLE_EVALUATION, type ExampleEvaluationState } from './example-evaluation.js';
|
|
4
|
+
/** Select a composition branch once for both generated values and supplied example metadata. */
|
|
5
|
+
export declare const selectExampleComposition: (schema: SchemaObject, schemaPath: string[], options?: GetExampleFromSchemaOptions, arrayItem?: boolean, value?: Record<string, unknown>) => SchemaObject | undefined;
|
|
6
|
+
/** Options shared by data generation and schema-aware serializers. */
|
|
7
|
+
export type GetExampleFromSchemaOptions = {
|
|
8
|
+
/** Internal provenance capture, excluded from persistent result caches. */
|
|
9
|
+
[EXAMPLE_EVALUATION]?: ExampleEvaluationState;
|
|
4
10
|
/** Fallback string for empty string values. */
|
|
5
11
|
emptyString?: string;
|
|
6
|
-
/**
|
|
12
|
+
/** @deprecated Use getXmlExampleFromSchema for schema-aware XML serialization. */
|
|
7
13
|
xml?: boolean;
|
|
8
14
|
/** Whether to show read-only/write-only properties. */
|
|
9
15
|
mode?: 'read' | 'write';
|
|
@@ -37,7 +43,7 @@ type GetExampleFromSchemaOptions = {
|
|
|
37
43
|
* @param name - The name of the property being processed.
|
|
38
44
|
* @returns An example value for the given schema.
|
|
39
45
|
*/
|
|
40
|
-
|
|
46
|
+
declare const generateExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, { level, parentSchema, name, seen, schemaPath, dynamicScope, }?: Partial<{
|
|
41
47
|
level: number;
|
|
42
48
|
parentSchema: SchemaObject;
|
|
43
49
|
name: string;
|
|
@@ -47,5 +53,7 @@ export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetE
|
|
|
47
53
|
/** Chain of schema resources entered so far, used to resolve `$dynamicRef` (JSON Schema 2020-12). */
|
|
48
54
|
dynamicScope: DynamicScope;
|
|
49
55
|
}>) => unknown;
|
|
56
|
+
/** Generate data, optionally retaining the exact schema decisions for another output format. */
|
|
57
|
+
export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, context?: Parameters<typeof generateExampleFromSchema>[2]) => unknown;
|
|
50
58
|
export {};
|
|
51
59
|
//# sourceMappingURL=get-example-from-schema.d.ts.map
|
|
@@ -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;
|
|
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;AAoZ9G,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,SAmBjB,CAAA;AAuZD,sEAAsE;AACtE,MAAM,MAAM,2BAA2B,GAAG;IACxC,2EAA2E;IAC3E,CAAC,kBAAkB,CAAC,CAAC,EAAE,sBAAsB,CAAA;IAC7C,+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;AAuPD;;;;;;;;;;;;;;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,OA8OF,CAAA;AAED,gGAAgG;AAChG,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,YAAY,EACpB,UAAU,2BAA2B,EACrC,UAAS,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAM,KAC5D,OA0BF,CAAA"}
|