]> git.proxmox.com Git - pve-common.git/commit - src/PVE/CLIHandler.pm
json schema: implement 'oneOf' schema
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 16 Nov 2023 15:21:49 +0000 (16:21 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 17 Nov 2023 08:24:09 +0000 (09:24 +0100)
commit942583468fe8087a63579ee409c4096591683f28
treed534e2abea825f680200aeedcdb43527d99e62c5
parent15645af168557bcae180d0145d33ac1034876bde
json schema: implement 'oneOf' schema

a schema can now have the 'oneOf' property which is an array of regular
schemas. In the default case any of that has to match. If the
'type-property'/'instance-types' are given, only the schema for the specific
type will be checked (and handles as 'additionalProperties' if there is
no matching type)

the field found in 'type-property' has to be on the same level
(so for oneOf the nested schemas should not include that).

Documentation is adapted so that options are grouped per `type-property=value`
after the regular options (with their individual descriptions/types/etc.)

oneOfs without 'type-property'/'instance-tyeps' simply show up twice for
now with an 'or' line in between.

command line parsing is a bit weird for now since Getopt::Long
can't have multiple variants for the same property (but works fine with
pvesh for our current use cases). it gets shown as '--foo <multiple' if
they are not optional.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/CLIHandler.pm
src/PVE/JSONSchema.pm
src/PVE/RESTHandler.pm