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:
François-Xavier Talbot
2026-07-04 14:19:21 +00:00
committed by GitHub
co-authored by aecsocket
parent b26d048a63
commit 4a6fa9fc3d
103 changed files with 4546 additions and 1387 deletions
+28 -4
View File
@@ -18,7 +18,7 @@ use crate::models::ids::OAuthClientId;
use crate::models::pats::Scopes;
use crate::queue::session::AuthQueue;
use actix_web::http::header::{CACHE_CONTROL, LOCATION, PRAGMA};
use actix_web::web::{Data, Query, ServiceConfig};
use actix_web::web::{Data, Query};
use actix_web::{HttpRequest, HttpResponse, get, post, web};
use chrono::{DateTime, Duration};
use rand::distributions::Alphanumeric;
@@ -33,7 +33,7 @@ use super::AuthenticationError;
pub mod errors;
pub mod uris;
pub fn config(cfg: &mut ServiceConfig) {
pub fn config(cfg: &mut actix_web::web::ServiceConfig) {
cfg.service(init_oauth)
.service(accept_client_scopes)
.service(reject_client_scopes)
@@ -57,6 +57,18 @@ pub struct OAuthClientAccessRequest {
pub requested_scopes: Scopes,
}
#[utoipa::path(
context_path = "/oauth",
path = "/authorize",
tag = "oauth",
params(
("client_id" = OAuthClientId, Query),
("redirect_uri" = Option<String>, Query),
("scope" = Option<String>, Query),
("state" = Option<String>, Query)
),
responses((status = OK))
)]
#[get("authorize")]
pub async fn init_oauth(
req: HttpRequest,
@@ -165,11 +177,15 @@ pub async fn init_oauth(
}
}
#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, utoipa::ToSchema)]
pub struct RespondToOAuthClientScopes {
pub flow: String,
}
#[utoipa::path(
context_path = "/oauth",
path = "/accept", tag = "oauth", responses((status = OK))
)]
#[post("accept")]
pub async fn accept_client_scopes(
req: HttpRequest,
@@ -189,6 +205,10 @@ pub async fn accept_client_scopes(
.await
}
#[utoipa::path(
context_path = "/oauth",
path = "/reject", tag = "oauth", responses((status = OK))
)]
#[post("reject")]
pub async fn reject_client_scopes(
req: HttpRequest,
@@ -201,7 +221,7 @@ pub async fn reject_client_scopes(
.await
}
#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, utoipa::ToSchema)]
pub struct TokenRequest {
pub grant_type: String,
pub code: String,
@@ -216,6 +236,10 @@ pub struct TokenResponse {
pub expires_in: i64,
}
#[utoipa::path(
context_path = "/oauth",
path = "/token", tag = "oauth", responses((status = OK))
)]
#[post("token")]
/// Params should be in the urlencoded request body
/// And client secret should be in the HTTP basic authorization header