Skip to content

[Daxia] [ FastAPI ] Fix duplicate operation IDs across routers#7232

Closed
daxia778 wants to merge 1 commit into
UnsafeLabs:mainfrom
daxia778:daxia/fastapi-operation-ids-764
Closed

[Daxia] [ FastAPI ] Fix duplicate operation IDs across routers#7232
daxia778 wants to merge 1 commit into
UnsafeLabs:mainfrom
daxia778:daxia/fastapi-operation-ids-764

Conversation

@daxia778

@daxia778 daxia778 commented Jun 26, 2026

Copy link
Copy Markdown

/claim #764

Summary

  • Generate default FastAPI operation IDs as method + route path/prefix + function name.
  • Sanitize generated IDs to lowercase ASCII alphanumeric characters and underscores.
  • Generate method-specific OpenAPI IDs for multi-method routes.
  • Add numeric suffixes for generated operation ID collisions after sanitization.

Demo

https://github.com/daxia778/Bounty-Hunters/releases/download/issue-764-demo-f3b13904/fastapi-operation-id-764-demo-f3b13904.mp4

Validation

  • UV_PYTHON=<Python 3.12> uv run ruff check fastapi/utils.py fastapi/openapi/utils.py tests/test_operation_id_generation.py
  • UV_PYTHON=<Python 3.12> uv run ruff format --check fastapi/utils.py fastapi/openapi/utils.py tests/test_operation_id_generation.py
  • UV_PYTHON=<Python 3.12> uv run python -m pytest tests/test_generate_unique_id_function.py tests/test_operation_id_generation.py -q
  • git diff --check

@github-actions

Copy link
Copy Markdown
Contributor

Unfortunately the changes in this PR didn't fully resolve the issue. Please rework your solution and submit a new pull request.

Make sure to review the acceptance criteria in the linked issue and verify all conditions are met before resubmitting. See CONTRIBUTING.md for guidelines.

@github-actions github-actions Bot closed this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant