@@ -358,7 +358,59 @@ def test_generate_services(model_data):
358358 result = generate_services (model_data .paths , library_config_dict [HTTPLibrary .httpx ])
359359 for i in result :
360360 compile (i .content , "<string>" , "exec" )
361+ result2 = generate_services (model_data .paths , library_config_dict [HTTPLibrary .requests ])
362+ for i in result2 :
363+ compile (i .content , "<string>" , "exec" )
361364
362- result = generate_services (model_data .paths , library_config_dict [HTTPLibrary .requests ])
363- for i in result :
364- compile (i .content , "<string>" , "exec" )
365+
366+ def test_generate_body_param_missing_type_object_like ():
367+ """Schema with properties but no explicit type should not raise and returns 'data'."""
368+ op = Operation (
369+ responses = default_responses , # type: ignore[arg-type]
370+ requestBody = RequestBody (
371+ content = {
372+ "application/json" : MediaType (
373+ media_type_schema = Schema (properties = {"a" : Schema (type = DataType .STRING )}) # type: ignore[arg-type]
374+ )
375+ }
376+ ),
377+ )
378+ assert generate_body_param (op ) == "data"
379+
380+
381+ def test_generate_body_param_array_primitive ():
382+ op = Operation (
383+ responses = default_responses , # type: ignore[arg-type]
384+ requestBody = RequestBody (
385+ content = {
386+ "application/json" : MediaType (
387+ media_type_schema = Schema (type = DataType .ARRAY , items = Schema (type = DataType .STRING )) # type: ignore[arg-type]
388+ )
389+ }
390+ ),
391+ )
392+ assert generate_body_param (op ) == "data"
393+
394+
395+ def test_generate_body_param_array_object_like ():
396+ op = Operation (
397+ responses = default_responses , # type: ignore[arg-type]
398+ requestBody = RequestBody (
399+ content = {
400+ "application/json" : MediaType (
401+ media_type_schema = Schema (
402+ type = DataType .ARRAY ,
403+ items = Schema (type = DataType .OBJECT , properties = {"a" : Schema (type = DataType .STRING )}), # type: ignore[arg-type]
404+ )
405+ )
406+ }
407+ ),
408+ )
409+ assert generate_body_param (op ) == "[i.dict() for i in data]"
410+
411+
412+ def test_generate_operation_id_path_param_separator ():
413+ path_name = "/lists/{listId}"
414+ op = Operation (responses = default_responses , operationId = None ) # type: ignore[arg-type]
415+ op_id = generate_operation_id (op , "get" , path_name )
416+ assert op_id == "get_lists_listId"
0 commit comments