Skip to content

Commit 96af06d

Browse files
Copilotks6088ts
andcommitted
Complete router refactoring: apply explicit prefix pattern to foodies and speeches routers
Co-authored-by: ks6088ts <[email protected]>
1 parent d75dd72 commit 96af06d

File tree

3 files changed

+37
-28
lines changed

3 files changed

+37
-28
lines changed

template_fastapi/app.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,30 @@ def server_request_hook(span: Span, scope: dict):
5050
)
5151
app.include_router(demos.router)
5252
app.include_router(games.router)
53-
app.include_router(foodies.router)
53+
app.include_router(
54+
router=foodies.router,
55+
prefix="/foodies",
56+
tags=[
57+
"foodies",
58+
],
59+
responses={
60+
404: {
61+
"description": "Not found",
62+
},
63+
},
64+
)
5465
app.include_router(files.router)
55-
app.include_router(speeches.router)
66+
app.include_router(
67+
router=speeches.router,
68+
prefix="/speeches",
69+
tags=[
70+
"speeches",
71+
],
72+
responses={
73+
404: {
74+
"description": "Not found",
75+
},
76+
},
77+
)
5678
app.include_router(chats.router)
5779
app.include_router(agents.router)

template_fastapi/routers/foodies.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

99

1010
@router.get(
11-
"/foodies/restaurants/",
11+
"/restaurants/",
1212
response_model=list[Restaurant],
13-
tags=["foodies"],
1413
operation_id="list_foodies_restaurants",
1514
)
1615
async def list_foodies_restaurants(
@@ -27,9 +26,8 @@ async def list_foodies_restaurants(
2726

2827

2928
@router.get(
30-
"/foodies/restaurants/{restaurant_id}",
29+
"/restaurants/{restaurant_id}",
3130
response_model=Restaurant,
32-
tags=["foodies"],
3331
operation_id="get_foodies_restaurant",
3432
)
3533
async def get_foodies_restaurant(restaurant_id: str) -> Restaurant:
@@ -43,9 +41,8 @@ async def get_foodies_restaurant(restaurant_id: str) -> Restaurant:
4341

4442

4543
@router.post(
46-
"/foodies/restaurants/",
44+
"/restaurants/",
4745
response_model=Restaurant,
48-
tags=["foodies"],
4946
operation_id="create_foodies_restaurant",
5047
)
5148
async def create_foodies_restaurant(restaurant: Restaurant) -> Restaurant:
@@ -59,9 +56,8 @@ async def create_foodies_restaurant(restaurant: Restaurant) -> Restaurant:
5956

6057

6158
@router.put(
62-
"/foodies/restaurants/{restaurant_id}",
59+
"/restaurants/{restaurant_id}",
6360
response_model=Restaurant,
64-
tags=["foodies"],
6561
operation_id="update_foodies_restaurant",
6662
)
6763
async def update_foodies_restaurant(restaurant_id: str, restaurant: Restaurant) -> Restaurant:
@@ -82,8 +78,7 @@ async def update_foodies_restaurant(restaurant_id: str, restaurant: Restaurant)
8278

8379

8480
@router.delete(
85-
"/foodies/restaurants/{restaurant_id}",
86-
tags=["foodies"],
81+
"/restaurants/{restaurant_id}",
8782
operation_id="delete_foodies_restaurant",
8883
)
8984
async def delete_foodies_restaurant(restaurant_id: str) -> dict:
@@ -98,9 +93,8 @@ async def delete_foodies_restaurant(restaurant_id: str) -> dict:
9893

9994

10095
@router.get(
101-
"/foodies/restaurants/search/",
96+
"/restaurants/search/",
10297
response_model=list[Restaurant],
103-
tags=["foodies"],
10498
operation_id="search_foodies_restaurants",
10599
)
106100
async def search_foodies_restaurants(
@@ -118,9 +112,8 @@ async def search_foodies_restaurants(
118112

119113

120114
@router.get(
121-
"/foodies/restaurants/near/",
115+
"/restaurants/near/",
122116
response_model=list[Restaurant],
123-
tags=["foodies"],
124117
operation_id="find_nearby_restaurants",
125118
)
126119
async def find_nearby_restaurants(

template_fastapi/routers/speeches.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515

1616

1717
@router.post(
18-
"/speeches/transcriptions/",
18+
"/transcriptions/",
1919
response_model=BatchTranscriptionResponse,
20-
tags=["speeches"],
2120
operation_id="create_transcription_job",
2221
)
2322
async def create_transcription_job(request: BatchTranscriptionRequest) -> BatchTranscriptionResponse:
@@ -31,9 +30,8 @@ async def create_transcription_job(request: BatchTranscriptionRequest) -> BatchT
3130

3231

3332
@router.get(
34-
"/speeches/transcriptions/{job_id}",
33+
"/transcriptions/{job_id}",
3534
response_model=TranscriptionJob,
36-
tags=["speeches"],
3735
operation_id="get_transcription_job",
3836
)
3937
async def get_transcription_job(job_id: str) -> TranscriptionJob:
@@ -47,9 +45,8 @@ async def get_transcription_job(job_id: str) -> TranscriptionJob:
4745

4846

4947
@router.get(
50-
"/speeches/transcriptions/{job_id}/files",
48+
"/transcriptions/{job_id}/files",
5149
response_model=list[dict[str, Any]],
52-
tags=["speeches"],
5350
operation_id="get_transcription_files",
5451
)
5552
async def get_transcription_files(job_id: str) -> list[dict[str, Any]]:
@@ -63,9 +60,8 @@ async def get_transcription_files(job_id: str) -> list[dict[str, Any]]:
6360

6461

6562
@router.get(
66-
"/speeches/transcriptions/{job_id}/result",
63+
"/transcriptions/{job_id}/result",
6764
response_model=TranscriptionContent,
68-
tags=["speeches"],
6965
operation_id="get_transcription_result",
7066
)
7167
async def get_transcription_result(
@@ -81,8 +77,7 @@ async def get_transcription_result(
8177

8278

8379
@router.delete(
84-
"/speeches/transcriptions/{job_id}",
85-
tags=["speeches"],
80+
"/transcriptions/{job_id}",
8681
operation_id="delete_transcription_job",
8782
)
8883
async def delete_transcription_job(job_id: str) -> dict:
@@ -100,9 +95,8 @@ async def delete_transcription_job(job_id: str) -> dict:
10095

10196

10297
@router.get(
103-
"/speeches/transcriptions/",
98+
"/transcriptions/",
10499
response_model=list[TranscriptionJob],
105-
tags=["speeches"],
106100
operation_id="list_transcription_jobs",
107101
)
108102
async def list_transcription_jobs() -> list[TranscriptionJob]:

0 commit comments

Comments
 (0)