feat: add documentation crate and integrate OpenAPI specifications
- Added a new crate `doc` for API documentation. - Integrated `utoipa` for OpenAPI support in the presentation layer. - Updated routes to include social features (follow, unfollow, etc.) and diary export. - Enhanced API request and response structures with new DTOs for social interactions. - Updated `Cargo.toml` files to include new dependencies and features. - Modified Dockerfile to copy the new documentation crate. - Refactored existing handlers and routes to accommodate new API endpoints. - Updated tests to cover new functionality and ensure proper API behavior.
This commit is contained in:
16
crates/doc/src/lib.rs
Normal file
16
crates/doc/src/lib.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use axum::Router;
|
||||
use utoipa::openapi::OpenApi;
|
||||
use utoipa_scalar::{Scalar, Servable};
|
||||
use utoipa_swagger_ui::SwaggerUi;
|
||||
|
||||
pub trait ApiDocExt {
|
||||
fn with_api_doc(self, spec: OpenApi) -> Self;
|
||||
}
|
||||
|
||||
impl ApiDocExt for Router {
|
||||
fn with_api_doc(self, spec: OpenApi) -> Self {
|
||||
tracing::info!("API docs at /docs (Swagger) and /scalar");
|
||||
self.merge(SwaggerUi::new("/docs").url("/openapi.json", spec.clone()))
|
||||
.merge(Scalar::with_url("/scalar", spec))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user