pub struct TypeMapper { /* private fields */ }Implementations§
Source§impl TypeMapper
impl TypeMapper
pub fn new(config: TypeMappingConfig) -> Self
Sourcepub fn used_features(&self) -> UsedFeatures
pub fn used_features(&self) -> UsedFeatures
Snapshot of typed-scalar crates this mapper has referenced.
Sourcepub fn config(&self) -> &TypeMappingConfig
pub fn config(&self) -> &TypeMappingConfig
Borrow the underlying type-mapping config — useful for
non-format-mapping toggles (shape, enums, constraints)
that other modules need to inspect.
Sourcepub fn config_shape_primitive_unions(&self) -> Option<bool>
pub fn config_shape_primitive_unions(&self) -> Option<bool>
Q2.7 helper: should anyOf of primitives become an untagged
enum with primitive variant types directly (true), or fall
back to the pre-Q2.7 type-alias-per-variant shape (false)?
Default: true.
Sourcepub fn config_shape_additional_properties_typed(&self) -> Option<bool>
pub fn config_shape_additional_properties_typed(&self) -> Option<bool>
Q2.3 helper: should additionalProperties: <schema> produce
BTreeMap<String, T> (true) or degrade to BTreeMap<String, serde_json::Value> (false)? Default: true.
Sourcepub fn config_constraint_mode(&self) -> ConstraintMode
pub fn config_constraint_mode(&self) -> ConstraintMode
Q2.4 helper: which constraint-annotation mode is active?
Defaults to ConstraintMode::Doc when the
[generator.types.constraints] block is absent or its mode
field is unset.
Sourcepub fn string_format(&self, format: Option<&str>) -> MappedType
pub fn string_format(&self, format: Option<&str>) -> MappedType
Map string + optional format → typed Rust scalar.
Routing:
- Apply user-provided + built-in
format_aliases. - Dispatch on the normalized format.
- Honor each format’s strategy in
self.config. - Record any introduced crate in
used_features.
Sourcepub fn integer_format(&self, format: Option<&str>) -> MappedType
pub fn integer_format(&self, format: Option<&str>) -> MappedType
Map integer + optional format → Rust type.
Q2.1: honors uint32 / uint64 (and a few vendor variants
like uint) when config.unsigned is true (default).
Setting unsigned = false reverts to the pre-Q2.1 behavior
where unsigned formats degrade to i64.
Sourcepub fn number_format(&self, format: Option<&str>) -> MappedType
pub fn number_format(&self, format: Option<&str>) -> MappedType
Map number + optional format → Rust type.
format: float maps to f64 by default rather than f32. JSON has no
binary32: a value written on the wire as 0.03 parses losslessly into
f64, but through f32 it becomes 0.029999999329447746. The declared
format describes the server’s internal storage, not the transport, so
f32 discards precision the response actually carried. Observed live on
RunPod’s catalog prices, which declare float while the billing
endpoints declare double.
Set float_precision = "f32" under [generator.types] to map strictly
by declared format instead.
pub fn boolean(&self) -> MappedType
pub fn untyped_array(&self) -> MappedType
pub fn dynamic_json(&self) -> MappedType
pub fn null_unit(&self) -> MappedType
Sourcepub fn map(&self, ty: OpenApiSchemaType, details: &SchemaDetails) -> MappedType
pub fn map(&self, ty: OpenApiSchemaType, details: &SchemaDetails) -> MappedType
One-shot dispatch from (OpenApiSchemaType, &SchemaDetails).