@@ -59,79 +59,77 @@ impl ValidateRequest for RequestData {
5959 . get ( self . path . as_str ( ) )
6060 . context ( "Path not found" ) ?;
6161
62- let path_base = path
63- . get ( & Method :: Get )
64- . context ( "GET method not defined for this path" ) ?;
65-
66- let query_str = self . inner . uri ( ) . query ( ) . unwrap_or_default ( ) ;
67- let query_pairs: HashMap < _ , _ > = url:: form_urlencoded:: parse ( query_str. as_bytes ( ) )
68- . into_owned ( )
69- . collect ( ) ;
62+ if let Some ( path_base) = path. get ( & Method :: Get ) {
63+ let query_str = self . inner . uri ( ) . query ( ) . unwrap_or_default ( ) ;
64+ let query_pairs: HashMap < _ , _ > = url:: form_urlencoded:: parse ( query_str. as_bytes ( ) )
65+ . into_owned ( )
66+ . collect ( ) ;
7067
71- let mut requireds: HashSet < String > = HashSet :: new ( ) ;
68+ let mut requireds: HashSet < String > = HashSet :: new ( ) ;
7269
73- if let Some ( parameters) = & path_base. parameters {
74- for parameter in parameters {
75- if parameter. _in != In :: Query {
76- continue ;
77- }
70+ if let Some ( parameters) = & path_base. parameters {
71+ for parameter in parameters {
72+ if parameter. _in != In :: Query {
73+ continue ;
74+ }
7875
79- if let Some ( value) = query_pairs. get ( & parameter. name ) {
80- validate_field_format (
81- & parameter. name ,
82- & Value :: from ( value. as_str ( ) ) ,
83- parameter. schema . format . clone ( ) ,
84- ) ?;
85- }
76+ if let Some ( value) = query_pairs. get ( & parameter. name ) {
77+ validate_field_format (
78+ & parameter. name ,
79+ & Value :: from ( value. as_str ( ) ) ,
80+ parameter. schema . format . clone ( ) ,
81+ ) ?;
82+ }
8683
87- let mut refs = Vec :: new ( ) ;
88- if let Some ( r) = & parameter. schema . _ref {
89- refs. push ( r. as_str ( ) ) ;
90- }
91- if let Some ( one_of) = & parameter. schema . one_of {
92- for s in one_of {
93- if let Some ( r) = & s. _ref {
94- refs. push ( r. as_str ( ) ) ;
84+ let mut refs = Vec :: new ( ) ;
85+ if let Some ( r) = & parameter. schema . _ref {
86+ refs. push ( r. as_str ( ) ) ;
87+ }
88+ if let Some ( one_of) = & parameter. schema . one_of {
89+ for s in one_of {
90+ if let Some ( r) = & s. _ref {
91+ refs. push ( r. as_str ( ) ) ;
92+ }
9593 }
9694 }
97- }
98- if let Some ( all_of ) = & parameter . schema . all_of {
99- for s in all_of {
100- if let Some ( r ) = & s . _ref {
101- refs . push ( r . as_str ( ) ) ;
95+ if let Some ( all_of ) = & parameter . schema . all_of {
96+ for s in all_of {
97+ if let Some ( r ) = & s . _ref {
98+ refs . push ( r . as_str ( ) ) ;
99+ }
102100 }
103101 }
104- }
105102
106- for schema_ref in refs {
107- if let Some ( components) = & open_api. components {
108- if let Some ( schema) = components. schemas . get ( schema_ref) {
109- if !schema. required . is_empty ( ) {
110- requireds. extend ( schema. required . clone ( ) ) ;
111- }
112- if let Some ( properties) = & schema. properties {
113- for ( key, prop) in properties {
114- if let Some ( value) = query_pairs. get ( key) {
115- validate_field_format (
116- key,
117- & Value :: from ( value. as_str ( ) ) ,
118- prop. format . clone ( ) ,
119- ) ?;
103+ for schema_ref in refs {
104+ if let Some ( components) = & open_api. components {
105+ if let Some ( schema) = components. schemas . get ( schema_ref) {
106+ if !schema. required . is_empty ( ) {
107+ requireds. extend ( schema. required . clone ( ) ) ;
108+ }
109+ if let Some ( properties) = & schema. properties {
110+ for ( key, prop) in properties {
111+ if let Some ( value) = query_pairs. get ( key) {
112+ validate_field_format (
113+ key,
114+ & Value :: from ( value. as_str ( ) ) ,
115+ prop. format . clone ( ) ,
116+ ) ?;
117+ }
120118 }
121119 }
122120 }
123121 }
124122 }
125123 }
126124 }
127- }
128125
129- for key in & requireds {
130- if !query_pairs. contains_key ( key) {
131- return Err ( anyhow:: anyhow!(
132- "Missing required query parameter: '{}'" ,
133- key
134- ) ) ;
126+ for key in & requireds {
127+ if !query_pairs. contains_key ( key) {
128+ return Err ( anyhow:: anyhow!(
129+ "Missing required query parameter: '{}'" ,
130+ key
131+ ) ) ;
132+ }
135133 }
136134 }
137135
0 commit comments