|
|
@ -1,4 +1,12 @@
|
|
|
|
"""Contains all the units for the spec."""
|
|
|
|
"""
|
|
|
|
|
|
|
|
Contains all the units for the spec.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This file loads swagger and JSON schema files and parses out the useful bits
|
|
|
|
|
|
|
|
and returns them as Units for use in Batesian.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For the actual conversion of data -> RST (including templates), see the sections
|
|
|
|
|
|
|
|
file instead.
|
|
|
|
|
|
|
|
"""
|
|
|
|
from batesian.units import Units
|
|
|
|
from batesian.units import Units
|
|
|
|
import inspect
|
|
|
|
import inspect
|
|
|
|
import json
|
|
|
|
import json
|
|
|
@ -134,7 +142,7 @@ class MatrixUnits(Units):
|
|
|
|
"good_response": ""
|
|
|
|
"good_response": ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.log(".o.O.o. Endpoint: %s %s" % (method, path))
|
|
|
|
self.log(" ------- Endpoint: %s %s ------- " % (method, path))
|
|
|
|
for param in single_api.get("parameters", []):
|
|
|
|
for param in single_api.get("parameters", []):
|
|
|
|
# description
|
|
|
|
# description
|
|
|
|
desc = param.get("description", "")
|
|
|
|
desc = param.get("description", "")
|
|
|
@ -183,6 +191,9 @@ class MatrixUnits(Units):
|
|
|
|
"desc": json_body[key]["description"]
|
|
|
|
"desc": json_body[key]["description"]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
# endfor[param]
|
|
|
|
# endfor[param]
|
|
|
|
|
|
|
|
for row in endpoint["req_params"]:
|
|
|
|
|
|
|
|
self.log("Request parameter: %s" % row)
|
|
|
|
|
|
|
|
|
|
|
|
# group params by location to ease templating
|
|
|
|
# group params by location to ease templating
|
|
|
|
endpoint["req_param_by_loc"] = {
|
|
|
|
endpoint["req_param_by_loc"] = {
|
|
|
|
# path: [...], query: [...], body: [...]
|
|
|
|
# path: [...], query: [...], body: [...]
|
|
|
@ -240,6 +251,7 @@ class MatrixUnits(Units):
|
|
|
|
|
|
|
|
|
|
|
|
# add response params if this API has any.
|
|
|
|
# add response params if this API has any.
|
|
|
|
if good_response:
|
|
|
|
if good_response:
|
|
|
|
|
|
|
|
self.log("Found a 200 response for this API")
|
|
|
|
res_type = Units.prop(good_response, "schema/type")
|
|
|
|
res_type = Units.prop(good_response, "schema/type")
|
|
|
|
if res_type and res_type not in ["object", "array"]:
|
|
|
|
if res_type and res_type not in ["object", "array"]:
|
|
|
|
# response is a raw string or something like that
|
|
|
|
# response is a raw string or something like that
|
|
|
@ -278,6 +290,16 @@ class MatrixUnits(Units):
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for response_table in endpoint["res_tables"]:
|
|
|
|
|
|
|
|
self.log("Response: %s" % response_table["title"])
|
|
|
|
|
|
|
|
for r in response_table["rows"]:
|
|
|
|
|
|
|
|
self.log("Row: %s" % r)
|
|
|
|
|
|
|
|
if len(endpoint["res_tables"]) == 0:
|
|
|
|
|
|
|
|
self.log(
|
|
|
|
|
|
|
|
"This API appears to have no response table. Are you " +
|
|
|
|
|
|
|
|
"sure this API returns no parameters?"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
endpoints.append(endpoint)
|
|
|
|
endpoints.append(endpoint)
|
|
|
|
|
|
|
|
|
|
|
|
aliases = single_api.get("x-alias", None)
|
|
|
|
aliases = single_api.get("x-alias", None)
|
|
|
@ -475,7 +497,7 @@ class MatrixUnits(Units):
|
|
|
|
if re.match("^v[0-9\.]+$", word):
|
|
|
|
if re.match("^v[0-9\.]+$", word):
|
|
|
|
version = word[1:] # strip the 'v'
|
|
|
|
version = word[1:] # strip the 'v'
|
|
|
|
|
|
|
|
|
|
|
|
self.log("Version: %s Title part: %s Changelog lines: %s" % (
|
|
|
|
self.log("Version: %s Title part: %s Changelog line count: %s" % (
|
|
|
|
version, title_part, len(changelog_lines)
|
|
|
|
version, title_part, len(changelog_lines)
|
|
|
|
))
|
|
|
|
))
|
|
|
|
if not version or len(changelog_lines) == 0:
|
|
|
|
if not version or len(changelog_lines) == 0:
|
|
|
|