[pdm-devel] [PATCH proxmox 4/4] docgen: add a stop-gap fix to allow generating schema for pve-api-types

Shannon Sterz s.sterz at proxmox.com
Wed Nov 12 17:09:43 CET 2025


note that Wolfgang is already working on a fix for this, so this commit
can just be dropped. since it's just about dropping this commit, i'll
refrain from respin this series just for that change. hope that's ok, if
not let me know.

On Wed Nov 12, 2025 at 11:24 AM CET, Shannon Sterz wrote:
> Signed-off-by: Shannon Sterz <s.sterz at proxmox.com>
> ---
>  proxmox-docgen/src/lib.rs | 38 +++++++++++++++++++++++++++-----------
>  1 file changed, 27 insertions(+), 11 deletions(-)
>
> diff --git a/proxmox-docgen/src/lib.rs b/proxmox-docgen/src/lib.rs
> index 67d502d5..f3d53519 100644
> --- a/proxmox-docgen/src/lib.rs
> +++ b/proxmox-docgen/src/lib.rs
> @@ -97,7 +97,7 @@ fn dump_schema(schema: &Schema) -> Value {
>              }
>          }
>          Schema::Object(object_schema) => {
> -            data = dump_property_schema(object_schema);
> +            data = dump_property_schema(object_schema, false);
>              data["type"] = "object".into();
>              if let Some(default_key) = object_schema.default_key {
>                  data["default_key"] = default_key.into();
> @@ -117,7 +117,12 @@ fn dump_schema(schema: &Schema) -> Value {
>              }
>          }
>          Schema::AllOf(alloff_schema) => {
> -            data = dump_property_schema(alloff_schema);
> +            let dirty_allof = alloff_schema
> +                .list
> +                .iter()
> +                .any(|schema| schema.any_object().is_none());
> +
> +            data = dump_property_schema(alloff_schema, dirty_allof);
>              data["type"] = "object".into();
>          }
>          Schema::OneOf(schema) => {
> @@ -144,7 +149,8 @@ fn dump_schema(schema: &Schema) -> Value {
>      data
>  }
>
> -fn dump_property_schema(param: &dyn ObjectSchemaType) -> Value {
> +// TODO: remove `dirty_allof` again once pve-api-types generates proper `AllOf` schema.
> +fn dump_property_schema(param: &dyn ObjectSchemaType, dirty_allof: bool) -> Value {
>      let mut properties = json!({});
>
>      for (prop, optional, schema) in param.properties() {
> @@ -155,13 +161,23 @@ fn dump_property_schema(param: &dyn ObjectSchemaType) -> Value {
>          properties[prop] = property;
>      }
>
> -    let data = json!({
> -        "description": param.description(),
> -        "additionalProperties": param.additional_properties(),
> -        "properties": properties,
> -    });
> -
> -    data
> +    if dirty_allof {
> +        json!({
> +            "description": param.description(),
> +            // stop gap for now. pve-api-types generates certain properties as string schema that
> +            // are really property strings (which wrap an object schema anyway). however,
> +            // `additional_properties()` panics there, because it will expect *only* object
> +            // schema.
> +            "additionalProperties": true,
> +            "properties": properties,
> +        })
> +    } else {
> +        json!({
> +            "description": param.description(),
> +            "additionalProperties": param.additional_properties(),
> +            "properties": properties,
> +        })
> +    }
>  }
>
>  fn dump_api_permission(permission: &Permission, privileges: &[(&str, u64)]) -> Value {
> @@ -222,7 +238,7 @@ fn dump_api_method_schema(
>          "description": api_method.parameters.description(),
>      });
>
> -    data["parameters"] = dump_property_schema(&api_method.parameters);
> +    data["parameters"] = dump_property_schema(&api_method.parameters, false);
>
>      let mut returns = dump_schema(api_method.returns.schema);
>      if api_method.returns.optional {





More information about the pdm-devel mailing list