@@ -386,3 +386,54 @@ def test_generate_services(model_data):
386386 )
387387 for i in result :
388388 compile (i .content , "<string>" , "exec" )
389+
390+
391+ def test_default_tag_and_path_param_injection ():
392+ """Untagged operation should generate default_service and include path placeholder as param."""
393+ from openapi_pydantic .v3 import PathItem
394+
395+ # Minimal GET with no tags and no explicit parameters but a placeholder in path
396+ # Cast responses dict to expected mapping type (Response | Reference)
397+ op = Operation (responses = {k : v for k , v in default_responses .items ()})
398+ paths = {"/items/{itemId}" : PathItem (get = op )}
399+ services = generate_services (paths , library_config_dict [HTTPLibrary .httpx ])
400+ # Find generated sync default service
401+ default_service = [s for s in services if s .file_name == "default_service" ]
402+ assert default_service , "default_service should be generated for untagged operation"
403+ content = default_service [0 ].content
404+ # Operation id will be derived; ensure parameter itemId injected
405+ assert "itemId" in content or "item_id" in content
406+
407+
408+ def test_aiohttp_204_no_json_parsing ():
409+ """204 response should not attempt to parse JSON in aiohttp template."""
410+ from openapi_pydantic .v3 import PathItem
411+
412+ op = Operation (responses = {"204" : Response (description = "No Content" )})
413+ paths = {"/resources/{rid}" : PathItem (delete = op )}
414+ services = generate_services (paths , library_config_dict [HTTPLibrary .aiohttp ])
415+ aio_services = [s for s in services if s .async_client ]
416+ assert aio_services
417+ content = aio_services [0 ].content
418+ # We expect conditional assignment that avoids json parsing when 204
419+ assert "== 204 else" in content
420+ # Should still return None
421+ assert "return None" in content
422+
423+
424+ @pytest .mark .parametrize ("library" , [HTTPLibrary .httpx , HTTPLibrary .requests , HTTPLibrary .aiohttp ])
425+ def test_204_skip_parsing_all_libraries (library ):
426+ """All libraries should skip JSON parsing for a 204 response and just return None."""
427+ from openapi_pydantic .v3 import PathItem
428+
429+ op = Operation (responses = {"204" : Response (description = "No Content" )})
430+ paths = {"/things/{tid}" : PathItem (delete = op )}
431+ services = generate_services (paths , library_config_dict [library ])
432+ # Pick a service that actually has generated operation content
433+ service = next ((s for s in services if s .content .strip ()), services [0 ])
434+ content = service .content
435+ # Ensure no .json() invocation occurs when status_code == 204 within this function body
436+ # Simpler heuristic: our injected early return comment for sync libs or conditional assignment for aiohttp
437+ assert "204 No Content" in content or "== 204 else" in content
438+ # Should contain 'return None'
439+ assert "return None" in content
0 commit comments