Fix: remove erroneous definitions_path (#264)

* fix bug,
1 remove erroneous definitions_path setting,"#/components/schemas/" is used for openapi3
2 show meta_schema

* Update crates/rmcp/src/handler/server/tool.rs

Remove the commented-out settings.inline_subschemas line to avoid confusion and clean up dead code.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: wenhaozhao <wenhaozhao@sohu-inc.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
wenhaozhao 2025-06-18 09:07:28 +08:00 • committed by GitHub
commit b9bba0be15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,13 +14,12 @@ use crate::{
};
/// A shortcut for generating a JSON schema for a type.
pub fn schema_for_type<T: JsonSchema>() -> JsonObject {
let mut settings = schemars::r#gen::SchemaSettings::default();
// explicitly to align json schema version to official specifications.
// https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-03-26/schema.json
let mut settings = schemars::r#gen::SchemaSettings::draft07();
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");