Add securityDefintions to generated swagger JSON

Also factor out to a common file
This commit is contained in:
Richard van der Hoff 2016-05-03 13:57:16 +01:00
parent cf87120d78
commit 23c4ffbc1b
33 changed files with 46 additions and 155 deletions

View file

@ -12,9 +12,12 @@ import os.path
import re
import shutil
import sys
import yaml
scripts_dir = os.path.dirname(os.path.abspath(__file__))
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)
from matrix_templates.units import resolve_references, MatrixUnits
@ -50,10 +53,15 @@ output = {
"title": "Matrix Client-Server API",
"version": release_label,
},
"securityDefinitions": {},
"paths": {},
"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 path, methods in contents["paths"].items():
for method, spec in methods.items():
@ -62,6 +70,8 @@ for file, contents in apis.items():
output["paths"][path] = {}
output["paths"][path][method] = spec
print "Generating %s" % output_file
try: