@@ -419,3 +419,89 @@ def test_parameter_default_value_with_reference(self, validator_v30):
419
419
420
420
errors_list = list (errors )
421
421
assert errors_list == []
422
+
423
+ def test_parameter_custom_format_checker_not_found (self , validator_v30 ):
424
+ spec = {
425
+ "openapi" : "3.0.0" ,
426
+ "info" : {
427
+ "title" : "Test Api" ,
428
+ "version" : "0.0.1" ,
429
+ },
430
+ "paths" : {
431
+ "/test/" : {
432
+ "get" : {
433
+ "responses" : {
434
+ "default" : {
435
+ "description" : "default response" ,
436
+ },
437
+ },
438
+ "parameters" : [
439
+ {
440
+ "name" : "param1" ,
441
+ "in" : "query" ,
442
+ "schema" : {
443
+ "type" : "string" ,
444
+ "format" : "custom" ,
445
+ "default" : "customvalue" ,
446
+ },
447
+ },
448
+ ],
449
+ },
450
+ },
451
+ },
452
+ }
453
+
454
+ errors = validator_v30 .iter_errors (spec )
455
+
456
+ errors_list = list (errors )
457
+ assert len (errors_list ) == 1
458
+ assert errors_list [0 ].__class__ == OpenAPIValidationError
459
+ assert errors_list [0 ].message == (
460
+ "Format checker for 'custom' format not found"
461
+ )
462
+
463
+ def test_parameter_default_value_custom_format_invalid (self , validator_v30 ):
464
+ from openapi_schema_validator import oas30_format_checker
465
+
466
+ @oas30_format_checker .checks ("custom" )
467
+ def validate (to_validate ) -> bool :
468
+ return to_validate is "valid"
469
+
470
+ spec = {
471
+ "openapi" : "3.0.0" ,
472
+ "info" : {
473
+ "title" : "Test Api" ,
474
+ "version" : "0.0.1" ,
475
+ },
476
+ "paths" : {
477
+ "/test/" : {
478
+ "get" : {
479
+ "responses" : {
480
+ "default" : {
481
+ "description" : "default response" ,
482
+ },
483
+ },
484
+ "parameters" : [
485
+ {
486
+ "name" : "param1" ,
487
+ "in" : "query" ,
488
+ "schema" : {
489
+ "type" : "string" ,
490
+ "format" : "custom" ,
491
+ "default" : "invalid" ,
492
+ },
493
+ },
494
+ ],
495
+ },
496
+ },
497
+ },
498
+ }
499
+
500
+ errors = validator_v30 .iter_errors (spec )
501
+
502
+ errors_list = list (errors )
503
+ assert len (errors_list ) == 1
504
+ assert errors_list [0 ].__class__ == OpenAPIValidationError
505
+ assert errors_list [0 ].message == (
506
+ "'invalid' is not a 'custom'"
507
+ )
0 commit comments