Flesh out content repo; modify templating to support headers
Edit content-repo.yaml to include examples and headers. Restructure content module to conform to the module template. Adjust the HTTP API template to give 1 more char to the response param to fit "Content-Disposition" correctly. Edit the templating system to support displaying enums for swagger APIs (before it was just JSON schema). Also add support for introspecting headers from swagger. Finally, replace - with _ when forming the {{ template_var }} else things whine.
This commit is contained in:
parent
4a7a682c0f
commit
87b6dd845e
4 changed files with 96 additions and 17 deletions
|
@ -151,6 +151,13 @@ class MatrixUnits(Units):
|
|||
|
||||
# assign value expected for this param
|
||||
val_type = param.get("type") # integer/string
|
||||
|
||||
if param.get("enum"):
|
||||
val_type = "enum"
|
||||
desc += (
|
||||
" One of: %s" % json.dumps(param.get("enum"))
|
||||
)
|
||||
|
||||
refType = Units.prop(param, "schema/$ref/") # Error,Event
|
||||
schemaFmt = Units.prop(param, "schema/format") # bytes e.g. uploads
|
||||
if not val_type and refType:
|
||||
|
@ -255,7 +262,7 @@ class MatrixUnits(Units):
|
|||
res_type = Units.prop(good_response, "schema/type")
|
||||
if res_type and res_type not in ["object", "array"]:
|
||||
# response is a raw string or something like that
|
||||
endpoint["res_tables"].append({
|
||||
good_table = {
|
||||
"title": None,
|
||||
"rows": [{
|
||||
"key": good_response["schema"].get("name", ""),
|
||||
|
@ -263,7 +270,16 @@ class MatrixUnits(Units):
|
|||
"desc": res.get("description", ""),
|
||||
"req_str": ""
|
||||
}]
|
||||
})
|
||||
}
|
||||
if good_response.get("headers"):
|
||||
for (header_name, header) in good_response.get("headers").iteritems():
|
||||
good_table["rows"].append({
|
||||
"key": header_name,
|
||||
"type": "Header<" + header["type"] + ">",
|
||||
"desc": header["description"],
|
||||
"req_str": ""
|
||||
})
|
||||
endpoint["res_tables"].append(good_table)
|
||||
elif res_type and Units.prop(good_response, "schema/properties"):
|
||||
# response is an object:
|
||||
schema = good_response["schema"]
|
||||
|
@ -328,7 +344,7 @@ class MatrixUnits(Units):
|
|||
self.log("Reading swagger API: %s" % filename)
|
||||
with open(os.path.join(path, filename), "r") as f:
|
||||
# strip .yaml
|
||||
group_name = filename[:-5]
|
||||
group_name = filename[:-5].replace("-", "_")
|
||||
api = yaml.load(f.read())
|
||||
api["__meta"] = self._load_swagger_meta(api, group_name)
|
||||
apis[group_name] = api
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue