diff --git a/Cargo.toml b/Cargo.toml index a436e1ad9..1862bdc60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ percent-encoding = "2.1" pin-utils = "0.1.0" pin-project = "1.0" 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 = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro", "websocket" ] } proxmox-fuse = "0.1.1" diff --git a/debian/control b/debian/control index 64f12c967..48070c0ff 100644 --- a/debian/control +++ b/debian/control @@ -36,10 +36,10 @@ Build-Depends: debhelper (>= 11), librust-percent-encoding-2+default-dev (>= 2.1-~~), librust-pin-project-1+default-dev, librust-pin-utils-0.1+default-dev, - librust-proxmox-0.10+api-macro-dev (>= 0.10.5-~~), - librust-proxmox-0.10+default-dev (>= 0.10.5-~~), - librust-proxmox-0.10+sortable-macro-dev (>= 0.10.5-~~), - librust-proxmox-0.10+websocket-dev (>= 0.10.5-~~), + librust-proxmox-0.10+api-macro-dev (>= 0.10.6-~~), + librust-proxmox-0.10+default-dev (>= 0.10.6-~~), + librust-proxmox-0.10+sortable-macro-dev (>= 0.10.6-~~), + librust-proxmox-0.10+websocket-dev (>= 0.10.6-~~), librust-proxmox-fuse-0.1+default-dev (>= 0.1.1-~~), librust-pxar-0.9+default-dev, librust-pxar-0.9+tokio-io-dev, diff --git a/src/bin/docgen.rs b/src/bin/docgen.rs index e038af76e..b0b85610a 100644 --- a/src/bin/docgen.rs +++ b/src/bin/docgen.rs @@ -7,10 +7,12 @@ use proxmox::{ Schema, ObjectSchemaType, SchemaPropertyEntry, + ApiStringFormat, }, format::{ dump_enum_properties, dump_section_config, + get_property_string_type_text, }, ApiMethod, ApiHandler, @@ -123,6 +125,30 @@ pub fn dump_schema(schema: &Schema) -> Value { if let Some(type_text) = string_schema.type_text { 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 = 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 } Schema::Integer(integer_schema) => { @@ -158,6 +184,9 @@ pub fn dump_schema(schema: &Schema) -> Value { Schema::Object(object_schema) => { data = dump_property_schema(object_schema); data["type"] = "object".into(); + if let Some(default_key) = object_schema.default_key { + data["default_key"] = default_key.into(); + } } Schema::Array(array_schema) => { data = json!({