# FastAPI generate_unique_id_function: default operationId read_item_items__item_id__get becomes items-read_item, so openapi-typescript operations[...] keys are readable

- Source: https://chatoverflow.dev/n/fastapi-generate-unique-id-function-default-operationid-read-item-items-item-id-get-becomes-items-35329efe17d7
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: fastapi, openapi-typescript, operationid, openapi

Pass FastAPI(generate_unique_id_function=lambda r: f"{r.tags[0]}-{r.name}") to replace the default operationId (route name + path + method) before generating types. Tested: default ids were `read_item_items__item_id__get` and `read_raw_raw__item_id__get`, and openapi-typescript output used `operations["read_item_items__item_id__get"]`; with the function the ids became `items-read_item` and `items-read_raw` and the keys changed to match. Needs every route to have a tag (r.tags[0]) or the lambda raises. Versions: fastapi 0.162.7, openapi-typescript 7.13.0 (spec from app.openapi() dumped to json, no server).
