@@ -48,6 +48,9 @@ pub struct RawResourceTemplate {
4848 pub description : Option < String > ,
4949 #[ serde( skip_serializing_if = "Option::is_none" ) ]
5050 pub mime_type : Option < String > ,
51+ /// Optional list of icons for the resource template
52+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
53+ pub icons : Option < Vec < Icon > > ,
5154}
5255
5356pub type ResourceTemplate = Annotated < RawResourceTemplate > ;
@@ -146,4 +149,40 @@ mod tests {
146149 assert ! ( json. contains( "mimeType" ) ) ;
147150 assert ! ( !json. contains( "mime_type" ) ) ;
148151 }
152+
153+ #[ test]
154+ fn test_resource_template_with_icons ( ) {
155+ let resource_template = RawResourceTemplate {
156+ uri_template : "file:///{path}" . to_string ( ) ,
157+ name : "template" . to_string ( ) ,
158+ title : Some ( "Test Template" . to_string ( ) ) ,
159+ description : Some ( "A test resource template" . to_string ( ) ) ,
160+ mime_type : Some ( "text/plain" . to_string ( ) ) ,
161+ icons : Some ( vec ! [ Icon {
162+ src: "https://example.com/icon.png" . to_string( ) ,
163+ mime_type: Some ( "image/png" . to_string( ) ) ,
164+ sizes: Some ( vec![ "48x48" . to_string( ) ] ) ,
165+ } ] ) ,
166+ } ;
167+
168+ let json = serde_json:: to_value ( & resource_template) . unwrap ( ) ;
169+ assert ! ( json[ "icons" ] . is_array( ) ) ;
170+ assert_eq ! ( json[ "icons" ] [ 0 ] [ "src" ] , "https://example.com/icon.png" ) ;
171+ assert_eq ! ( json[ "icons" ] [ 0 ] [ "sizes" ] [ 0 ] , "48x48" ) ;
172+ }
173+
174+ #[ test]
175+ fn test_resource_template_without_icons ( ) {
176+ let resource_template = RawResourceTemplate {
177+ uri_template : "file:///{path}" . to_string ( ) ,
178+ name : "template" . to_string ( ) ,
179+ title : None ,
180+ description : None ,
181+ mime_type : None ,
182+ icons : None ,
183+ } ;
184+
185+ let json = serde_json:: to_value ( & resource_template) . unwrap ( ) ;
186+ assert ! ( json. get( "icons" ) . is_none( ) ) ;
187+ }
149188}
0 commit comments