fastmcp 4.29.0 → 4.29.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 +23 -11
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +10 -0
- package/dist/openapi/index.d.ts +10 -0
- package/dist/openapi/index.js +23 -11
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
package/dist/openapi/index.js
CHANGED
|
@@ -65,11 +65,11 @@ function buildFlatSchema(route, sharedDefs) {
|
|
|
65
65
|
for (const param of occurrences) {
|
|
66
66
|
const base = collides ? `${name}__${param.in}` : name;
|
|
67
67
|
const key = collides ? allocateAlias(base) : name;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
);
|
|
68
|
+
const input = parameterInput(param);
|
|
69
|
+
properties[key] = rewriteComponentRefs(input.schema);
|
|
71
70
|
parameterMap[key] = {
|
|
72
71
|
allowReserved: param.allowReserved,
|
|
72
|
+
...input.encoding ? { encoding: input.encoding } : {},
|
|
73
73
|
explode: param.explode,
|
|
74
74
|
in: param.in,
|
|
75
75
|
name,
|
|
@@ -352,6 +352,13 @@ function omitReadOnlyRequired(value, mode) {
|
|
|
352
352
|
}
|
|
353
353
|
return node;
|
|
354
354
|
}
|
|
355
|
+
function parameterInput(param) {
|
|
356
|
+
const json = param.schema === void 0 ? findMediaType(param.content, "application/json") : void 0;
|
|
357
|
+
if (!json) {
|
|
358
|
+
return { schema: param.schema ?? { type: "string" } };
|
|
359
|
+
}
|
|
360
|
+
return { encoding: "json", schema: json.schema ?? {} };
|
|
361
|
+
}
|
|
355
362
|
function rewriteNode(value, mode, stripExamples = false) {
|
|
356
363
|
if (mode === "data") {
|
|
357
364
|
return value;
|
|
@@ -698,7 +705,7 @@ async function fetchResponse(options) {
|
|
|
698
705
|
if (!mapping || value === void 0) {
|
|
699
706
|
continue;
|
|
700
707
|
}
|
|
701
|
-
if (value === null && (mapping.in === "query" || mapping.in === "header" || mapping.in === "cookie")) {
|
|
708
|
+
if (value === null && mapping.encoding !== "json" && (mapping.in === "query" || mapping.in === "header" || mapping.in === "cookie")) {
|
|
702
709
|
continue;
|
|
703
710
|
}
|
|
704
711
|
switch (mapping.in) {
|
|
@@ -706,7 +713,8 @@ async function fetchResponse(options) {
|
|
|
706
713
|
bodyProps[mapping.name] = value;
|
|
707
714
|
break;
|
|
708
715
|
case "cookie": {
|
|
709
|
-
const
|
|
716
|
+
const encoded = mapping.encoding === "json" ? encodePathComponent(JSON.stringify(value)) : encodeCookieValue(mapping, value);
|
|
717
|
+
const pair = `${mapping.name}=${encoded}`;
|
|
710
718
|
const existing = headers.get("cookie");
|
|
711
719
|
headers.set("cookie", existing ? `${existing}; ${pair}` : pair);
|
|
712
720
|
break;
|
|
@@ -714,18 +722,19 @@ async function fetchResponse(options) {
|
|
|
714
722
|
case "header":
|
|
715
723
|
headers.set(
|
|
716
724
|
mapping.name,
|
|
717
|
-
serializeHeaderValue(value, mapping.style, mapping.explode)
|
|
725
|
+
mapping.encoding === "json" ? JSON.stringify(value) : serializeHeaderValue(value, mapping.style, mapping.explode)
|
|
718
726
|
);
|
|
719
727
|
break;
|
|
720
728
|
case "path":
|
|
721
|
-
pathParams[mapping.name] = encodePathValue(
|
|
722
|
-
value,
|
|
723
|
-
mapping.style,
|
|
724
|
-
mapping.explode
|
|
725
|
-
);
|
|
729
|
+
pathParams[mapping.name] = mapping.encoding === "json" ? encodePathComponent(JSON.stringify(value)) : encodePathValue(value, mapping.style, mapping.explode);
|
|
726
730
|
break;
|
|
727
731
|
case "query": {
|
|
728
732
|
const query = new URLSearchParams();
|
|
733
|
+
if (mapping.encoding === "json") {
|
|
734
|
+
query.append(mapping.name, JSON.stringify(value));
|
|
735
|
+
queryParts.push(serializeQuery(query, false));
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
729
738
|
appendQueryValue(
|
|
730
739
|
query,
|
|
731
740
|
mapping.name,
|
|
@@ -860,6 +869,9 @@ function isEligibleForResource(route, sharedDefs) {
|
|
|
860
869
|
if (param.in === "header" || param.in === "cookie") {
|
|
861
870
|
return false;
|
|
862
871
|
}
|
|
872
|
+
if (param.content && param.schema === void 0) {
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
863
875
|
return !hasStructuredType(param.schema ?? {}, sharedDefs);
|
|
864
876
|
});
|
|
865
877
|
}
|