|
3 | 3 |
|
4 | 4 | use schemars::JsonSchema;
|
5 | 5 | use serde::{Deserialize, Serialize};
|
| 6 | +use crate::schema::{get_registry_key_path_pattern, get_schema_uri}; |
6 | 7 |
|
7 | 8 | #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
|
8 | 9 | pub enum RegistryValueData {
|
| 10 | + #[schemars( |
| 11 | + title = t!("schema.valueData.String.title").to_string(), |
| 12 | + description = t!("schema.valueData.String.description").to_string(), |
| 13 | + extend( |
| 14 | + "markdownDescription" = t!("schema.valueData.String.markdownDescription").to_string() |
| 15 | + ) |
| 16 | + )] |
9 | 17 | String(String),
|
| 18 | + #[schemars( |
| 19 | + title = t!("schema.valueData.ExpandString.title").to_string(), |
| 20 | + description = t!("schema.valueData.ExpandString.description").to_string(), |
| 21 | + extend( |
| 22 | + "markdownDescription" = t!("schema.valueData.ExpandString.markdownDescription").to_string() |
| 23 | + ) |
| 24 | + )] |
10 | 25 | ExpandString(String),
|
| 26 | + #[schemars( |
| 27 | + title = t!("schema.valueData.Binary.title").to_string(), |
| 28 | + description = t!("schema.valueData.Binary.description").to_string(), |
| 29 | + extend( |
| 30 | + "markdownDescription" = t!("schema.valueData.Binary.markdownDescription").to_string() |
| 31 | + ) |
| 32 | + )] |
11 | 33 | Binary(Vec<u8>),
|
| 34 | + #[schemars( |
| 35 | + title = t!("schema.valueData.DWord.title").to_string(), |
| 36 | + description = t!("schema.valueData.DWord.description").to_string(), |
| 37 | + extend( |
| 38 | + "markdownDescription" = t!("schema.valueData.DWord.markdownDescription").to_string() |
| 39 | + ) |
| 40 | + )] |
12 | 41 | DWord(u32),
|
| 42 | + #[schemars( |
| 43 | + title = t!("schema.valueData.MultiString.title").to_string(), |
| 44 | + description = t!("schema.valueData.MultiString.description").to_string(), |
| 45 | + extend( |
| 46 | + "markdownDescription" = t!("schema.valueData.MultiString.markdownDescription").to_string() |
| 47 | + ) |
| 48 | + )] |
13 | 49 | MultiString(Vec<String>),
|
| 50 | + #[schemars( |
| 51 | + title = t!("schema.valueData.QWord.title").to_string(), |
| 52 | + description = t!("schema.valueData.QWord.description").to_string(), |
| 53 | + extend( |
| 54 | + "markdownDescription" = t!("schema.valueData.QWord.markdownDescription").to_string() |
| 55 | + ) |
| 56 | + )] |
14 | 57 | QWord(u64),
|
15 | 58 | }
|
16 | 59 |
|
17 | 60 | #[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
|
18 | 61 | #[serde(rename = "Registry", deny_unknown_fields)]
|
| 62 | +#[schemars( |
| 63 | + title=t!("schema.title").to_string(), |
| 64 | + description=t!("schema.description").to_string(), |
| 65 | + extend( |
| 66 | + "$id" = get_schema_uri(true), |
| 67 | + "dependentRequired" = { "valueData": ["valueName"] }, |
| 68 | + "markdownDescription" = t!("schema.markdownDescription").to_string() |
| 69 | + ) |
| 70 | +)] |
19 | 71 | pub struct Registry {
|
20 | 72 | /// The path to the registry key.
|
21 | 73 | #[serde(rename = "keyPath")]
|
| 74 | + #[schemars( |
| 75 | + title = t!("schema.keyPath.title").to_string(), |
| 76 | + description = t!("schema.keyPath.description").to_string(), |
| 77 | + required, |
| 78 | + regex(pattern = get_registry_key_path_pattern()), |
| 79 | + extend( |
| 80 | + "markdownDescription" = t!("schema.keyPath.markdownDescription").to_string(), |
| 81 | + "patternErrorMessage" = t!("schema.keyPath.patternErrorMessage").to_string(), |
| 82 | + ) |
| 83 | + )] |
22 | 84 | pub key_path: String,
|
23 | 85 | /// The information from a config set --what-if operation.
|
24 | 86 | #[serde(rename = "_metadata", skip_serializing_if = "Option::is_none")]
|
| 87 | + #[schemars( |
| 88 | + title = t!("schema.metadata.title").to_string(), |
| 89 | + description = t!("schema.metadata.description").to_string(), |
| 90 | + extend( |
| 91 | + "readOnly" = true, |
| 92 | + "markdownDescription" = t!("schema.metadata.markdownDescription").to_string() |
| 93 | + ) |
| 94 | + )] |
25 | 95 | pub metadata: Option<Metadata>,
|
26 | 96 | /// The name of the registry value.
|
27 | 97 | #[serde(rename = "valueName", skip_serializing_if = "Option::is_none")]
|
| 98 | + #[schemars( |
| 99 | + title = t!("schema.valueName.title").to_string(), |
| 100 | + description = t!("schema.valueName.description").to_string(), |
| 101 | + extend( |
| 102 | + "markdownDescription" = t!("schema.valueName.markdownDescription").to_string() |
| 103 | + ) |
| 104 | + )] |
28 | 105 | pub value_name: Option<String>,
|
29 | 106 | /// The data of the registry value.
|
30 | 107 | #[serde(rename = "valueData", skip_serializing_if = "Option::is_none")]
|
| 108 | + #[schemars( |
| 109 | + title = t!("schema.valueData.title").to_string(), |
| 110 | + description = t!("schema.valueData.description").to_string(), |
| 111 | + extend( |
| 112 | + "markdownDescription" = t!("schema.valueData.markdownDescription").to_string() |
| 113 | + ) |
| 114 | + )] |
31 | 115 | pub value_data: Option<RegistryValueData>,
|
32 |
| - #[serde(rename = "_exist", skip_serializing_if = "Option::is_none")] |
| 116 | + #[serde(rename = "_exist")] |
| 117 | + #[schemars( |
| 118 | + title = t!("schema.exist.title").to_string(), |
| 119 | + description = t!("schema.exist.description").to_string(), |
| 120 | + extend( |
| 121 | + "default" = true, |
| 122 | + "markdownDescription" = t!("schema.exist.markdownDescription").to_string() |
| 123 | + ) |
| 124 | + )] |
33 | 125 | pub exist: Option<bool>,
|
34 | 126 | }
|
35 | 127 |
|
36 | 128 | #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
|
37 | 129 | #[serde(deny_unknown_fields)]
|
38 | 130 | pub struct Metadata {
|
39 | 131 | #[serde(rename = "whatIf", skip_serializing_if = "Option::is_none")]
|
| 132 | + #[schemars( |
| 133 | + title = t!("schema.metadata.whatIf.title").to_string(), |
| 134 | + description = t!("schema.metadata.whatIf.description").to_string(), |
| 135 | + extend( |
| 136 | + "readOnly" = true, |
| 137 | + "markdownDescription" = t!("schema.metadata.whatIf.markdownDescription").to_string() |
| 138 | + ) |
| 139 | + )] |
40 | 140 | pub what_if: Option<Vec<String>>
|
41 | 141 | }
|
0 commit comments