Use "anyOf" instead of "oneOf" in users@openstack plugin

In case if we specify only argument user_choice_method schema
will match both oneOf sections and fail, however it's right schema
and should pass (in other words we need anyOf)

As well fix doc extension to work with anyOf as well

Change-Id: I2b2a3a1c42277a83511cdac81496b5240d983d33
This commit is contained in:
Boris Pavlovic 2017-09-17 17:02:37 -07:00
parent d2ebe23761
commit 00c3ff1552
2 changed files with 13 additions and 8 deletions

View File

@ -131,7 +131,7 @@ def process_jsonschema(schema):
"additionalProperties"})):
# it is ok, schema accepts any object. nothing to add more
pass
elif "oneOf" in schema:
elif "oneOf" in schema or "anyOf" in schema:
# Example:
# SCHEMA = {"type": "object", "$schema": consts.JSON_SCHEMA,
# "oneOf": [{"properties": {"foo": {"type": "string"}}
@ -141,15 +141,20 @@ def process_jsonschema(schema):
# "required": ["bar"],
# "additionalProperties": False},
#
oneOf = copy.deepcopy(schema["oneOf"])
for item in oneOf:
schema_key = "oneOf" if "oneOf" in schema else "anyOf"
schema_value = copy.deepcopy(schema.get(schema_key))
for item in schema_value:
for k, v in schema.items():
if k not in ("oneOf", "description"):
if k not in (schema_key, "description"):
item[k] = v
return {"doc": schema.get("description", ""),
return {
"doc": schema.get("description", ""),
"type": "dict",
"oneOf": [process_jsonschema(item) for item in oneOf]}
schema_key: [
process_jsonschema(item) for item in schema_value]
}
else:
raise Exception("Failed to parse jsonschema: %s" % schema)

View File

@ -54,7 +54,7 @@ class UserGenerator(context.Context):
CONFIG_SCHEMA = {
"type": "object",
"$schema": consts.JSON_SCHEMA,
"oneOf": [
"anyOf": [
{"description": "Create new temporary users and tenants.",
"properties": {
"tenants": {