Skip to content

Commit

Permalink
release v1.5.4: add api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
theMackabu committed Nov 28, 2023
1 parent 404b57f commit 945f755
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/daemon/api/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,23 @@ pub struct MetricsRoot<'a> {

#[derive(Serialize, ToSchema)]
pub struct Version<'a> {
#[schema(example = "v1.0.0")]
pub pkg: String,
pub hash: &'a str,
#[schema(example = "2000-01-01")]
pub build_date: &'a str,
#[schema(example = "release")]
pub target: &'a str,
}

#[derive(Serialize, ToSchema)]
pub struct Daemon {
pub pid: String,
pub pid: Option<i32>,
#[schema(example = true)]
pub running: bool,
pub uptime: String,
pub process_count: usize,
#[schema(example = "default")]
pub daemon_type: String,
pub stats: Stats,
}
Expand Down Expand Up @@ -354,15 +359,10 @@ pub async fn metrics_handler() -> Result<impl Reply, Infallible> {
None => string!("none"),
};

let pid = match pid {
Some(pid) => string!(pid),
None => string!("n/a"),
};

let response = json!(MetricsRoot {
version: Version {
pkg: format!("v{}", env!("CARGO_PKG_VERSION")),
hash: env!("GIT_HASH"),
hash: env!("GIT_HASH_FULL"),
build_date: env!("BUILD_DATE"),
target: env!("PROFILE"),
},
Expand Down
2 changes: 2 additions & 0 deletions src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub struct ProcessItem {
restarts: u64,
status: String,
uptime: String,
#[schema(example = "/path")]
watch_path: String,
#[schema(value_type = String, example = "2000-01-01T01:00:00.000Z")]
start_time: DateTime<Utc>,
Expand Down Expand Up @@ -96,6 +97,7 @@ pub struct Crash {
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
pub struct Watch {
pub enabled: bool,
#[schema(example = "/path")]
pub path: String,
pub hash: String,
}
Expand Down

0 comments on commit 945f755

Please sign in to comment.