From 26c06b96fd3b6d1fd0bedba0e121b366bc42aef4 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 13 Nov 2025 11:15:47 +0100 Subject: [PATCH] controllers/krate/owners: Add request body to OpenAPI docs --- src/controllers/krate/owners.rs | 9 +++- ...egration__openapi__openapi_snapshot-2.snap | 52 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/controllers/krate/owners.rs b/src/controllers/krate/owners.rs index 2f58fd6dca0..abe5fda0daf 100644 --- a/src/controllers/krate/owners.rs +++ b/src/controllers/krate/owners.rs @@ -119,6 +119,7 @@ pub struct ModifyResponse { put, path = "/api/v1/crates/{name}/owners", params(CratePath), + request_body = inline(ChangeOwnersRequest), security( ("api_token" = []), ("cookie" = []), @@ -140,6 +141,7 @@ pub async fn add_owners( delete, path = "/api/v1/crates/{name}/owners", params(CratePath), + request_body = inline(ChangeOwnersRequest), security( ("api_token" = []), ("cookie" = []), @@ -156,8 +158,13 @@ pub async fn remove_owners( modify_owners(app, path.name, parts, body, false).await } -#[derive(Deserialize)] +#[derive(Deserialize, utoipa::ToSchema)] pub struct ChangeOwnersRequest { + /// List of owner login names to add or remove. + /// + /// For users, use just the username (e.g., `"octocat"`). + /// For GitHub teams, use the format `github:org:team` (e.g., `"github:rust-lang:owners"`). + #[schema(example = json!(["octocat", "github:rust-lang:owners"]))] #[serde(alias = "users")] owners: Vec, } diff --git a/src/tests/snapshots/integration__openapi__openapi_snapshot-2.snap b/src/tests/snapshots/integration__openapi__openapi_snapshot-2.snap index be723e9e571..44f0c3e181e 100644 --- a/src/tests/snapshots/integration__openapi__openapi_snapshot-2.snap +++ b/src/tests/snapshots/integration__openapi__openapi_snapshot-2.snap @@ -2590,6 +2590,32 @@ expression: response.json() } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "owners": { + "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\"`).", + "example": [ + "octocat", + "github:rust-lang:owners" + ], + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "owners" + ], + "type": "object" + } + } + }, + "required": true + }, "responses": { "200": { "content": { @@ -2684,6 +2710,32 @@ expression: response.json() } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "owners": { + "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\"`).", + "example": [ + "octocat", + "github:rust-lang:owners" + ], + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "owners" + ], + "type": "object" + } + } + }, + "required": true + }, "responses": { "200": { "content": {