schema: add 'description' builder methods to schema types

To cover the use case where we want to change only the description of
an existing type.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2025-01-15 11:07:07 +01:00
parent 72c95c35bb
commit c040054827

View File

@ -198,6 +198,11 @@ impl BooleanSchema {
}
}
pub const fn description(mut self, description: &'static str) -> Self {
self.description = description;
self
}
pub const fn default(mut self, default: bool) -> Self {
self.default = Some(default);
self
@ -240,6 +245,11 @@ impl IntegerSchema {
}
}
pub const fn description(mut self, description: &'static str) -> Self {
self.description = description;
self
}
pub const fn default(mut self, default: isize) -> Self {
self.default = Some(default);
self
@ -316,6 +326,11 @@ impl NumberSchema {
}
}
pub const fn description(mut self, description: &'static str) -> Self {
self.description = description;
self
}
pub const fn default(mut self, default: f64) -> Self {
self.default = Some(default);
self
@ -420,6 +435,11 @@ impl StringSchema {
}
}
pub const fn description(mut self, description: &'static str) -> Self {
self.description = description;
self
}
pub const fn default(mut self, text: &'static str) -> Self {
self.default = Some(text);
self
@ -537,6 +557,11 @@ impl ArraySchema {
}
}
pub const fn description(mut self, description: &'static str) -> Self {
self.description = description;
self
}
pub const fn min_length(mut self, min_length: usize) -> Self {
self.min_length = Some(min_length);
self