Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion crates/rmcp/src/handler/server/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ use crate::{
};
/// A shortcut for generating a JSON schema for a type.
pub fn schema_for_type<T: JsonSchema>() -> JsonObject {
let settings = schemars::r#gen::SchemaSettings::openapi3();
let mut settings = schemars::r#gen::SchemaSettings::default();
Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment here explaining why the custom settings are used instead of openapi3(), detailing the specific needs addressed by these settings to aid future maintainers.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need to do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a better solution. Nice work

settings.option_nullable = true;
settings.option_add_null_type = false;
settings.definitions_path = "#/components/schemas/".to_owned();
settings.meta_schema = None;
settings.visitors = Vec::default();
settings.inline_subschemas = false;
let generator = settings.into_generator();
let schema = generator.into_root_schema_for::<T>();
let object = serde_json::to_value(schema).expect("failed to serialize schema");
Expand Down
Loading