@avidian/mcp-openapi 0.1.1 → 0.1.2
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/index.js +21 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -635,19 +635,26 @@ function base64ToBlob(base64) {
|
|
|
635
635
|
import { z } from "zod/v4";
|
|
636
636
|
import { convertJsonSchemaToZod } from "zod-from-json-schema";
|
|
637
637
|
function normalizeJsonSchema(schema) {
|
|
638
|
-
|
|
638
|
+
const seen = new WeakSet;
|
|
639
|
+
return normalizeNode(schema, seen);
|
|
639
640
|
}
|
|
640
|
-
function normalizeNode(node) {
|
|
641
|
+
function normalizeNode(node, seen) {
|
|
641
642
|
if (Array.isArray(node)) {
|
|
642
|
-
|
|
643
|
+
if (seen.has(node))
|
|
644
|
+
return node;
|
|
645
|
+
seen.add(node);
|
|
646
|
+
return node.map((item) => normalizeNode(item, seen));
|
|
643
647
|
}
|
|
644
648
|
if (node === null || typeof node !== "object") {
|
|
645
649
|
return node;
|
|
646
650
|
}
|
|
651
|
+
if (seen.has(node))
|
|
652
|
+
return node;
|
|
653
|
+
seen.add(node);
|
|
647
654
|
const source = node;
|
|
648
655
|
const normalized = {};
|
|
649
656
|
for (const [key, value] of Object.entries(source)) {
|
|
650
|
-
normalized[key] = normalizeNode(value);
|
|
657
|
+
normalized[key] = normalizeNode(value, seen);
|
|
651
658
|
}
|
|
652
659
|
const nullable = normalized.nullable === true || normalized["x-nullable"] === true;
|
|
653
660
|
delete normalized.nullable;
|
|
@@ -666,7 +673,16 @@ function normalizeNode(node) {
|
|
|
666
673
|
return normalized;
|
|
667
674
|
}
|
|
668
675
|
function toZodType(schema, options) {
|
|
669
|
-
|
|
676
|
+
let base;
|
|
677
|
+
if (!schema) {
|
|
678
|
+
base = z.unknown();
|
|
679
|
+
} else {
|
|
680
|
+
try {
|
|
681
|
+
base = convertJsonSchemaToZod(normalizeJsonSchema(schema));
|
|
682
|
+
} catch {
|
|
683
|
+
base = z.unknown();
|
|
684
|
+
}
|
|
685
|
+
}
|
|
670
686
|
const described = options.description !== undefined ? base.describe(options.description) : base;
|
|
671
687
|
return options.required ? described : described.optional();
|
|
672
688
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avidian/mcp-openapi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "MCP server for OpenAPI/Swagger — gives AI agents the ability to discover, search, and call any REST API described by an OpenAPI document.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|