Skip to content

Commit a88f495

Browse files
authored
controllers/krate/owners: Add request body to OpenAPI docs (#12320)
1 parent 40d8342 commit a88f495

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

src/controllers/krate/owners.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pub struct ModifyResponse {
119119
put,
120120
path = "/api/v1/crates/{name}/owners",
121121
params(CratePath),
122+
request_body = inline(ChangeOwnersRequest),
122123
security(
123124
("api_token" = []),
124125
("cookie" = []),
@@ -140,6 +141,7 @@ pub async fn add_owners(
140141
delete,
141142
path = "/api/v1/crates/{name}/owners",
142143
params(CratePath),
144+
request_body = inline(ChangeOwnersRequest),
143145
security(
144146
("api_token" = []),
145147
("cookie" = []),
@@ -156,8 +158,13 @@ pub async fn remove_owners(
156158
modify_owners(app, path.name, parts, body, false).await
157159
}
158160

159-
#[derive(Deserialize)]
161+
#[derive(Deserialize, utoipa::ToSchema)]
160162
pub struct ChangeOwnersRequest {
163+
/// List of owner login names to add or remove.
164+
///
165+
/// For users, use just the username (e.g., `"octocat"`).
166+
/// For GitHub teams, use the format `github:org:team` (e.g., `"github:rust-lang:owners"`).
167+
#[schema(example = json!(["octocat", "github:rust-lang:owners"]))]
161168
#[serde(alias = "users")]
162169
owners: Vec<String>,
163170
}

src/tests/snapshots/integration__openapi__openapi_snapshot-2.snap

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,32 @@ expression: response.json()
25902590
}
25912591
}
25922592
],
2593+
"requestBody": {
2594+
"content": {
2595+
"application/json": {
2596+
"schema": {
2597+
"properties": {
2598+
"owners": {
2599+
"description": "List of owner login names to add or remove.\n\nFor users, use just the username (e.g., `\"octocat\"`).\nFor GitHub teams, use the format `github:org:team` (e.g., `\"github:rust-lang:owners\"`).",
2600+
"example": [
2601+
"octocat",
2602+
"github:rust-lang:owners"
2603+
],
2604+
"items": {
2605+
"type": "string"
2606+
},
2607+
"type": "array"
2608+
}
2609+
},
2610+
"required": [
2611+
"owners"
2612+
],
2613+
"type": "object"
2614+
}
2615+
}
2616+
},
2617+
"required": true
2618+
},
25932619
"responses": {
25942620
"200": {
25952621
"content": {
@@ -2684,6 +2710,32 @@ expression: response.json()
26842710
}
26852711
}
26862712
],
2713+
"requestBody": {
2714+
"content": {
2715+
"application/json": {
2716+
"schema": {
2717+
"properties": {
2718+
"owners": {
2719+
"description": "List of owner login names to add or remove.\n\nFor users, use just the username (e.g., `\"octocat\"`).\nFor GitHub teams, use the format `github:org:team` (e.g., `\"github:rust-lang:owners\"`).",
2720+
"example": [
2721+
"octocat",
2722+
"github:rust-lang:owners"
2723+
],
2724+
"items": {
2725+
"type": "string"
2726+
},
2727+
"type": "array"
2728+
}
2729+
},
2730+
"required": [
2731+
"owners"
2732+
],
2733+
"type": "object"
2734+
}
2735+
}
2736+
},
2737+
"required": true
2738+
},
26872739
"responses": {
26882740
"200": {
26892741
"content": {

0 commit comments

Comments
 (0)