feat(lib/git): annotate remote and signature handlers with ToSchema derives
ZhenYi committed
Modified lib/git/src/handler/remotes/add.rs lib/git/src/handler/remotes/add.rs +12 −2 View lib/git/src/handler/remotes/add.rs
@@ -7,18 +7,28 @@
77use crate::handler::require_writer;
88use crate::service::GitService;
99
10#[derive(Debug, Clone, serde::Deserialize)]
10#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
1111pub struct RemotePath {
1212 pub space_name: String,
1313 pub repo_name: String,
1414 pub name: String,
1515}
1616
17#[derive(Debug, Clone, serde::Deserialize)]
17#[derive(Debug, Clone, serde::Deserialize, utoipa::ToSchema)]
1818pub struct RemoteAddBody {
1919 pub url: String,
2020}
2121
22#[utoipa::path(
23 post,
24 path = "/repos/{space_name}/{repo_name}/remotes/{name}",
25 tag = "remotes",
26 params(RemotePath),
27 request_body = RemoteAddBody,
28 responses(
29 (status = 200, description = "add remote", body = AppResponseData<NoData>)
30 )
31)]
2232pub async fn add(
2333 State(service): State<GitService>,
2434 session: Session,
Modified lib/git/src/handler/remotes/clone_import.rs lib/git/src/handler/remotes/clone_import.rs +11 −1 View lib/git/src/handler/remotes/clone_import.rs
@@ -8,13 +8,23 @@
88use crate::service::GitService;
99use crate::service::remotes::{ImportResultDto, RemoteAuthDto};
1010
11#[derive(Debug, Clone, serde::Deserialize)]
11#[derive(Debug, Clone, serde::Deserialize, utoipa::ToSchema)]
1212pub struct RemoteImportBody {
1313 pub url: String,
1414 #[serde(default)]
1515 pub auth: Option<RemoteAuthDto>,
1616}
1717
18#[utoipa::path(
19 post,
20 path = "/repos/{space_name}/{repo_name}/remotes/import",
21 tag = "remotes",
22 params(RepoPath),
23 request_body = RemoteImportBody,
24 responses(
25 (status = 200, description = "clone and import remote repo", body = AppResponseData<ImportResultDto>)
26 )
27)]
1828pub async fn clone_import(
1929 State(service): State<GitService>,
2030 session: Session,
Modified lib/git/src/handler/remotes/fetch.rs lib/git/src/handler/remotes/fetch.rs +11 −1 View lib/git/src/handler/remotes/fetch.rs
@@ -8,13 +8,23 @@
88use crate::service::GitService;
99use crate::service::remotes::{FetchResultDto, RemoteAuthDto};
1010
11#[derive(Debug, Clone, serde::Deserialize)]
11#[derive(Debug, Clone, serde::Deserialize, utoipa::ToSchema)]
1212pub struct RemoteFetchBody {
1313 pub remote: String,
1414 #[serde(default)]
1515 pub auth: Option<RemoteAuthDto>,
1616}
1717
18#[utoipa::path(
19 post,
20 path = "/repos/{space_name}/{repo_name}/remotes/fetch",
21 tag = "remotes",
22 params(RepoPath),
23 request_body = RemoteFetchBody,
24 responses(
25 (status = 200, description = "fetch from remote", body = AppResponseData<FetchResultDto>)
26 )
27)]
1828pub async fn fetch(
1929 State(service): State<GitService>,
2030 session: Session,
Modified lib/git/src/handler/remotes/push.rs lib/git/src/handler/remotes/push.rs +11 −1 View lib/git/src/handler/remotes/push.rs
@@ -8,7 +8,7 @@
88use crate::service::GitService;
99use crate::service::remotes::{PushResultDto, RemoteAuthDto};
1010
11#[derive(Debug, Clone, serde::Deserialize)]
11#[derive(Debug, Clone, serde::Deserialize, utoipa::ToSchema)]
1212pub struct RemotePushBody {
1313 pub remote: String,
1414 #[serde(default)]
@@ -17,6 +17,16 @@
1717 pub auth: Option<RemoteAuthDto>,
1818}
1919
20#[utoipa::path(
21 post,
22 path = "/repos/{space_name}/{repo_name}/remotes/push",
23 tag = "remotes",
24 params(RepoPath),
25 request_body = RemotePushBody,
26 responses(
27 (status = 200, description = "push to remote", body = AppResponseData<PushResultDto>)
28 )
29)]
2030pub async fn push(
2131 State(service): State<GitService>,
2232 session: Session,
Modified lib/git/src/handler/remotes/remove.rs lib/git/src/handler/remotes/remove.rs +10 −1 View lib/git/src/handler/remotes/remove.rs
@@ -6,13 +6,22 @@
66use crate::handler::require_writer;
77use crate::service::GitService;
88
9#[derive(Debug, Clone, serde::Deserialize)]
9#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
1010pub struct RemotePath {
1111 pub space_name: String,
1212 pub repo_name: String,
1313 pub name: String,
1414}
1515
16#[utoipa::path(
17 delete,
18 path = "/repos/{space_name}/{repo_name}/remotes/{name}",
19 tag = "remotes",
20 params(RemotePath),
21 responses(
22 (status = 200, description = "remove remote", body = AppResponseData<NoData>)
23 )
24)]
1625pub async fn remove(
1726 State(service): State<GitService>,
1827 session: Session,
Modified lib/git/src/handler/signatures/verify_commit.rs lib/git/src/handler/signatures/verify_commit.rs +10 −1 View lib/git/src/handler/signatures/verify_commit.rs
@@ -7,13 +7,22 @@
77use crate::service::GitService;
88use crate::service::signatures::VerifyResultDto;
99
10#[derive(Debug, Clone, serde::Deserialize)]
10#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
1111pub struct CommitShaPath {
1212 pub space_name: String,
1313 pub repo_name: String,
1414 pub sha: String,
1515}
1616
17#[utoipa::path(
18 get,
19 path = "/repos/{space_name}/{repo_name}/signatures/commit/{sha}",
20 tag = "signatures",
21 params(CommitShaPath),
22 responses(
23 (status = 200, description = "verify commit signature", body = AppResponseData<VerifyResultDto>)
24 )
25)]
1726pub async fn verify_commit(
1827 State(service): State<GitService>,
1928 session: Session,
Modified lib/git/src/handler/signatures/verify_tag.rs lib/git/src/handler/signatures/verify_tag.rs +10 −1 View lib/git/src/handler/signatures/verify_tag.rs
@@ -7,13 +7,22 @@
77use crate::service::GitService;
88use crate::service::signatures::VerifyResultDto;
99
10#[derive(Debug, Clone, serde::Deserialize)]
10#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
1111pub struct TagNamePath {
1212 pub space_name: String,
1313 pub repo_name: String,
1414 pub name: String,
1515}
1616
17#[utoipa::path(
18 get,
19 path = "/repos/{space_name}/{repo_name}/signatures/tag/{name}",
20 tag = "signatures",
21 params(TagNamePath),
22 responses(
23 (status = 200, description = "verify tag signature", body = AppResponseData<VerifyResultDto>)
24 )
25)]
1726pub async fn verify_tag(
1827 State(service): State<GitService>,
1928 session: Session,
Modified lib/git/src/service/blame.rs lib/git/src/service/blame.rs +1 −1 View lib/git/src/service/blame.rs
@@ -4,7 +4,7 @@
44use crate::service::GitService;
55use crate::share::errors::{GitError, map_baby};
66
7#[derive(Debug, Clone, Serialize)]
7#[derive(Debug, Clone, Serialize, utoipa::ToSchema)]
88pub struct BlameRangeDto {
99 pub starting_line: i32,
1010 pub ending_line: i32,
Modified lib/git/src/service/blobs.rs lib/git/src/service/blobs.rs +4 −4 View lib/git/src/service/blobs.rs
@@ -7,14 +7,14 @@
77
88pub const SNIFF_LIMIT: i64 = 8192;
99
10#[derive(Debug, Clone, serde::Serialize)]
10#[derive(Debug, Clone, serde::Serialize, utoipa::ToSchema)]
1111pub struct LfsPointerDto {
1212 pub version: String,
1313 pub oid: Option<String>,
1414 pub size: Option<i64>,
1515}
1616
17#[derive(Debug, Clone, serde::Serialize)]
17#[derive(Debug, Clone, serde::Serialize, utoipa::ToSchema)]
1818pub struct BlobMetaDto {
1919 pub oid: String,
2020 pub size: i64,
@@ -23,7 +23,7 @@
2323 pub lfs: Option<LfsPointerDto>,
2424}
2525
26#[derive(Debug, Clone, serde::Serialize)]
26#[derive(Debug, Clone, serde::Serialize, utoipa::ToSchema)]
2727pub struct BlobContentDto {
2828 pub oid: String,
2929 pub data: Vec<u8>,
@@ -32,7 +32,7 @@
3232 pub truncated: bool,
3333}
3434
35#[derive(Debug, Clone, serde::Serialize)]
35#[derive(Debug, Clone, serde::Serialize, utoipa::ToSchema)]
3636pub struct RawDownloadDto {
3737 pub id: String,
3838 pub size: i64,
Modified lib/git/src/service/diffs.rs lib/git/src/service/diffs.rs +1 −1 View lib/git/src/service/diffs.rs
@@ -31,7 +31,7 @@
3131 }
3232}
3333
34#[derive(Debug, Clone, Serialize)]
34#[derive(Debug, Clone, Serialize, utoipa::ToSchema)]
3535pub struct DiffTreeRecordDto {
3636 pub status: String,
3737 pub score: u8,
Modified lib/git/src/service/path_log.rs lib/git/src/service/path_log.rs +1 −1 View lib/git/src/service/path_log.rs
@@ -6,7 +6,7 @@
66use crate::service::GitService;
77use crate::share::errors::{GitError, map_baby};
88
9#[derive(Debug, Clone, Serialize)]
9#[derive(Debug, Clone, Serialize, utoipa::ToSchema)]
1010pub struct PathLogEntryDto {
1111 pub path: String,
1212 pub short_sha: String,
Modified lib/git/src/service/submodules.rs lib/git/src/service/submodules.rs +1 −1 View lib/git/src/service/submodules.rs
@@ -6,7 +6,7 @@
66use crate::service::GitService;
77use crate::share::errors::{GitError, map_baby};
88
9#[derive(Debug, Clone, Serialize)]
9#[derive(Debug, Clone, Serialize, utoipa::ToSchema)]
1010pub struct SubmoduleDto {
1111 pub path: String,
1212 pub url: String,
Modified lib/git/src/service/trees.rs lib/git/src/service/trees.rs +1 −1 View lib/git/src/service/trees.rs
@@ -7,7 +7,7 @@
77use crate::share::errors::{GitError, map_baby};
88use crate::share::validate::validate_revision;
99
10#[derive(Debug, Clone, serde::Serialize)]
10#[derive(Debug, Clone, serde::Serialize, utoipa::ToSchema)]
1111pub struct PathLastUpdated {
1212 pub path: String,
1313 pub object_type: i8,