Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.
/ api Public archive

Commit ffe9314

Browse files
committed
general code cleanup & openapi fixes
1 parent c9ae485 commit ffe9314

File tree

13 files changed

+45
-53
lines changed

13 files changed

+45
-53
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "api"
3-
version = "3.2.3"
3+
version = "3.2.4"
44
edition = "2024"
55

66
[dependencies]

src/routes/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ mod v1;
2121
mod v2;
2222

2323
#[derive(ToSchema, Serialize)]
24-
pub struct ApiError {
24+
pub struct ApiError<'a> {
2525
#[schema(default = false)]
2626
pub success: bool,
27-
pub errors: Vec<String>,
27+
pub errors: &'a [&'a str],
2828
}
2929

30-
impl ApiError {
31-
pub fn new(errors: &[&str]) -> Self {
30+
impl<'a> ApiError<'a> {
31+
pub fn new(errors: &'a [&'a str]) -> Self {
3232
Self {
3333
success: false,
34-
errors: errors.iter().map(|s| s.to_string()).collect(),
34+
errors,
3535
}
3636
}
3737

src/routes/organization/v1/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ mod get {
4040

4141
#[utoipa::path(get, path = "/", responses(
4242
(status = OK, body = inline(Response)),
43-
), params(
44-
(
45-
"organization" = u32,
46-
description = "The organization ID",
47-
example = 1,
48-
),
4943
))]
5044
pub async fn route(
5145
state: GetState,

src/routes/organization/v1/types.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ mod get {
1818

1919
#[utoipa::path(get, path = "/", responses(
2020
(status = OK, body = inline(Response)),
21-
), params(
22-
(
23-
"organization" = u32,
24-
description = "The organization ID",
25-
example = 1,
26-
),
2721
))]
2822
pub async fn route(
2923
state: GetState,

src/routes/user/organizations/_organization_/api_keys/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod get {
2323
(status = OK, body = inline(Response)),
2424
), params(
2525
(
26-
"organization" = u32,
26+
"organization" = i32,
2727
description = "The organization ID",
2828
example = 1,
2929
),
@@ -69,7 +69,7 @@ mod post {
6969
(status = BAD_REQUEST, body = inline(ApiError)),
7070
), params(
7171
(
72-
"organization" = u32,
72+
"organization" = i32,
7373
description = "The organization ID",
7474
example = 1,
7575
),

src/routes/user/organizations/_organization_/icon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod post {
2020
(status = BAD_REQUEST, body = inline(ApiError)),
2121
), params(
2222
(
23-
"organization" = u32,
23+
"organization" = i32,
2424
description = "The organization ID",
2525
example = 1,
2626
),

src/routes/user/organizations/_organization_/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ mod get {
9090
(status = OK, body = inline(Response)),
9191
), params(
9292
(
93-
"organization" = u32,
93+
"organization" = i32,
9494
description = "The organization ID",
9595
example = 1,
9696
),
@@ -138,7 +138,7 @@ mod patch {
138138
(status = NOT_FOUND, body = inline(ApiError)),
139139
), params(
140140
(
141-
"organization" = u32,
141+
"organization" = i32,
142142
description = "The organization ID",
143143
example = 1,
144144
),
@@ -222,7 +222,7 @@ mod delete {
222222
(status = OK, body = inline(Response)),
223223
), params(
224224
(
225-
"organization" = u32,
225+
"organization" = i32,
226226
description = "The organization ID",
227227
example = 1,
228228
),

src/routes/user/organizations/_organization_/stats.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod get {
3131
(status = OK, body = inline(Response)),
3232
), params(
3333
(
34-
"organization" = u32,
34+
"organization" = i32,
3535
description = "The organization ID",
3636
example = 1,
3737
),
@@ -49,12 +49,12 @@ mod get {
4949
let data = sqlx::query(
5050
r#"
5151
SELECT
52-
COUNT(*) AS requests,
53-
COUNT(DISTINCT requests.user_agent) AS user_agents,
54-
COUNT(DISTINCT requests.ip) AS ips,
55-
COUNT(DISTINCT requests.origin) AS origins,
56-
COUNT(DISTINCT requests.continent) AS continents,
57-
COUNT(DISTINCT requests.country) AS countries
52+
COUNT(*),
53+
COUNT(DISTINCT requests.user_agent),
54+
COUNT(DISTINCT requests.ip),
55+
COUNT(DISTINCT requests.origin),
56+
COUNT(DISTINCT requests.continent),
57+
COUNT(DISTINCT requests.country)
5858
FROM requests
5959
WHERE requests.organization_id = $1
6060
"#,
@@ -65,12 +65,12 @@ mod get {
6565
.unwrap();
6666

6767
Stats {
68-
requests: data.get("requests"),
69-
user_agents: data.get("user_agents"),
70-
ips: data.get("ips"),
71-
origins: data.get("origins"),
72-
continents: data.get("continents"),
73-
countries: data.get("countries"),
68+
requests: data.get(0),
69+
user_agents: data.get(1),
70+
ips: data.get(2),
71+
origins: data.get(3),
72+
continents: data.get(4),
73+
countries: data.get(5),
7474
}
7575
},
7676
)

src/routes/user/organizations/_organization_/subusers/_subuser_.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod get {
2121
(status = NOT_FOUND, body = inline(ApiError)),
2222
), params(
2323
(
24-
"organization" = u32,
24+
"organization" = i32,
2525
description = "The organization ID",
2626
example = 1,
2727
),
@@ -34,7 +34,7 @@ mod get {
3434
pub async fn route(
3535
state: GetState,
3636
organization: GetOrganization,
37-
Path((_organization, login)): Path<(u32, String)>,
37+
Path((_organization, login)): Path<(i32, String)>,
3838
) -> (StatusCode, axum::Json<serde_json::Value>) {
3939
let user = User::by_login(&state.database, &state.cache, &login).await;
4040

@@ -92,7 +92,7 @@ mod delete {
9292
(status = NOT_FOUND, body = inline(ApiError)),
9393
), params(
9494
(
95-
"organization" = u32,
95+
"organization" = i32,
9696
description = "The organization ID",
9797
example = 1,
9898
),
@@ -106,7 +106,7 @@ mod delete {
106106
state: GetState,
107107
auth_user: GetUser,
108108
organization: GetOrganization,
109-
Path((_organization, login)): Path<(u32, String)>,
109+
Path((_organization, login)): Path<(i32, String)>,
110110
) -> (StatusCode, axum::Json<serde_json::Value>) {
111111
let user = User::by_login(&state.database, &state.cache, &login).await;
112112

0 commit comments

Comments
 (0)