Add utoipa and Scalar for API documentation
- Add utoipa and utoipa-scalar dependencies - Add ToSchema derives to all models - Add OpenAPI path annotations to auth, users, and health handlers - Create openapi.rs module with API documentation - Serve Scalar UI at /docs endpoint - Include JWT bearer auth security scheme Co-Authored-By: Warp <agent@warp.dev>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::FromRow;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// User model representing the users table
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, FromRow, ToSchema)]
|
||||
pub struct User {
|
||||
pub id: i32,
|
||||
pub date_registered: DateTime<Utc>,
|
||||
@@ -25,7 +26,7 @@ pub struct User {
|
||||
}
|
||||
|
||||
/// User public profile (without sensitive data)
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
pub struct UserProfile {
|
||||
pub id: i32,
|
||||
pub date_registered: DateTime<Utc>,
|
||||
@@ -57,7 +58,7 @@ impl From<User> for UserProfile {
|
||||
}
|
||||
|
||||
/// Create user request (internal use)
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct CreateUser {
|
||||
pub firstname: String,
|
||||
pub lastname: String,
|
||||
@@ -67,7 +68,7 @@ pub struct CreateUser {
|
||||
}
|
||||
|
||||
/// Update user request
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct UpdateUser {
|
||||
pub firstname: Option<String>,
|
||||
pub lastname: Option<String>,
|
||||
@@ -76,7 +77,7 @@ pub struct UpdateUser {
|
||||
}
|
||||
|
||||
/// Player stats response
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
pub struct PlayerStats {
|
||||
pub id: i32,
|
||||
pub username: String,
|
||||
|
||||
Reference in New Issue
Block a user