Skip to content

Commit 6a3f3d7

Browse files
chore: minor changes
1 parent 999a2a4 commit 6a3f3d7

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

packages/core/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "muppet",
33
"description": "Toolkit for building MCPs on Honojs",
4-
"version": "0.1.0",
4+
"version": "0.2.0",
55
"license": "MIT",
66
"type": "module",
77
"main": "dist/index.cjs",
@@ -40,7 +40,6 @@
4040
"@standard-community/standard-json": "^0.1.2",
4141
"@standard-schema/spec": "^1.0.0",
4242
"hono": "^4.6.13",
43-
"lodash-es": "^4.17.21",
4443
"openapi-types": "^12.1.3"
4544
},
4645
"peerDependenciesMeta": {
@@ -50,9 +49,6 @@
5049
"hono": {
5150
"optional": true
5251
},
53-
"lodash-es": {
54-
"optional": true
55-
},
5652
"openapi-types": {
5753
"optional": true
5854
}
@@ -92,7 +88,6 @@
9288
"devDependencies": {
9389
"@hono/event-emitter": "^2.0.0",
9490
"@types/json-schema": "^7.0.15",
95-
"@types/lodash-es": "^4.17.12",
9691
"pino": "^9.6.0",
9792
"pkgroll": "^2.5.1",
9893
"zod": "^3.24.2"

packages/core/src/openapi.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { createMuppetServer, generateKey, mergeSchemas } from "./muppet";
44
import { Hono } from "hono";
55
import { proxy } from "hono/proxy";
66
import type { JSONSchema7 } from "json-schema";
7-
import { get as _get } from "lodash-es";
87

98
export function fromOpenAPI(specs: OpenAPIV3_1.Document) {
109
const config: MuppetConfiguration = {
@@ -38,7 +37,11 @@ export function fromOpenAPI(specs: OpenAPIV3_1.Document) {
3837
.split("/")
3938
.slice(1)
4039
.join(".");
41-
pSchema = _get(specs, path);
40+
const _pSchema = getPropByPath(specs, path);
41+
42+
if (_pSchema) {
43+
pSchema = _pSchema;
44+
}
4245
}
4346

4447
schema[parameter.in] = {
@@ -89,3 +92,20 @@ export function fromOpenAPI(specs: OpenAPIV3_1.Document) {
8992
app,
9093
});
9194
}
95+
96+
const getPropByPath = <T>(
97+
object: Record<string, unknown>,
98+
path: string | string[],
99+
defaultValue?: T,
100+
): T | undefined => {
101+
const _path = Array.isArray(path) ? path : path.split(".");
102+
103+
const _key = _path.shift();
104+
if (object && _key)
105+
return getPropByPath(
106+
object[_key] as Record<string, unknown>,
107+
_path,
108+
defaultValue,
109+
);
110+
return object === undefined ? defaultValue : (object as T);
111+
};

0 commit comments

Comments
 (0)