@@ -507,9 +507,38 @@ def test_add_parameters_parse_error(self, mocker):
507
507
)
508
508
assert result == (
509
509
ParseError (data = parse_error .data , detail = f"cannot parse parameter of endpoint { endpoint .name } " ),
510
- property_schemas ,
510
+ initial_schemas ,
511
511
)
512
512
513
+ @pytest .mark .parametrize (
514
+ "data_type, allowed" ,
515
+ [
516
+ (oai .DataType .STRING , True ),
517
+ (oai .DataType .INTEGER , True ),
518
+ (oai .DataType .NUMBER , True ),
519
+ (oai .DataType .BOOLEAN , True ),
520
+ (oai .DataType .ARRAY , False ),
521
+ (oai .DataType .OBJECT , False ),
522
+ ],
523
+ )
524
+ def test_add_parameters_header_types (self , data_type , allowed ):
525
+ from openapi_python_client .parser .openapi import Endpoint
526
+
527
+ endpoint = self .make_endpoint ()
528
+ initial_schemas = Schemas ()
529
+ param = oai .Parameter .construct (
530
+ name = "test" , required = True , param_schema = oai .Schema (type = data_type ), param_in = oai .ParameterLocation .HEADER
531
+ )
532
+ config = Config ()
533
+
534
+ result = Endpoint .add_parameters (
535
+ endpoint = endpoint , data = oai .Operation .construct (parameters = [param ]), schemas = initial_schemas , config = config
536
+ )
537
+ if allowed :
538
+ assert isinstance (result [0 ], Endpoint )
539
+ else :
540
+ assert isinstance (result [0 ], ParseError )
541
+
513
542
def test__add_parameters_parse_error_on_non_required_path_param (self ):
514
543
endpoint = self .make_endpoint ()
515
544
param = oai .Parameter .construct (
@@ -534,13 +563,12 @@ def test_validation_error_when_location_not_supported(self, mocker):
534
563
def test__add_parameters_with_location_postfix_conflict1 (self , mocker , property_factory ):
535
564
"""Checks when the PythonIdentifier of new parameter already used."""
536
565
from openapi_python_client .parser .openapi import Endpoint
537
- from openapi_python_client .parser .properties import Property
538
566
539
567
endpoint = self .make_endpoint ()
540
568
541
- path_prop_conflicted = property_factory (name = "prop_name_path" , required = False , nullable = False , default = None )
542
- query_prop = property_factory (name = "prop_name" , required = False , nullable = False , default = None )
543
- path_prop = property_factory (name = "prop_name" , required = False , nullable = False , default = None )
569
+ path_prop_conflicted = property_factory (name = "prop_name_path" , required = True , nullable = False , default = None )
570
+ query_prop = property_factory (name = "prop_name" , required = True , nullable = False , default = None )
571
+ path_prop = property_factory (name = "prop_name" , required = True , nullable = False , default = None )
544
572
545
573
schemas_1 = mocker .MagicMock ()
546
574
schemas_2 = mocker .MagicMock ()
@@ -582,9 +610,9 @@ def test__add_parameters_with_location_postfix_conflict2(self, mocker, property_
582
610
from openapi_python_client .parser .openapi import Endpoint
583
611
584
612
endpoint = self .make_endpoint ()
585
- path_prop_conflicted = property_factory (name = "prop_name_path" , required = False , nullable = False , default = None )
586
- path_prop = property_factory (name = "prop_name" , required = False , nullable = False , default = None )
587
- query_prop = property_factory (name = "prop_name" , required = False , nullable = False , default = None )
613
+ path_prop_conflicted = property_factory (name = "prop_name_path" , required = True , nullable = False , default = None )
614
+ path_prop = property_factory (name = "prop_name" , required = True , nullable = False , default = None )
615
+ query_prop = property_factory (name = "prop_name" , required = True , nullable = False , default = None )
588
616
schemas_1 = mocker .MagicMock ()
589
617
schemas_2 = mocker .MagicMock ()
590
618
schemas_3 = mocker .MagicMock ()
0 commit comments