pub struct SchemaShaper;Expand description
Shapes JSON Schema at runtime by removing fields or variants that the current user lacks capabilities for.
This is the Rust equivalent of RbsSchemaCompiler in the Ruby gem:
the full schema is generated once at compile time (via schemars),
then filtered per-request based on the user’s AuthContext.
Implementations§
Source§impl SchemaShaper
impl SchemaShaper
Sourcepub fn shape_input<T: JsonSchema + AuthSchemaMetadata + 'static>(
auth: &AuthContext,
) -> Arc<Map<String, Value>>
pub fn shape_input<T: JsonSchema + AuthSchemaMetadata + 'static>( auth: &AuthContext, ) -> Arc<Map<String, Value>>
Generate a shaped input schema for type T.
Starts from the full schemars-generated schema, then removes
properties whose AuthSchemaMetadata requirements are not
satisfied by the given AuthContext.
Sourcepub fn shape_output<T: JsonSchema + AuthSchemaMetadata + 'static>(
auth: &AuthContext,
) -> Option<Arc<Map<String, Value>>>
pub fn shape_output<T: JsonSchema + AuthSchemaMetadata + 'static>( auth: &AuthContext, ) -> Option<Arc<Map<String, Value>>>
Generate a shaped output schema for type T.
Removes oneOf/anyOf variants whose AuthSchemaMetadata
requirements are not satisfied.
Auto Trait Implementations§
impl Freeze for SchemaShaper
impl RefUnwindSafe for SchemaShaper
impl Send for SchemaShaper
impl Sync for SchemaShaper
impl Unpin for SchemaShaper
impl UnsafeUnpin for SchemaShaper
impl UnwindSafe for SchemaShaper
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
Mutably borrows from an owned value. Read more