@scalar/workspace-store 0.54.1 → 0.54.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/entities/auth/schema.d.ts +110 -15
  3. package/dist/entities/auth/schema.d.ts.map +1 -1
  4. package/dist/helpers/for-each-path-item-operation.d.ts +33 -0
  5. package/dist/helpers/for-each-path-item-operation.d.ts.map +1 -0
  6. package/dist/helpers/for-each-path-item-operation.js +75 -0
  7. package/dist/mutators/auth.d.ts.map +1 -1
  8. package/dist/mutators/auth.js +7 -13
  9. package/dist/mutators/operation/body.d.ts.map +1 -1
  10. package/dist/mutators/operation/body.js +3 -2
  11. package/dist/mutators/operation/extensions.d.ts.map +1 -1
  12. package/dist/mutators/operation/extensions.js +2 -1
  13. package/dist/mutators/operation/history.d.ts.map +1 -1
  14. package/dist/mutators/operation/history.js +3 -2
  15. package/dist/mutators/operation/operation.d.ts.map +1 -1
  16. package/dist/mutators/operation/operation.js +16 -16
  17. package/dist/mutators/operation/parameters.d.ts.map +1 -1
  18. package/dist/mutators/operation/parameters.js +30 -9
  19. package/dist/mutators/server.d.ts.map +1 -1
  20. package/dist/mutators/server.js +2 -1
  21. package/dist/mutators/tag.d.ts.map +1 -1
  22. package/dist/mutators/tag.js +9 -15
  23. package/dist/navigation/helpers/get-openapi-object.d.ts.map +1 -1
  24. package/dist/navigation/helpers/get-openapi-object.js +2 -1
  25. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  26. package/dist/navigation/helpers/traverse-paths.js +5 -8
  27. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  28. package/dist/navigation/helpers/traverse-webhooks.js +4 -7
  29. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
  30. package/dist/request-example/builder/body/build-request-body.js +81 -7
  31. package/dist/request-example/builder/header/de-serialize-parameter.js +37 -4
  32. package/dist/request-example/builder/security/build-request-security.d.ts.map +1 -1
  33. package/dist/request-example/builder/security/build-request-security.js +9 -4
  34. package/dist/request-example/context/get-request-example-context.d.ts.map +1 -1
  35. package/dist/request-example/context/get-request-example-context.js +3 -2
  36. package/dist/schemas/extensions/document/x-scalar-sdk-installation.d.ts +8 -0
  37. package/dist/schemas/extensions/document/x-scalar-sdk-installation.d.ts.map +1 -1
  38. package/dist/schemas/extensions/document/x-scalar-sdk-installation.js +2 -0
  39. package/dist/schemas/reference-config/index.d.ts +22 -3
  40. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  41. package/dist/schemas/reference-config/settings.d.ts +22 -3
  42. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  43. package/dist/schemas/v3.1/openapi/index.d.ts +1 -0
  44. package/dist/schemas/v3.1/openapi/index.d.ts.map +1 -1
  45. package/dist/schemas/v3.1/strict/components.d.ts +11 -2
  46. package/dist/schemas/v3.1/strict/components.d.ts.map +1 -1
  47. package/dist/schemas/v3.1/strict/components.js +1 -1
  48. package/dist/schemas/v3.1/strict/info.d.ts +1 -0
  49. package/dist/schemas/v3.1/strict/info.d.ts.map +1 -1
  50. package/dist/schemas/v3.1/strict/openapi-document.d.ts +770 -105
  51. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  52. package/dist/schemas/v3.1/strict/openapi-document.js +2 -2
  53. package/dist/schemas/v3.1/strict/paths.d.ts +12 -2
  54. package/dist/schemas/v3.1/strict/paths.d.ts.map +1 -1
  55. package/dist/schemas/v3.1/strict/paths.js +2 -1
  56. package/dist/server.d.ts.map +1 -1
  57. package/dist/server.js +12 -9
  58. package/package.json +5 -5
