Skip to content

Commit fb52bcf

Browse files
authored
utoipa: Add remaining Path params (#10213)
1 parent 139824d commit fb52bcf

10 files changed

+175
-0
lines changed

src/controllers/category.rs

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ pub async fn list_categories(app: AppState, req: Parts) -> AppResult<ErasedJson>
5151
#[utoipa::path(
5252
get,
5353
path = "/api/v1/categories/{category}",
54+
params(
55+
("category" = String, Path, description = "Name of the category"),
56+
),
5457
tag = "categories",
5558
responses((status = 200, description = "Successful Response")),
5659
)]

src/controllers/crate_owner_invitation.rs

+6
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ struct OwnerInvitation {
287287
#[utoipa::path(
288288
put,
289289
path = "/api/v1/me/crate_owner_invitations/{crate_id}",
290+
params(
291+
("crate_id" = i32, Path, description = "ID of the crate"),
292+
),
290293
tag = "owners",
291294
responses((status = 200, description = "Successful Response")),
292295
)]
@@ -324,6 +327,9 @@ pub async fn handle_crate_owner_invitation(
324327
#[utoipa::path(
325328
put,
326329
path = "/api/v1/me/crate_owner_invitations/accept/{token}",
330+
params(
331+
("token" = String, Path, description = "Secret token sent to the user's email address"),
332+
),
327333
tag = "owners",
328334
responses((status = 200, description = "Successful Response")),
329335
)]

src/controllers/keyword.rs

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ pub async fn list_keywords(
5656
#[utoipa::path(
5757
get,
5858
path = "/api/v1/keywords/{keyword}",
59+
params(
60+
("keyword" = String, Path, description = "The keyword to find"),
61+
),
5962
tag = "keywords",
6063
responses((status = 200, description = "Successful Response")),
6164
)]

src/controllers/team.rs

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ use diesel_async::RunQueryDsl;
1212
#[utoipa::path(
1313
get,
1414
path = "/api/v1/teams/{team}",
15+
params(
16+
("team" = String, Path, description = "Name of the team", example = "github:rust-lang:crates-io"),
17+
),
1518
tag = "teams",
1619
responses((status = 200, description = "Successful Response")),
1720
)]

src/controllers/token.rs

+6
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ pub async fn create_api_token(
181181
#[utoipa::path(
182182
get,
183183
path = "/api/v1/me/tokens/{id}",
184+
params(
185+
("id" = i32, Path, description = "ID of the API token"),
186+
),
184187
tag = "api_tokens",
185188
responses((status = 200, description = "Successful Response")),
186189
)]
@@ -205,6 +208,9 @@ pub async fn find_api_token(
205208
#[utoipa::path(
206209
delete,
207210
path = "/api/v1/me/tokens/{id}",
211+
params(
212+
("id" = i32, Path, description = "ID of the API token"),
213+
),
208214
tag = "api_tokens",
209215
responses((status = 200, description = "Successful Response")),
210216
)]

src/controllers/user/me.rs

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ pub async fn get_authenticated_user_updates(app: AppState, req: Parts) -> AppRes
117117
#[utoipa::path(
118118
put,
119119
path = "/api/v1/confirm/{email_token}",
120+
params(
121+
("email_token" = String, Path, description = "Secret verification token sent to the user's email address"),
122+
),
120123
tag = "users",
121124
responses((status = 200, description = "Successful Response")),
122125
)]

src/controllers/user/other.rs

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ use crate::views::EncodablePublicUser;
1616
#[utoipa::path(
1717
get,
1818
path = "/api/v1/users/{user}",
19+
params(
20+
("user" = String, Path, description = "Login name of the user"),
21+
),
1922
tag = "users",
2023
responses((status = 200, description = "Successful Response")),
2124
)]
@@ -41,6 +44,9 @@ pub async fn find_user(state: AppState, Path(user_name): Path<String>) -> AppRes
4144
#[utoipa::path(
4245
get,
4346
path = "/api/v1/users/{id}/stats",
47+
params(
48+
("id" = i32, Path, description = "ID of the user"),
49+
),
4450
tag = "users",
4551
responses((status = 200, description = "Successful Response")),
4652
)]

src/controllers/user/resend.rs

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ use http::request::Parts;
1818
#[utoipa::path(
1919
put,
2020
path = "/api/v1/users/{id}/resend",
21+
params(
22+
("id" = i32, Path, description = "ID of the user"),
23+
),
2124
tag = "users",
2225
responses((status = 200, description = "Successful Response")),
2326
)]

src/controllers/user/update.rs

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ pub struct User {
3232
#[utoipa::path(
3333
put,
3434
path = "/api/v1/users/{user}",
35+
params(
36+
("user" = i32, Path, description = "ID of the user"),
37+
),
3538
tag = "users",
3639
responses((status = 200, description = "Successful Response")),
3740
)]

src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap

