Bugfix/Parse JSON correctly (#5220)

* parse JSON correctly

* add codeblock highlight
This commit is contained in:
Henry Heng
2025-09-18 19:18:50 +01:00
committed by GitHub
parent 011d60332e
commit cf6539cd3f
18 changed files with 283 additions and 69 deletions
@@ -1,7 +1,7 @@
import { z } from 'zod'
import { DynamicStructuredTool } from '../OpenAPIToolkit/core'
import { secureFetch } from '../../../src/httpSecurity'
import JSON5 from 'json5'
import { parseJsonBody } from '../../../src/utils'
export const desc = `Use this when you want to execute a POST request to create or update a resource.`
@@ -28,7 +28,7 @@ const createRequestsPostSchema = (bodySchema?: string) => {
// If bodySchema is provided, parse it and add dynamic body params
if (bodySchema) {
try {
const parsedSchema = JSON5.parse(bodySchema)
const parsedSchema = parseJsonBody(bodySchema)
const bodyParamsObject: Record<string, z.ZodTypeAny> = {}
Object.entries(parsedSchema).forEach(([key, config]: [string, any]) => {