Populate aliases from canonical endpoint

Swagger validates badly if you have endpoints without the full
specification of things, so instead let's generate them the other way
around.
pull/977/head
Daniel Wagner-Hall 9 years ago
parent 26ebe3e68b
commit 90f5dc370b

@ -105,19 +105,7 @@ class MatrixUnits(Units):
for path in api["paths"]: for path in api["paths"]:
for method in api["paths"][path]: for method in api["paths"][path]:
single_api = api["paths"][path][method] single_api = api["paths"][path][method]
full_path = api.get("basePath", "") + path full_path = api.get("basePath", "") + path
alias_for_path = single_api.get("x-alias-for-path", "")
alias_link = single_api.get("x-alias-link", "")
if alias_for_path:
endpoints.append({
"method": method.upper(),
"path": full_path,
"alias_for_path": alias_for_path,
"alias_link": alias_link
})
continue
endpoint = { endpoint = {
"title": single_api.get("summary", ""), "title": single_api.get("summary", ""),
"desc": single_api.get("description", single_api.get("summary", "")), "desc": single_api.get("description", single_api.get("summary", "")),
@ -260,6 +248,16 @@ class MatrixUnits(Units):
endpoints.append(endpoint) endpoints.append(endpoint)
for alias in single_api.get("x-aliases", []):
canonical_alias_link = single_api.get("x-alias-link")
alias_link = single_api.get("x-alias-link", "")
endpoints.append({
"method": method.upper(),
"path": alias,
"alias_for_path": full_path,
"alias_link": alias_link
})
return { return {
"base": api.get("basePath"), "base": api.get("basePath"),
"group": group_name, "group": group_name,

Loading…
Cancel
Save