@@ -119,6 +119,7 @@ impl TypeSpace {
119119 additional_properties @ Some ( _) => {
120120 let sub_type_name = type_name. as_ref ( ) . map ( |base| format ! ( "{}_extra" , base) ) ;
121121 let map_type = self . make_map (
122+ self . settings . map_to_use . clone ( ) ,
122123 sub_type_name,
123124 & validation. property_names ,
124125 additional_properties,
@@ -205,6 +206,7 @@ impl TypeSpace {
205206
206207 pub ( crate ) fn make_map (
207208 & mut self ,
209+ map_to_use : String ,
208210 type_name : Option < String > ,
209211 property_names : & Option < Box < Schema > > ,
210212 additional_properties : & Option < Box < Schema > > ,
@@ -237,7 +239,12 @@ impl TypeSpace {
237239 None => self . id_for_schema ( Name :: Unknown , & Schema :: Bool ( true ) ) ?,
238240 } ;
239241
240- Ok ( TypeEntryDetails :: Map ( key_id, value_id) . into ( ) )
242+ Ok ( TypeEntryDetails :: Map {
243+ map_to_use,
244+ key_id,
245+ value_id,
246+ }
247+ . into ( ) )
241248 }
242249
243250 /// Perform a schema conversion for a type that must be string-like.
@@ -381,7 +388,14 @@ pub(crate) fn generate_serde_attr(
381388 serde_options. push ( quote ! { skip_serializing_if = "::std::vec::Vec::is_empty" } ) ;
382389 DefaultFunction :: Default
383390 }
384- ( StructPropertyState :: Optional , TypeEntryDetails :: Map ( key_id, value_id) ) => {
391+ (
392+ StructPropertyState :: Optional ,
393+ TypeEntryDetails :: Map {
394+ map_to_use,
395+ key_id,
396+ value_id,
397+ } ,
398+ ) => {
385399 serde_options. push ( quote ! { default } ) ;
386400
387401 let key_ty = type_space
@@ -400,8 +414,10 @@ pub(crate) fn generate_serde_attr(
400414 skip_serializing_if = "::serde_json::Map::is_empty"
401415 } ) ;
402416 } else {
417+ // Append ::is_empty to the string.
418+ let map_to_use = format ! ( "{}::is_empty" , map_to_use) ;
403419 serde_options. push ( quote ! {
404- skip_serializing_if = "::std::collections::HashMap::is_empty"
420+ skip_serializing_if = #map_to_use
405421 } ) ;
406422 }
407423 DefaultFunction :: Default
@@ -458,7 +474,7 @@ fn has_default(
458474 // No default specified.
459475 ( Some ( TypeEntryDetails :: Option ( _) ) , None ) => StructPropertyState :: Optional ,
460476 ( Some ( TypeEntryDetails :: Vec ( _) ) , None ) => StructPropertyState :: Optional ,
461- ( Some ( TypeEntryDetails :: Map ( .. ) ) , None ) => StructPropertyState :: Optional ,
477+ ( Some ( TypeEntryDetails :: Map { .. } ) , None ) => StructPropertyState :: Optional ,
462478 ( Some ( TypeEntryDetails :: Unit ) , None ) => StructPropertyState :: Optional ,
463479 ( _, None ) => StructPropertyState :: Required ,
464480
@@ -471,7 +487,9 @@ fn has_default(
471487 StructPropertyState :: Optional
472488 }
473489 // Default specified is the same as the implicit default: {}
474- ( Some ( TypeEntryDetails :: Map ( ..) ) , Some ( serde_json:: Value :: Object ( m) ) ) if m. is_empty ( ) => {
490+ ( Some ( TypeEntryDetails :: Map { .. } ) , Some ( serde_json:: Value :: Object ( m) ) )
491+ if m. is_empty ( ) =>
492+ {
475493 StructPropertyState :: Optional
476494 }
477495 // Default specified is the same as the implicit default: false
0 commit comments