pub struct SchemaComponents {
pub schemas: BTreeMap<String, Value>,
}Expand description
Every struct and enum referenced by a set of endpoints, emitted once.
crate::model::Type::to_json_schema already produces JSON Schema 2020-12,
and OpenAPI 3.1 is a superset of it, so these values drop into a document
essentially verbatim. The only work is hoisting them to document scope:
to_mcp_input_schema/to_mcp_output_schema deliberately build a fresh
defs map per endpoint so each MCP tool schema is self-contained, which is
exactly wrong for a document where operations should share $refs.
Refs in SchemaComponents::schemas and in the per-endpoint schemas
returned by SchemaComponents::request_schema /
SchemaComponents::response_schema are already relocated to
COMPONENTS_SCHEMAS_PREFIX — callers do not need to call
relocate_refs themselves.
Fields§
§schemas: BTreeMap<String, Value>Definition name → schema, e.g. "User" → { "type": "object", ... }.
Implementations§
Source§impl SchemaComponents
impl SchemaComponents
Sourcepub fn collect(
endpoints: &[EndpointSchema],
registry: &TypeRegistry,
) -> Result<Self>
pub fn collect( endpoints: &[EndpointSchema], registry: &TypeRegistry, ) -> Result<Self>
Walks endpoints, collecting every referenced definition exactly once.
Fails if any StructRef/EnumRef/StructTable is missing from
registry — a document with dangling $refs is worse than no document,
because validators accept it and generators emit broken clients.
Sourcepub fn request_schema(
&self,
endpoint: &EndpointSchema,
registry: &TypeRegistry,
) -> Result<Value>
pub fn request_schema( &self, endpoint: &EndpointSchema, registry: &TypeRegistry, ) -> Result<Value>
Object schema over an endpoint’s parameters, with refs pointing at
Self::schemas. Non-Optional parameters land in required.
Sourcepub fn response_schema(
&self,
endpoint: &EndpointSchema,
registry: &TypeRegistry,
) -> Result<Value>
pub fn response_schema( &self, endpoint: &EndpointSchema, registry: &TypeRegistry, ) -> Result<Value>
Object schema over an endpoint’s returns. See Self::request_schema.
Trait Implementations§
Source§impl Clone for SchemaComponents
impl Clone for SchemaComponents
Source§fn clone(&self) -> SchemaComponents
fn clone(&self) -> SchemaComponents
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SchemaComponents
impl Debug for SchemaComponents
Source§impl Default for SchemaComponents
impl Default for SchemaComponents
Source§fn default() -> SchemaComponents
fn default() -> SchemaComponents
impl Eq for SchemaComponents
Source§impl PartialEq for SchemaComponents
impl PartialEq for SchemaComponents
impl StructuralPartialEq for SchemaComponents
Auto Trait Implementations§
impl Freeze for SchemaComponents
impl RefUnwindSafe for SchemaComponents
impl Send for SchemaComponents
impl Sync for SchemaComponents
impl Unpin for SchemaComponents
impl UnsafeUnpin for SchemaComponents
impl UnwindSafe for SchemaComponents
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more