refac
This commit is contained in:
@@ -530,7 +530,9 @@ export const executeToolServer = async (
|
||||
try {
|
||||
// Find the matching operationId in the OpenAPI spec
|
||||
const matchingRoute = Object.entries(serverData.openapi.paths).find(([_, methods]) =>
|
||||
Object.entries(methods as any).some(([__, operation]: any) => operation.operationId === name)
|
||||
Object.entries(methods as any).some(
|
||||
([__, operation]: any) => operation && typeof operation === 'object' && operation.operationId === name
|
||||
)
|
||||
);
|
||||
|
||||
if (!matchingRoute) {
|
||||
@@ -540,7 +542,7 @@ export const executeToolServer = async (
|
||||
const [routePath, methods] = matchingRoute;
|
||||
|
||||
const methodEntry = Object.entries(methods as any).find(
|
||||
([_, operation]: any) => operation.operationId === name
|
||||
([_, operation]: any) => operation && typeof operation === 'object' && operation.operationId === name
|
||||
);
|
||||
|
||||
if (!methodEntry) {
|
||||
|
||||
@@ -1395,7 +1395,8 @@ export const convertOpenApiToToolPayload = (openApiSpec) => {
|
||||
|
||||
for (const [path, methods] of Object.entries(openApiSpec.paths)) {
|
||||
for (const [method, operation] of Object.entries(methods)) {
|
||||
if (operation?.operationId) {
|
||||
if (!operation || typeof operation !== 'object') continue;
|
||||
if ((operation as any)?.operationId) {
|
||||
const tool = {
|
||||
name: operation.operationId,
|
||||
description: operation.description || operation.summary || 'No description available.',
|
||||
|
||||
Reference in New Issue
Block a user