@@ -1,3 +1,4 @@
1
+ import { getPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
1
2
  import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
2
3
  import { isOpenApiDocument } from '../../schemas/type-guards.js';
3
4
  import { isContentTypeParameterObject } from '../../schemas/v3.1/strict/type-guards.js';
@@ -12,7 +13,7 @@ export const addResponseToHistory = async (store, document, { payload, meta }) =
12
13
  if (!documentName || !payload) {
13
14
  return;
14
15
  }
15
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
16
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
16
17
  if (!operation) {
17
18
  return;
18
19
  }
@@ -48,7 +49,7 @@ export const reloadOperationHistory = (store, document, { meta, index, callback
48
49
  console.error('Document not found', meta.path, meta.method);
49
50
  return;
50
51
  }
51
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
52
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
52
53
  if (!operation) {
53
54
  console.error('Operation not found', meta.path, meta.method);
54
55
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/operation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAOrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAGlD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAC1B,gBAAgB,cAAc,GAAG,IAAI,EACrC,SAAS,eAAe,CAAC,4BAA4B,CAAC,KACrD,MAAM,GAAG,SA0DX,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,cAAc,GAAG,IAAI,EAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,mBAAmB,eAAe,CAAC,uBAAuB,CAAC,SAsB5D,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAU,iBAAiB,GAAG,IAAI,EAClC,OAAO,cAAc,GAAG,IAAI,EAC5B,mEAAmE,eAAe,CAAC,6BAA6B,CAAC,KAChH,IAqGF,CAAA;AAED;;;;;;;;;;GAUG;A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KAChH,IAoGF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,cAAc,GAAG,IAAI,EAChC,wBAAwB,eAAe,CAAC,4BAA4B,CAAC,SAgBtE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACtC,WAAW,cAAc,GAAG,IAAI,EAChC,uDAAuD,eAAe,CAAC,gCAAgC,CAAC,SAuBzG,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,cAAc,GAAG,IAAI,EAChC,sDAAsD,eAAe,CAAC,0BAA0B,CAAC,SAiDlG,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,cAAc,GAAG,IAAI,EAChC,+DAA+D,eAAe,CAAC,0BAA0B,CAAC,SAuE3G,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
2
2
  import { preventPollution } from '@scalar/helpers/object/prevent-pollution';
3
3
  import { findVariables } from '@scalar/helpers/regex/find-variables';
4
+ import { deletePathItemOperation, getPathItemOperation, pathItemIsEmpty, setPathItemOperation, } from '../../helpers/for-each-path-item-operation.js';
4
5
  import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
5
6
  import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
6
7
  import { syncParametersForPathChange } from '../../mutators/operation/helpers/sync-path-parameters.js';
@@ -44,7 +45,7 @@ export const createOperation = (workspaceStore, payload) => {
44
45
  preventPollution(normalizedPath);
45
46
  preventPollution(method);
46
47
  /** Create the operation in the document */
47
- document.paths[normalizedPath][method] = operation;
48
+ setPathItemOperation(document.paths[normalizedPath], method, operation);
48
49
  // Make sure that we are selecting the new operation server
49
50
  const { servers } = operation;
50
51
  const firstServer = unpackProxyObject(servers?.[0]);
@@ -91,7 +92,7 @@ export const updateOperationMeta = (store, document, { meta, payload }) => {
91
92
  if (documentName === undefined) {
92
93
  return;
93
94
  }
94
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
95
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
95
96
  if (!operation) {
96
97
  console.error('Operation not found', { meta, document });
97
98
  return;
@@ -136,7 +137,7 @@ export const updateOperationPathMethod = (document, store, { meta, payload: { me
136
137
  return;
137
138
  }
138
139
  // Check for conflicts at the target location
139
- if (document.paths?.[finalPath]?.[finalMethod]) {
140
+ if (getPathItemOperation(document.paths?.[finalPath], finalMethod)) {
140
141
  callback('conflict', blurTargetSelector);
141
142
  return;
142
143
  }
@@ -145,7 +146,7 @@ export const updateOperationPathMethod = (document, store, { meta, payload: { me
145
146
  console.error('Document navigation missing', { document });
146
147
  return;
147
148
  }
148
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
149
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
149
150
  if (!operation) {
150
151
  console.error('Operation not found', { meta, document });
151
152
  return;
@@ -185,13 +186,12 @@ export const updateOperationPathMethod = (document, store, { meta, payload: { me
185
186
  preventPollution(meta.path);
186
187
  preventPollution(finalMethod);
187
188
  // Move the operation to the new location
188
- document.paths[finalPath][finalMethod] = unpackProxyObject(operation);
189
+ setPathItemOperation(document.paths[finalPath], finalMethod, unpackProxyObject(operation));
189
190
  // Remove the operation from the old location
190
- const oldPathItems = document.paths[meta.path];
191
- if (oldPathItems && isHttpMethod(meta.method)) {
192
- delete oldPathItems[meta.method];
193
- // If the old path has no more operations, remove the path entry
194
- if (Object.keys(oldPathItems).length === 0) {
191
+ if (isHttpMethod(meta.method)) {
192
+ deletePathItemOperation(document.paths[meta.path], meta.method);
193
+ // If the old path is now empty, remove the path entry (path-level metadata is kept otherwise)
194
+ if (pathItemIsEmpty(document.paths[meta.path])) {
195
195
  delete document.paths[meta.path];
196
196
  }
197
197
  }
@@ -217,9 +217,9 @@ export const deleteOperation = (workspace, { meta, documentName }) => {
217
217
  }
218
218
  preventPollution(meta.path);
219
219
  preventPollution(meta.method);
220
- delete document.paths?.[meta.path]?.[meta.method];
221
- // If the path has no more operations, remove the path entry
222
- if (Object.keys(document.paths?.[meta.path] ?? {}).length === 0) {
220
+ deletePathItemOperation(document.paths?.[meta.path], meta.method);
221
+ // If the path is now empty, remove the path entry (path-level metadata is kept otherwise)
222
+ if (pathItemIsEmpty(document.paths?.[meta.path])) {
223
223
  delete document.paths?.[meta.path];
224
224
  }
225
225
  };
@@ -236,7 +236,7 @@ export const createOperationDraftExample = (workspace, { meta: { path, method },
236
236
  console.error('Document not found', { documentName });
237
237
  return;
238
238
  }
239
- const operation = getResolvedRef(document.paths?.[path]?.[method]);
239
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[path], method));
240
240
  if (!operation) {
241
241
  console.error('Operation not found', { path, method });
242
242
  return;
@@ -264,7 +264,7 @@ export const deleteOperationExample = (workspace, { meta: { path, method, exampl
264
264
  return;
265
265
  }
266
266
  // Get the operation object for the given path and method
267
- const operation = getResolvedRef(document.paths?.[path]?.[method]);
267
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[path], method));
268
268
  if (!operation) {
269
269
  return;
270
270
  }
@@ -314,7 +314,7 @@ export const renameOperationExample = (workspace, { meta: { path, method, exampl
314
314
  if (!isOpenApiDocument(document)) {
315
315
  return;
316
316
  }
317
- const operation = getResolvedRef(document.paths?.[path]?.[method]);
317
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[path], method));
318
318
  if (!operation) {
319
319
  return;
320
320
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAGrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAMlD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,4CAA4C,eAAe,CAAC,4BAA4B,CAAC,SAkD1F,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,GACzC,UAAU,iBAAiB,GAAG,IAAI,EAClC,uCAAuC,eAAe,CAAC,mCAAmC,CAAC,SA8C5F,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,6BAA6B,eAAe,CAAC,4BAA4B,CAAC,SA6B3E,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gBAAgB,eAAe,CAAC,iCAAiC,CAAC,SAanE,CAAA"}
1
+ {"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAIrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAmClD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,4CAA4C,eAAe,CAAC,4BAA4B,CAAC,SAkD1F,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,GACzC,UAAU,iBAAiB,GAAG,IAAI,EAClC,uCAAuC,eAAe,CAAC,mCAAmC,CAAC,SA8C5F,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,EAClC,6BAA6B,eAAe,CAAC,4BAA4B,CAAC,SAkC3E,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,iBAAiB,GAAG,IAAI,EAClC,gBAAgB,eAAe,CAAC,iCAAiC,CAAC,SAanE,CAAA"}
@@ -1,6 +1,25 @@
1
+ import { getPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
1
2
  import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
2
3
  import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
3
4
  import { isOpenApiDocument } from '../../schemas/type-guards.js';
5
+ const getPathItemsForParameterMutation = (pathItemRef) => {
6
+ if (!pathItemRef || typeof pathItemRef !== 'object') {
7
+ return [];
8
+ }
9
+ if ('$ref' in pathItemRef) {
10
+ const targets = [];
11
+ const refWrapper = pathItemRef;
12
+ if (refWrapper.parameters !== undefined) {
13
+ targets.push(refWrapper);
14
+ }
15
+ const resolved = getResolvedRef(pathItemRef);
16
+ if (resolved) {
17
+ targets.push(resolved);
18
+ }
19
+ return targets;
20
+ }
21
+ return [pathItemRef];
22
+ };
4
23
  /**
5
24
  * Updates an existing parameter of a given `type` by its index within that
6
25
  * type subset (e.g. the N-th query parameter). Supports updating name, value,
@@ -42,7 +61,7 @@ export const upsertOperationParameter = (document, { meta, type, payload, origin
42
61
  if (!isOpenApiDocument(document)) {
43
62
  return;
44
63
  }
45
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
64
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
46
65
  if (!operation) {
47
66
  console.error('Operation not found', { meta, document });
48
67
  return;
@@ -84,7 +103,7 @@ export const updateOperationExtraParameters = (document, { type, meta, payload,
84
103
  return;
85
104
  }
86
105
  // Resolve the referenced operation from the document using the path and method
87
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
106
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
88
107
  if (!operation) {
89
108
  return;
90
109
  }
@@ -130,7 +149,7 @@ export const deleteOperationParameter = (document, { meta, originalParameter })
130
149
  if (!isOpenApiDocument(document)) {
131
150
  return;
132
151
  }
133
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
152
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
134
153
  // Lets check if its on the operation first as its more likely
135
154
  const operationIndex = operation?.parameters?.findIndex((it) => getResolvedRef(it) === originalParameter) ?? -1;
136
155
  // We cannot call splice on a proxy object, so we unwrap the array and filter it
@@ -138,11 +157,13 @@ export const deleteOperationParameter = (document, { meta, originalParameter })
138
157
  operation.parameters = unpackProxyObject(operation.parameters?.filter((_, i) => i !== operationIndex), { depth: 1 });
139
158
  return;
140
159
  }
141
- // If it wasn't on the operation it might be on the path
142
- const path = getResolvedRef(document.paths?.[meta.path]);
143
- const pathIndex = path?.parameters?.findIndex((it) => getResolvedRef(it) === originalParameter) ?? -1;
144
- if (path && pathIndex >= 0) {
145
- path.parameters = unpackProxyObject(path.parameters?.filter((_, i) => i !== pathIndex), { depth: 1 });
160
+ // If it wasn't on the operation it might be on the path (wrapper siblings or $ref-value)
161
+ for (const path of getPathItemsForParameterMutation(document.paths?.[meta.path])) {
162
+ const pathIndex = path.parameters?.findIndex((parameter) => getResolvedRef(parameter) === originalParameter) ?? -1;
163
+ if (pathIndex >= 0) {
164
+ path.parameters = unpackProxyObject(path.parameters?.filter((_, i) => i !== pathIndex), { depth: 1 });
165
+ return;
166
+ }
146
167
  }
147
168
  };
148
169
  /**
@@ -162,7 +183,7 @@ export const deleteAllOperationParameters = (document, { meta, type }) => {
162
183
  if (!isOpenApiDocument(document)) {
163
184
  return;
164
185
  }
165
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
186
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method));
166
187
  if (!operation) {
167
188
  return;
168
189
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mutators/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA;AAE9E,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,6BAA6B,CAAA;AAK3E,OAAO,EAAE,KAAK,YAAY,EAAsB,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kCAAkC,CAAC;CAG5F,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { findVariables } from '@scalar/helpers/regex/find-variables';
2
+ import { getPathItemOperation } from '../helpers/for-each-path-item-operation.js';
2
3
  import { getResolvedRef } from '../helpers/get-resolved-ref.js';
3
4
  import { unpackProxyObject } from '../helpers/unpack-proxy.js';
4
5
  import { isAsyncApiDocument, isOpenApiDocument } from '../schemas/type-guards.js';
@@ -15,7 +16,7 @@ const getServerTarget = (document, meta) => {
15
16
  if (meta.type === 'document') {
16
17
  return document;
17
18
  }
18
- return getResolvedRef(document.paths?.[meta.path]?.[meta.method]) ?? null;
19
+ return getResolvedRef(getPathItemOperation(document.paths?.[meta.path], meta.method)) ?? null;
19
20
  };
20
21
  /**
21
22
  * Initializes the servers for the document or operation based on meta.
@@ -1 +1 @@
1
- {"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/mutators/tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAQzD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,SAe3F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,cAAc,CAAC,SAqEvF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,SAwC/F,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,WAAW;IAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CAAE;yBAErD,SAAS,CAAC,gBAAgB,CAAC;uBAC7B,SAAS,CAAC,cAAc,CAAC;yBACvB,SAAS,CAAC,gBAAgB,CAAC;CAEnD,CAAA"}
1
+ {"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/mutators/tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AASzD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,SAe3F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,cAAc,CAAC,SAqEvF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,cAAc,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,gBAAgB,CAAC,SA+B/F,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,WAAW;IAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CAAE;yBAErD,SAAS,CAAC,gBAAgB,CAAC;uBAC7B,SAAS,CAAC,cAAc,CAAC;yBACvB,SAAS,CAAC,gBAAgB,CAAC;CAEnD,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { forEachPathItemOperation, getPathItemOperation } from '../helpers/for-each-path-item-operation.js';
1
2
  import { getResolvedRef } from '../helpers/get-resolved-ref.js';
2
3
  import { unpackProxyObject } from '../helpers/unpack-proxy.js';
3
4
  import { getNavigationOptions } from '../navigation/get-navigation-options.js';
@@ -55,7 +56,7 @@ export const editTag = (store, payload) => {
55
56
  payload.tag.children?.forEach((child) => {
56
57
  // Operation
57
58
  if (child.type === 'operation') {
58
- const operation = getResolvedRef(document.paths?.[child.path]?.[child.method]);
59
+ const operation = getResolvedRef(getPathItemOperation(document.paths?.[child.path], child.method));
59
60
  if (operation && 'tags' in operation) {
60
61
  const plainTags = unpackProxyObject(operation.tags, { depth: null });
61
62
  operation.tags = plainTags?.map((tag) => (tag === oldName ? newName : tag));
@@ -63,7 +64,7 @@ export const editTag = (store, payload) => {
63
64
  }
64
65
  // Webhook
65
66
  else if (child.type === 'webhook') {
66
- const webhook = getResolvedRef(document.webhooks?.[child.name]?.[child.method]);
67
+ const webhook = getResolvedRef(getPathItemOperation(document.webhooks?.[child.name], child.method));
67
68
  if (webhook && 'tags' in webhook) {
68
69
  const plainTags = unpackProxyObject(webhook.tags, { depth: null });
69
70
  webhook.tags = plainTags?.map((tag) => (tag === oldName ? newName : tag));
@@ -108,13 +109,9 @@ export const deleteTag = (workspace, payload) => {
108
109
  return;
109
110
  }
110
111
  // Clear tags from all operations that have this tag
111
- Object.values(document.paths ?? {}).forEach((path) => {
112
- Object.values(path).forEach((operation) => {
113
- // Only process operations that are objects
114
- if (typeof operation !== 'object' || Array.isArray(operation)) {
115
- return;
116
- }
117
- const resolvedOperation = getResolvedRef(operation);
112
+ Object.values(document.paths ?? {}).forEach((pathItemRef) => {
113
+ forEachPathItemOperation(pathItemRef, (_method, operationRef) => {
114
+ const resolvedOperation = getResolvedRef(operationRef);
118
115
  if ('tags' in resolvedOperation) {
119
116
  const plainTags = unpackProxyObject(resolvedOperation.tags, { depth: 1 });
120
117
  resolvedOperation.tags = plainTags?.filter((tag) => tag !== payload.name);
@@ -122,12 +119,9 @@ export const deleteTag = (workspace, payload) => {
122
119
  });
123
120
  });
124
121
  // Remove the tag from all webhooks that have this tag
125
- Object.values(document.webhooks ?? {}).forEach((webhook) => {
126
- Object.values(webhook).forEach((operation) => {
127
- if (typeof operation !== 'object' || Array.isArray(operation)) {
128
- return;
129
- }
130
- const resolvedOperation = getResolvedRef(operation);
122
+ Object.values(document.webhooks ?? {}).forEach((pathItemRef) => {
123
+ forEachPathItemOperation(pathItemRef, (_method, operationRef) => {
124
+ const resolvedOperation = getResolvedRef(operationRef);
131
125
  const plainTags = unpackProxyObject(resolvedOperation.tags, { depth: 1 });
132
126
  resolvedOperation.tags = plainTags?.filter((tag) => tag !== payload.name);
133
127
  });
@@ -1 +1 @@
1
- {"version":3,"file":"get-openapi-object.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/get-openapi-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAE/G,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAIxF,KAAK,kBAAkB,GAAG,iBAAiB,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAE/E,KAAK,gBAAgB,CAAC,KAAK,SAAS,kBAAkB,IAAI,KAAK,SAAS,iBAAiB,GACrF,iBAAiB,GACjB,KAAK,SAAS,YAAY,GACxB,SAAS,GACT,KAAK,SAAS,kBAAkB,GAC9B,eAAe,GACf,KAAK,CAAA;AAEb,0EAA0E;AAC1E,eAAO,MAAM,YAAY,GAAI,OAAO,cAAc,KAAG,KAAK,IAAI,kBACmB,CAAA;AAEjF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,SAAS,kBAAkB,EAAE,mBAGhE;IACD,KAAK,EAAE,cAAc,CAAA;IACrB,KAAK,EAAE,KAAK,CAAA;CACb,KAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAgC7B,CAAA"}
1
+ {"version":3,"file":"get-openapi-object.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/get-openapi-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAE/G,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAIxF,KAAK,kBAAkB,GAAG,iBAAiB,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAE/E,KAAK,gBAAgB,CAAC,KAAK,SAAS,kBAAkB,IAAI,KAAK,SAAS,iBAAiB,GACrF,iBAAiB,GACjB,KAAK,SAAS,YAAY,GACxB,SAAS,GACT,KAAK,SAAS,kBAAkB,GAC9B,eAAe,GACf,KAAK,CAAA;AAEb,0EAA0E;AAC1E,eAAO,MAAM,YAAY,GAAI,OAAO,cAAc,KAAG,KAAK,IAAI,kBACmB,CAAA;AAEjF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,SAAS,kBAAkB,EAAE,mBAGhE;IACD,KAAK,EAAE,cAAc,CAAA;IACrB,KAAK,EAAE,KAAK,CAAA;CACb,KAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAoC7B,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { getPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
1
2
  import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
2
3
  import { isOpenApiDocument } from '../../schemas/type-guards.js';
3
4
  import { getParentEntry } from './get-parent-entry.js';
@@ -46,7 +47,7 @@ export const getOpenapiObject = ({ store, entry, }) => {
46
47
  }
47
48
  if (entry.type === 'operation') {
48
49
  // Fetch and resolve the referenced operation object at the given path/method
49
- return getResolvedRef(document.paths?.[entry.path]?.[entry.method]) ?? null;
50
+ return (getResolvedRef(getPathItemOperation(document.paths?.[entry.path], entry.method)) ?? null);
50
51
  }
51
52
  // If entry type is unknown, return null
52
53
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-paths.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-paths.ts"],"names":[],"mappings":"AAQ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C,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,6 +1,5 @@
1
- import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
2
- import { objectKeys } from '@scalar/helpers/object/object-keys';
3
1
  import { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointer';
2
+ import { forEachPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
4
3
  import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
5
4
  import { isHidden } from '../../helpers/is-hidden.js';
6
5
  import { traverseOperationExamples } from '../../navigation/helpers/traverse-examples.js';
@@ -74,16 +73,14 @@ const createOperationEntry = ({ ref, operation, method, path, generateId, parent
74
73
  export const traversePaths = ({ document, tagsMap, generateId, documentId, operationTitleSource, }) => {
75
74
  const untaggedOperations = [];
76
75
  // Traverse paths
77
- Object.entries(document.paths ?? {}).forEach(([path, pathItemObject]) => {
78
- const pathKeys = objectKeys(pathItemObject ?? {}).filter((key) => isHttpMethod(key));
79
- pathKeys.forEach((method) => {
80
- const _operation = pathItemObject?.[method];
81
- const operation = getResolvedRef(_operation, mergeSiblingReferences);
76
+ Object.entries(document.paths ?? {}).forEach(([path, pathItemRef]) => {
77
+ forEachPathItemOperation(pathItemRef, (method, operationRef) => {
78
+ const operation = getResolvedRef(operationRef, mergeSiblingReferences);
82
79
  if (!operation) {
83
80
  return;
84
81
  }
85
82
  // Skip if the operation is internal or scalar-ignore
86
- if (isHidden(operation) || !isHttpMethod(method)) {
83
+ if (isHidden(operation)) {
87
84
  return;
88
85
  }
89
86
  const ref = `#/paths/${escapeJsonPointer(path)}/${method}`;
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAOA,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,EA0DnB,CAAA"}
1
+ {"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAMA,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,5 +1,4 @@
1
- import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
2
- import { objectKeys } from '@scalar/helpers/object/object-keys';
1
+ import { forEachPathItemOperation } from '../../helpers/for-each-path-item-operation.js';
3
2
  import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
4
3
  import { isHidden } from '../../helpers/is-hidden.js';
5
4
  import { isDeprecatedOperation } from '../../navigation/helpers/traverse-paths.js';
@@ -53,11 +52,9 @@ const createWebhookEntry = ({ ref, method, name, title, generateId, parentTag, w
53
52
  export const traverseWebhooks = ({ document, tagsMap, generateId, untaggedWebhooksParentId, documentId, }) => {
54
53
  const untagged = [];
55
54
  // Traverse webhooks
56
- Object.entries(document.webhooks ?? {}).forEach(([name, pathItemObject]) => {
57
- const pathKeys = objectKeys(pathItemObject ?? {}).filter((key) => isHttpMethod(key));
58
- pathKeys.forEach((method) => {
59
- const _operation = pathItemObject?.[method];
60
- const operation = getResolvedRef(_operation, mergeSiblingReferences);
55
+ Object.entries(document.webhooks ?? {}).forEach(([name, pathItemRef]) => {
56
+ forEachPathItemOperation(pathItemRef, (method, operationRef) => {
57
+ const operation = getResolvedRef(operationRef, mergeSiblingReferences);
61
58
  if (!operation) {
62
59
  return;
63
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAOjG,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;KACd,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;AAED,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,GAAG,QAAQ,GAAG,UAAU,GAAG,GAAG,CAAA;AAiCrD;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;AACrC,oBAAuB;AACvB,sEAAsE;AACtE,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,WAAW,GAAG,IAkRhB,CAAA"}
1
+ {"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAOjG,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;KACd,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;AAED,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,GAAG,QAAQ,GAAG,UAAU,GAAG,GAAG,CAAA;AA2GrD;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;AACrC,oBAAuB;AACvB,sEAAsE;AACtE,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,WAAW,GAAG,IA2RhB,CAAA"}
@@ -1,7 +1,7 @@
1
1
  // import { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables'
2
2
  import { isObject } from '@scalar/helpers/object/is-object';
3
3
  import { setValueAtPath } from '@scalar/helpers/object/set-value-at-path';
4
- import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref';
4
+ import { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref';
5
5
  import { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy';
6
6
  import { isObjectSchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards';
7
7
  import { getExampleFromBody } from './get-request-body-example.js';
@@ -16,13 +16,15 @@ const getMultipartEncodingContentType = (requestBody, bodyContentType, fieldName
16
16
  * by `get-form-body-rows.ts` are folded back via `foldDottedRowsToObject`.
17
17
  */
18
18
  const buildDottedNestedRowPredicate = (schema) => {
19
- const resolved = schema ? getResolvedRef(schema) : undefined;
19
+ const resolved = schema ? getResolvedRef(schema, mergeSiblingReferences) : undefined;
20
20
  if (!resolved || !isObjectSchema(resolved) || !resolved.properties) {
21
21
  return (_name, _value) => false;
22
22
  }
23
23
  const nestedTopKeys = new Set();
24
24
  for (const [key, child] of Object.entries(resolved.properties)) {
25
- const childResolved = child ? getResolvedRef(child) : undefined;
25
+ const childResolved = child
26
+ ? getResolvedRef(child, mergeSiblingReferences)
27
+ : undefined;
26
28
  if (childResolved && isObjectSchema(childResolved) && childResolved.properties) {
27
29
  nestedTopKeys.add(key);
28
30
  }
@@ -35,6 +37,75 @@ const buildDottedNestedRowPredicate = (schema) => {
35
37
  return !!head && nestedTopKeys.has(head);
36
38
  };
37
39
  };
40
+ /** Normalize a schema's `type` (string | string[] | absent) into a plain string array. */
41
+ const normalizeSchemaTypes = (schema) => {
42
+ const type = 'type' in schema ? schema.type : undefined;
43
+ return Array.isArray(type) ? [...type] : type == null ? [] : [type];
44
+ };
45
+ /**
46
+ * Walk an object schema along a dotted-row path and return the resolved leaf schema,
47
+ * or undefined when any segment is not a declared object property.
48
+ */
49
+ const resolveLeafSchema = (schema, segments) => {
50
+ let current = schema;
51
+ for (const segment of segments) {
52
+ if (!current || !isObjectSchema(current) || !current.properties) {
53
+ return undefined;
54
+ }
55
+ current = getResolvedRef(current.properties[segment], mergeSiblingReferences);
56
+ }
57
+ return current;
58
+ };
59
+ /** True when a JSON-parsed value's runtime type is allowed by the schema's declared types. */
60
+ const parsedValueMatchesSchemaType = (value, types) => {
61
+ if (value === null) {
62
+ return types.includes('null');
63
+ }
64
+ if (Array.isArray(value)) {
65
+ return types.includes('array');
66
+ }
67
+ if (typeof value === 'object') {
68
+ return types.includes('object');
69
+ }
70
+ if (typeof value === 'boolean') {
71
+ return types.includes('boolean');
72
+ }
73
+ if (typeof value === 'number') {
74
+ // A fractional value only satisfies `number`; `integer` requires a whole number so a
75
+ // string like "3.14" against an integer-only leaf stays untouched instead of being coerced.
76
+ return types.includes('number') || (types.includes('integer') && Number.isInteger(value));
77
+ }
78
+ if (typeof value === 'string') {
79
+ return types.includes('string');
80
+ }
81
+ return false;
82
+ };
83
+ /**
84
+ * The form table stringifies every value for display, so an edited nested field comes back
85
+ * as a string (`false` -> "false", `[]` -> "[]"). When the leaf schema declares a non-string
86
+ * type, parse the string back to that type so the regrouped JSON part keeps its original
87
+ * shape instead of becoming string-typed (issue #9416).
88
+ *
89
+ * Coercion is deliberately conservative: schemas that allow `string` keep the raw text, and a
90
+ * value that does not parse as its declared type is left untouched so user input is never lost.
91
+ */
92
+ const coerceLeafValueToSchemaType = (value, schema) => {
93
+ if (typeof value !== 'string' || !schema) {
94
+ return value;
95
+ }
96
+ const types = normalizeSchemaTypes(schema);
97
+ // No declared type, or a string is allowed: keep the user's text as-is.
98
+ if (types.length === 0 || types.includes('string')) {
99
+ return value;
100
+ }
101
+ try {
102
+ const parsed = JSON.parse(value);
103
+ return parsedValueMatchesSchemaType(parsed, types) ? parsed : value;
104
+ }
105
+ catch {
106
+ return value;
107
+ }
108
+ };
38
109
  /**
39
110
  * Create the fetch request body
40
111
  */
@@ -81,9 +152,10 @@ requestBodyCompositionSelection) => {
81
152
  // lazily allocate the regrouped object for its top-level key and push it into
82
153
  // `entries` at the position of the *first* matching row, then keep folding leaves
83
154
  // into the same live object reference so interleaved flat rows keep their order.
84
- const isDottedNestedRow = result.mode === 'formdata'
85
- ? buildDottedNestedRowPredicate(requestBody.content[bodyContentType]?.schema)
86
- : () => false;
155
+ const multipartSchema = result.mode === 'formdata'
156
+ ? getResolvedRef(requestBody.content[bodyContentType]?.schema, mergeSiblingReferences)
157
+ : undefined;
158
+ const isDottedNestedRow = result.mode === 'formdata' ? buildDottedNestedRowPredicate(multipartSchema) : () => false;
87
159
  const entries = [];
88
160
  const regroupedByTopKey = new Map();
89
161
  for (const row of exampleValue) {
@@ -102,7 +174,9 @@ requestBodyCompositionSelection) => {
102
174
  regroupedByTopKey.set(topKey, target);
103
175
  entries.push({ name: topKey, value: target });
104
176
  }
105
- setValueAtPath(target, segments.slice(1), row.value);
177
+ // The form table stringifies leaf values; restore the schema-declared type so the
178
+ // regrouped JSON part keeps booleans/numbers/arrays instead of string-typing them.
179
+ setValueAtPath(target, segments.slice(1), coerceLeafValueToSchemaType(row.value, resolveLeafSchema(multipartSchema, segments)));
106
180
  }
107
181
  // Loop over all entries and add them to the form
108
182
  entries.forEach(({ name, value }) => {
@@ -29,6 +29,40 @@ const deSerializeContentExample = (example, contentType) => {
29
29
  };
30
30
  /** Schema types that must become arrays/objects — serializers branch on `Array.isArray` / objects. */
31
31
  const structuredSchemaTypes = new Set(['array', 'object']);
32
+ /**
33
+ * Find the structured (`array` or `object`) type a schema represents, looking through
34
+ * `anyOf`/`oneOf`/`allOf` composition.
35
+ *
36
+ * Optional array/object parameters are commonly described as `anyOf: [{ type: 'array' }, { type: 'null' }]`
37
+ * (e.g. FastAPI/Pydantic `Optional[List[str]]`). Without unwrapping these we would treat the value as a
38
+ * plain string and send a single `id=a,b` query parameter instead of repeating `id=a&id=b`.
39
+ */
40
+ const getStructuredType = (schema) => {
41
+ const resolved = getResolvedRef(schema);
42
+ if (!resolved || typeof resolved !== 'object') {
43
+ return undefined;
44
+ }
45
+ if ('type' in resolved && resolved.type) {
46
+ const type = Array.isArray(resolved.type)
47
+ ? resolved.type.find((t) => structuredSchemaTypes.has(t))
48
+ : resolved.type;
49
+ if (type === 'array' || type === 'object') {
50
+ return type;
51
+ }
52
+ }
53
+ for (const key of ['anyOf', 'oneOf', 'allOf']) {
54
+ const subSchemas = resolved[key];
55
+ if (Array.isArray(subSchemas)) {
56
+ for (const subSchema of subSchemas) {
57
+ const type = getStructuredType(subSchema);
58
+ if (type) {
59
+ return type;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ return undefined;
65
+ };
32
66
  /**
33
67
  * Schema-based parameters from the request editor.
34
68
  *
@@ -36,10 +70,9 @@ const structuredSchemaTypes = new Set(['array', 'object']);
36
70
  * Only `array` and `object` values are parsed so OpenAPI style serialization can expand them.
37
71
  */
38
72
  const deSerializeSchemaExample = (example, schema) => {
39
- const resolvedSchema = getResolvedRef(schema);
40
- if (typeof example === 'string' && resolvedSchema && 'type' in resolvedSchema) {
41
- const type = Array.isArray(resolvedSchema.type) ? resolvedSchema.type[0] : resolvedSchema.type;
42
- if (type && structuredSchemaTypes.has(type)) {
73
+ if (typeof example === 'string') {
74
+ const type = getStructuredType(schema);
75
+ if (type) {
43
76
  try {
44
77
  return JSON.parse(example);
45
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;AAC5D,yBAAyB,0BAA0B,EAAE;AACrD,qEAAqE;AACrE,8BAA0B,KACzB,0BAA0B,EAuF5B,CAAA"}
1
+ {"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;AAC5D,yBAAyB,0BAA0B,EAAE;AACrD,qEAAqE;AACrE,8BAA0B,KACzB,0BAA0B,EA6F5B,CAAA"}
@@ -39,14 +39,19 @@ emptyTokenPlaceholder = '') => {
39
39
  // HTTP
40
40
  if (scheme.type === 'http') {
41
41
  if (scheme.scheme === 'basic') {
42
- const username = scheme['x-scalar-secret-username'];
43
- const password = scheme['x-scalar-secret-password'];
44
- const value = `${username}:${password}`;
42
+ const username = scheme['x-scalar-secret-username'] || '';
43
+ const password = scheme['x-scalar-secret-password'] || '';
44
+ // When the user has cleared both fields we must not send any credentials.
45
+ // Falling back to placeholder values here would emit `Basic username:password`,
46
+ // which some servers accept as a valid (but bogus) credential instead of returning 401.
47
+ if (username === '' && password === '') {
48
+ return null;
49
+ }
45
50
  return result.push({
46
51
  in: 'header',
47
52
  name: 'Authorization',
48
53
  // We encode the value when we build the request since we want to be able to replace the variables in the value
49
- value: value === ':' ? 'username:password' : value,
54
+ value: `${username}:${password}`,
50
55
  format: 'basic',
51
56
  });
52
57
  }