Skip to main content

pan_common/
schema.rs

1use serde::Serialize;
2
3/// Describes a single parameter for a command (used by --schema).
4#[derive(Debug, Clone, Serialize)]
5pub struct ParamSchema {
6    pub name: String,
7    #[serde(rename = "type")]
8    pub param_type: ParamType,
9    pub required: bool,
10    pub description: String,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub default: Option<serde_json::Value>,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub choices: Option<Vec<String>>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub range: Option<ParamRange>,
17}
18
19#[derive(Debug, Clone, Serialize)]
20#[serde(rename_all = "lowercase")]
21pub enum ParamType {
22    String,
23    Integer,
24    Float,
25    Boolean,
26    Path,
27}
28
29#[derive(Debug, Clone, Serialize)]
30pub struct ParamRange {
31    pub min: f64,
32    pub max: f64,
33}
34
35/// Full schema for a command.
36#[derive(Debug, Clone, Serialize)]
37pub struct CommandSchema {
38    pub command: String,
39    pub description: String,
40    pub params: Vec<ParamSchema>,
41}