+139
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ snapshot_kind: text
9595
"/api/v1/categories/{category}": {
9696
"get": {
9797
"operationId": "find_category",
98+
"parameters": [
99+
{
100+
"description": "Name of the category",
101+
"in": "path",
102+
"name": "category",
103+
"required": true,
104+
"schema": {
105+
"type": "string"
106+
}
107+
}
108+
],
98109
"responses": {
99110
"200": {
100111
"description": "Successful Response"
@@ -123,6 +134,17 @@ snapshot_kind: text
123134
"/api/v1/confirm/{email_token}": {
124135
"put": {
125136
"operationId": "confirm_user_email",
137+
"parameters": [
138+
{
139+
"description": "Secret verification token sent to the user's email address",
140+
"in": "path",
141+
"name": "email_token",
142+
"required": true,
143+
"schema": {
144+
"type": "string"
145+
}
146+
}
147+
],
126148
"responses": {
127149
"200": {
128150
"description": "Successful Response"
@@ -833,6 +855,17 @@ snapshot_kind: text
833855
"/api/v1/keywords/{keyword}": {
834856
"get": {
835857
"operationId": "find_keyword",
858+
"parameters": [
859+
{
860+
"description": "The keyword to find",
861+
"in": "path",
862+
"name": "keyword",
863+
"required": true,
864+
"schema": {
865+
"type": "string"
866+
}
867+
}
868+
],
836869
"responses": {
837870
"200": {
838871
"description": "Successful Response"
@@ -875,6 +908,17 @@ snapshot_kind: text
875908
"/api/v1/me/crate_owner_invitations/accept/{token}": {
876909
"put": {
877910
"operationId": "accept_crate_owner_invitation_with_token",
911+
"parameters": [
912+
{
913+
"description": "Secret token sent to the user's email address",
914+
"in": "path",
915+
"name": "token",
916+
"required": true,
917+
"schema": {
918+
"type": "string"
919+
}
920+
}
921+
],
878922
"responses": {
879923
"200": {
880924
"description": "Successful Response"
@@ -889,6 +933,18 @@ snapshot_kind: text
889933
"/api/v1/me/crate_owner_invitations/{crate_id}": {
890934
"put": {
891935
"operationId": "handle_crate_owner_invitation",
936+
"parameters": [
937+
{
938+
"description": "ID of the crate",
939+
"in": "path",
940+
"name": "crate_id",
941+
"required": true,
942+
"schema": {
943+
"format": "int32",
944+
"type": "integer"
945+
}
946+
}
947+
],
892948
"responses": {
893949
"200": {
894950
"description": "Successful Response"
@@ -945,6 +1001,18 @@ snapshot_kind: text
9451001
"/api/v1/me/tokens/{id}": {
9461002
"delete": {
9471003
"operationId": "revoke_api_token",
1004+
"parameters": [
1005+
{
1006+
"description": "ID of the API token",
1007+
"in": "path",
1008+
"name": "id",
1009+
"required": true,
1010+
"schema": {
1011+
"format": "int32",
1012+
"type": "integer"
1013+
}
1014+
}
1015+
],
9481016
"responses": {
9491017
"200": {
9501018
"description": "Successful Response"
@@ -957,6 +1025,18 @@ snapshot_kind: text
9571025
},
9581026
"get": {
9591027
"operationId": "find_api_token",
1028+
"parameters": [
1029+
{
1030+
"description": "ID of the API token",
1031+
"in": "path",
1032+
"name": "id",
1033+
"required": true,
1034+
"schema": {
1035+
"format": "int32",
1036+
"type": "integer"
1037+
}
1038+
}
1039+
],
9601040
"responses": {
9611041
"200": {
9621042
"description": "Successful Response"
@@ -1015,6 +1095,18 @@ snapshot_kind: text
10151095
"/api/v1/teams/{team}": {
10161096
"get": {
10171097
"operationId": "find_team",
1098+
"parameters": [
1099+
{
1100+
"description": "Name of the team",
1101+
"example": "github:rust-lang:crates-io",
1102+
"in": "path",
1103+
"name": "team",
1104+
"required": true,
1105+
"schema": {
1106+
"type": "string"
1107+
}
1108+
}
1109+
],
10181110
"responses": {
10191111
"200": {
10201112
"description": "Successful Response"
@@ -1044,6 +1136,18 @@ snapshot_kind: text
10441136
"/api/v1/users/{id}/resend": {
10451137
"put": {
10461138
"operationId": "resend_email_verification",
1139+
"parameters": [
1140+
{
1141+
"description": "ID of the user",
1142+
"in": "path",
1143+
"name": "id",
1144+
"required": true,
1145+
"schema": {
1146+
"format": "int32",
1147+
"type": "integer"
1148+
}
1149+
}
1150+
],
10471151
"responses": {
10481152
"200": {
10491153
"description": "Successful Response"
@@ -1059,6 +1163,18 @@ snapshot_kind: text
10591163
"get": {
10601164
"description": "This currently only returns the total number of downloads for crates owned\nby the user.",
10611165
"operationId": "get_user_stats",
1166+
"parameters": [
1167+
{
1168+
"description": "ID of the user",
1169+
"in": "path",
1170+
"name": "id",
1171+
"required": true,
1172+
"schema": {
1173+
"format": "int32",
1174+
"type": "integer"
1175+
}
1176+
}
1177+
],
10621178
"responses": {
10631179
"200": {
10641180
"description": "Successful Response"
@@ -1073,6 +1189,17 @@ snapshot_kind: text
10731189
"/api/v1/users/{user}": {
10741190
"get": {
10751191
"operationId": "find_user",
1192+
"parameters": [
1193+
{
1194+
"description": "Login name of the user",
1195+
"in": "path",
1196+
"name": "user",
1197+
"required": true,
1198+
"schema": {
1199+
"type": "string"
1200+
}
1201+
}
1202+
],
10761203
"responses": {
10771204
"200": {
10781205
"description": "Successful Response"
@@ -1086,6 +1213,18 @@ snapshot_kind: text
10861213
"put": {
10871214
"description": "This endpoint allows users to update their email address and publish notifications settings.\n\nThe `id` parameter needs to match the ID of the currently authenticated user.",
10881215
"operationId": "update_user",
1216+
"parameters": [
1217+
{
1218+
"description": "ID of the user",
1219+
"in": "path",
1220+
"name": "user",
1221+
"required": true,
1222+
"schema": {
1223+
"format": "int32",
1224+
"type": "integer"
1225+
}
1226+
}
1227+
],
10891228
"responses": {
10901229
"200": {
10911230
"description": "Successful Response"

0 commit comments

Comments
 (0)