feat: add OpenAPI spec generation with utoipa and justfile
- Add utoipa v5 dependency with ToSchema derives on all REST API DTOs - Annotate free-function handlers with #[utoipa::path] (trash, share, favorites, recent) - Create ApiDoc struct with OpenApi derive registering 37 schemas across 7 tags - Add generate-openapi binary outputting resources/gen/openapi.json - Serve OpenAPI spec at GET /api/openapi.json (public, no auth) - Add justfile with common dev commands (build, test, lint, check, openapi, db)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use utoipa::{IntoParams, ToSchema};
|
||||
|
||||
/// A DTO to represent pagination information
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
||||
pub struct PaginationDto {
|
||||
/// Current page (starts at 0)
|
||||
pub page: usize,
|
||||
@@ -18,7 +19,7 @@ pub struct PaginationDto {
|
||||
}
|
||||
|
||||
/// A DTO to represent a pagination request
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
|
||||
pub struct PaginationRequestDto {
|
||||
/// Requested page (starts at 0)
|
||||
#[serde(default)]
|
||||
@@ -29,7 +30,7 @@ pub struct PaginationRequestDto {
|
||||
}
|
||||
|
||||
/// A DTO to represent a paginated response
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
||||
pub struct PaginatedResponseDto<T> {
|
||||
/// Data on the current page
|
||||
pub items: Vec<T>,
|
||||
|
||||
Reference in New Issue
Block a user