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:
parent
d45136c3ed
commit
b9bba0be15
1 changed files with 3 additions and 4 deletions
|
|
@ -14,13 +14,12 @@ use crate::{
|
||||||
};
|
};
|
||||||
/// A shortcut for generating a JSON schema for a type.
|
/// A shortcut for generating a JSON schema for a type.
|
||||||
pub fn schema_for_type<T: JsonSchema>() -> JsonObject {
|
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_nullable = true;
|
||||||
settings.option_add_null_type = false;
|
settings.option_add_null_type = false;
|
||||||
settings.definitions_path = "#/components/schemas/".to_owned();
|
|
||||||
settings.meta_schema = None;
|
|
||||||
settings.visitors = Vec::default();
|
settings.visitors = Vec::default();
|
||||||
settings.inline_subschemas = false;
|
|
||||||
let generator = settings.into_generator();
|
let generator = settings.into_generator();
|
||||||
let schema = generator.into_root_schema_for::<T>();
|
let schema = generator.into_root_schema_for::<T>();
|
||||||
let object = serde_json::to_value(schema).expect("failed to serialize schema");
|
let object = serde_json::to_value(schema).expect("failed to serialize schema");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue