@@ -100,15 +100,21 @@ impl HttpAuthPlace {
100100 fn from_value ( input : & Value ) -> Result < Option < HttpAuthPlace > , String > {
101101 match input. kind . as_ref ( ) {
102102 Some ( Kind :: NullValue ( _) ) | None => Ok ( None ) ,
103- Some ( Kind :: StringValue ( value) ) => match value. as_str ( ) {
104- "Header" => Ok ( Some ( HttpAuthPlace :: Header ) ) ,
105- "Url" => Ok ( Some ( HttpAuthPlace :: Url ) ) ,
106- "undefined" | "" => Ok ( None ) ,
107- other => Err ( format ! (
108- "Auth Placement must be 'Header', 'Url', or undefined, got '{}'" ,
109- other
110- ) ) ,
111- } ,
103+ Some ( Kind :: StringValue ( value) ) => {
104+ if value. eq_ignore_ascii_case ( "header" ) {
105+ Ok ( Some ( HttpAuthPlace :: Header ) )
106+ } else if value. eq_ignore_ascii_case ( "url" ) {
107+ Ok ( Some ( HttpAuthPlace :: Url ) )
108+ } else {
109+ match value. as_str ( ) {
110+ "undefined" | "" => Ok ( None ) ,
111+ other => Err ( format ! (
112+ "Auth Placement must be 'Header', 'Url', or undefined, got '{}'" ,
113+ other
114+ ) ) ,
115+ }
116+ }
117+ }
112118 _ => Err ( "Auth Placement must be a string or undefined" . to_string ( ) ) ,
113119 }
114120 }
@@ -698,6 +704,18 @@ mod tests {
698704 ) ;
699705 }
700706
707+ #[ test]
708+ fn auth_place_parses_values_case_insensitively ( ) {
709+ assert_eq ! (
710+ HttpAuthPlace :: from_value( & string_value( "header" ) ) ,
711+ Ok ( Some ( HttpAuthPlace :: Header ) )
712+ ) ;
713+ assert_eq ! (
714+ HttpAuthPlace :: from_value( & string_value( "url" ) ) ,
715+ Ok ( Some ( HttpAuthPlace :: Url ) )
716+ ) ;
717+ }
718+
701719 #[ test]
702720 fn encode_headers_rejects_null_values ( ) {
703721 let headers = Struct {
0 commit comments