@@ -235,7 +235,7 @@ def test_get_pet(self, validator):
235
235
class TestPathItemParamsValidator (object ):
236
236
237
237
@pytest .fixture
238
- def spec_dict (self , factory ):
238
+ def spec_dict (self ):
239
239
return {
240
240
"openapi" : "3.0.0" ,
241
241
"info" : {
@@ -305,6 +305,49 @@ def test_request_valid_param(self, validator):
305
305
assert result .body is None
306
306
assert result .parameters == {'query' : {'resId' : 10 }}
307
307
308
+ @pytest .mark .xfail
309
+ def test_request_override_param (self , spec_dict ):
310
+ # override parameter path parameter on operation (name and in property must match)
311
+ spec_dict ["paths" ]["/resource" ]["get" ]["parameters" ] = [
312
+ {
313
+ # full valid parameter object required
314
+ "name" : "resId" ,
315
+ "in" : "query" ,
316
+ "required" : False ,
317
+ "schema" : {
318
+ "type" : "integer" ,
319
+ },
320
+ }
321
+ ]
322
+ validator = RequestValidator (create_spec (spec_dict ))
323
+ request = MockRequest ('http://example.com' , 'get' , '/resource' )
324
+ result = validator .validate (request )
325
+
326
+ assert len (result .errors ) == 0
327
+ assert result .body is None
328
+ assert result .parameters == {}
329
+
330
+ @pytest .mark .xfail
331
+ def test_request_override_invalid_param (self , spec_dict ):
332
+ # override parameter path parameter on operation
333
+ # This here should result in an invalid spec object, because there are
334
+ # now two parameters with the same name, but different location.
335
+ # (The openapi3 spec is also not very explicit about this case)
336
+ spec_dict ["paths" ]["/resource" ]["get" ]["parameters" ] = [
337
+ {
338
+ # full valid parameter object required
339
+ "name" : "resId" ,
340
+ "in" : "path" ,
341
+ "required" : False ,
342
+ "schema" : {
343
+ "type" : "integer" ,
344
+ },
345
+ }
346
+ ]
347
+ from openapi_spec_validator .exceptions import OpenAPIValidationError
348
+ with pytest .raises (OpenAPIValidationError ):
349
+ spec = create_spec (spec_dict )
350
+
308
351
309
352
class TestResponseValidator (object ):
310
353
0 commit comments