tsk-56: Added API docs
All checks were successful
Rust Build / Check (pull_request) Successful in 2m3s
Rust Build / Test Suite (pull_request) Successful in 2m54s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 2m2s
Rust Build / build (pull_request) Successful in 3m36s

This commit is contained in:
2025-08-24 19:02:20 -04:00
parent d4ec3c5d1c
commit be053ac0dc
4 changed files with 117 additions and 11 deletions

View File

@@ -6,7 +6,7 @@ use crate::repo;
pub mod request {
use serde::{Deserialize, Serialize};
#[derive(Default, Deserialize, Serialize)]
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
pub struct Request {
#[serde(skip_serializing_if = "String::is_empty")]
pub username: String,
@@ -26,13 +26,28 @@ pub mod request {
pub mod response {
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
pub struct Response {
pub message: String,
pub data: Vec<icarus_models::user::User>,
}
}
/// Endpoint to register a user
#[utoipa::path(
post,
path = super::endpoints::REGISTER,
request_body(
content = request::Request,
description = "Data required to register",
content_type = "application/json"
),
responses(
(status = 201, description = "User created", body = response::Response),
(status = 404, description = "User already exists", body = response::Response),
(status = 400, description = "Issue creating user", body = response::Response)
)
)]
pub async fn register_user(
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
Json(payload): Json<request::Request>,