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.
|
pushkey was last updated.
|
||||||
data:
|
data:
|
||||||
type: object
|
type: object
|
||||||
|
title: PusherData
|
||||||
description: |-
|
description: |-
|
||||||
A dictionary of additional pusher-specific data. For
|
A dictionary of additional pusher-specific data. For
|
||||||
'http' pushers, this is the data dictionary passed in at
|
'http' pushers, this is the data dictionary passed in at
|
||||||
pusher creation minus the ``url`` key.
|
pusher creation minus the ``url`` key.
|
||||||
|
properties:
|
||||||
|
foo:
|
||||||
|
type: string
|
||||||
tweaks:
|
tweaks:
|
||||||
type: object
|
type: object
|
||||||
|
title: Tweaks
|
||||||
description: |-
|
description: |-
|
||||||
A dictionary of customisations made to the way this
|
A dictionary of customisations made to the way this
|
||||||
notification is to be presented. These are added by push rules.
|
notification is to be presented. These are added by push rules.
|
||||||
|
|
|
@ -413,6 +413,8 @@ paths:
|
||||||
always matches.
|
always matches.
|
||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
|
title: conditions
|
||||||
|
allOf: [ "$ref": "definitions/push_condition.json" ]
|
||||||
required: ["actions"]
|
required: ["actions"]
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
|
|
|
@ -219,23 +219,39 @@ class MatrixUnits(Units):
|
||||||
if Units.prop(param, "schema/required"):
|
if Units.prop(param, "schema/required"):
|
||||||
required_params = Units.prop(param, "schema/required")
|
required_params = Units.prop(param, "schema/required")
|
||||||
for key in json_body:
|
for key in json_body:
|
||||||
pdesc = json_body[key]["description"]
|
req_obj = json_body[key]
|
||||||
|
pdesc = req_obj["description"]
|
||||||
if key in required_params:
|
if key in required_params:
|
||||||
pdesc = "**Required.** " + pdesc
|
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({
|
endpoint["req_params"].append({
|
||||||
"key": key,
|
"key": key,
|
||||||
"loc": "JSON body",
|
"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
|
"desc": pdesc
|
||||||
})
|
})
|
||||||
if json_body[key]["type"] in ["object"]:
|
if not is_array_of_objects and req_obj["type"] == "array":
|
||||||
req_tables = get_json_schema_object_fields(
|
continue
|
||||||
json_body[key]
|
# 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:
|
for table in req_tables:
|
||||||
|
if table.get("no-table"):
|
||||||
|
continue
|
||||||
for row in table["rows"]:
|
for row in table["rows"]:
|
||||||
endpoint["req_params"].append({
|
endpoint["req_params"].append({
|
||||||
"key": key + "." + row["key"],
|
"key": key + key_sep + row["key"],
|
||||||
"loc": "JSON body",
|
"loc": "JSON body",
|
||||||
"type": row["type"],
|
"type": row["type"],
|
||||||
"desc": row["req_str"] + row["desc"]
|
"desc": row["req_str"] + row["desc"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue