mirror of https://gitee.com/bigwinds/arangodb
Documentation/fix swagger (#4622)
This commit is contained in:
parent
aa5e02c82d
commit
0b03d08c02
|
@ -120,7 +120,7 @@ def getRestDescription():
|
||||||
#print >>sys.stderr, "RESTDESCRIPTION"
|
#print >>sys.stderr, "RESTDESCRIPTION"
|
||||||
if thisVerb['description']:
|
if thisVerb['description']:
|
||||||
#print >> sys.stderr, thisVerb['description']
|
#print >> sys.stderr, thisVerb['description']
|
||||||
return thisVerb['description']
|
return RX3[0].sub(RX3[1], thisVerb['description'])
|
||||||
else:
|
else:
|
||||||
#print >> sys.stderr, "ELSE"
|
#print >> sys.stderr, "ELSE"
|
||||||
return ""
|
return ""
|
||||||
|
@ -254,6 +254,7 @@ RX2 = [
|
||||||
(re.compile(r"@RESTRETURNCODE{(.*)}"), r"* *\g<1>*:")
|
(re.compile(r"@RESTRETURNCODE{(.*)}"), r"* *\g<1>*:")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
RX3 = (re.compile(r'\*\*Example:\*\*((?:.|\n)*?)</code></pre>'), r"")
|
||||||
|
|
||||||
match_RESTHEADER = re.compile(r"@RESTHEADER\{(.*)\}")
|
match_RESTHEADER = re.compile(r"@RESTHEADER\{(.*)\}")
|
||||||
match_RESTRETURNCODE = re.compile(r"@RESTRETURNCODE\{(.*)\}")
|
match_RESTRETURNCODE = re.compile(r"@RESTRETURNCODE\{(.*)\}")
|
||||||
|
|
|
@ -552,7 +552,7 @@ def restheader(cargo, r=Regexen()):
|
||||||
'x-filename': fn,
|
'x-filename': fn,
|
||||||
'x-examples': [],
|
'x-examples': [],
|
||||||
'tags': [currentTag],
|
'tags': [currentTag],
|
||||||
'summary': summary,
|
'summary': summary.strip(),
|
||||||
'description': '',
|
'description': '',
|
||||||
'parameters' : [],
|
'parameters' : [],
|
||||||
}
|
}
|
||||||
|
@ -1254,6 +1254,10 @@ for name, filenames in sorted(files.items(), key=operator.itemgetter(0)):
|
||||||
currentDocuBlock = None
|
currentDocuBlock = None
|
||||||
lastDocuBlock = None
|
lastDocuBlock = None
|
||||||
|
|
||||||
|
# Sort arrays by offset helper:
|
||||||
|
def descOffsetGet(value):
|
||||||
|
return value["descOffset"]
|
||||||
|
|
||||||
for route in swagger['paths'].keys():
|
for route in swagger['paths'].keys():
|
||||||
for verb in swagger['paths'][route].keys():
|
for verb in swagger['paths'][route].keys():
|
||||||
offsetPlus = 0;
|
offsetPlus = 0;
|
||||||
|
@ -1263,31 +1267,53 @@ for route in swagger['paths'].keys():
|
||||||
print >> sys.stderr, "in :" + verb + " " + route
|
print >> sys.stderr, "in :" + verb + " " + route
|
||||||
#raise TODO
|
#raise TODO
|
||||||
# insert the post json description into the place we extracted it:
|
# insert the post json description into the place we extracted it:
|
||||||
|
# Collect the blocks we want to work on, sort them by replacement place:
|
||||||
|
sortVec = []
|
||||||
for nParam in range(0, len(thisVerb['parameters'])):
|
for nParam in range(0, len(thisVerb['parameters'])):
|
||||||
if thisVerb['parameters'][nParam]['in'] == 'body':
|
if thisVerb['parameters'][nParam]['in'] == 'body':
|
||||||
|
sortVec.append({
|
||||||
|
"nParam": nParam,
|
||||||
|
"descOffset": thisVerb['parameters'][nParam]['x-description-offset']
|
||||||
|
})
|
||||||
|
|
||||||
|
sortVec.sort(key=descOffsetGet)
|
||||||
|
for oneItem in sortVec:
|
||||||
|
nParam = oneItem["nParam"]
|
||||||
descOffset = thisVerb['parameters'][nParam]['x-description-offset']
|
descOffset = thisVerb['parameters'][nParam]['x-description-offset']
|
||||||
addText = ''
|
addText = ''
|
||||||
postText = ''
|
postText = ''
|
||||||
paramDesc = thisVerb['description'][:descOffset]
|
paramDesc = thisVerb['description'][:(descOffset+offsetPlus)]
|
||||||
if len(paramDesc) > 0:
|
if len(paramDesc) > 0:
|
||||||
postText += paramDesc
|
postText += paramDesc
|
||||||
if 'additionalProperties' not in thisVerb['parameters'][nParam]['schema']:
|
if 'additionalProperties' not in thisVerb['parameters'][nParam]['schema']:
|
||||||
addText = "\n" + unwrapPostJson(getReference(thisVerb['parameters'][nParam]['schema'], route, verb),1) + "\n\n"
|
addText = "\n" + unwrapPostJson(getReference(thisVerb['parameters'][nParam]['schema'], route, verb),1) + "\n\n"
|
||||||
|
|
||||||
postText += addText
|
postText += addText
|
||||||
postText += thisVerb['description'][descOffset:]
|
postText += thisVerb['description'][(offsetPlus+descOffset):]
|
||||||
offsetPlus += len(addText)
|
offsetPlus += len(addText)
|
||||||
thisVerb['description'] = postText
|
thisVerb['description'] = postText
|
||||||
|
|
||||||
|
|
||||||
# insert the reply json description into the place we extracted it:
|
# insert the reply json description into the place we extracted it:
|
||||||
if 'responses' in thisVerb:
|
if 'responses' in thisVerb:
|
||||||
|
|
||||||
|
# Collect the blocks we want to work on, sort them by replacement place:
|
||||||
|
sortVec = []
|
||||||
for nRC in thisVerb['responses']:
|
for nRC in thisVerb['responses']:
|
||||||
if 'x-description-offset' in thisVerb['responses'][nRC]:
|
if 'x-description-offset' in thisVerb['responses'][nRC]:
|
||||||
|
sortVec.append({
|
||||||
|
"nParam": nRC,
|
||||||
|
"descOffset": thisVerb['responses'][nRC]['x-description-offset']
|
||||||
|
})
|
||||||
|
|
||||||
|
sortVec.sort(key=descOffsetGet)
|
||||||
|
for oneItem in sortVec:
|
||||||
|
nRC = oneItem["nParam"]
|
||||||
descOffset = thisVerb['responses'][nRC]['x-description-offset']
|
descOffset = thisVerb['responses'][nRC]['x-description-offset']
|
||||||
#print descOffset
|
#print descOffset
|
||||||
#print offsetPlus
|
#print offsetPlus
|
||||||
descOffset += offsetPlus
|
descOffset += offsetPlus
|
||||||
addText = '\n## HTTP ' + nRC
|
addText = '\n#### HTTP ' + nRC
|
||||||
#print thisVerb['responses'][nRC]['description']
|
#print thisVerb['responses'][nRC]['description']
|
||||||
postText = thisVerb['description'][:descOffset]
|
postText = thisVerb['description'][:descOffset]
|
||||||
#print postText
|
#print postText
|
||||||
|
|
Loading…
Reference in New Issue