fastmcp 4.30.0 → 4.30.1
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/dist/openapi/index.cjs +25 -12
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.js +25 -12
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
package/dist/openapi/index.js
CHANGED
|
@@ -84,9 +84,10 @@ function buildFlatSchema(route, sharedDefs) {
|
|
|
84
84
|
const requiredBodyKeys = [];
|
|
85
85
|
for (const [name, { required: isRequired, schema }] of bodyProperties) {
|
|
86
86
|
const key = name === "__proto__" ? allocateAlias(`${name}__body`) : name;
|
|
87
|
-
properties[key] =
|
|
87
|
+
properties[key] = omitRequiredByAnnotation(
|
|
88
88
|
rewriteComponentRefs(schema),
|
|
89
|
-
"schema"
|
|
89
|
+
"schema",
|
|
90
|
+
"readOnly"
|
|
90
91
|
);
|
|
91
92
|
parameterMap[key] = { in: "body", name };
|
|
92
93
|
bodyKeys.push(key);
|
|
@@ -109,7 +110,11 @@ function buildFlatSchema(route, sharedDefs) {
|
|
|
109
110
|
}
|
|
110
111
|
const usedDefs = sharedDefs && filterReferencedDefs(properties, sharedDefs);
|
|
111
112
|
if (usedDefs) {
|
|
112
|
-
flatSchema.$defs =
|
|
113
|
+
flatSchema.$defs = omitRequiredByAnnotation(
|
|
114
|
+
usedDefs,
|
|
115
|
+
"schemaMap",
|
|
116
|
+
"readOnly"
|
|
117
|
+
);
|
|
113
118
|
}
|
|
114
119
|
return {
|
|
115
120
|
bodyEncoding,
|
|
@@ -161,12 +166,17 @@ function buildOutputSchema(route, sharedDefs) {
|
|
|
161
166
|
if (usedDefs && Object.keys(usedDefs).length > MAX_OUTPUT_SCHEMA_DEFS) {
|
|
162
167
|
return void 0;
|
|
163
168
|
}
|
|
164
|
-
|
|
169
|
+
const outputSchema = {
|
|
165
170
|
...normalized,
|
|
166
171
|
...usedDefs ? {
|
|
167
172
|
$defs: rewriteNode(usedDefs, "schemaMap", true)
|
|
168
173
|
} : {}
|
|
169
174
|
};
|
|
175
|
+
return omitRequiredByAnnotation(
|
|
176
|
+
outputSchema,
|
|
177
|
+
"schema",
|
|
178
|
+
"writeOnly"
|
|
179
|
+
);
|
|
170
180
|
}
|
|
171
181
|
function resolveComponentRef(schema, sharedDefs) {
|
|
172
182
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -323,29 +333,32 @@ function normalizeNullable(schema) {
|
|
|
323
333
|
}
|
|
324
334
|
return rest;
|
|
325
335
|
}
|
|
326
|
-
function
|
|
336
|
+
function omitRequiredByAnnotation(value, mode, annotation) {
|
|
327
337
|
if (mode === "data" || !value || typeof value !== "object") {
|
|
328
338
|
return value;
|
|
329
339
|
}
|
|
330
340
|
if (Array.isArray(value)) {
|
|
331
|
-
return value.map(
|
|
341
|
+
return value.map(
|
|
342
|
+
(item) => omitRequiredByAnnotation(item, "schema", annotation)
|
|
343
|
+
);
|
|
332
344
|
}
|
|
333
345
|
const node = Object.fromEntries(
|
|
334
346
|
Object.entries(value).map(([key, child]) => [
|
|
335
347
|
key,
|
|
336
|
-
|
|
348
|
+
omitRequiredByAnnotation(
|
|
337
349
|
child,
|
|
338
|
-
mode === "schemaMap" ? "schema" : childMode(key)
|
|
350
|
+
mode === "schemaMap" ? "schema" : childMode(key),
|
|
351
|
+
annotation
|
|
339
352
|
)
|
|
340
353
|
])
|
|
341
354
|
);
|
|
342
355
|
const { properties, required } = node;
|
|
343
356
|
if (mode === "schema" && Array.isArray(required) && properties && typeof properties === "object") {
|
|
344
|
-
const
|
|
345
|
-
(name) => !(typeof name === "string" && Object.hasOwn(properties, name) && properties[name]?.
|
|
357
|
+
const remaining = required.filter(
|
|
358
|
+
(name) => !(typeof name === "string" && Object.hasOwn(properties, name) && properties[name]?.[annotation] === true)
|
|
346
359
|
);
|
|
347
|
-
if (
|
|
348
|
-
node.required =
|
|
360
|
+
if (remaining.length > 0) {
|
|
361
|
+
node.required = remaining;
|
|
349
362
|
} else {
|
|
350
363
|
delete node.required;
|
|
351
364
|
}
|