Skip to content

Commit 767da4a

Browse files
committed
Add rustdoc on translating 'number' into 'rust_decimal:Decimal'
1 parent 5721eca commit 767da4a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

typify-impl/src/lib.rs

+20
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,26 @@ impl TypeSpaceSettings {
468468
/// Typical usage is to map a schema definition to a builtin type or type
469469
/// provided by a crate, such as `'rust_decimal::Decimal'`. If the same schema
470470
/// is specified multiple times, the first one is honored.
471+
///
472+
/// # Examples
473+
///
474+
/// ```
475+
/// // Setup 'number' json type to be translated into 'rust_decimal::Decimal'
476+
/// use schemars::schema::{InstanceType, SchemaObject};
477+
/// use typify_impl::{TypeSpace, TypeSpaceImpl, TypeSpaceSettings};
478+
/// let mut type_space = TypeSpace::new(
479+
/// TypeSpaceSettings::default()
480+
/// .with_struct_builder(true)
481+
/// .with_conversion(
482+
/// SchemaObject {
483+
/// instance_type: Some(InstanceType::Number.into()),
484+
/// ..Default::default()
485+
/// },
486+
/// "rust_decimal::Decimal",
487+
/// [TypeSpaceImpl::Display].into_iter(),
488+
/// ),
489+
/// );
490+
/// ```
471491
pub fn with_conversion<S: ToString, I: Iterator<Item = TypeSpaceImpl>>(
472492
&mut self,
473493
schema: schemars::schema::SchemaObject,

0 commit comments

Comments
 (0)