[docs] Fix representation of items
In case of oneOf of anyOf usage in "items" section without type (see nics property of servers context) the schema is displayed like regular string withou json.dumps which leads to the very long lines. Change-Id: I4ee5067a0985ef5df782dd4d16591daf0b924951
This commit is contained in:
parent
d8995226fe
commit
725c3470f8
@ -76,27 +76,25 @@ def process_jsonschema(schema):
|
||||
"described below:\n\n")
|
||||
|
||||
items = schema["items"]
|
||||
itype = None
|
||||
if "type" in items:
|
||||
itype = JSON_SCHEMA_TYPES_MAP.get(items["type"],
|
||||
items["type"])
|
||||
info["doc"] += "- Type: %s. " % itype
|
||||
if "description" in items:
|
||||
# add indention
|
||||
desc = items["description"].split("\n")
|
||||
info["doc"] += "\n ".join(desc)
|
||||
if "description" in items:
|
||||
# add indention
|
||||
desc = items["description"].split("\n")
|
||||
info["doc"] += "\n ".join(desc)
|
||||
|
||||
if itype in ("list", "dict"):
|
||||
new_schema = copy.copy(items)
|
||||
new_schema.pop("description", None)
|
||||
new_schema = json.dumps(new_schema, indent=4)
|
||||
new_schema = "\n ".join(
|
||||
new_schema.split("\n"))
|
||||
new_schema = copy.copy(items)
|
||||
new_schema.pop("description", None)
|
||||
new_schema = json.dumps(new_schema, indent=4)
|
||||
new_schema = "\n ".join(
|
||||
new_schema.split("\n"))
|
||||
|
||||
info["doc"] += ("\n Format:\n\n"
|
||||
" .. code-block:: json\n\n"
|
||||
" %s\n" % new_schema)
|
||||
else:
|
||||
info["doc"] += " - ``%s`` " % items
|
||||
info["doc"] += ("\n Format:\n\n"
|
||||
" .. code-block:: json\n\n"
|
||||
" %s\n" % new_schema)
|
||||
return info
|
||||
|
||||
elif isinstance(schema["type"], list):
|
||||
|
Loading…
x
Reference in New Issue
Block a user