-
Notifications
You must be signed in to change notification settings - Fork 153
Resolve the option param with using OpenAPI v3 for tools macro #137
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
Resolve the option param with using OpenAPI v3 for tools macro #137
Conversation
2113a98
to
3ccbc64
Compare
a70f10a
to
6527e83
Compare
.map(|text| text.text.as_str()) | ||
.expect("Expected text content"); | ||
|
||
assert_eq!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think this would fail per #135
} | ||
|
||
#[test] | ||
fn test_optional_field_schema_generation_via_macro() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about use a more little change test .
impl Server {
/// This tool is used to get the weather of a city.
#[tool(name = "get-weather", description = "Get the weather of a city.", vis = )]
pub async fn get_weather(&self, #[tool(param)] city: String) -> String {
drop(city);
"rain".to_string()
}
#[tool(description = "Empty Parameter")]
async fn empty_param(&self) {}
+#[tool(description = "Optional Parameter")]
+async fn optional_param(&self, #[tool(param)] city: Option<String>) -> String {
+ city.unwrap_or_default()
+}
}
#[tokio::test]
async fn test_tool_macros_with_optional_param() {
let _attr = Server::optional_param_tool_attr();
// println!("{_attr:?}");
let attr_type = _attr.input_schema.get("properties").unwrap().get("city").unwrap().get("type").unwrap();
println!("_attr.input_schema: {:?}", attr_type);
assert_eq!(attr_type, "string");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
Sorry for the late reply, as the questioner has not updated for a long time. |
b5919e0
to
9642796
Compare
…ld schema workaround (modelcontextprotocol#135) test(update): added test tool macro with optional
@jokemanfire feel free to approve. Maybe fixing this will fix other issues as well? I may have more time to work on this soon. |
Adds doc and test.
#135
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context