@@ -197,18 +197,18 @@ impl jtd_codegen::target::Target for Target {
197197 return Ok ( Some ( s. into ( ) ) ) ;
198198 }
199199
200- state
201- . imports
202- . entry ( "serde" . into ( ) )
203- . or_default ( )
204- . extend ( vec ! [ "Deserialize" . to_owned( ) , "Serialize" . to_owned( ) ] ) ;
205-
206200 let mut derives = vec ! [ "Serialize" , "Deserialize" ] ;
207201
208202 if let Some ( s) = metadata. get ( "rustCustomDerive" ) . and_then ( |v| v. as_str ( ) ) {
209203 derives. extend ( s. split ( "," ) ) ;
210204 }
211205
206+ state
207+ . imports
208+ . entry ( "serde" . into ( ) )
209+ . or_default ( )
210+ . extend ( vec ! [ "Deserialize" . to_owned( ) , "Serialize" . to_owned( ) ] ) ;
211+
212212 writeln ! ( out) ?;
213213 write ! ( out, "{}" , description( & metadata, 0 ) ) ?;
214214 writeln ! ( out, "#[derive({})]" , derives. join( ", " ) ) ?;
@@ -327,6 +327,12 @@ impl jtd_codegen::target::Target for Target {
327327 return Ok ( Some ( s. into ( ) ) ) ;
328328 }
329329
330+ let mut derives = vec ! [ "Serialize" , "Deserialize" ] ;
331+
332+ if let Some ( s) = metadata. get ( "rustCustomDerive" ) . and_then ( |v| v. as_str ( ) ) {
333+ derives. extend ( s. split ( "," ) ) ;
334+ }
335+
330336 state
331337 . imports
332338 . entry ( "serde" . into ( ) )
@@ -335,7 +341,7 @@ impl jtd_codegen::target::Target for Target {
335341
336342 writeln ! ( out) ?;
337343 write ! ( out, "{}" , description( & metadata, 0 ) ) ?;
338- writeln ! ( out, "#[derive(Serialize, Deserialize )]" ) ?;
344+ writeln ! ( out, "#[derive({} )]" , derives . join ( ", " ) ) ?;
339345 writeln ! ( out, "#[serde(tag = {:?})]" , tag_json_name) ?;
340346 writeln ! ( out, "pub enum {} {{" , name) ?;
341347
@@ -368,6 +374,12 @@ impl jtd_codegen::target::Target for Target {
368374 return Ok ( Some ( s. into ( ) ) ) ;
369375 }
370376
377+ let mut derives = vec ! [ "Serialize" , "Deserialize" ] ;
378+
379+ if let Some ( s) = metadata. get ( "rustCustomDerive" ) . and_then ( |v| v. as_str ( ) ) {
380+ derives. extend ( s. split ( "," ) ) ;
381+ }
382+
371383 state
372384 . imports
373385 . entry ( "serde" . into ( ) )
@@ -376,7 +388,7 @@ impl jtd_codegen::target::Target for Target {
376388
377389 writeln ! ( out) ?;
378390 write ! ( out, "{}" , description( & metadata, 0 ) ) ?;
379- writeln ! ( out, "#[derive(Serialize, Deserialize )]" ) ?;
391+ writeln ! ( out, "#[derive({} )]" , derives . join ( ", " ) ) ?;
380392
381393 if fields. is_empty ( ) {
382394 writeln ! ( out, "pub struct {} {{}}" , name) ?;
0 commit comments