|
|
@ -12,9 +12,12 @@ import os.path
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
import shutil
|
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
|
|
|
|
scripts_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
scripts_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
templating_dir = os.path.join(os.path.dirname(scripts_dir), "templating")
|
|
|
|
templating_dir = os.path.join(os.path.dirname(scripts_dir), "templating")
|
|
|
|
|
|
|
|
api_dir = os.path.join(os.path.dirname(scripts_dir), "api")
|
|
|
|
|
|
|
|
|
|
|
|
sys.path.insert(0, templating_dir)
|
|
|
|
sys.path.insert(0, templating_dir)
|
|
|
|
|
|
|
|
|
|
|
|
from matrix_templates.units import resolve_references, MatrixUnits
|
|
|
|
from matrix_templates.units import resolve_references, MatrixUnits
|
|
|
@ -50,10 +53,15 @@ output = {
|
|
|
|
"title": "Matrix Client-Server API",
|
|
|
|
"title": "Matrix Client-Server API",
|
|
|
|
"version": release_label,
|
|
|
|
"version": release_label,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
"securityDefinitions": {},
|
|
|
|
"paths": {},
|
|
|
|
"paths": {},
|
|
|
|
"swagger": "2.0",
|
|
|
|
"swagger": "2.0",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open(os.path.join(api_dir, 'client-server', 'definitions',
|
|
|
|
|
|
|
|
'security.yaml')) as f:
|
|
|
|
|
|
|
|
output['securityDefinitions'] = yaml.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
for file, contents in apis.items():
|
|
|
|
for file, contents in apis.items():
|
|
|
|
for path, methods in contents["paths"].items():
|
|
|
|
for path, methods in contents["paths"].items():
|
|
|
|
for method, spec in methods.items():
|
|
|
|
for method, spec in methods.items():
|
|
|
@ -62,6 +70,8 @@ for file, contents in apis.items():
|
|
|
|
output["paths"][path] = {}
|
|
|
|
output["paths"][path] = {}
|
|
|
|
output["paths"][path][method] = spec
|
|
|
|
output["paths"][path][method] = spec
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print "Generating %s" % output_file
|
|
|
|
print "Generating %s" % output_file
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|