Skip to content

Commit fd274dc

Browse files
committed
Remove utoipa
1 parent 8ebfc4e commit fd274dc

File tree

9 files changed

+34
-548
lines changed

9 files changed

+34
-548
lines changed

backend/Cargo.lock

Lines changed: 14 additions & 114 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@ tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread", "signal"]
2121
tower-http = { version = "0.6.1", features = ["cors", "fs", "trace"] }
2222
tracing = "0.1.40"
2323
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
24-
utoipa = { version = "5.3.1", features = ["axum_extras", "time", "uuid"] }
25-
utoipa-axum = "0.2.0"
26-
uuid = { version = "1.8.0", features = ["fast-rng", "serde", "v4"] }
24+
uuid = { version = "1.8.0", features = ["serde"] }
2725
validator = { version = "0.20.0", features = ["derive"] }

backend/src/api.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,10 @@ use axum_valid::Valid;
88
use crate::{
99
dto::{Project, ProjectIndex, ProjectPreview},
1010
error::{AppError, AppResult, WithAppRejection},
11-
repository::ProjectRepository
12-
,
11+
repository::ProjectRepository,
1312
utils::{Page, Pager},
1413
};
1514

16-
#[utoipa::path(
17-
get,
18-
path = "/projects",
19-
responses(
20-
(status = 200, description = "Comments found successfully", body = Page<ProjectPreview>),
21-
),
22-
)]
2315
pub async fn list_projects(
2416
State(repo): State<ProjectRepository>,
2517
WithRejection(Valid(Query(pager)), _): WithAppRejection<Valid<Query<Pager<ProjectIndex>>>>,
@@ -28,16 +20,6 @@ pub async fn list_projects(
2820
Ok(Json(page))
2921
}
3022

31-
#[utoipa::path(
32-
get,
33-
path = "/projects/{id}",
34-
params(
35-
("id" = String, Path, description = "ID of project to fetch"),
36-
),
37-
responses(
38-
(status = 200, description = "Project found successfully", body = Project),
39-
),
40-
)]
4123
pub async fn get_project(
4224
Path(id): Path<String>,
4325
State(project_repo): State<ProjectRepository>,

backend/src/dto.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
use serde::{Deserialize, Serialize};
2-
use sqlx::types::time::OffsetDateTime;
3-
use utoipa::ToSchema;
4-
use uuid::Uuid;
2+
use sqlx::types::{time::OffsetDateTime, uuid::Uuid};
53

6-
#[derive(Debug, Deserialize, ToSchema)]
4+
#[derive(Debug, Deserialize)]
75
#[serde(rename_all = "kebab-case")]
86
pub struct ProjectIndex {
97
#[serde(with = "time::serde::rfc3339")]
108
pub date_posted: OffsetDateTime,
119
pub id: String,
1210
}
1311

14-
#[derive(Debug, Serialize, ToSchema)]
12+
#[derive(Debug, Serialize)]
1513
#[serde(rename_all = "camelCase")]
1614
pub struct ProjectPreview {
1715
pub id: String,
@@ -22,7 +20,7 @@ pub struct ProjectPreview {
2220
pub date_posted: OffsetDateTime,
2321
}
2422

25-
#[derive(Debug, Serialize, ToSchema)]
23+
#[derive(Debug, Serialize)]
2624
#[serde(rename_all = "camelCase")]
2725
pub struct Project {
2826
pub id: String,

backend/src/main.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use axum::routing::get;
1+
use axum::{routing::get, Router};
22
use axum_prometheus::PrometheusMetricLayerBuilder;
33
use tokio::net::TcpListener;
44
use tower_http::{cors::CorsLayer, trace::TraceLayer};
55
use tracing::info;
6-
use utoipa_axum::{router::OpenApiRouter, routes};
76

87
use crate::{config::AppConfig, error::AppError, state::AppState};
98

@@ -30,16 +29,15 @@ async fn main() {
3029

3130
let state = AppState::new().await;
3231

33-
let (app, api) = OpenApiRouter::new()
34-
.routes(routes!(api::list_projects))
35-
.routes(routes!(api::get_project))
32+
let app = Router::new()
33+
.route("/projects", get(api::list_projects))
34+
.route("/projects/{id}", get(api::get_project))
3635
.fallback(async || AppError::NotFound)
3736
.route("/metrics", get(async move || metric_handle.render()))
3837
.layer(prometheus_layer)
3938
.layer(TraceLayer::new_for_http())
4039
.layer(CorsLayer::permissive())
41-
.with_state(state)
42-
.split_for_parts();
40+
.with_state(state);
4341

4442
let addr = config.socket_addr();
4543
let listener = TcpListener::bind(addr).await.unwrap();

backend/src/repository.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use sqlx::{query, query_as, SqlitePool};
2-
use time::OffsetDateTime;
3-
use uuid::Uuid;
1+
use sqlx::{
2+
query, query_as,
3+
types::{time::OffsetDateTime, uuid::Uuid},
4+
SqlitePool,
5+
};
46

57
use crate::{
68
dto::{Project, ProjectIndex, ProjectPreview},

backend/src/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{config::AppConfig, repository::ProjectRepository};
99

1010
#[derive(Clone, Debug)]
1111
pub struct AppState {
12-
pub(super) pool: SqlitePool,
12+
pool: SqlitePool,
1313
}
1414

1515
impl AppState {

0 commit comments

Comments
 (0)