Recursive JSON Schema for Tool Parameters
# support
z
Hey @User , I'm running into an issue with the validation of a tool's JSON schema and was hoping to get some clarification. After a bit of debugging, I've received specific errors stating that property
$defs
should not exist within the tool's parameters. This suggests that standard recursive schema definitions aren't supported. Could you please confirm if this is a known limitation, and if there's a recommended workaround for handling recursive structures? For context, I'm trying to implement a schema like the one below. Thanks!
Copy code
{
  "name": "Test",
  "parameters": {
    "type": "object",
    "$defs": {
      "selectedOption": {
        "type": "object",
        "properties": {
          "selectedOptions": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/selectedOption"
            }
          }
        }
      }
    },
    "properties": {
      "items": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "selectedOptions": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/selectedOption"
              }
            }
          }
        }
      }
    }
  }
}
c
Hi zee_chief_beef, It appears that standard recursive schema definitions, such as using
$defs
for recursive properties, are not supported within the Vapi tool's parameters. To handle complex or recursive structures, try flattening the schema to avoid using references, or break down the recursion into separate, non-recursive schemas where possible. You could also process recursiveness in the logic outside the schema before passing values into the tool. For more comprehensive error handling, ensure that your JSON follows the specific format outlined for Vapi tools. You can refer to the [Vapi Custom Tools Troubleshooting Guide](https://docs.vapi.ai/tools/custom-tools-troubleshooting) for additional guidance on resolving common configuration and schema issues.
2 Views