@@ -404,6 +404,64 @@ impl<T> JsonSchemaAs<T> for DisplayFromStr {
404
404
forward_schema ! ( String ) ;
405
405
}
406
406
407
+ #[ cfg( feature = "hex" ) ]
408
+ impl < T > JsonSchemaAs < T > for hex:: Hex < formats:: Lowercase > {
409
+ fn schema_name ( ) -> String {
410
+ "Hex<Lowercase>" . into ( )
411
+ }
412
+
413
+ fn schema_id ( ) -> Cow < ' static , str > {
414
+ "serde_with::hex::Hex<Lowercase>" . into ( )
415
+ }
416
+
417
+ fn json_schema ( _: & mut SchemaGenerator ) -> Schema {
418
+ use :: schemars_0_8:: schema:: StringValidation ;
419
+
420
+ SchemaObject {
421
+ instance_type : Some ( InstanceType :: String . into ( ) ) ,
422
+ string : Some ( Box :: new ( StringValidation {
423
+ pattern : Some ( r"^(?:[0-9a-f]{2})*$" . to_owned ( ) ) ,
424
+ ..Default :: default ( )
425
+ } ) ) ,
426
+ ..Default :: default ( )
427
+ }
428
+ . into ( )
429
+ }
430
+
431
+ fn is_referenceable ( ) -> bool {
432
+ false
433
+ }
434
+ }
435
+
436
+ #[ cfg( feature = "hex" ) ]
437
+ impl < T > JsonSchemaAs < T > for hex:: Hex < formats:: Uppercase > {
438
+ fn schema_name ( ) -> String {
439
+ "Hex<Uppercase>" . into ( )
440
+ }
441
+
442
+ fn schema_id ( ) -> Cow < ' static , str > {
443
+ "serde_with::hex::Hex<Uppercase>" . into ( )
444
+ }
445
+
446
+ fn json_schema ( _: & mut SchemaGenerator ) -> Schema {
447
+ use :: schemars_0_8:: schema:: StringValidation ;
448
+
449
+ SchemaObject {
450
+ instance_type : Some ( InstanceType :: String . into ( ) ) ,
451
+ string : Some ( Box :: new ( StringValidation {
452
+ pattern : Some ( r"^(?:[0-9A-F]{2})*$" . to_owned ( ) ) ,
453
+ ..Default :: default ( )
454
+ } ) ) ,
455
+ ..Default :: default ( )
456
+ }
457
+ . into ( )
458
+ }
459
+
460
+ fn is_referenceable ( ) -> bool {
461
+ false
462
+ }
463
+ }
464
+
407
465
impl JsonSchemaAs < bool > for BoolFromInt < Strict > {
408
466
fn schema_name ( ) -> String {
409
467
"BoolFromInt<Strict>" . into ( )
0 commit comments