1
0
Fork 0

Fix swagger generation as reported by @baslr

This commit is contained in:
Wilfried Goesgens 2016-10-04 12:08:35 +02:00
parent 0b35e28010
commit f7907950d2
1 changed files with 12 additions and 2 deletions

View File

@ -1166,14 +1166,17 @@ def unwrapPostJson(reference, layer):
elif swagger['definitions'][reference]['properties'][param]['type'] == 'array': elif swagger['definitions'][reference]['properties'][param]['type'] == 'array':
rc += ' ' * layer + "- **" + param + "**" rc += ' ' * layer + "- **" + param + "**"
trySubStruct = False trySubStruct = False
lf=""
if 'type' in thisParam['items']: if 'type' in thisParam['items']:
rc += " (" + thisParam['items']['type'] + ")" rc += " (" + thisParam['items']['type'] + ")"
lf="\n"
else: else:
if len(thisParam['items']) == 0: if len(thisParam['items']) == 0:
rc += " (anonymous json object)" rc += " (anonymous json object)"
lf="\n"
else: else:
trySubStruct = True trySubStruct = True
rc += ": " + TrimThisParam(brTrim(thisParam['description']), layer) rc += ": " + TrimThisParam(brTrim(thisParam['description']), layer) + lf
if trySubStruct: if trySubStruct:
try: try:
subStructRef = getReference(thisParam['items'], reference, None) subStructRef = getReference(thisParam['items'], reference, None)
@ -1189,7 +1192,7 @@ def unwrapPostJson(reference, layer):
if len(sys.argv) < 4: if len(sys.argv) < 4:
print >> sys.stderr, "usage: " + sys.argv[0] + " <scriptDir> <outDir> <relDir> <docublockdir>" print >> sys.stderr, "usage: " + sys.argv[0] + " <scriptDir> <outDir> <relDir> <docublockdir> <optional: filter>"
sys.exit(1) sys.exit(1)
scriptDir = sys.argv[1] scriptDir = sys.argv[1]
@ -1204,6 +1207,10 @@ relDir = sys.argv[3]
if not relDir.endswith("/"): if not relDir.endswith("/"):
relDir += "/" relDir += "/"
fileFilter = ""
if len(sys.argv) > 5:
fileFilter = sys.argv[5]
print >> sys.stderr, "Filtering for: [" + fileFilter + "]"
# read ArangoDB version # read ArangoDB version
f = open(scriptDir + "VERSION", "r") f = open(scriptDir + "VERSION", "r")
for version in f: for version in f:
@ -1226,6 +1233,9 @@ for chapter in os.listdir(topdir):
files[chapter] = [] files[chapter] = []
curPath = os.path.join(topdir, chapter) curPath = os.path.join(topdir, chapter)
for oneFile in os.listdir(curPath): for oneFile in os.listdir(curPath):
if fileFilter != "" and oneFile != fileFilter:
print >> sys.stderr, "Skipping: [" + oneFile + "]"
continue
curPath2 = os.path.join(curPath, oneFile) curPath2 = os.path.join(curPath, oneFile)
if os.path.isfile(curPath2) and oneFile[0] != "." and oneFile.endswith(".md"): if os.path.isfile(curPath2) and oneFile[0] != "." and oneFile.endswith(".md"):
files[chapter].append(os.path.join(topdir, chapter, oneFile)) files[chapter].append(os.path.join(topdir, chapter, oneFile))