mirror of https://gitee.com/bigwinds/arangodb
some fixes in generateSwagger
This commit is contained in:
parent
a10eab9b5f
commit
1d232d6967
|
@ -135,7 +135,7 @@ class StateMachine:
|
||||||
class Regexen:
|
class Regexen:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.brief = re.compile('.*@brief')
|
self.brief = re.compile('.*@brief')
|
||||||
self.RESTHEADER = re.compile('.*@RESTHEADER')
|
self.RESTHEADER = re.compile('.*@RESTHEADER{')
|
||||||
self.RESTURLPARAMETERS = re.compile('.*@RESTURLPARAMETERS')
|
self.RESTURLPARAMETERS = re.compile('.*@RESTURLPARAMETERS')
|
||||||
self.RESTQUERYPARAMETERS = re.compile('.*@RESTQUERYPARAMETERS')
|
self.RESTQUERYPARAMETERS = re.compile('.*@RESTQUERYPARAMETERS')
|
||||||
self.RESTHEADERPARAMETERS = re.compile('.*@RESTHEADERPARAMETERS')
|
self.RESTHEADERPARAMETERS = re.compile('.*@RESTHEADERPARAMETERS')
|
||||||
|
@ -161,6 +161,9 @@ def resturlparameters(cargo, r=Regexen()):
|
||||||
if not line: return eof, (fp, line)
|
if not line: return eof, (fp, line)
|
||||||
elif r.read_through.match(line): return read_through, (fp, line)
|
elif r.read_through.match(line): return read_through, (fp, line)
|
||||||
elif r.RESTURLPARAM.match(line): return resturlparam, (fp, line)
|
elif r.RESTURLPARAM.match(line): return resturlparam, (fp, line)
|
||||||
|
elif r.RESTQUERYPARAMETERS.match(line): return restqueryparameters, (fp, line)
|
||||||
|
elif r.RESTHEADERPARAMETERS.match(line): return restheaderparameters, (fp, line)
|
||||||
|
elif r.RESTBODYPARAM.match(line): return restbodyparam, (fp, line)
|
||||||
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
||||||
else: continue
|
else: continue
|
||||||
|
|
||||||
|
@ -192,8 +195,11 @@ def restqueryparameters(cargo, r=Regexen()):
|
||||||
line = fp.readline()
|
line = fp.readline()
|
||||||
if not line: return eof, (fp, line)
|
if not line: return eof, (fp, line)
|
||||||
elif r.read_through.match(line): return read_through, (fp, line)
|
elif r.read_through.match(line): return read_through, (fp, line)
|
||||||
elif r.RESTQUERYPARAM.match(line): return restqueryparam, (fp, line)
|
elif r.RESTURLPARAMETERS.match(line): return resturlparameters, (fp, line)
|
||||||
|
elif r.RESTHEADERPARAMETERS.match(line): return restheaderparameters, (fp, line)
|
||||||
|
elif r.RESTBODYPARAM.match(line): return restbodyparam, (fp, line)
|
||||||
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
||||||
|
elif r.RESTQUERYPARAM.match(line): return restqueryparam, (fp, line)
|
||||||
else: continue
|
else: continue
|
||||||
|
|
||||||
def restheaderparameters(cargo, r=Regexen()):
|
def restheaderparameters(cargo, r=Regexen()):
|
||||||
|
@ -203,6 +209,9 @@ def restheaderparameters(cargo, r=Regexen()):
|
||||||
if not line: return eof, (fp, line)
|
if not line: return eof, (fp, line)
|
||||||
elif r.read_through.match(line): return read_through, (fp, line)
|
elif r.read_through.match(line): return read_through, (fp, line)
|
||||||
elif r.RESTHEADERPARAM.match(line): return restheaderparam, (fp, line)
|
elif r.RESTHEADERPARAM.match(line): return restheaderparam, (fp, line)
|
||||||
|
elif r.RESTQUERYPARAMETERS.match(line): return restqueryparameters, (fp, line)
|
||||||
|
elif r.RESTURLPARAMETERS.match(line): return resturlparameters, (fp, line)
|
||||||
|
elif r.RESTBODYPARAM.match(line): return restbodyparam, (fp, line)
|
||||||
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
||||||
else: continue
|
else: continue
|
||||||
|
|
||||||
|
@ -213,35 +222,41 @@ def restheaderparam(cargo, r=Regexen()):
|
||||||
para = {}
|
para = {}
|
||||||
para['paramType'] = 'header'
|
para['paramType'] = 'header'
|
||||||
para['dataType'] = parametersList[1].capitalize()
|
para['dataType'] = parametersList[1].capitalize()
|
||||||
if parametersList[2] == 'required':
|
|
||||||
para['required'] = 'true'
|
|
||||||
else:
|
|
||||||
para['required'] = 'false'
|
|
||||||
para['name'] = parametersList[0]
|
para['name'] = parametersList[0]
|
||||||
para['description']=''
|
para['description']=''
|
||||||
while 1:
|
while 1:
|
||||||
line = fp.readline()
|
line = fp.readline()
|
||||||
if not line: return eof, (fp, line)
|
if not line: return eof, (fp, line)
|
||||||
elif r.read_through.match(line): return read_through, (fp, line)
|
elif r.read_through.match(line): return read_through, (fp, line)
|
||||||
elif r.RESTQUERYPARAMETERS.match(line): return restqueryparameters, (fp, line)
|
|
||||||
elif r.RESTBODYPARAM.match(line): return restbodyparam, (fp, line)
|
|
||||||
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
|
||||||
elif r.EMPTY_COMMENT.match(line):
|
elif r.EMPTY_COMMENT.match(line):
|
||||||
operation['parameters'].append(para)
|
operation['parameters'].append(para)
|
||||||
return restqueryparameters, (fp, line)
|
return restheaderparameters, (fp, line)
|
||||||
else:
|
else:
|
||||||
para['description'] += Typography(line[4:-1]) + ' '
|
para['description'] += Typography(line[4:-1]) + ' '
|
||||||
|
|
||||||
def restbodyparam(cargo, r=Regexen()):
|
def restbodyparam(cargo, r=Regexen()):
|
||||||
# TODO see POST processing in comment till PUT
|
|
||||||
fp, last = cargo
|
fp, last = cargo
|
||||||
|
parametersList = parameters(last).split(',')
|
||||||
|
para = {}
|
||||||
|
para['paramType'] = 'body'
|
||||||
|
para['dataType'] = parametersList[1].capitalize()
|
||||||
|
if parametersList[2] == 'required':
|
||||||
|
para['required'] = 'true'
|
||||||
|
para['name'] = parametersList[0]
|
||||||
|
para['description']=''
|
||||||
while 1:
|
while 1:
|
||||||
line = fp.readline()
|
line = fp.readline()
|
||||||
if not line: return eof, (fp, line)
|
if not line: return eof, (fp, line)
|
||||||
elif r.read_through.match(line): return read_through, (fp, line)
|
elif r.read_through.match(line): return read_through, (fp, line)
|
||||||
elif r.RESTQUERYPARAM.match(line): return restqueryparam, (fp, line)
|
elif r.RESTURLPARAMETERS.match(line): return resturlparameters, (fp, line)
|
||||||
|
elif r.RESTHEADERPARAMETERS.match(line): return restheaderparameters, (fp, line)
|
||||||
|
elif r.RESTQUERYPARAMETERS.match(line): return restqueryparameters, (fp, line)
|
||||||
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
||||||
else: continue
|
elif r.EMPTY_COMMENT.match(line):
|
||||||
|
operation['parameters'].append(para)
|
||||||
|
return comment, (fp, line)
|
||||||
|
else:
|
||||||
|
para['description'] += Typography(line[4:-1]) + ' '
|
||||||
|
|
||||||
def restqueryparam(cargo, r=Regexen()):
|
def restqueryparam(cargo, r=Regexen()):
|
||||||
fp, last = cargo
|
fp, last = cargo
|
||||||
|
@ -250,9 +265,7 @@ def restqueryparam(cargo, r=Regexen()):
|
||||||
para['paramType'] = 'query'
|
para['paramType'] = 'query'
|
||||||
para['dataType'] = parametersList[1].capitalize()
|
para['dataType'] = parametersList[1].capitalize()
|
||||||
if parametersList[2] == 'required':
|
if parametersList[2] == 'required':
|
||||||
para['required'] = 'true'
|
para['required'] = 'True'
|
||||||
else:
|
|
||||||
para['required'] = 'false'
|
|
||||||
para['name'] = parametersList[0]
|
para['name'] = parametersList[0]
|
||||||
para['description']=''
|
para['description']=''
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -373,14 +386,6 @@ def comment(cargo, r=Regexen()):
|
||||||
_operation = { 'httpMethod': None, 'nickname': None, 'parameters': [],
|
_operation = { 'httpMethod': None, 'nickname': None, 'parameters': [],
|
||||||
'summary': None, 'notes': '', 'examples': '', 'errorResponses':[]}
|
'summary': None, 'notes': '', 'examples': '', 'errorResponses':[]}
|
||||||
_operation['httpMethod'] = method
|
_operation['httpMethod'] = method
|
||||||
if method == 'POST' or method == 'PUT' or method == 'PATCH':
|
|
||||||
parameter = {}
|
|
||||||
parameter['paramType'] = 'body'
|
|
||||||
parameter['name'] = 'body'
|
|
||||||
parameter['description'] = 'A valid json document for your data, for instance {"hello": "world"}.'
|
|
||||||
parameter['dataType'] = 'String'
|
|
||||||
parameter['required'] = 'false'
|
|
||||||
_operation['parameters'] = [parameter]
|
|
||||||
summaryList = summary.split()
|
summaryList = summary.split()
|
||||||
_operation['nickname'] = summaryList[0] + ''.join([word.capitalize() for word in summaryList[1:]])
|
_operation['nickname'] = summaryList[0] + ''.join([word.capitalize() for word in summaryList[1:]])
|
||||||
_operation['summary'] = summary
|
_operation['summary'] = summary
|
||||||
|
@ -389,6 +394,7 @@ def comment(cargo, r=Regexen()):
|
||||||
operation = _operation
|
operation = _operation
|
||||||
elif r.RESTURLPARAMETERS.match(line): return resturlparameters, (fp, line)
|
elif r.RESTURLPARAMETERS.match(line): return resturlparameters, (fp, line)
|
||||||
elif r.RESTHEADERPARAMETERS.match(line): return restheaderparameters, (fp, line)
|
elif r.RESTHEADERPARAMETERS.match(line): return restheaderparameters, (fp, line)
|
||||||
|
elif r.RESTBODYPARAM.match(line): return restbodyparam, (fp, line)
|
||||||
elif r.RESTQUERYPARAMETERS.match(line): return restqueryparameters, (fp, line)
|
elif r.RESTQUERYPARAMETERS.match(line): return restqueryparameters, (fp, line)
|
||||||
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
elif r.RESTDESCRIPTION.match(line): return restdescription, (fp, line)
|
||||||
elif len(line) >= 4 and line[:4] == "////": continue
|
elif len(line) >= 4 and line[:4] == "////": continue
|
||||||
|
|
|
@ -171,6 +171,9 @@ HttpHandler::status_e RestDocumentHandler::execute () {
|
||||||
///
|
///
|
||||||
/// @RESTHEADER{POST /_api/document,creates a document}
|
/// @RESTHEADER{POST /_api/document,creates a document}
|
||||||
///
|
///
|
||||||
|
/// @RESTBODYPARAM{document,json,required}
|
||||||
|
/// A JSON representation of document.
|
||||||
|
///
|
||||||
/// @RESTQUERYPARAMETERS
|
/// @RESTQUERYPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTQUERYPARAM{collection,string,required}
|
/// @RESTQUERYPARAM{collection,string,required}
|
||||||
|
@ -462,6 +465,7 @@ bool RestDocumentHandler::readDocument () {
|
||||||
/// @RESTURLPARAMETERS
|
/// @RESTURLPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTURLPARAM{document-handle,string,required}
|
/// @RESTURLPARAM{document-handle,string,required}
|
||||||
|
/// The Handle of the Document.
|
||||||
///
|
///
|
||||||
/// @RESTHEADERPARAMETERS
|
/// @RESTHEADERPARAMETERS
|
||||||
///
|
///
|
||||||
|
@ -639,11 +643,20 @@ bool RestDocumentHandler::readSingleDocument (bool generateBody) {
|
||||||
/// @RESTQUERYPARAMETERS
|
/// @RESTQUERYPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTQUERYPARAM{collection,string,required}
|
/// @RESTQUERYPARAM{collection,string,required}
|
||||||
|
/// The Id of the collection.
|
||||||
///
|
///
|
||||||
/// @RESTDESCRIPTION
|
/// @RESTDESCRIPTION
|
||||||
/// Returns a list of all URI for all documents from the collection identified
|
/// Returns a list of all URI for all documents from the collection identified
|
||||||
/// by `collection`.
|
/// by `collection`.
|
||||||
///
|
///
|
||||||
|
/// @RESTRETURNCODES
|
||||||
|
///
|
||||||
|
/// @RESTRETURNCODE{200}
|
||||||
|
/// All went good.
|
||||||
|
///
|
||||||
|
/// @RESTRETURNCODE{404}
|
||||||
|
/// The collection does not exist.
|
||||||
|
///
|
||||||
/// @EXAMPLES
|
/// @EXAMPLES
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_RUN{RestReadDocumentAll}
|
/// @EXAMPLE_ARANGOSH_RUN{RestReadDocumentAll}
|
||||||
|
@ -734,6 +747,24 @@ bool RestDocumentHandler::readAllDocuments () {
|
||||||
/// @RESTURLPARAMETERS
|
/// @RESTURLPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTURLPARAM{document-handle,string,required}
|
/// @RESTURLPARAM{document-handle,string,required}
|
||||||
|
/// The Handle of the Document.
|
||||||
|
///
|
||||||
|
/// @RESTQUERYPARAMETERS
|
||||||
|
///
|
||||||
|
/// @RESTQUERYPARAM{rev,string,optional}
|
||||||
|
/// You can conditionally delete a document based on a target revision id by
|
||||||
|
/// using the `rev` URL parameter.
|
||||||
|
///
|
||||||
|
/// @RESTQUERYPARAM{policy,string,optional}
|
||||||
|
/// To control the update behavior in case there is a revision mismatch, you
|
||||||
|
/// can use the `policy` parameter. This is the same as when replacing
|
||||||
|
/// documents (see replacing documents for more details).
|
||||||
|
///
|
||||||
|
/// @RESTHEADERPARAMETERS
|
||||||
|
///
|
||||||
|
/// @RESTHEADERPARAM{If-Match,string,optional}
|
||||||
|
/// You can conditionally delete a document based on a target revision id by
|
||||||
|
/// using the `if-match` HTTP header.
|
||||||
///
|
///
|
||||||
/// @RESTDESCRIPTION
|
/// @RESTDESCRIPTION
|
||||||
/// Like `GET`, but only returns the header fields and not the body. You
|
/// Like `GET`, but only returns the header fields and not the body. You
|
||||||
|
@ -795,6 +826,7 @@ bool RestDocumentHandler::checkDocument () {
|
||||||
/// @RESTURLPARAMETERS
|
/// @RESTURLPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTURLPARAM{document-handle,string,required}
|
/// @RESTURLPARAM{document-handle,string,required}
|
||||||
|
/// The Handle of the Document.
|
||||||
///
|
///
|
||||||
/// @RESTQUERYPARAMETERS
|
/// @RESTQUERYPARAMETERS
|
||||||
///
|
///
|
||||||
|
@ -802,6 +834,9 @@ bool RestDocumentHandler::checkDocument () {
|
||||||
///
|
///
|
||||||
/// @RESTQUERYPARAM{policy,string,optional}
|
/// @RESTQUERYPARAM{policy,string,optional}
|
||||||
///
|
///
|
||||||
|
/// @RESTQUERYPARAM{waitForSync,boolean,optional}
|
||||||
|
/// Wait until document has been sync to disk.
|
||||||
|
///
|
||||||
/// @RESTHEADERPARAMETERS
|
/// @RESTHEADERPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTHEADERPARAM{If-Match,string,optional}
|
/// @RESTHEADERPARAM{If-Match,string,optional}
|
||||||
|
@ -851,7 +886,8 @@ bool RestDocumentHandler::checkDocument () {
|
||||||
///
|
///
|
||||||
/// For example, to conditionally replace a document based on a specific revision
|
/// For example, to conditionally replace a document based on a specific revision
|
||||||
/// id, you the following request:
|
/// id, you the following request:
|
||||||
/// @REST{PUT /_api/document/`document-handle`?rev=`etag`}
|
///
|
||||||
|
/// - PUT /_api/document/`document-handle`?rev=`etag`
|
||||||
///
|
///
|
||||||
/// If a target revision id is provided in the request (e.g. via the `etag` value
|
/// If a target revision id is provided in the request (e.g. via the `etag` value
|
||||||
/// in the `rev` URL query parameter above), ArangoDB will check that
|
/// in the `rev` URL query parameter above), ArangoDB will check that
|
||||||
|
@ -862,7 +898,7 @@ bool RestDocumentHandler::checkDocument () {
|
||||||
///
|
///
|
||||||
/// The conditional update behavior can be overriden with the `policy` URL query parameter:
|
/// The conditional update behavior can be overriden with the `policy` URL query parameter:
|
||||||
///
|
///
|
||||||
/// @REST{PUT /_api/document/`document-handle`?policy=`policy`}
|
/// - PUT /_api/document/`document-handle`?policy=`policy`
|
||||||
///
|
///
|
||||||
/// If `policy` is set to `error`, then the behavior is as before: replacements
|
/// If `policy` is set to `error`, then the behavior is as before: replacements
|
||||||
/// will fail if the revision id found in the database does not match the target
|
/// will fail if the revision id found in the database does not match the target
|
||||||
|
@ -993,6 +1029,7 @@ bool RestDocumentHandler::replaceDocument () {
|
||||||
/// @RESTURLPARAMETERS
|
/// @RESTURLPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTURLPARAM{document-handle,string,required}
|
/// @RESTURLPARAM{document-handle,string,required}
|
||||||
|
/// The Handle of the Document.
|
||||||
///
|
///
|
||||||
/// @RESTQUERYPARAMETERS
|
/// @RESTQUERYPARAMETERS
|
||||||
///
|
///
|
||||||
|
@ -1002,6 +1039,9 @@ bool RestDocumentHandler::replaceDocument () {
|
||||||
///
|
///
|
||||||
/// @RESTQUERYPARAM{policy,string,optional}
|
/// @RESTQUERYPARAM{policy,string,optional}
|
||||||
///
|
///
|
||||||
|
/// @RESTQUERYPARAM{waitForSync,boolean,optional}
|
||||||
|
/// Wait until document has been sync to disk.
|
||||||
|
///
|
||||||
/// @RESTHEADERPARAMETERS
|
/// @RESTHEADERPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTHEADERPARAM{If-Match,string,optional}
|
/// @RESTHEADERPARAM{If-Match,string,optional}
|
||||||
|
@ -1224,41 +1264,35 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) {
|
||||||
/// @RESTURLPARAMETERS
|
/// @RESTURLPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTURLPARAM{document-handle,string,required}
|
/// @RESTURLPARAM{document-handle,string,required}
|
||||||
|
/// Deletes the document identified by `document-handle`.
|
||||||
///
|
///
|
||||||
/// @RESTQUERYPARAMETERS
|
/// @RESTQUERYPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTQUERYPARAM{rev,string,optional}
|
/// @RESTQUERYPARAM{rev,string,optional}
|
||||||
|
/// You can conditionally delete a document based on a target revision id by
|
||||||
|
/// using the `rev` URL parameter.
|
||||||
///
|
///
|
||||||
/// @RESTQUERYPARAM{policy,string,optional}
|
/// @RESTQUERYPARAM{policy,string,optional}
|
||||||
|
/// To control the update behavior in case there is a revision mismatch, you
|
||||||
|
/// can use the `policy` parameter. This is the same as when replacing
|
||||||
|
/// documents (see replacing documents for more details).
|
||||||
|
///
|
||||||
|
/// @RESTQUERYPARAM{waitForSync,boolean,optional}
|
||||||
|
/// Wait until document has been sync to disk.
|
||||||
///
|
///
|
||||||
/// @RESTHEADERPARAMETERS
|
/// @RESTHEADERPARAMETERS
|
||||||
///
|
///
|
||||||
/// @RESTHEADERPARAM{If-Match,string,optional}
|
/// @RESTHEADERPARAM{If-Match,string,optional}
|
||||||
|
/// You can conditionally delete a document based on a target revision id by
|
||||||
|
/// using the `if-match` HTTP header.
|
||||||
///
|
///
|
||||||
/// @RESTDESCRIPTION
|
/// @RESTDESCRIPTION
|
||||||
/// Deletes the document identified by `document-handle`. If the document
|
|
||||||
/// exists and could be deleted, then a `HTTP 200` is returned.
|
|
||||||
///
|
|
||||||
/// The body of the response contains a JSON object with the information about
|
/// The body of the response contains a JSON object with the information about
|
||||||
/// the handle and the revision. The attribute `_id` contains the known
|
/// the handle and the revision. The attribute `_id` contains the known
|
||||||
/// `document-handle` of the updated document, the attribute `_rev`
|
/// `document-handle` of the updated document, the attribute `_rev`
|
||||||
/// contains the known document revision.
|
/// contains the known document revision.
|
||||||
///
|
///
|
||||||
/// If the document does not exist, then a `HTTP 404` is returned and the
|
/// If the `waitForSync` parameter is not specified or set to
|
||||||
/// body of the response contains an error document.
|
|
||||||
///
|
|
||||||
/// You can conditionally delete a document based on a target revision id by
|
|
||||||
/// using either the `rev` URL parameter or the `if-match` HTTP header.
|
|
||||||
/// To control the update behavior in case there is a revision mismatch, you
|
|
||||||
/// can use the `policy` parameter. This is the same as when replacing
|
|
||||||
/// documents (see replacing documents for more details).
|
|
||||||
///
|
|
||||||
/// Optionally, the URL parameter `waitForSync` can be used to force
|
|
||||||
/// synchronisation of the document deletion operation to disk even in case
|
|
||||||
/// that the `waitForSync` flag had been disabled for the entire collection.
|
|
||||||
/// Thus, the `waitForSync` URL parameter can be used to force synchronisation
|
|
||||||
/// of just specific operations. To use this, set the `waitForSync` parameter
|
|
||||||
/// to `true`. If the `waitForSync` parameter is not specified or set to
|
|
||||||
/// `false`, then the collection's default `waitForSync` behavior is
|
/// `false`, then the collection's default `waitForSync` behavior is
|
||||||
/// applied. The `waitForSync` URL parameter cannot be used to disable
|
/// applied. The `waitForSync` URL parameter cannot be used to disable
|
||||||
/// synchronisation for collections that have a default `waitForSync` value
|
/// synchronisation for collections that have a default `waitForSync` value
|
||||||
|
|
Loading…
Reference in New Issue