@@ -650,22 +650,29 @@ mod serde_impl {
650650 #[ cfg( feature = "schema" ) ]
651651 mod schema {
652652 use super :: * ;
653- use alloc :: borrow :: Cow ;
653+ use schemars :: schema :: { InstanceType , SchemaObject } ;
654654 use schemars:: JsonSchema ;
655655
656656 // we cannot use attributes, because the do not work with `const`, only numeric literals supported
657657 impl < T : JsonSchema , const L : usize , const U : usize > JsonSchema for BoundedVec < T , L , U > {
658- fn schema_name ( ) -> Cow < ' static , str > {
659- alloc:: format!( "BoundedVec{}Min{}Max{}" , T :: schema_name( ) , L , U ) . into ( )
658+ fn schema_name ( ) -> alloc :: string :: String {
659+ alloc:: format!( "BoundedVec{}Min{}Max{}" , T :: schema_name( ) , L , U )
660660 }
661661
662- fn json_schema ( gen : & mut schemars:: SchemaGenerator ) -> schemars:: Schema {
663- schemars:: json_schema!( {
664- "type" : "array" ,
665- "items" : T :: json_schema( gen ) ,
666- "minItems" : L as u32 ,
667- "maxItems" : L as u32
668- } )
662+ fn json_schema ( gen : & mut schemars:: gen:: SchemaGenerator ) -> schemars:: schema:: Schema {
663+ SchemaObject {
664+ instance_type : Some ( InstanceType :: Array . into ( ) ) ,
665+ array : Some ( alloc:: boxed:: Box :: new ( schemars:: schema:: ArrayValidation {
666+ items : Some ( schemars:: schema:: SingleOrVec :: Single (
667+ T :: json_schema ( gen) . into ( ) ,
668+ ) ) ,
669+ min_items : Some ( L as u32 ) ,
670+ max_items : Some ( U as u32 ) ,
671+ ..Default :: default ( )
672+ } ) ) ,
673+ ..Default :: default ( )
674+ }
675+ . into ( )
669676 }
670677 }
671678 }
0 commit comments