Skip to content

Input schemas do not properly support optional fields #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
m-roberts opened this issue Apr 3, 2025 · 0 comments · May be fixed by #67
Open

Input schemas do not properly support optional fields #66

m-roberts opened this issue Apr 3, 2025 · 0 comments · May be fixed by #67

Comments

@m-roberts
Copy link

m-roberts commented Apr 3, 2025

The current implementation does not correctly support optional fields. Any field that defines itself as optional is marked as "string", and no "required" field is specified to define which fields are optional.

Test Schema

schema = {
  transactionId: {
    type: z.string(),
    description: "The id of the transaction to modify",
  },
  cleared: {
    type: z.boolean().optional(),
    description: "Whether the transaction is cleared (optional, defaults to false)",
  },
  approved: {
    type: z.boolean().optional(),
    description: "Whether the transaction is approved (optional, defaults to false)",
  },
};

Resulting JSON

{
  "name": "update_transaction",
  "description": "Update a transaction to mark it as cleared/uncleared and/or approved/not approved.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "transactionId": {
        "type": "string",
        "description": "The id of the transaction to modify"
      },
      "cleared": {
        "type": "string",
        "description": "Whether the transaction is cleared (optional, defaults to false)"
      },
      "approved": {
        "type": "string",
        "description": "Whether the transaction is approved (optional, defaults to false)"
      }
    }
  }
}

Desired JSON

{
  "name": "update_transaction",
  "description": "Update a transaction to mark it as cleared/uncleared and/or approved/not approved.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "transactionId": {
        "type": "string",
        "description": "The id of the transaction to modify"
      },
      "cleared": {
        "type": "boolean",
        "description": "Whether the transaction is cleared (optional, defaults to false)"
      },
      "approved": {
        "type": "boolean",
        "description": "Whether the transaction is approved (optional, defaults to false)"
      }
    },
    "required": ["transactionId"]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant