|
|
|
@ -2,6 +2,7 @@ |
|
|
|
Test that routes with multiple methods get unique operation IDs. |
|
|
|
This is a regression test for issue #13175. |
|
|
|
""" |
|
|
|
|
|
|
|
import warnings |
|
|
|
|
|
|
|
from fastapi import FastAPI |
|
|
|
@ -25,10 +26,11 @@ def test_multiple_methods_generate_unique_operation_ids(): |
|
|
|
|
|
|
|
# There should be no duplicate operation_id warnings |
|
|
|
dup_warnings = [ |
|
|
|
warning for warning in w |
|
|
|
if "Duplicate Operation ID" in str(warning.message) |
|
|
|
warning for warning in w if "Duplicate Operation ID" in str(warning.message) |
|
|
|
] |
|
|
|
assert len(dup_warnings) == 0, f"Expected no duplicate warnings, got: {dup_warnings}" |
|
|
|
assert len(dup_warnings) == 0, ( |
|
|
|
f"Expected no duplicate warnings, got: {dup_warnings}" |
|
|
|
) |
|
|
|
|
|
|
|
openapi_schema = response.json() |
|
|
|
|
|
|
|
@ -43,8 +45,12 @@ def test_multiple_methods_generate_unique_operation_ids(): |
|
|
|
) |
|
|
|
|
|
|
|
# Verify the operation IDs contain the correct method suffix |
|
|
|
assert post_operation_id.endswith("_post"), f"POST operation_id should end with '_post', got: {post_operation_id}" |
|
|
|
assert delete_operation_id.endswith("_delete"), f"DELETE operation_id should end with '_delete', got: {delete_operation_id}" |
|
|
|
assert post_operation_id.endswith("_post"), ( |
|
|
|
f"POST operation_id should end with '_post', got: {post_operation_id}" |
|
|
|
) |
|
|
|
assert delete_operation_id.endswith("_delete"), ( |
|
|
|
f"DELETE operation_id should end with '_delete', got: {delete_operation_id}" |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|