mirror of
https://github.com/modrinth/code.git
synced 2026-09-05 06:19:11 +00:00
feat: better api docs (#6586)
* feat: docs * fix tombi * chore: fix some of the routes rendering with missing / * response schemas * fix: restore labrinth docs routes * Fix path parameter docs in routes * remove utoipa-actix-web * consistency * improve version intros * improve formatting, examples * better hash examples, move openapi stuff to openapi.rs * more utoipa param fixes * request body docs * chore: remove moderation route from v2, remove ingest & webhooks from v3 spec * fixes * chore: tweak sources titles * fix * fix test * improve examples * increase compiler spawned thread stack size * remove unused tests & script * test * bro what * fix --------- Co-authored-by: aecsocket <43144841+aecsocket@users.noreply.github.com>
This commit is contained in:
co-authored by
aecsocket
parent
b26d048a63
commit
4a6fa9fc3d
@@ -46,20 +46,26 @@ pub const FILTERED_HEADERS: &[&str] = &[
|
||||
"x-vercel-ip-country",
|
||||
];
|
||||
|
||||
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||
pub fn config(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
cfg.service(page_view_ingest)
|
||||
.service(playtime_ingest)
|
||||
.service(minecraft_server_play_ingest);
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, utoipa::ToSchema)]
|
||||
pub struct UrlInput {
|
||||
url: String,
|
||||
}
|
||||
|
||||
//this route should be behind the cloudflare WAF to prevent non-browsers from calling it
|
||||
#[post("view")]
|
||||
async fn page_view_ingest(
|
||||
#[utoipa::path(
|
||||
context_path = "/analytics",
|
||||
tag = "analytics",
|
||||
request_body = UrlInput,
|
||||
responses((status = NO_CONTENT))
|
||||
)]
|
||||
#[post("/view")]
|
||||
pub async fn page_view_ingest(
|
||||
req: HttpRequest,
|
||||
analytics_queue: web::Data<Arc<AnalyticsQueue>>,
|
||||
session_queue: web::Data<AuthQueue>,
|
||||
@@ -171,7 +177,7 @@ async fn page_view_ingest(
|
||||
Ok(HttpResponse::NoContent().body(""))
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, utoipa::ToSchema)]
|
||||
pub struct PlaytimeInput {
|
||||
seconds: u16,
|
||||
loader: String,
|
||||
@@ -179,8 +185,14 @@ pub struct PlaytimeInput {
|
||||
parent: Option<crate::models::ids::VersionId>,
|
||||
}
|
||||
|
||||
#[post("playtime")]
|
||||
async fn playtime_ingest(
|
||||
#[utoipa::path(
|
||||
context_path = "/analytics",
|
||||
tag = "analytics",
|
||||
request_body = serde_json::Value,
|
||||
responses((status = NO_CONTENT))
|
||||
)]
|
||||
#[post("/playtime")]
|
||||
pub async fn playtime_ingest(
|
||||
req: HttpRequest,
|
||||
analytics_queue: web::Data<Arc<AnalyticsQueue>>,
|
||||
session_queue: web::Data<AuthQueue>,
|
||||
@@ -249,7 +261,7 @@ struct MinecraftProfile {
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, utoipa::ToSchema)]
|
||||
pub struct MinecraftJavaServerPlayInput {
|
||||
project_id: ProjectId,
|
||||
username: String,
|
||||
@@ -258,8 +270,14 @@ pub struct MinecraftJavaServerPlayInput {
|
||||
|
||||
pub const MINECRAFT_SERVER_PLAYS: &str = "minecraft_server_plays";
|
||||
|
||||
#[post("minecraft-server-play")]
|
||||
async fn minecraft_server_play_ingest(
|
||||
#[utoipa::path(
|
||||
context_path = "/analytics",
|
||||
tag = "analytics",
|
||||
request_body = MinecraftJavaServerPlayInput,
|
||||
responses((status = NO_CONTENT))
|
||||
)]
|
||||
#[post("/minecraft-server-play")]
|
||||
pub async fn minecraft_server_play_ingest(
|
||||
req: HttpRequest,
|
||||
analytics_queue: web::Data<Arc<AnalyticsQueue>>,
|
||||
session_queue: web::Data<AuthQueue>,
|
||||
|
||||
Reference in New Issue
Block a user