@@ -21,12 +21,19 @@ use crate::{
2121// we note that V1 requests are snake cased UNLIKE v2 which are camel cased
2222#[ serde( rename_all = "snake_case" ) ]
2323pub struct VpcLatticeRequestV1 {
24- /// The url path for the request
25- pub raw_path : String ,
24+ /// The url path for the request.
25+ /// Present only if the protocol is HTTP, HTTPS, or gRPC.
26+ #[ serde( default ) ]
27+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
28+ pub raw_path : Option < String > ,
2629
27- /// The HTTP method of the request
28- #[ serde( with = "http_method" ) ]
29- pub method : Method ,
30+ /// The HTTP method of the request.
31+ /// Present only if the protocol is HTTP, HTTPS, or gRPC.
32+ #[ serde( deserialize_with = "http_method::deserialize_optional" ) ]
33+ #[ serde( serialize_with = "http_method::serialize_optional" ) ]
34+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
35+ #[ serde( default ) ]
36+ pub method : Option < Method > ,
3037
3138 /// HTTP headers of the request (V1 uses comma-separated strings for multi-values)
3239 #[ serde( deserialize_with = "deserialize_comma_separated_headers" , default ) ]
@@ -64,8 +71,8 @@ mod test {
6471 let data = include_bytes ! ( "../../fixtures/example-vpc-lattice-v1-request.json" ) ;
6572 let parsed: VpcLatticeRequestV1 = serde_json:: from_slice ( data) . unwrap ( ) ;
6673
67- assert_eq ! ( "/api/product" , parsed. raw_path) ;
68- assert_eq ! ( " POST" , parsed. method) ;
74+ assert_eq ! ( Some ( "/api/product" . to_string ( ) ) , parsed. raw_path) ;
75+ assert_eq ! ( Some ( Method :: POST ) , parsed. method) ;
6976 assert_eq ! (
7077 "curl/7.68.0" ,
7178 parsed. headers. get_all( "user-agent" ) . iter( ) . next( ) . unwrap( )
0 commit comments