@scalar/workspace-store 0.75.0 → 0.76.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 +17 -0
- package/dist/helpers/get-resolved-security-scheme.d.ts +12 -0
- package/dist/helpers/get-resolved-security-scheme.d.ts.map +1 -0
- package/dist/helpers/get-resolved-security-scheme.js +24 -0
- package/dist/helpers/resolve-security-requirements.js +2 -2
- package/dist/request-example/builder/body/aspnet-form-fields.d.ts +26 -0
- package/dist/request-example/builder/body/aspnet-form-fields.d.ts.map +1 -0
- package/dist/request-example/builder/body/aspnet-form-fields.js +179 -0
- package/dist/request-example/builder/body/build-multipart.d.ts.map +1 -1
- package/dist/request-example/builder/body/build-multipart.js +9 -5
- package/dist/request-example/builder/body/build-request-body.d.ts +5 -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 +38 -8
- package/dist/request-example/builder/request-factory.d.ts +3 -1
- package/dist/request-example/builder/request-factory.d.ts.map +1 -1
- package/dist/request-example/builder/request-factory.js +4 -2
- package/dist/request-example/index.d.ts +1 -0
- package/dist/request-example/index.d.ts.map +1 -1
- package/dist/request-example/index.js +1 -0
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @scalar/workspace-store
|
|
2
2
|
|
|
3
|
+
## 0.76.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#11137](https://github.com/scalar/scalar/pull/11137): Add an opt-in ASP.NET Core form naming mode through the API Reference configuration option `multipartNaming: "indexed-dot"`. The body editor, sent requests, and code samples use indexed dotted names such as `Certificates[0].name` for nested fields in multipart and URL-encoded request bodies.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#11146](https://github.com/scalar/scalar/pull/11146): Update compatible npm dependencies for AI chat, encoding, analytics, date handling, HTTP serving, and application query caching.
|
|
12
|
+
- [#11147](https://github.com/scalar/scalar/pull/11147): Honor OpenAPI 3.2 `dataValue` and `serializedValue` examples for multipart part headers. Serialize structured header values using simple style and preserve explicit falsy examples and serialized text.
|
|
13
|
+
Use schema fallbacks for null examples and omit the header when no value is available.
|
|
14
|
+
- [#11148](https://github.com/scalar/scalar/pull/11148): Resolve URI security requirements in Node Markdown exports for OpenAPI 3.2 descriptions.
|
|
15
|
+
|
|
16
|
+
Follow annotated security scheme references when resolving URI requirements.
|
|
17
|
+
|
|
18
|
+
Preserve security scheme reference descriptions in OpenAPI 3.1 and 3.2 Markdown exports.
|
|
19
|
+
|
|
3
20
|
## 0.75.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NodeInput } from './get-resolved-ref.js';
|
|
2
|
+
/**
|
|
3
|
+
* Follow Security Scheme Reference Objects through annotated aliases. Unlike schema
|
|
4
|
+
* references, these do not establish new resources, so annotations do not stop resolution.
|
|
5
|
+
* The nearest description overrides the target without mutating shared schemes. Callers
|
|
6
|
+
* handling OpenAPI 3.0 must disable overrides because that version ignores reference siblings.
|
|
7
|
+
* Missing targets and cycles stay unresolved instead of becoming empty auth schemes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getResolvedSecurityScheme: <Node>(node: NodeInput<Node>, { overrideDescription }?: {
|
|
10
|
+
overrideDescription?: boolean;
|
|
11
|
+
}) => Node | undefined;
|
|
12
|
+
//# sourceMappingURL=get-resolved-security-scheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-resolved-security-scheme.d.ts","sourceRoot":"","sources":["../../src/helpers/get-resolved-security-scheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,IAAI,QACtC,SAAS,CAAC,IAAI,CAAC,4BACW;IAAE,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAE,KAChE,IAAI,GAAG,SAeT,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isObject } from '@scalar/helpers/object/is-object';
|
|
2
|
+
/**
|
|
3
|
+
* Follow Security Scheme Reference Objects through annotated aliases. Unlike schema
|
|
4
|
+
* references, these do not establish new resources, so annotations do not stop resolution.
|
|
5
|
+
* The nearest description overrides the target without mutating shared schemes. Callers
|
|
6
|
+
* handling OpenAPI 3.0 must disable overrides because that version ignores reference siblings.
|
|
7
|
+
* Missing targets and cycles stay unresolved instead of becoming empty auth schemes.
|
|
8
|
+
*/
|
|
9
|
+
export const getResolvedSecurityScheme = (node, { overrideDescription = true } = {}) => {
|
|
10
|
+
const seen = new Set();
|
|
11
|
+
let current = node;
|
|
12
|
+
let description;
|
|
13
|
+
while (isObject(current) && typeof current.$ref === 'string') {
|
|
14
|
+
if (seen.has(current)) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
seen.add(current);
|
|
18
|
+
if (overrideDescription && description === undefined && typeof current.description === 'string') {
|
|
19
|
+
description = current.description;
|
|
20
|
+
}
|
|
21
|
+
current = current['$ref-value'];
|
|
22
|
+
}
|
|
23
|
+
return (isObject(current) && description !== undefined ? { ...current, description } : current);
|
|
24
|
+
};
|
|
@@ -6,7 +6,7 @@ import { bundle, resolveReferencePath } from '@scalar/json-magic/bundle';
|
|
|
6
6
|
import { createMagicProxy } from '@scalar/json-magic/magic-proxy';
|
|
7
7
|
import { Value } from '@scalar/typebox/value';
|
|
8
8
|
import { generateUniqueValue } from './generate-unique-value.js';
|
|
9
|
-
import {
|
|
9
|
+
import { getResolvedSecurityScheme } from './get-resolved-security-scheme.js';
|
|
10
10
|
import { normalizeAuthSchemes } from '../plugins/bundler/index.js';
|
|
11
11
|
import { resolveOpenApiDocument } from '../plugins/bundler/openapi-document.js';
|
|
12
12
|
import { SecuritySchemeObjectSchema } from '../schemas/v3.2/strict/openapi-document.js';
|
|
@@ -101,7 +101,7 @@ export const resolveSecurityRequirements = async (document, { origin = '/', load
|
|
|
101
101
|
const proxy = createMagicProxy({ ...document, 'x-scalar-security-uri-target': reference }, {
|
|
102
102
|
documentUri: resolveOpenApiDocument(document, origin)?.baseUri,
|
|
103
103
|
});
|
|
104
|
-
const target =
|
|
104
|
+
const target = getResolvedSecurityScheme(proxy['x-scalar-security-uri-target']);
|
|
105
105
|
// The strict runtime schema requires refreshUrl, while authored OAuth flows may omit it.
|
|
106
106
|
const validationTarget = isObject(target) && target.type === 'oauth2' && isObject(target.flows)
|
|
107
107
|
? {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MultipartNaming } from '@scalar/types/api-reference';
|
|
2
|
+
import type { MediaTypeObject, SchemaObject } from '../../../schemas/v3.2/strict/openapi-document.js';
|
|
3
|
+
/** ASP.NET Core binds named form fields. Ordered and nested MIME bodies use their own encodings. */
|
|
4
|
+
export declare const usesAspNetFormNaming: (contentType: string, media: MediaTypeObject | undefined, multipartNaming?: MultipartNaming) => boolean;
|
|
5
|
+
type FormField = {
|
|
6
|
+
name: string;
|
|
7
|
+
/** Encoding entries use the original property name, before indexed-dot flattening. */
|
|
8
|
+
rootName: string;
|
|
9
|
+
value: unknown;
|
|
10
|
+
schema: SchemaObject | undefined;
|
|
11
|
+
isRequired: boolean;
|
|
12
|
+
isDisabled: boolean;
|
|
13
|
+
isDisabledByDefault?: boolean;
|
|
14
|
+
isArray?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/** Map a structured example or saved editor rows to the field names understood by ASP.NET Core. */
|
|
17
|
+
export declare const getAspNetFormFields: (value: unknown, schema: SchemaObject | undefined, compositionSelection?: Record<string, number>, includeMissing?: boolean) => FormField[];
|
|
18
|
+
/** Add explicit indices for sparse collections so MVC binds items beyond the first gap. */
|
|
19
|
+
export declare const getAspNetFormIndexFields: (names: string[]) => {
|
|
20
|
+
key: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}[];
|
|
23
|
+
/** Include file upload examples when generating snippets for schema-backed multipart fields. */
|
|
24
|
+
export declare const withAspNetMultipartFilePlaceholder: (field: FormField, includeMissing: boolean, contentType?: string) => FormField;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=aspnet-form-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aspnet-form-fields.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/aspnet-form-fields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAKlE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAO3F,oGAAoG;AACpG,eAAO,MAAM,oBAAoB,gBAClB,MAAM,SACZ,eAAe,GAAG,SAAS,oBAChB,eAAe,KAChC,OAI0C,CAAA;AAE7C,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,sFAAsF;IACtF,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,YAAY,GAAG,SAAS,CAAA;IAChC,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAwCD,mGAAmG;AACnG,eAAO,MAAM,mBAAmB,UACvB,OAAO,UACN,YAAY,GAAG,SAAS,yBACT,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,+BAE5C,SAAS,EAgHX,CAAA;AAED,2FAA2F;AAC3F,eAAO,MAAM,wBAAwB,UAAW,MAAM,EAAE,KAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAuBxF,CAAA;AAED,gGAAgG;AAChG,eAAO,MAAM,kCAAkC,UACtC,SAAS,kBACA,OAAO,gBACT,MAAM,KACnB,SAcF,CAAA"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { isObject } from '@scalar/helpers/object/is-object';
|
|
2
|
+
import { isFileSchema } from '../../../helpers/is-file-schema.js';
|
|
3
|
+
import { resolveFormSchema } from '../../../helpers/resolve-form-schema.js';
|
|
4
|
+
import { unpackProxyShallow } from '../../../helpers/unpack-proxy.js';
|
|
5
|
+
import { isArraySchema, isObjectSchema } from '../../../schemas/v3.2/strict/type-guards.js';
|
|
6
|
+
import { needsMultipartEncoding } from './build-multipart.js';
|
|
7
|
+
import { coerceLeafValueToSchemaType } from './schema-value-coercion.js';
|
|
8
|
+
/** ASP.NET Core binds named form fields. Ordered and nested MIME bodies use their own encodings. */
|
|
9
|
+
export const usesAspNetFormNaming = (contentType, media, multipartNaming) => multipartNaming === 'indexed-dot' &&
|
|
10
|
+
(contentType === 'multipart/form-data' || contentType === 'application/x-www-form-urlencoded') &&
|
|
11
|
+
media !== undefined &&
|
|
12
|
+
!needsMultipartEncoding(contentType, media);
|
|
13
|
+
const getProperty = (schema, name) => schema && 'properties' in schema && schema.properties && Object.hasOwn(schema.properties, name)
|
|
14
|
+
? schema.properties[name]
|
|
15
|
+
: undefined;
|
|
16
|
+
const getItem = (schema, index) => {
|
|
17
|
+
if (!schema || !isArraySchema(schema)) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const item = schema.prefixItems?.[index] ?? schema.items;
|
|
21
|
+
return typeof item === 'object' ? item : undefined;
|
|
22
|
+
};
|
|
23
|
+
const isRequiredProperty = (schema, key) => Boolean(schema && 'required' in schema && schema.required?.includes(key));
|
|
24
|
+
const resolveField = (schema, name, compositionSelection) => {
|
|
25
|
+
const segments = getProperty(schema, name) === undefined ? name.split(/\.|\[(\d+)\]/).filter(Boolean) : [name];
|
|
26
|
+
let current = schema;
|
|
27
|
+
let isRequired = segments.length > 0;
|
|
28
|
+
const path = ['requestBody'];
|
|
29
|
+
for (const segment of segments) {
|
|
30
|
+
if (current && isArraySchema(current) && /^\d+$/.test(segment)) {
|
|
31
|
+
path.push('items');
|
|
32
|
+
current = resolveFormSchema(getItem(current, Number(segment)), compositionSelection, path);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
path.push(segment);
|
|
36
|
+
isRequired = isRequired && isRequiredProperty(current, segment);
|
|
37
|
+
current = resolveFormSchema(getProperty(current, segment), compositionSelection, path);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { schema: current, isRequired, rootName: segments[0] ?? name };
|
|
41
|
+
};
|
|
42
|
+
/** Map a structured example or saved editor rows to the field names understood by ASP.NET Core. */
|
|
43
|
+
export const getAspNetFormFields = (value, schema, compositionSelection, includeMissing = false) => {
|
|
44
|
+
const fields = [];
|
|
45
|
+
const ancestors = new Set();
|
|
46
|
+
const visit = (field, inputSchema, schemaPath) => {
|
|
47
|
+
const { name, value, schema } = field;
|
|
48
|
+
// Schema placeholders can reach recursive references even when the example is finite.
|
|
49
|
+
const missingValueSchema = value === undefined ? inputSchema : undefined;
|
|
50
|
+
const source = isObject(value) || Array.isArray(value) ? value : missingValueSchema;
|
|
51
|
+
const identity = source && unpackProxyShallow(source);
|
|
52
|
+
if (identity && ancestors.has(identity)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (identity) {
|
|
56
|
+
ancestors.add(identity);
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
if (Array.isArray(value) || (includeMissing && value === undefined)) {
|
|
60
|
+
const entries = Array.isArray(value) ? value : [];
|
|
61
|
+
const itemPath = [...schemaPath, 'items'];
|
|
62
|
+
const item = resolveFormSchema(getItem(schema, 0), compositionSelection, itemPath);
|
|
63
|
+
if (entries.some((entry) => isObject(entry) || Array.isArray(entry)) ||
|
|
64
|
+
(item && (isObjectSchema(item) || isArraySchema(item)))) {
|
|
65
|
+
const canAddItem = schema && isArraySchema(schema) && schema.maxItems !== 0;
|
|
66
|
+
const items = entries.length || !includeMissing || !canAddItem ? entries : [undefined];
|
|
67
|
+
items.forEach((entry, index) => {
|
|
68
|
+
const itemInput = getItem(schema, index);
|
|
69
|
+
visit({
|
|
70
|
+
...field,
|
|
71
|
+
name: `${name}[${index}]`,
|
|
72
|
+
value: entry,
|
|
73
|
+
schema: resolveFormSchema(itemInput, compositionSelection, itemPath),
|
|
74
|
+
isArray: undefined,
|
|
75
|
+
}, itemInput, itemPath);
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const data = isObject(value) ? value : undefined;
|
|
81
|
+
const properties = schema && 'properties' in schema ? schema.properties : undefined;
|
|
82
|
+
if (data || (includeMissing && value === undefined && properties)) {
|
|
83
|
+
const names = new Set([...Object.keys(properties ?? {}), ...Object.keys(data ?? {})]);
|
|
84
|
+
for (const key of names) {
|
|
85
|
+
const childInput = getProperty(schema, key);
|
|
86
|
+
const path = [...schemaPath, key];
|
|
87
|
+
const childSchema = resolveFormSchema(childInput, compositionSelection, path);
|
|
88
|
+
const childValue = data && Object.hasOwn(data, key) ? data[key] : undefined;
|
|
89
|
+
if (childValue === undefined && (!includeMissing || childSchema?.readOnly)) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const isRequired = isRequiredProperty(schema, key);
|
|
93
|
+
const optionalRoot = !name && childInput !== undefined && !isRequired && !schema?.allOf && !schema?.oneOf && !schema?.anyOf;
|
|
94
|
+
visit({
|
|
95
|
+
name: name ? `${name}.${key}` : key,
|
|
96
|
+
rootName: name ? field.rootName : key,
|
|
97
|
+
value: childValue,
|
|
98
|
+
schema: childSchema,
|
|
99
|
+
isRequired: field.isRequired && isRequired,
|
|
100
|
+
isDisabled: field.isDisabled || optionalRoot,
|
|
101
|
+
isDisabledByDefault: field.isDisabledByDefault || optionalRoot || undefined,
|
|
102
|
+
}, childInput, path);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (name) {
|
|
107
|
+
fields.push(field);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
if (identity) {
|
|
112
|
+
ancestors.delete(identity);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
if (Array.isArray(value)) {
|
|
117
|
+
for (const row of value) {
|
|
118
|
+
if (!isObject(row) || typeof row.name !== 'string') {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const field = resolveField(schema, row.name, compositionSelection);
|
|
122
|
+
// Older form rows store structured values as JSON text. Keep scalar input verbatim.
|
|
123
|
+
const restored = coerceLeafValueToSchemaType(row.value, row.isArray === true ? { type: 'array' } : field.schema);
|
|
124
|
+
visit({
|
|
125
|
+
name: row.name,
|
|
126
|
+
value: Array.isArray(restored) || isObject(restored) ? restored : row.value,
|
|
127
|
+
...field,
|
|
128
|
+
isDisabled: row.isDisabled === true,
|
|
129
|
+
isDisabledByDefault: row.isDisabledByDefault === true || undefined,
|
|
130
|
+
isArray: row.isArray === true || undefined,
|
|
131
|
+
}, field.schema, ['requestBody', row.name]);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
visit({ name: '', rootName: '', value, schema, isRequired: true, isDisabled: false }, schema, ['requestBody']);
|
|
136
|
+
}
|
|
137
|
+
return fields;
|
|
138
|
+
};
|
|
139
|
+
/** Add explicit indices for sparse collections so MVC binds items beyond the first gap. */
|
|
140
|
+
export const getAspNetFormIndexFields = (names) => {
|
|
141
|
+
const explicitNames = new Set(names.map((name) => name.toLowerCase()));
|
|
142
|
+
const collections = new Map();
|
|
143
|
+
for (const name of names) {
|
|
144
|
+
for (const match of name.matchAll(/\[(\d+)\](?=\.|\[|$)/g)) {
|
|
145
|
+
const index = match[1];
|
|
146
|
+
if (index === undefined || match.index === 0) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const key = `${name.slice(0, match.index)}.index`;
|
|
150
|
+
const normalized = key.toLowerCase();
|
|
151
|
+
if (explicitNames.has(normalized)) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const collection = collections.get(normalized) ?? { key, indices: new Set() };
|
|
155
|
+
collection.indices.add(index);
|
|
156
|
+
collections.set(normalized, collection);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return [...collections.values()].flatMap(({ key, indices }) => {
|
|
160
|
+
const values = [...indices];
|
|
161
|
+
return values.every((_, index) => indices.has(String(index))) ? [] : values.map((value) => ({ key, value }));
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
/** Include file upload examples when generating snippets for schema-backed multipart fields. */
|
|
165
|
+
export const withAspNetMultipartFilePlaceholder = (field, includeMissing, contentType) => {
|
|
166
|
+
if (!field.schema || !isFileSchema(field.schema, false, contentType)) {
|
|
167
|
+
return field;
|
|
168
|
+
}
|
|
169
|
+
const toFile = (value) => {
|
|
170
|
+
if (typeof value === 'string' && value.startsWith('@') && value.length > 1) {
|
|
171
|
+
return new File([], value.slice(1), { lastModified: 0 });
|
|
172
|
+
}
|
|
173
|
+
if (includeMissing && (value === undefined || value === null || value === '')) {
|
|
174
|
+
return new File([], 'filename', { lastModified: 0 });
|
|
175
|
+
}
|
|
176
|
+
return value;
|
|
177
|
+
};
|
|
178
|
+
return { ...field, value: Array.isArray(field.value) ? field.value.map(toFile) : toFile(field.value) };
|
|
179
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-multipart.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-multipart.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-multipart.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-multipart.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAWrE,sGAAsG;AACtG,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC,GAAG,CACA;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CACrE,CAAA;AAED,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,gBAAiB,MAAM,SAAS,eAAe,KAAG,OASnF,CAAA;AAED,4EAA4E;AAC5E,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,SAAS,eAAe,KAAG,OASpF,CAAA;AA4CD,sFAAsF;AACtF,eAAO,MAAM,sBAAsB,WACzB,YAAY,GAAG,SAAS,SACzB,MAAM,eACA,eAAe,CAAC,YAAY,CAAC,KACzC,YAAY,GAAG,SAMa,CAAA;AAc/B,6FAA6F;AAC7F,eAAO,MAAM,cAAc,UAClB,OAAO,eACD,MAAM,aACT,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,gBAAgB,GAAG,cAAc,GAAG,YAAY,CAAC,WACrF,YAAY,uBAEpB,aAAa,EAqIf,CAAA"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { isDefined } from '@scalar/helpers/array/is-defined';
|
|
1
2
|
import { parseMimeType } from '@scalar/helpers/http/mime-type';
|
|
2
3
|
import { isObject } from '@scalar/helpers/object/is-object';
|
|
3
4
|
import { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref';
|
|
4
5
|
import { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy';
|
|
5
6
|
import { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards';
|
|
7
|
+
import { getExampleValue } from '../../../helpers/get-example-value.js';
|
|
6
8
|
import { serializeXmlPart } from '../../xml/serialize-xml-part.js';
|
|
9
|
+
import { serializeSimpleStyle } from '../header/serialize-parameter.js';
|
|
7
10
|
import { MAX_MULTIPART_NESTING } from './multipart-limits.js';
|
|
8
11
|
import { resolveLeafSchema } from './schema-value-coercion.js';
|
|
9
12
|
import { hasEncodingStyle, serializeFormPropertyWithEncoding } from './serialize-form-property.js';
|
|
@@ -125,12 +128,13 @@ export const buildMultipart = (value, contentType, encoding = {}, schema, nestin
|
|
|
125
128
|
if (!header || !('schema' in header)) {
|
|
126
129
|
return [];
|
|
127
130
|
}
|
|
131
|
+
const example = getExampleValue(isDefined(header.example) ? { value: header.example } : Object.values(header.examples ?? {})[0]);
|
|
132
|
+
if (example?.source === 'serialized') {
|
|
133
|
+
return [[name, example.value]];
|
|
134
|
+
}
|
|
128
135
|
const headerSchema = getResolvedRef(header.schema);
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
headerSchema?.const ??
|
|
132
|
-
headerSchema?.default;
|
|
133
|
-
return example === undefined ? [] : [[name, String(example)]];
|
|
136
|
+
const value = example?.value ?? headerSchema?.const ?? headerSchema?.default;
|
|
137
|
+
return isDefined(value) ? [[name, String(serializeSimpleStyle(value, header.explode ?? false))]] : [];
|
|
134
138
|
}));
|
|
135
139
|
if (partSchema?.contentEncoding &&
|
|
136
140
|
!Object.keys(headers).some((name) => name.toLowerCase() === 'content-transfer-encoding')) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MultipartNaming } from '@scalar/types/api-reference';
|
|
1
2
|
import type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.2/strict/request-body';
|
|
2
3
|
import { type MultipartPart } from './build-multipart.js';
|
|
3
4
|
type FormData = {
|
|
@@ -43,6 +44,9 @@ export declare const buildRequestBody: (requestBody: RequestBodyObject | undefin
|
|
|
43
44
|
/** The key of the current example */
|
|
44
45
|
exampleName?: string,
|
|
45
46
|
/** Selected anyOf/oneOf request-body variants keyed by schema path */
|
|
46
|
-
requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string, jsonSchemaDialect?: string
|
|
47
|
+
requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string, jsonSchemaDialect?: string, options?: {
|
|
48
|
+
multipartNaming?: MultipartNaming;
|
|
49
|
+
aspNetFilePlaceholders?: boolean;
|
|
50
|
+
}) => RequestBody | null;
|
|
47
51
|
export {};
|
|
48
52
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAGlE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAajG,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,gBACd,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;;AAErC,sEAAsE;kCACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,sBACH,MAAM,YAChB;IAAE,eAAe,CAAC,EAAE,eAAe,CAAC;IAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAE,KAChF,WAAW,GAAG,IA+ZhB,CAAA"}
|
|
@@ -6,6 +6,8 @@ import { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'
|
|
|
6
6
|
import { isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards';
|
|
7
7
|
import { getExampleValue, getExplicitExampleText } from '../../../helpers/get-example-value.js';
|
|
8
8
|
import { resolveFormSchema } from '../../../helpers/resolve-form-schema.js';
|
|
9
|
+
import { getExample } from '../helpers/get-example.js';
|
|
10
|
+
import { getAspNetFormFields, getAspNetFormIndexFields, usesAspNetFormNaming, withAspNetMultipartFilePlaceholder, } from './aspnet-form-fields.js';
|
|
9
11
|
import { buildMultipart, getMultipartItemSchema, isPositionalMultipart, needsMultipartEncoding, } from './build-multipart.js';
|
|
10
12
|
import { getExampleFromBody } from './get-request-body-example.js';
|
|
11
13
|
import { getSelectedBodyContentType } from './get-selected-body-content-type.js';
|
|
@@ -67,7 +69,7 @@ export const buildRequestBody = (requestBody,
|
|
|
67
69
|
/** The key of the current example */
|
|
68
70
|
exampleName = 'default',
|
|
69
71
|
/** Selected anyOf/oneOf request-body variants keyed by schema path */
|
|
70
|
-
requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
|
|
72
|
+
requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect, options) => {
|
|
71
73
|
if (!requestBody) {
|
|
72
74
|
return null;
|
|
73
75
|
}
|
|
@@ -102,6 +104,7 @@ requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
|
|
|
102
104
|
// (`toString`, `constructor`, …) is not misread as declared-and-optional and dropped.
|
|
103
105
|
const isOptionalBodyProperty = (key) => Boolean(bodyProperties && Object.hasOwn(bodyProperties, key) && !requiredBodyProperties.has(key));
|
|
104
106
|
const media = requestBody.content[bodyContentType];
|
|
107
|
+
const aspNetNaming = usesAspNetFormNaming(bodyContentType, media, options?.multipartNaming);
|
|
105
108
|
if (media && needsMultipartEncoding(bodyContentType, media)) {
|
|
106
109
|
// Raw editors store JSON text, while form editors store named rows.
|
|
107
110
|
const value = (() => {
|
|
@@ -146,11 +149,34 @@ requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
|
|
|
146
149
|
value: multipartParts,
|
|
147
150
|
};
|
|
148
151
|
}
|
|
149
|
-
|
|
152
|
+
const formRows = (() => {
|
|
153
|
+
if (!aspNetNaming || (!isObject(example.value) && !Array.isArray(example.value))) {
|
|
154
|
+
return example.value;
|
|
155
|
+
}
|
|
156
|
+
const includeMissing = options?.aspNetFilePlaceholders === true &&
|
|
157
|
+
!getExampleValue(getExample(requestBody, exampleName, bodyContentType));
|
|
158
|
+
const fields = getAspNetFormFields(example.value, resolvedBodySchema, requestBodyCompositionSelection, includeMissing);
|
|
159
|
+
return options?.aspNetFilePlaceholders
|
|
160
|
+
? fields.map((field) => withAspNetMultipartFilePlaceholder(field, includeMissing, media?.encoding?.[field.rootName]?.contentType))
|
|
161
|
+
: fields;
|
|
162
|
+
})();
|
|
163
|
+
if (aspNetNaming && bodyContentType === 'application/x-www-form-urlencoded' && Array.isArray(formRows)) {
|
|
164
|
+
const value = formRows
|
|
165
|
+
.filter((field) => !field.isDisabled && field.name)
|
|
166
|
+
.flatMap((field) => {
|
|
167
|
+
const encoded = serializeFormPropertyWithEncoding(field.name, field.value, media?.encoding?.[field.rootName]);
|
|
168
|
+
const values = Array.isArray(field.value) ? field.value : [field.value];
|
|
169
|
+
return (encoded ??
|
|
170
|
+
values
|
|
171
|
+
.filter((value) => value !== undefined && value !== null)
|
|
172
|
+
.map((value) => ({ key: field.name, value: String(value) })));
|
|
173
|
+
});
|
|
174
|
+
return { mode: 'urlencoded', value: [...value, ...getAspNetFormIndexFields(value.map(({ key }) => key))] };
|
|
175
|
+
}
|
|
176
|
+
// Form data - array format (from UI editor or flattened for ASP.NET Core)
|
|
150
177
|
if ((bodyContentType === 'multipart/form-data' || bodyContentType === 'application/x-www-form-urlencoded') &&
|
|
151
|
-
Array.isArray(
|
|
152
|
-
const
|
|
153
|
-
const exampleValue = value.filter((item) => !item.isDisabled);
|
|
178
|
+
Array.isArray(formRows)) {
|
|
179
|
+
const exampleValue = formRows.filter((item) => !item.isDisabled);
|
|
154
180
|
const result = bodyContentType === 'multipart/form-data'
|
|
155
181
|
? {
|
|
156
182
|
mode: 'formdata',
|
|
@@ -172,13 +198,13 @@ requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
|
|
|
172
198
|
// `entries` at the position of the *first* matching row, then keep folding leaves
|
|
173
199
|
// into the same live object reference so interleaved flat rows keep their order.
|
|
174
200
|
const multipartSchema = result.mode === 'formdata' ? resolvedBodySchema : undefined;
|
|
175
|
-
const entries = result.mode === 'formdata' ? regroupMultipartRows(exampleValue, multipartSchema) : exampleValue;
|
|
201
|
+
const entries = result.mode === 'formdata' && !aspNetNaming ? regroupMultipartRows(exampleValue, multipartSchema) : exampleValue;
|
|
176
202
|
// Loop over all entries and add them to the form
|
|
177
|
-
entries.forEach(({ name, value }) => {
|
|
203
|
+
entries.forEach(({ name, value, rootName }) => {
|
|
178
204
|
if (!name) {
|
|
179
205
|
return;
|
|
180
206
|
}
|
|
181
|
-
const partEncoding =
|
|
207
|
+
const partEncoding = media?.encoding?.[aspNetNaming ? (rootName ?? name) : name];
|
|
182
208
|
if (result.mode === 'formdata') {
|
|
183
209
|
// Older saved form rows store JSON text. Only restore arrays declared by the schema.
|
|
184
210
|
const schema = resolveLeafSchema(multipartSchema, [name]);
|
|
@@ -239,6 +265,10 @@ requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
|
|
|
239
265
|
}
|
|
240
266
|
return;
|
|
241
267
|
});
|
|
268
|
+
if (aspNetNaming && result.mode === 'formdata') {
|
|
269
|
+
const indices = getAspNetFormIndexFields(result.value.map(({ key }) => key));
|
|
270
|
+
result.value.push(...indices.map(({ key, value }) => ({ type: 'text', key, value })));
|
|
271
|
+
}
|
|
242
272
|
return result;
|
|
243
273
|
}
|
|
244
274
|
// Form data - object format (from schema examples)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MultipartNaming } from '@scalar/types/api-reference';
|
|
1
2
|
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
2
3
|
import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
3
4
|
import type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
@@ -187,7 +188,7 @@ export type RequestFactory = {
|
|
|
187
188
|
* Builds a request object fastory which can be used to build a request object.
|
|
188
189
|
* @returns A request object factory
|
|
189
190
|
*/
|
|
190
|
-
export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, }: RequestExampleMeta & {
|
|
191
|
+
export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, multipartNaming, }: RequestExampleMeta & {
|
|
191
192
|
/** The operation object */
|
|
192
193
|
operation: OperationObject;
|
|
193
194
|
/** For environment variables in the inputs */
|
|
@@ -210,6 +211,7 @@ export declare const requestFactory: ({ exampleName, globalCookies, method, oper
|
|
|
210
211
|
/** Document default for schema resources without $schema. */
|
|
211
212
|
jsonSchemaDialect?: string;
|
|
212
213
|
requestBodyCompositionSelection?: Record<string, number>;
|
|
214
|
+
multipartNaming?: MultipartNaming;
|
|
213
215
|
}) => {
|
|
214
216
|
request: RequestFactory;
|
|
215
217
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAE5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,2DAA2D,CAAA;AAClE,OAA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AGG;IACH,8BAA8B,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAE5C;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;QACf;;;WAGG;QACH,UAAU,EAAE,OAAO,CAAA;QACnB;;;WAGG;QACH,eAAe,EAAE,OAAO,CAAA;KACzB,CAAC,CAAA;CACH,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,yNAexB,kBAAkB,GAAG;IACtB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,8DAA8D;IAC9D,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,sEAAsE;IACtE,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC,KAAG;IACF,OAAO,EAAE,cAAc,CAAA;CAkFxB,CAAA"}
|
|
@@ -12,7 +12,7 @@ import { buildRequestParameters } from './header/build-request-parameters.js';
|
|
|
12
12
|
* Builds a request object fastory which can be used to build a request object.
|
|
13
13
|
* @returns A request object factory
|
|
14
14
|
*/
|
|
15
|
-
export const requestFactory = ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, }) => {
|
|
15
|
+
export const requestFactory = ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, multipartNaming, }) => {
|
|
16
16
|
const requestBody = getResolvedRef(operation.requestBody);
|
|
17
17
|
/** Build out the request parameters */
|
|
18
18
|
const params = buildRequestParameters(operation.parameters ?? [], exampleName, openapiVersion);
|
|
@@ -29,7 +29,9 @@ export const requestFactory = ({ exampleName, globalCookies, method, operation,
|
|
|
29
29
|
});
|
|
30
30
|
// If the method can have a body, build the request body, otherwise set it to null
|
|
31
31
|
const body = canMethodHaveBody(method)
|
|
32
|
-
? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect
|
|
32
|
+
? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect, {
|
|
33
|
+
multipartNaming,
|
|
34
|
+
})
|
|
33
35
|
: null;
|
|
34
36
|
// Delete the Content-Type header so the browser will set it automatically based on the request body
|
|
35
37
|
if (body?.mode === 'formdata' || body?.mode === 'urlencoded') {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { ApiKeyObjectSecret, BuildRequestData, BuildRequestFailureCode, BuildRequestResult, EncryptionObjectSecret, GssapiObjectSecret, HttpObjectSecret, OAuth2ObjectSecret, OAuthFlowAuthorizationCodeSecret, OAuthFlowClientCredentialsSecret, OAuthFlowDeviceAuthorizationSecret, OAuthFlowImplicitSecret, OAuthFlowPasswordSecret, OAuthFlowsObjectSecret, OpenIdConnectObjectSecret, RequestPayload, ResolveRequestFactoryUrlError, ResolveRequestFactoryUrlResult, SaslObjectSecret, SecuritySchemeObjectSecret, X509ObjectSecret, } from './builder/index.js';
|
|
2
2
|
export { BUILD_REQUEST_FAILED, INVALID_REQUEST_FACTORY_URL, MISSING_REQUEST_SERVER_BASE, type RequestFactory, type SerializedFormProperty, buildDottedNestedRowPredicate, buildRequest, buildRequestSecurity, coerceLeafValueToSchemaType, coerceUntypedValue, deSerializeParameter, deSerializeSchemaValue, filterDisabledProperties, filterGlobalCookie, getEnvironmentVariables, getExample, getExampleFromBody, getExampleFromSchema, getResolvedUrl, getSchemaExampleFromBody, getSelectedBodyContentType, getServerVariables, isEncryptionSchemeType, isParamDisabled, isSaslSchemeType, requestFactory, resolveExecutableRequestUrl, resolveLeafSchema, resolveRequestFactoryUrl, serializeContentValue, serializeCookieStyle, serializeDeepObjectStyle, serializeFormPropertyWithEncoding, serializeFormStyle, serializeFormStyleForCookies, serializeMultipartArray, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './builder/index.js';
|
|
3
|
+
export { getAspNetFormFields, usesAspNetFormNaming, } from './builder/body/aspnet-form-fields.js';
|
|
3
4
|
export { getMultipartItemSchema, needsMultipartEncoding } from './builder/body/build-multipart.js';
|
|
4
5
|
export { buildRequestBody } from './builder/body/build-request-body.js';
|
|
5
6
|
export { serializeMultipartBody } from './builder/body/encode-multipart-body.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,6BAA6B,EAC7B,YAAY,EACZ,oB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BAA8B,EAAE,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,6BAA6B,EAC7B,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,2BAA2B,EAC3B,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,oB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AAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BUILD_REQUEST_FAILED, INVALID_REQUEST_FACTORY_URL, MISSING_REQUEST_SERVER_BASE, buildDottedNestedRowPredicate, buildRequest, buildRequestSecurity, coerceLeafValueToSchemaType, coerceUntypedValue, deSerializeParameter, deSerializeSchemaValue, filterDisabledProperties, filterGlobalCookie, getEnvironmentVariables, getExample, getExampleFromBody, getExampleFromSchema, getResolvedUrl, getSchemaExampleFromBody, getSelectedBodyContentType, getServerVariables, isEncryptionSchemeType, isParamDisabled, isSaslSchemeType, requestFactory, resolveExecutableRequestUrl, resolveLeafSchema, resolveRequestFactoryUrl, serializeContentValue, serializeCookieStyle, serializeDeepObjectStyle, serializeFormPropertyWithEncoding, serializeFormStyle, serializeFormStyleForCookies, serializeMultipartArray, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './builder/index.js';
|
|
2
|
+
export { getAspNetFormFields, usesAspNetFormNaming, } from './builder/body/aspnet-form-fields.js';
|
|
2
3
|
export { getMultipartItemSchema, needsMultipartEncoding } from './builder/body/build-multipart.js';
|
|
3
4
|
export { buildRequestBody } from './builder/body/build-request-body.js';
|
|
4
5
|
export { serializeMultipartBody } from './builder/body/encode-multipart-body.js';
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"openapi",
|
|
17
17
|
"scalar"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.76.0",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=22.19.0"
|
|
22
22
|
},
|
|
@@ -155,26 +155,27 @@
|
|
|
155
155
|
"dependencies": {
|
|
156
156
|
"@scalar/asyncapi-upgrader": "0.1.23",
|
|
157
157
|
"@scalar/helpers": "0.19.0",
|
|
158
|
-
"@scalar/json-magic": "0.
|
|
158
|
+
"@scalar/json-magic": "0.22.0",
|
|
159
159
|
"@scalar/openapi-upgrader": "0.5.1",
|
|
160
|
-
"@scalar/schemas": "0.
|
|
161
|
-
"@scalar/snippetz": "0.10.
|
|
160
|
+
"@scalar/schemas": "0.20.0",
|
|
161
|
+
"@scalar/snippetz": "0.10.22",
|
|
162
162
|
"@scalar/typebox": "0.1.4",
|
|
163
|
-
"@scalar/types": "0.
|
|
163
|
+
"@scalar/types": "0.32.0",
|
|
164
164
|
"@scalar/validation": "0.6.9",
|
|
165
|
-
"js-base64": "^3.9.
|
|
165
|
+
"js-base64": "^3.9.7",
|
|
166
166
|
"type-fest": "^5.10.0",
|
|
167
167
|
"vue": "^3.5.45",
|
|
168
168
|
"yaml": "^2.9.1"
|
|
169
169
|
},
|
|
170
170
|
"devDependencies": {
|
|
171
|
-
"@google-cloud/storage": "
|
|
171
|
+
"@google-cloud/storage": "9.0.0",
|
|
172
172
|
"ajv": "^8.20.0",
|
|
173
173
|
"fake-indexeddb": "6.2.8",
|
|
174
174
|
"fastify": "^5.12.8",
|
|
175
|
+
"google-auth-library": "11.3.1",
|
|
175
176
|
"typescript": "7.0.2",
|
|
176
177
|
"vite": "8.3.8",
|
|
177
|
-
"vitest": "5.1.
|
|
178
|
+
"vitest": "5.1.1"
|
|
178
179
|
},
|
|
179
180
|
"scripts": {
|
|
180
181
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|