Display nested keys on arrays of objects. Make it valid swagger.
This commit is contained in:
parent
31ae4b3859
commit
65504db7bb
3 changed files with 30 additions and 7 deletions
|
@ -151,12 +151,17 @@ paths:
|
|||
pushkey was last updated.
|
||||
data:
|
||||
type: object
|
||||
title: PusherData
|
||||
description: |-
|
||||
A dictionary of additional pusher-specific data. For
|
||||
'http' pushers, this is the data dictionary passed in at
|
||||
pusher creation minus the ``url`` key.
|
||||
properties:
|
||||
foo:
|
||||
type: string
|
||||
tweaks:
|
||||
type: object
|
||||
title: Tweaks
|
||||
description: |-
|
||||
A dictionary of customisations made to the way this
|
||||
notification is to be presented. These are added by push rules.
|
||||
|
|
|
@ -413,6 +413,8 @@ paths:
|
|||
always matches.
|
||||
items:
|
||||
type: object
|
||||
title: conditions
|
||||
allOf: [ "$ref": "definitions/push_condition.json" ]
|
||||
required: ["actions"]
|
||||
responses:
|
||||
200:
|
||||
|
|
|
@ -219,23 +219,39 @@ class MatrixUnits(Units):
|
|||
if Units.prop(param, "schema/required"):
|
||||
required_params = Units.prop(param, "schema/required")
|
||||
for key in json_body:
|
||||
pdesc = json_body[key]["description"]
|
||||
req_obj = json_body[key]
|
||||
pdesc = req_obj["description"]
|
||||
if key in required_params:
|
||||
pdesc = "**Required.** " + pdesc
|
||||
|
||||
is_array = req_obj["type"] == "array"
|
||||
is_array_of_objects = (
|
||||
is_array and req_obj["items"]["type"] == "object"
|
||||
)
|
||||
endpoint["req_params"].append({
|
||||
"key": key,
|
||||
"loc": "JSON body",
|
||||
"type": json_body[key]["type"],
|
||||
"type": (
|
||||
req_obj["type"] if not is_array else
|
||||
"array[%s]" % req_obj["items"]["type"]
|
||||
),
|
||||
"desc": pdesc
|
||||
})
|
||||
if json_body[key]["type"] in ["object"]:
|
||||
req_tables = get_json_schema_object_fields(
|
||||
json_body[key]
|
||||
)
|
||||
if not is_array_of_objects and req_obj["type"] == "array":
|
||||
continue
|
||||
# Put in request.dot.notation for nested keys
|
||||
if req_obj["type"] in ["object", "array"]:
|
||||
if is_array_of_objects:
|
||||
req_obj = req_obj["items"]
|
||||
|
||||
req_tables = get_json_schema_object_fields(req_obj)
|
||||
key_sep = "[0]." if is_array else "."
|
||||
for table in req_tables:
|
||||
if table.get("no-table"):
|
||||
continue
|
||||
for row in table["rows"]:
|
||||
endpoint["req_params"].append({
|
||||
"key": key + "." + row["key"],
|
||||
"key": key + key_sep + row["key"],
|
||||
"loc": "JSON body",
|
||||
"type": row["type"],
|
||||
"desc": row["req_str"] + row["desc"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue