Skip to content

Commit

Permalink
Add rustdoc on translating 'number' into 'rust_decimal:Decimal' (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
kairsas authored Feb 3, 2025
1 parent 0226a73 commit 82868f8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions typify-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,26 @@ impl TypeSpaceSettings {
/// Typical usage is to map a schema definition to a builtin type or type
/// provided by a crate, such as `'rust_decimal::Decimal'`. If the same schema
/// is specified multiple times, the first one is honored.
///
/// # Examples
///
/// ```
/// // Setup 'number' json type to be translated into 'rust_decimal::Decimal'
/// use schemars::schema::{InstanceType, SchemaObject};
/// use typify_impl::{TypeSpace, TypeSpaceImpl, TypeSpaceSettings};
/// let mut type_space = TypeSpace::new(
/// TypeSpaceSettings::default()
/// .with_struct_builder(true)
/// .with_conversion(
/// SchemaObject {
/// instance_type: Some(InstanceType::Number.into()),
/// ..Default::default()
/// },
/// "::rust_decimal::Decimal",
/// [TypeSpaceImpl::Display].into_iter(),
/// ),
/// );
/// ```
pub fn with_conversion<S: ToString, I: Iterator<Item = TypeSpaceImpl>>(
&mut self,
schema: schemars::schema::SchemaObject,
Expand Down

0 comments on commit 82868f8

Please sign in to comment.