用Python在Swagger中订购参数 flask-restplus/x

0 人关注

我正在用Flask-restx(Python 2.7)记录我的REST端点,端点的参数在Swagger中的排序非常奇怪。现在,所需的参数并不总是在列表的第一位。

在Swagger中输出

似乎可以用 "sortParamsByRequiredFlag "以某种方式对参数进行排序,但我没有看到可以在哪里设置。有谁知道吗?

My code for one of the endpoints:

@g_api.route('/apx_export', methods=['GET'])
@g_api.doc(params={
    'date_time_start': {
        'required': True,
        'type': 'string',
        'format': 'YYYY-MM-DD',
        'description': 'Start date'},
    'date_time_end': {
        'required': False,
        'type': 'string',
        'format': 'YYYY-MM-DD',
        'description': 'End date'},
    'portfolio': {
        'required': False,
        'type': 'string',
        'description': 'The apx id of the account or portfolio to be filtered on'}, })
class ApxExport(Resource):
    def get(self):
        date_time_start = _unicode_to_latin1(flask.request.args.get(key='date_time_start', default=None, type=str))
        date_time_end = _unicode_to_latin1(flask.request.args.get('date_time_end', None))
        apx_portfolio = _unicode_to_latin1(flask.request.args.get('portfolio', None))
        if date_time_start is None:
            def apx_error_binder():
                raise ServerError('apx_export: date_time_start is unassigned', status_code=400, include_traceback=False)
            return QueuedCall.redirect(apx_error_binder)
        def apx_export_binder():
            return ipm.ats.apx_export.apx_export(date_time_start, date_time_end, apx_portfolio)
        return QueuedCall.redirect(apx_export_binder)

Swagger中的输出是按照这个顺序的。