From 00c3ff1552e7057edcf8fd1e86675be96f20c83c Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Sun, 17 Sep 2017 17:02:37 -0700 Subject: [PATCH] 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 --- doc/ext/plugin_reference.py | 19 ++++++++++++------- .../openstack/context/keystone/users.py | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/doc/ext/plugin_reference.py b/doc/ext/plugin_reference.py index 3c4bb16d..b510e418 100644 --- a/doc/ext/plugin_reference.py +++ b/doc/ext/plugin_reference.py @@ -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", ""), - "type": "dict", - "oneOf": [process_jsonschema(item) for item in oneOf]} + return { + "doc": schema.get("description", ""), + "type": "dict", + schema_key: [ + process_jsonschema(item) for item in schema_value] + } else: raise Exception("Failed to parse jsonschema: %s" % schema) diff --git a/rally/plugins/openstack/context/keystone/users.py b/rally/plugins/openstack/context/keystone/users.py index 0e45cee5..a39f27ab 100644 --- a/rally/plugins/openstack/context/keystone/users.py +++ b/rally/plugins/openstack/context/keystone/users.py @@ -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": {