docgen: dump string format (property strings)
This commit is contained in:
parent
bc2358319b
commit
8616a4afe5
@ -48,7 +48,7 @@ percent-encoding = "2.1"
|
|||||||
pin-utils = "0.1.0"
|
pin-utils = "0.1.0"
|
||||||
pin-project = "1.0"
|
pin-project = "1.0"
|
||||||
pathpatterns = "0.1.2"
|
pathpatterns = "0.1.2"
|
||||||
proxmox = { version = "0.10.5", features = [ "sortable-macro", "api-macro", "websocket" ] }
|
proxmox = { version = "0.10.6", features = [ "sortable-macro", "api-macro", "websocket" ] }
|
||||||
#proxmox = { git = "git://git.proxmox.com/git/proxmox", version = "0.1.2", features = [ "sortable-macro", "api-macro" ] }
|
#proxmox = { git = "git://git.proxmox.com/git/proxmox", version = "0.1.2", features = [ "sortable-macro", "api-macro" ] }
|
||||||
#proxmox = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro", "websocket" ] }
|
#proxmox = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro", "websocket" ] }
|
||||||
proxmox-fuse = "0.1.1"
|
proxmox-fuse = "0.1.1"
|
||||||
|
8
debian/control
vendored
8
debian/control
vendored
@ -36,10 +36,10 @@ Build-Depends: debhelper (>= 11),
|
|||||||
librust-percent-encoding-2+default-dev (>= 2.1-~~),
|
librust-percent-encoding-2+default-dev (>= 2.1-~~),
|
||||||
librust-pin-project-1+default-dev,
|
librust-pin-project-1+default-dev,
|
||||||
librust-pin-utils-0.1+default-dev,
|
librust-pin-utils-0.1+default-dev,
|
||||||
librust-proxmox-0.10+api-macro-dev (>= 0.10.5-~~),
|
librust-proxmox-0.10+api-macro-dev (>= 0.10.6-~~),
|
||||||
librust-proxmox-0.10+default-dev (>= 0.10.5-~~),
|
librust-proxmox-0.10+default-dev (>= 0.10.6-~~),
|
||||||
librust-proxmox-0.10+sortable-macro-dev (>= 0.10.5-~~),
|
librust-proxmox-0.10+sortable-macro-dev (>= 0.10.6-~~),
|
||||||
librust-proxmox-0.10+websocket-dev (>= 0.10.5-~~),
|
librust-proxmox-0.10+websocket-dev (>= 0.10.6-~~),
|
||||||
librust-proxmox-fuse-0.1+default-dev (>= 0.1.1-~~),
|
librust-proxmox-fuse-0.1+default-dev (>= 0.1.1-~~),
|
||||||
librust-pxar-0.9+default-dev,
|
librust-pxar-0.9+default-dev,
|
||||||
librust-pxar-0.9+tokio-io-dev,
|
librust-pxar-0.9+tokio-io-dev,
|
||||||
|
@ -7,10 +7,12 @@ use proxmox::{
|
|||||||
Schema,
|
Schema,
|
||||||
ObjectSchemaType,
|
ObjectSchemaType,
|
||||||
SchemaPropertyEntry,
|
SchemaPropertyEntry,
|
||||||
|
ApiStringFormat,
|
||||||
},
|
},
|
||||||
format::{
|
format::{
|
||||||
dump_enum_properties,
|
dump_enum_properties,
|
||||||
dump_section_config,
|
dump_section_config,
|
||||||
|
get_property_string_type_text,
|
||||||
},
|
},
|
||||||
ApiMethod,
|
ApiMethod,
|
||||||
ApiHandler,
|
ApiHandler,
|
||||||
@ -123,6 +125,30 @@ pub fn dump_schema(schema: &Schema) -> Value {
|
|||||||
if let Some(type_text) = string_schema.type_text {
|
if let Some(type_text) = string_schema.type_text {
|
||||||
data["typetext"] = type_text.into();
|
data["typetext"] = type_text.into();
|
||||||
}
|
}
|
||||||
|
match string_schema.format {
|
||||||
|
None | Some(ApiStringFormat::VerifyFn(_)) => { /* do nothing */ }
|
||||||
|
Some(ApiStringFormat::Pattern(const_regex)) => {
|
||||||
|
data["pattern"] = const_regex.regex_string.into();
|
||||||
|
}
|
||||||
|
Some(ApiStringFormat::Enum(variants)) => {
|
||||||
|
let variants: Vec<String> = variants
|
||||||
|
.iter()
|
||||||
|
.map(|e| e.value.to_string())
|
||||||
|
.collect();
|
||||||
|
data["enum"] = serde_json::to_value(variants).unwrap();
|
||||||
|
}
|
||||||
|
Some(ApiStringFormat::PropertyString(subschema)) => {
|
||||||
|
|
||||||
|
match subschema {
|
||||||
|
Schema::Object(_) | Schema::Array(_) => {
|
||||||
|
data["format"] = dump_schema(subschema);
|
||||||
|
data["typetext"] = get_property_string_type_text(subschema)
|
||||||
|
.into();
|
||||||
|
}
|
||||||
|
_ => { /* do nothing - shouldnot happen */ }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
// fixme: dump format
|
// fixme: dump format
|
||||||
}
|
}
|
||||||
Schema::Integer(integer_schema) => {
|
Schema::Integer(integer_schema) => {
|
||||||
@ -158,6 +184,9 @@ pub fn dump_schema(schema: &Schema) -> Value {
|
|||||||
Schema::Object(object_schema) => {
|
Schema::Object(object_schema) => {
|
||||||
data = dump_property_schema(object_schema);
|
data = dump_property_schema(object_schema);
|
||||||
data["type"] = "object".into();
|
data["type"] = "object".into();
|
||||||
|
if let Some(default_key) = object_schema.default_key {
|
||||||
|
data["default_key"] = default_key.into();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Schema::Array(array_schema) => {
|
Schema::Array(array_schema) => {
|
||||||
data = json!({
|
data = json!({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user