Skip to content

Commit 796a568

Browse files
authored
utoipa: Rename route handler fns to remove operation_id attributes (#10207)
... and unify some of the differing naming patterns.
1 parent 31e2ae1 commit 796a568

26 files changed

+157
-156
lines changed

src/controllers/category.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ use http::request::Parts;
1616
#[utoipa::path(
1717
get,
1818
path = "/api/v1/categories",
19-
operation_id = "list_categories",
2019
tag = "categories",
2120
responses((status = 200, description = "Successful Response")),
2221
)]
23-
pub async fn index(app: AppState, req: Parts) -> AppResult<ErasedJson> {
22+
pub async fn list_categories(app: AppState, req: Parts) -> AppResult<ErasedJson> {
2423
// FIXME: There are 69 categories, 47 top level. This isn't going to
2524
// grow by an OoM. We need a limit for /summary, but we don't need
2625
// to paginate this.
@@ -52,11 +51,10 @@ pub async fn index(app: AppState, req: Parts) -> AppResult<ErasedJson> {
5251
#[utoipa::path(
5352
get,
5453
path = "/api/v1/categories/{category}",
55-
operation_id = "get_category",
5654
tag = "categories",
5755
responses((status = 200, description = "Successful Response")),
5856
)]
59-
pub async fn show(state: AppState, Path(slug): Path<String>) -> AppResult<ErasedJson> {
57+
pub async fn find_category(state: AppState, Path(slug): Path<String>) -> AppResult<ErasedJson> {
6058
let mut conn = state.db_read().await?;
6159

6260
let cat: Category = Category::by_slug(&slug).first(&mut conn).await?;
@@ -92,11 +90,10 @@ pub async fn show(state: AppState, Path(slug): Path<String>) -> AppResult<Erased
9290
#[utoipa::path(
9391
get,
9492
path = "/api/v1/category_slugs",
95-
operation_id = "list_category_slugs",
9693
tag = "categories",
9794
responses((status = 200, description = "Successful Response")),
9895
)]
99-
pub async fn slugs(state: AppState) -> AppResult<ErasedJson> {
96+
pub async fn list_category_slugs(state: AppState) -> AppResult<ErasedJson> {
10097
let mut conn = state.db_read().await?;
10198

10299
let slugs: Vec<Slug> = categories::table

src/controllers/crate_owner_invitation.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ use std::collections::{HashMap, HashSet};
2727
#[utoipa::path(
2828
get,
2929
path = "/api/v1/me/crate_owner_invitations",
30-
operation_id = "list_crate_owner_invitations_for_user",
3130
tag = "owners",
3231
responses((status = 200, description = "Successful Response")),
3332
)]
34-
pub async fn list(app: AppState, req: Parts) -> AppResult<ErasedJson> {
33+
pub async fn list_crate_owner_invitations_for_user(
34+
app: AppState,
35+
req: Parts,
36+
) -> AppResult<ErasedJson> {
3537
let mut conn = app.db_read().await?;
3638
let auth = AuthCheck::only_cookie().check(&req, &mut conn).await?;
3739

@@ -72,11 +74,13 @@ pub async fn list(app: AppState, req: Parts) -> AppResult<ErasedJson> {
7274
#[utoipa::path(
7375
get,
7476
path = "/api/private/crate_owner_invitations",
75-
operation_id = "list_crate_owner_invitations",
7677
tag = "owners",
7778
responses((status = 200, description = "Successful Response")),
7879
)]
79-
pub async fn private_list(app: AppState, req: Parts) -> AppResult<Json<PrivateListResponse>> {
80+
pub async fn list_crate_owner_invitations(
81+
app: AppState,
82+
req: Parts,
83+
) -> AppResult<Json<PrivateListResponse>> {
8084
let mut conn = app.db_read().await?;
8185
let auth = AuthCheck::only_cookie().check(&req, &mut conn).await?;
8286

@@ -283,11 +287,13 @@ struct OwnerInvitation {
283287
#[utoipa::path(
284288
put,
285289
path = "/api/v1/me/crate_owner_invitations/{crate_id}",
286-
operation_id = "handle_crate_owner_invitation",
287290
tag = "owners",
288291
responses((status = 200, description = "Successful Response")),
289292
)]
290-
pub async fn handle_invite(state: AppState, req: BytesRequest) -> AppResult<ErasedJson> {
293+
pub async fn handle_crate_owner_invitation(
294+
state: AppState,
295+
req: BytesRequest,
296+
) -> AppResult<ErasedJson> {
291297
let (parts, body) = req.0.into_parts();
292298

293299
let crate_invite: OwnerInvitation =
@@ -318,11 +324,10 @@ pub async fn handle_invite(state: AppState, req: BytesRequest) -> AppResult<Eras
318324
#[utoipa::path(
319325
put,
320326
path = "/api/v1/me/crate_owner_invitations/accept/{token}",
321-
operation_id = "accept_crate_owner_invitation_with_token",
322327
tag = "owners",
323328
responses((status = 200, description = "Successful Response")),
324329
)]
325-
pub async fn handle_invite_with_token(
330+
pub async fn accept_crate_owner_invitation_with_token(
326331
state: AppState,
327332
Path(token): Path<String>,
328333
) -> AppResult<ErasedJson> {

src/controllers/keyword.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ pub struct IndexQuery {
1919
#[utoipa::path(
2020
get,
2121
path = "/api/v1/keywords",
22-
operation_id = "list_keywords",
2322
tag = "keywords",
2423
responses((status = 200, description = "Successful Response")),
2524
)]
26-
pub async fn index(state: AppState, qp: Query<IndexQuery>, req: Parts) -> AppResult<ErasedJson> {
25+
pub async fn list_keywords(
26+
state: AppState,
27+
qp: Query<IndexQuery>,
28+
req: Parts,
29+
) -> AppResult<ErasedJson> {
2730
use crate::schema::keywords;
2831

2932
let mut query = keywords::table.into_boxed();
@@ -53,11 +56,10 @@ pub async fn index(state: AppState, qp: Query<IndexQuery>, req: Parts) -> AppRes
5356
#[utoipa::path(
5457
get,
5558
path = "/api/v1/keywords/{keyword}",
56-
operation_id = "get_keyword",
5759
tag = "keywords",
5860
responses((status = 200, description = "Successful Response")),
5961
)]
60-
pub async fn show(Path(name): Path<String>, state: AppState) -> AppResult<ErasedJson> {
62+
pub async fn find_keyword(Path(name): Path<String>, state: AppState) -> AppResult<ErasedJson> {
6163
let mut conn = state.db_read().await?;
6264
let kw = Keyword::find_by_keyword(&mut conn, &name).await?;
6365

src/controllers/krate/delete.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ const AVAILABLE_AFTER: TimeDelta = TimeDelta::hours(24);
3030
#[utoipa::path(
3131
delete,
3232
path = "/api/v1/crates/{name}",
33-
operation_id = "delete_crate",
3433
tag = "crates",
3534
responses((status = 200, description = "Successful Response")),
3635
)]
37-
pub async fn delete(
36+
pub async fn delete_crate(
3837
Path(name): Path<String>,
3938
parts: Parts,
4039
app: AppState,

src/controllers/krate/downloads.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ use std::cmp;
2323
#[utoipa::path(
2424
get,
2525
path = "/api/v1/crates/{name}/downloads",
26-
operation_id = "get_crate_downloads",
2726
tag = "crates",
2827
responses((status = 200, description = "Successful Response")),
2928
)]
3029

31-
pub async fn downloads(state: AppState, Path(crate_name): Path<String>) -> AppResult<ErasedJson> {
30+
pub async fn get_crate_downloads(
31+
state: AppState,
32+
Path(crate_name): Path<String>,
33+
) -> AppResult<ErasedJson> {
3234
let mut conn = state.db_read().await?;
3335

3436
use diesel::dsl::*;

src/controllers/krate/follow.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ async fn follow_target(
3333
#[utoipa::path(
3434
put,
3535
path = "/api/v1/crates/{name}/follow",
36-
operation_id = "follow_crate",
3736
tag = "crates",
3837
responses((status = 200, description = "Successful Response")),
3938
)]
40-
pub async fn follow(
39+
pub async fn follow_crate(
4140
app: AppState,
4241
Path(crate_name): Path<String>,
4342
req: Parts,
@@ -58,11 +57,10 @@ pub async fn follow(
5857
#[utoipa::path(
5958
delete,
6059
path = "/api/v1/crates/{name}/follow",
61-
operation_id = "unfollow_crate",
6260
tag = "crates",
6361
responses((status = 200, description = "Successful Response")),
6462
)]
65-
pub async fn unfollow(
63+
pub async fn unfollow_crate(
6664
app: AppState,
6765
Path(crate_name): Path<String>,
6866
req: Parts,
@@ -79,11 +77,10 @@ pub async fn unfollow(
7977
#[utoipa::path(
8078
get,
8179
path = "/api/v1/crates/{name}/following",
82-
operation_id = "get_following_crate",
8380
tag = "crates",
8481
responses((status = 200, description = "Successful Response")),
8582
)]
86-
pub async fn following(
83+
pub async fn get_following_crate(
8784
app: AppState,
8885
Path(crate_name): Path<String>,
8986
req: Parts,

src/controllers/krate/metadata.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,25 @@ use std::str::FromStr;
3333
#[utoipa::path(
3434
get,
3535
path = "/api/v1/crates/new",
36-
operation_id = "crates_show_new",
3736
tag = "crates",
3837
responses((status = 200, description = "Successful Response")),
3938
)]
40-
pub async fn show_new(app: AppState, req: Parts) -> AppResult<ErasedJson> {
41-
show(app, Path("new".to_string()), req).await
39+
pub async fn find_new_crate(app: AppState, req: Parts) -> AppResult<ErasedJson> {
40+
find_crate(app, Path("new".to_string()), req).await
4241
}
4342

4443
/// Get crate metadata.
4544
#[utoipa::path(
4645
get,
4746
path = "/api/v1/crates/{name}",
48-
operation_id = "get_crate",
4947
tag = "crates",
5048
responses((status = 200, description = "Successful Response")),
5149
)]
52-
pub async fn show(app: AppState, Path(name): Path<String>, req: Parts) -> AppResult<ErasedJson> {
50+
pub async fn find_crate(
51+
app: AppState,
52+
Path(name): Path<String>,
53+
req: Parts,
54+
) -> AppResult<ErasedJson> {
5355
let mut conn = app.db_read().await?;
5456

5557
let include = req
@@ -248,11 +250,10 @@ impl FromStr for ShowIncludeMode {
248250
#[utoipa::path(
249251
get,
250252
path = "/api/v1/crates/{name}/{version}/readme",
251-
operation_id = "get_version_readme",
252253
tag = "versions",
253254
responses((status = 200, description = "Successful Response")),
254255
)]
255-
pub async fn readme(
256+
pub async fn get_version_readme(
256257
app: AppState,
257258
Path((crate_name, version)): Path<(String, String)>,
258259
req: Parts,
@@ -269,11 +270,10 @@ pub async fn readme(
269270
#[utoipa::path(
270271
get,
271272
path = "/api/v1/crates/{name}/reverse_dependencies",
272-
operation_id = "list_reverse_dependencies",
273273
tag = "crates",
274274
responses((status = 200, description = "Successful Response")),
275275
)]
276-
pub async fn reverse_dependencies(
276+
pub async fn list_reverse_dependencies(
277277
app: AppState,
278278
Path(name): Path<String>,
279279
req: Parts,

src/controllers/krate/owners.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ use secrecy::{ExposeSecret, SecretString};
2121
#[utoipa::path(
2222
get,
2323
path = "/api/v1/crates/{name}/owners",
24-
operation_id = "list_owners",
2524
tag = "owners",
2625
responses((status = 200, description = "Successful Response")),
2726
)]
28-
pub async fn owners(state: AppState, Path(crate_name): Path<String>) -> AppResult<ErasedJson> {
27+
pub async fn list_owners(state: AppState, Path(crate_name): Path<String>) -> AppResult<ErasedJson> {
2928
let mut conn = state.db_read().await?;
3029

3130
let krate: Crate = Crate::by_name(&crate_name)
@@ -48,11 +47,13 @@ pub async fn owners(state: AppState, Path(crate_name): Path<String>) -> AppResul
4847
#[utoipa::path(
4948
get,
5049
path = "/api/v1/crates/{name}/owner_team",
51-
operation_id = "get_team_owners",
5250
tag = "owners",
5351
responses((status = 200, description = "Successful Response")),
5452
)]
55-
pub async fn owner_team(state: AppState, Path(crate_name): Path<String>) -> AppResult<ErasedJson> {
53+
pub async fn get_team_owners(
54+
state: AppState,
55+
Path(crate_name): Path<String>,
56+
) -> AppResult<ErasedJson> {
5657
let mut conn = state.db_read().await?;
5758
let krate: Crate = Crate::by_name(&crate_name)
5859
.first(&mut conn)
@@ -73,11 +74,13 @@ pub async fn owner_team(state: AppState, Path(crate_name): Path<String>) -> AppR
7374
#[utoipa::path(
7475
get,
7576
path = "/api/v1/crates/{name}/owner_user",
76-
operation_id = "get_user_owners",
7777
tag = "owners",
7878
responses((status = 200, description = "Successful Response")),
7979
)]
80-
pub async fn owner_user(state: AppState, Path(crate_name): Path<String>) -> AppResult<ErasedJson> {
80+
pub async fn get_user_owners(
81+
state: AppState,
82+
Path(crate_name): Path<String>,
83+
) -> AppResult<ErasedJson> {
8184
let mut conn = state.db_read().await?;
8285

8386
let krate: Crate = Crate::by_name(&crate_name)
@@ -99,7 +102,6 @@ pub async fn owner_user(state: AppState, Path(crate_name): Path<String>) -> AppR
99102
#[utoipa::path(
100103
put,
101104
path = "/api/v1/crates/{name}/owners",
102-
operation_id = "add_owners",
103105
tag = "owners",
104106
responses((status = 200, description = "Successful Response")),
105107
)]
@@ -116,7 +118,6 @@ pub async fn add_owners(
116118
#[utoipa::path(
117119
delete,
118120
path = "/api/v1/crates/{name}/owners",
119-
operation_id = "delete_owners",
120121
tag = "owners",
121122
responses((status = 200, description = "Successful Response")),
122123
)]

src/controllers/krate/publish.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const MAX_DESCRIPTION_LENGTH: usize = 1000;
5656
#[utoipa::path(
5757
put,
5858
path = "/api/v1/crates/new",
59-
operation_id = "publish",
6059
tag = "publish",
6160
responses((status = 200, description = "Successful Response")),
6261
)]

src/controllers/krate/search.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ use crate::util::RequestUtils;
3333
#[utoipa::path(
3434
get,
3535
path = "/api/v1/crates",
36-
operation_id = "crates_list",
3736
tag = "crates",
3837
responses((status = 200, description = "Successful Response")),
3938
)]
40-
pub async fn search(app: AppState, req: Parts) -> AppResult<ErasedJson> {
39+
pub async fn list_crates(app: AppState, req: Parts) -> AppResult<ErasedJson> {
4140
// Notes:
4241
// The different use cases this function covers is handled through passing
4342
// in parameters in the GET request.

src/controllers/krate/versions.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ use crate::views::EncodableVersion;
2424
#[utoipa::path(
2525
get,
2626
path = "/api/v1/crates/{name}/versions",
27-
operation_id = "list_crate_versions",
2827
tag = "versions",
2928
responses((status = 200, description = "Successful Response")),
3029
)]
31-
pub async fn versions(
30+
pub async fn list_versions(
3231
state: AppState,
3332
Path(crate_name): Path<String>,
3433
req: Parts,

src/controllers/site_metadata.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ use axum_extra::json;
99
#[utoipa::path(
1010
get,
1111
path = "/api/v1/site_metadata",
12-
operation_id = "get_site_metadata",
1312
tag = "other",
1413
responses((status = 200, description = "Successful Response")),
1514
)]
16-
pub async fn show_deployed_sha(state: AppState) -> impl IntoResponse {
15+
pub async fn get_site_metadata(state: AppState) -> impl IntoResponse {
1716
let read_only = state.config.db.are_all_read_only();
1817

1918
let deployed_sha =

src/controllers/summary.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ use std::future::Future;
1919
#[utoipa::path(
2020
get,
2121
path = "/api/v1/summary",
22-
operation_id = "get_summary",
2322
tag = "other",
2423
responses((status = 200, description = "Successful Response")),
2524
)]
26-
pub async fn summary(state: AppState) -> AppResult<ErasedJson> {
25+
pub async fn get_summary(state: AppState) -> AppResult<ErasedJson> {
2726
let mut conn = state.db_read().await?;
2827

2928
let config = &state.config;

src/controllers/team.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ use diesel_async::RunQueryDsl;
1212
#[utoipa::path(
1313
get,
1414
path = "/api/v1/teams/{team}",
15-
operation_id = "get_team",
1615
tag = "teams",
1716
responses((status = 200, description = "Successful Response")),
1817
)]
19-
pub async fn show_team(state: AppState, Path(name): Path<String>) -> AppResult<ErasedJson> {
18+
pub async fn find_team(state: AppState, Path(name): Path<String>) -> AppResult<ErasedJson> {
2019
use crate::schema::teams::dsl::{login, teams};
2120

2221
let mut conn = state.db_read().await?;

0 commit comments

Comments
 (0)