chore: update routes to use utoipa

This commit is contained in:
Zomatree
2025-11-17 22:13:07 +00:00
parent ac60b2c795
commit 43c94b68b0
110 changed files with 891 additions and 231 deletions

View File

@@ -7,10 +7,16 @@ use revolt_result::Result;
use rocket::State;
use rocket_empty::EmptyResponse;
/// # Deletes a webhook
/// Deletes a webhook
///
/// Deletes a webhook
#[utoipa::path(tag = "Webhooks")]
#[utoipa::path(
tag = "Webhooks",
security(("Session-Token" = []), ("Bot-Token" = [])),
responses(
(status = 204),
),
)]
#[delete("/<webhook_id>")]
pub async fn webhook_delete(
db: &State<Database>,

View File

@@ -3,10 +3,15 @@ use revolt_result::Result;
use rocket::State;
use rocket_empty::EmptyResponse;
/// # Deletes a webhook
/// Deletes a webhook
///
/// Deletes a webhook with a token
#[utoipa::path(tag = "Webhooks")]
#[utoipa::path(
tag = "Webhooks",
responses(
(status = 204),
),
)]
#[delete("/<webhook_id>/<token>")]
pub async fn webhook_delete_token(
db: &State<Database>,

View File

@@ -8,10 +8,16 @@ use revolt_result::{create_error, Result};
use rocket::{serde::json::Json, State};
use validator::Validate;
/// # Edits a webhook
/// Edits a webhook
///
/// Edits a webhook
#[utoipa::path(tag = "Webhooks")]
#[utoipa::path(
tag = "Webhooks",
security(("Session-Token" = []), ("Bot-Token" = [])),
responses(
(status = 200, body = Webhook),
),
)]
#[patch("/<webhook_id>", data = "<data>")]
pub async fn webhook_edit(
db: &State<Database>,

View File

@@ -5,10 +5,15 @@ use revolt_models::validator::Validate;
use revolt_result::{create_error, Result};
use rocket::{serde::json::Json, State};
/// # Edits a webhook
/// Edits a webhook
///
/// Edits a webhook with a token
#[utoipa::path(tag = "Webhooks")]
#[utoipa::path(
tag = "Webhooks",
responses(
(status = 200, body = Webhook),
),
)]
#[patch("/<webhook_id>/<token>", data = "<data>")]
pub async fn webhook_edit_token(
db: &State<Database>,

View File

@@ -10,10 +10,16 @@ use rocket::{serde::json::Json, State};
use validator::Validate;
/// # Executes a webhook
/// Executes a webhook
///
/// Executes a webhook and sends a message
#[utoipa::path(tag = "Webhooks")]
#[utoipa::path(
tag = "Webhooks",
params(IdempotencyKey),
responses(
(status = 200, body = v0::Message)
)
)]
#[post("/<webhook_id>/<token>", data = "<data>")]
pub async fn webhook_execute(
db: &State<Database>,

View File

@@ -708,10 +708,13 @@ fn convert_event(data: &str, event_name: &str) -> Result<Event> {
})
}
/// # Executes a webhook specific to github
/// Executes a webhook specific to github
///
/// Executes a webhook specific to github and sends a message containing the relevant info about the event
#[utoipa::path(tag = "Webhooks", params(EventHeader))]
#[utoipa::path(
tag = "Webhooks",
params(EventHeader)
)]
#[post("/<webhook_id>/<token>/github", data = "<data>")]
pub async fn webhook_execute_github(
db: &State<Database>,

View File

@@ -7,10 +7,16 @@ use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
use revolt_result::Result;
use rocket::{serde::json::Json, State};
/// # Gets a webhook
/// Gets a webhook
///
/// Gets a webhook
#[utoipa::path(tag = "Webhooks")]
#[utoipa::path(
tag = "Webhooks",
security(("Session-Token" = []), ("Bot-Token" = [])),
responses(
(status = 200, body = Webhook),
),
)]
#[get("/<webhook_id>")]
pub async fn webhook_fetch(
db: &State<Database>,

View File

@@ -3,10 +3,15 @@ use revolt_models::v0::Webhook;
use revolt_result::Result;
use rocket::{serde::json::Json, State};
/// # Gets a webhook
/// Gets a webhook
///
/// Gets a webhook with a token
#[utoipa::path(tag = "Webhooks")]
#[utoipa::path(
tag = "Webhooks",
responses(
(status = 200, body = Webhook),
),
)]
#[get("/<webhook_id>/<token>")]
pub async fn webhook_fetch_token(
db: &State<Database>,