Showing the changes to packages/codemode-openapi/src (1 of 9 files). Show all
Unified · Split
| @@ -1,7 +1,12 @@ | ||
| 1 | 1 | import * as Data from "effect/Data"; |
| 2 | 2 | import * as Effect from "effect/Effect"; |
| 3 | 3 | |
| 4 | −import { toTool, type ToolMap } from "@executor-v3/codemode-core"; | |
| 4 | +import { | |
| 5 | + standardSchemaFromJsonSchema, | |
| 6 | + toTool, | |
| 7 | + type ToolMap, | |
| 8 | + unknownInputSchema, | |
| 9 | +} from "@executor-v3/codemode-core"; | |
| 5 | 10 | |
| 6 | 11 | import { |
| 7 | 12 | extractOpenApiManifest, |
| @@ -179,6 +184,22 @@ const decodeFetchResponseBody = async (response: Response): Promise<unknown> => · 171 unmodified lines | ||
| 179 | 184 | return response.text(); |
| 180 | 185 | }; |
| 181 | 186 | |
| 187 | +const inputSchemaFromTypingJson = (inputSchemaJson: string | undefined) => { | |
| 188 | + if (!inputSchemaJson) { | |
| 189 | + return unknownInputSchema; | |
| 190 | + } | |
| 191 | + | |
| 192 | + try { | |
| 193 | + return standardSchemaFromJsonSchema(JSON.parse(inputSchemaJson), { | |
| 194 | + vendor: "openapi", | |
| 195 | + fallback: unknownInputSchema, | |
| 196 | + }); | |
| 197 | + } catch { | |
| 198 | + return unknownInputSchema; | |
| 199 | + } | |
| 200 | +}; | |
| 201 | + | |
| 202 | + | |
| 182 | 203 | type CreateOpenApiToolsFromManifestInput = { |
| 183 | 204 | manifest: OpenApiToolManifest; |
| 184 | 205 | baseUrl: string; |
| @@ -297,6 +318,7 @@ export const createOpenApiToolsFromManifest = ( · 112 unmodified lines | ||
| 297 | 318 | result[toolPath] = toTool({ |
| 298 | 319 | tool: { |
| 299 | 320 | description, |
| 321 | + inputSchema: inputSchemaFromTypingJson(extracted.typing?.inputSchemaJson), | |
| 300 | 322 | execute: async (args: unknown) => { |
| 301 | 323 | const decodedArgs = asToolArgs(args); |
| 302 | 324 | const request = buildFetchRequest({ |